modules tab now shows mapped files

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@753 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
wj32
2009-02-27 23:33:26 +00:00
parent 2fd342e5ea
commit c977db697f
3 changed files with 55 additions and 1 deletions
+5
View File
@@ -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"
@@ -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)
{
@@ -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,