private string GetNextModule(IntPtr snapshot) { GetProcessModule.MODULEENTRY32 entry = GetProcessModule.MODULEENTRY32.NewEntry(); bool returnValue = GetProcessModule.Module32NextW(snapshot, ref entry); return(this.AnalyzeModuleResult(returnValue, entry)); }
private void ReadModuleList(GetProcessModule.ModuleHandler moduleHandler) { Process process = this.TryGetProcess(); if (process == null) { return; } using (process) { IntPtr value = this.TryGetHandle(process); if (!(value == IntPtr.Zero)) { IntPtr intPtr = this.CreateProcessSnapshot(); if (!(intPtr == IntPtr.Zero)) { try { for (string path = this.GetFirstModule(intPtr); path != null; path = this.GetNextModule(intPtr)) { moduleHandler(path); } } finally { GetProcessModule.CloseHandle(intPtr); } } } } }
private IntPtr CreateProcessSnapshot() { IntPtr intPtr = GetProcessModule.CreateToolhelp32Snapshot(24, this.ProcessId); if (intPtr == IntPtr.Zero || intPtr == (IntPtr)(-1)) { if (Marshal.GetLastWin32Error() != 299) { throw new Win32Exception(); } intPtr = IntPtr.Zero; } return(intPtr); }