[DllImport("kernel32.dll")]
static extern bool Module32First(IntPtr hSnapshot, ref MODULEENTRY32 lpme);
See struct MODULEENTRY32
None.
For example:
----------------
int procIDDDDDDDDDDDDD = Process.GetCurrentProcess().Id;
----------------
static void EnumProcessModules(int procIDDDDDDDDDDDDD)
{//http://pastebin.com/BzD1jdmH
var snapshot = CreateToolhelp32Snapshot(SnapshotFlags.Module | SnapshotFlags.Module32, (uint)procIDDDDDDDDDDDDD);
MODULEENTRY32 mod = new MODULEENTRY32() { dwSize = (uint)Marshal.SizeOf(typeof(MODULEENTRY32)) };
if (!Module32First(snapshot, ref mod))
return;
List<string> modules = new List<string>();
do
{
modules.Add(mod.szModule);
}
while (Module32Next(snapshot, ref mod));
Console.WriteLine("OK");
}
System.Diagnostics.Process class contains many module, process, and thread methods.
For example:
using System.Diagnostics;
...
private void DumpModuleInfo(IntPtr hProcess)
{
uint pid = Process.GetProcessById(hProcess).Id;
foreach (Process proc in Process.GetProcesses())
{
if (proc.Id == pid)
{
foreach (ProcessModule pm in proc.Modules)
{
Console.WriteLine("{0:X8} {1:X8} {2:X8} {3}", (int)pm.BaseAddress,
(int)pm.EntryPointAddress, (int)pm.BaseAddress + pm.ModuleMemorySize, pm.ModuleName);
}
}
}
}