diff --git a/trunk/CHANGELOG.txt b/trunk/CHANGELOG.txt index d7c321ac7..9e8a6db16 100644 --- a/trunk/CHANGELOG.txt +++ b/trunk/CHANGELOG.txt @@ -1,5 +1,10 @@ Process Hacker +1.3.5.5 + * NEW: + * Modules tab shows mapped files + * FIXED: + 1.3.5.0 * NEW: * #2596502 - "Add access keys" diff --git a/trunk/ProcessHacker/Providers/ModuleProvider.cs b/trunk/ProcessHacker/Providers/ModuleProvider.cs index 84a34a7bf..e6ca1a98a 100644 --- a/trunk/ProcessHacker/Providers/ModuleProvider.cs +++ b/trunk/ProcessHacker/Providers/ModuleProvider.cs @@ -27,6 +27,7 @@ using System.Drawing; using System.Threading; using System.Windows.Forms; using System.Text; +using System.Runtime.InteropServices; namespace ProcessHacker { @@ -53,7 +54,7 @@ namespace ProcessHacker try { _processHandle = new Win32.ProcessHandle(_pid, - Program.MinProcessQueryRights | + Win32.PROCESS_RIGHTS.PROCESS_QUERY_INFORMATION | Win32.PROCESS_RIGHTS.PROCESS_VM_READ); } catch @@ -147,6 +148,46 @@ namespace ProcessHacker foreach (var m in processModules) modules.Add(m.BaseAddress.ToInt32(), m); + // add mapped files + { + Win32.MEMORY_BASIC_INFORMATION info = new Win32.MEMORY_BASIC_INFORMATION(); + int address = 0; + + while (true) + { + if (!Win32.VirtualQueryEx(_processHandle, address, ref info, Marshal.SizeOf(info))) + { + break; + } + else + { + if (info.Type == Win32.MEMORY_TYPE.MEM_MAPPED) + { + StringBuilder sb = new StringBuilder(0x400); + int length = Win32.GetMappedFileName(_processHandle, info.BaseAddress, sb, sb.Capacity); + + if (length > 0) + { + string fileName = sb.ToString(0, length); + + if (fileName.StartsWith("\\")) + fileName = Win32.DeviceFileNameToDos(fileName); + + System.IO.FileInfo fi = new System.IO.FileInfo(fileName); + + modules.Add(info.BaseAddress, + new Win32.ProcessModule( + new IntPtr(info.BaseAddress), + info.RegionSize, IntPtr.Zero, + fi.Name, fi.FullName)); + } + } + + address += info.RegionSize; + } + } + } + // look for unloaded modules foreach (int b in Dictionary.Keys) { diff --git a/trunk/ProcessHacker/Win32/API/Functions.cs b/trunk/ProcessHacker/Win32/API/Functions.cs index 433c9dcb8..0a21b4e82 100644 --- a/trunk/ProcessHacker/Win32/API/Functions.cs +++ b/trunk/ProcessHacker/Win32/API/Functions.cs @@ -302,6 +302,14 @@ namespace ProcessHacker #region Processes + [DllImport("psapi.dll", SetLastError = true, CharSet = CharSet.Unicode)] + public static extern int GetMappedFileName( + int ProcessHandle, + int Address, + StringBuilder Buffer, + int Size + ); + [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] public static extern bool CreateProcess( [MarshalAs(UnmanagedType.LPWStr)] string ApplicationName,