mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
1. fixed definition of the DEBUG_MODULE_INFORMATION structure
2. implemented module and heap list enumeration for toolhelp svn path=/trunk/; revision=11698
This commit is contained in:
parent
c145b0b293
commit
cd57e3d41d
9 changed files with 92 additions and 81 deletions
|
@ -13,6 +13,36 @@ typedef BOOL STDCALL_FUNC
|
||||||
ULONG ul_reason_for_call,
|
ULONG ul_reason_for_call,
|
||||||
LPVOID lpReserved);
|
LPVOID lpReserved);
|
||||||
|
|
||||||
|
#if defined(__USE_W32API) || defined(__NTDLL__)
|
||||||
|
/*
|
||||||
|
* Fu***ng headers hell made me do this...i'm sick of it
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct _LOCK_INFORMATION
|
||||||
|
{
|
||||||
|
ULONG LockCount;
|
||||||
|
DEBUG_LOCK_INFORMATION LockEntry[1];
|
||||||
|
} LOCK_INFORMATION, *PLOCK_INFORMATION;
|
||||||
|
|
||||||
|
typedef struct _HEAP_INFORMATION
|
||||||
|
{
|
||||||
|
ULONG HeapCount;
|
||||||
|
DEBUG_HEAP_INFORMATION HeapEntry[1];
|
||||||
|
} HEAP_INFORMATION, *PHEAP_INFORMATION;
|
||||||
|
|
||||||
|
typedef struct _MODULE_INFORMATION
|
||||||
|
{
|
||||||
|
ULONG ModuleCount;
|
||||||
|
DEBUG_MODULE_INFORMATION ModuleEntry[1];
|
||||||
|
} MODULE_INFORMATION, *PMODULE_INFORMATION;
|
||||||
|
|
||||||
|
NTSTATUS STDCALL
|
||||||
|
LdrQueryProcessModuleInformation(IN PMODULE_INFORMATION ModuleInformation OPTIONAL,
|
||||||
|
IN ULONG Size OPTIONAL,
|
||||||
|
OUT PULONG ReturnedSize);
|
||||||
|
|
||||||
|
#endif /* __USE_W32API */
|
||||||
|
|
||||||
/* Module flags */
|
/* Module flags */
|
||||||
#define IMAGE_DLL 0x00000004
|
#define IMAGE_DLL 0x00000004
|
||||||
#define LOAD_IN_PROGRESS 0x00001000
|
#define LOAD_IN_PROGRESS 0x00001000
|
||||||
|
@ -55,27 +85,6 @@ typedef struct _LDR_SYMBOL_INFO {
|
||||||
|
|
||||||
#define RVA(m, b) ((ULONG)b + m)
|
#define RVA(m, b) ((ULONG)b + m)
|
||||||
|
|
||||||
|
|
||||||
typedef struct _MODULE_ENTRY
|
|
||||||
{
|
|
||||||
ULONG Unknown0;
|
|
||||||
ULONG Unknown1;
|
|
||||||
PVOID BaseAddress;
|
|
||||||
ULONG SizeOfImage;
|
|
||||||
ULONG Flags;
|
|
||||||
USHORT Unknown2;
|
|
||||||
USHORT Unknown3;
|
|
||||||
SHORT LoadCount;
|
|
||||||
USHORT PathLength;
|
|
||||||
CHAR ModuleName[256];
|
|
||||||
} MODULE_ENTRY, *PMODULE_ENTRY;
|
|
||||||
|
|
||||||
typedef struct _MODULE_INFORMATION
|
|
||||||
{
|
|
||||||
ULONG ModuleCount;
|
|
||||||
MODULE_ENTRY ModuleEntry[1];
|
|
||||||
} MODULE_INFORMATION, *PMODULE_INFORMATION;
|
|
||||||
|
|
||||||
#ifdef KDBG
|
#ifdef KDBG
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -140,11 +149,6 @@ LdrQueryImageFileExecutionOptions (IN PUNICODE_STRING SubKey,
|
||||||
IN ULONG BufferSize,
|
IN ULONG BufferSize,
|
||||||
OUT PULONG RetunedLength OPTIONAL);
|
OUT PULONG RetunedLength OPTIONAL);
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
|
||||||
LdrQueryProcessModuleInformation(IN PMODULE_INFORMATION ModuleInformation OPTIONAL,
|
|
||||||
IN ULONG Size OPTIONAL,
|
|
||||||
OUT PULONG ReturnedSize);
|
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
LdrShutdownProcess(VOID);
|
LdrShutdownProcess(VOID);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: rtl.h,v 1.51 2004/10/30 22:18:16 weiden Exp $
|
/* $Id: rtl.h,v 1.52 2004/11/19 01:30:34 weiden Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ typedef struct _DEBUG_BUFFER
|
||||||
|
|
||||||
typedef struct _DEBUG_MODULE_INFORMATION {
|
typedef struct _DEBUG_MODULE_INFORMATION {
|
||||||
ULONG Reserved[2];
|
ULONG Reserved[2];
|
||||||
ULONG Base;
|
PVOID Base;
|
||||||
ULONG Size;
|
ULONG Size;
|
||||||
ULONG Flags;
|
ULONG Flags;
|
||||||
USHORT Index;
|
USHORT Index;
|
||||||
|
@ -65,7 +65,7 @@ typedef struct _DEBUG_MODULE_INFORMATION {
|
||||||
} DEBUG_MODULE_INFORMATION, *PDEBUG_MODULE_INFORMATION;
|
} DEBUG_MODULE_INFORMATION, *PDEBUG_MODULE_INFORMATION;
|
||||||
|
|
||||||
typedef struct _DEBUG_HEAP_INFORMATION {
|
typedef struct _DEBUG_HEAP_INFORMATION {
|
||||||
ULONG Base;
|
PVOID Base;
|
||||||
ULONG Flags;
|
ULONG Flags;
|
||||||
USHORT Granularity;
|
USHORT Granularity;
|
||||||
USHORT Unknown;
|
USHORT Unknown;
|
||||||
|
@ -120,19 +120,6 @@ typedef LPCRITICAL_SECTION LPRTL_CRITICAL_SECTION;
|
||||||
|
|
||||||
#endif /* !__USE_W32API */
|
#endif /* !__USE_W32API */
|
||||||
|
|
||||||
|
|
||||||
typedef struct _LOCK_INFORMATION
|
|
||||||
{
|
|
||||||
ULONG LockCount;
|
|
||||||
DEBUG_LOCK_INFORMATION LockEntry[1];
|
|
||||||
} LOCK_INFORMATION, *PLOCK_INFORMATION;
|
|
||||||
|
|
||||||
typedef struct _HEAP_INFORMATION
|
|
||||||
{
|
|
||||||
ULONG HeapCount;
|
|
||||||
DEBUG_HEAP_INFORMATION HeapEntry[1];
|
|
||||||
} HEAP_INFORMATION, *PHEAP_INFORMATION;
|
|
||||||
|
|
||||||
typedef struct _RTL_PROCESS_INFO
|
typedef struct _RTL_PROCESS_INFO
|
||||||
{
|
{
|
||||||
ULONG Size;
|
ULONG Size;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: toolhelp.c,v 1.9 2004/11/05 11:51:18 weiden Exp $
|
/* $Id: toolhelp.c,v 1.10 2004/11/19 01:30:35 weiden Exp $
|
||||||
*
|
*
|
||||||
* KERNEL32.DLL toolhelp functions
|
* KERNEL32.DLL toolhelp functions
|
||||||
*
|
*
|
||||||
|
@ -348,8 +348,8 @@ TH32CreateSnapshotSectionInitialize(DWORD dwFlags,
|
||||||
{
|
{
|
||||||
HeapListEntry->dwSize = sizeof(HEAPLIST32);
|
HeapListEntry->dwSize = sizeof(HEAPLIST32);
|
||||||
HeapListEntry->th32ProcessID = th32ProcessID;
|
HeapListEntry->th32ProcessID = th32ProcessID;
|
||||||
HeapListEntry->th32HeapID = 0; /* FIXME - use the base address of the heap we're iterating */
|
HeapListEntry->th32HeapID = (ULONG_PTR)hi->HeapEntry[i].Base;
|
||||||
HeapListEntry->dwFlags = 0; /* FIXME - use the flags of the heap we're iterating */
|
HeapListEntry->dwFlags = hi->HeapEntry[i].Flags;
|
||||||
|
|
||||||
HeapListEntry++;
|
HeapListEntry++;
|
||||||
}
|
}
|
||||||
|
@ -366,9 +366,27 @@ TH32CreateSnapshotSectionInitialize(DWORD dwFlags,
|
||||||
for(i = 0; i < nModules; i++)
|
for(i = 0; i < nModules; i++)
|
||||||
{
|
{
|
||||||
ModuleListEntry->dwSize = sizeof(MODULEENTRY32W);
|
ModuleListEntry->dwSize = sizeof(MODULEENTRY32W);
|
||||||
|
ModuleListEntry->th32ModuleID = 1; /* no longer used, always set to one! */
|
||||||
ModuleListEntry->th32ProcessID = th32ProcessID;
|
ModuleListEntry->th32ProcessID = th32ProcessID;
|
||||||
|
ModuleListEntry->GlblcntUsage = mi->ModuleEntry[i].LoadCount;
|
||||||
|
ModuleListEntry->ProccntUsage = mi->ModuleEntry[i].LoadCount;
|
||||||
|
ModuleListEntry->modBaseAddr = (BYTE*)mi->ModuleEntry[i].Base;
|
||||||
|
ModuleListEntry->modBaseSize = mi->ModuleEntry[i].Size;
|
||||||
|
ModuleListEntry->hModule = (HMODULE)mi->ModuleEntry[i].Base;
|
||||||
|
|
||||||
/* FIXME - fill the MODULEENTRY32W structure */
|
MultiByteToWideChar(CP_ACP,
|
||||||
|
0,
|
||||||
|
&mi->ModuleEntry[i].ImageName[mi->ModuleEntry[i].ModuleNameOffset],
|
||||||
|
-1,
|
||||||
|
ModuleListEntry->szModule,
|
||||||
|
sizeof(ModuleListEntry->szModule) / sizeof(ModuleListEntry->szModule[0]));
|
||||||
|
|
||||||
|
MultiByteToWideChar(CP_ACP,
|
||||||
|
0,
|
||||||
|
mi->ModuleEntry[i].ImageName,
|
||||||
|
-1,
|
||||||
|
ModuleListEntry->szExePath,
|
||||||
|
sizeof(ModuleListEntry->szExePath) / sizeof(ModuleListEntry->szExePath[0]));
|
||||||
|
|
||||||
ModuleListEntry++;
|
ModuleListEntry++;
|
||||||
}
|
}
|
||||||
|
@ -728,6 +746,9 @@ Module32Next(HANDLE hSnapshot, LPMODULEENTRY32 lpme)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
BOOL
|
BOOL
|
||||||
STDCALL
|
STDCALL
|
||||||
Module32NextW(HANDLE hSnapshot, LPMODULEENTRY32W lpme)
|
Module32NextW(HANDLE hSnapshot, LPMODULEENTRY32W lpme)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: utils.c,v 1.100 2004/10/30 14:02:03 navaraf Exp $
|
/* $Id: utils.c,v 1.101 2004/11/19 01:30:35 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -2629,7 +2629,7 @@ LdrQueryProcessModuleInformation(IN PMODULE_INFORMATION ModuleInformation OPTION
|
||||||
PLIST_ENTRY ModuleListHead;
|
PLIST_ENTRY ModuleListHead;
|
||||||
PLIST_ENTRY Entry;
|
PLIST_ENTRY Entry;
|
||||||
PLDR_MODULE Module;
|
PLDR_MODULE Module;
|
||||||
PMODULE_ENTRY ModulePtr = NULL;
|
PDEBUG_MODULE_INFORMATION ModulePtr = NULL;
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
ULONG UsedSize = sizeof(ULONG);
|
ULONG UsedSize = sizeof(ULONG);
|
||||||
ANSI_STRING AnsiString;
|
ANSI_STRING AnsiString;
|
||||||
|
@ -2666,31 +2666,30 @@ LdrQueryProcessModuleInformation(IN PMODULE_INFORMATION ModuleInformation OPTION
|
||||||
}
|
}
|
||||||
else if (ModuleInformation != NULL)
|
else if (ModuleInformation != NULL)
|
||||||
{
|
{
|
||||||
ModulePtr->Unknown0 = 0; // FIXME: ??
|
ModulePtr->Reserved[0] = ModulePtr->Reserved[1] = 0; // FIXME: ??
|
||||||
ModulePtr->Unknown1 = 0; // FIXME: ??
|
ModulePtr->Base = Module->BaseAddress;
|
||||||
ModulePtr->BaseAddress = Module->BaseAddress;
|
ModulePtr->Size = Module->SizeOfImage;
|
||||||
ModulePtr->SizeOfImage = Module->SizeOfImage;
|
|
||||||
ModulePtr->Flags = Module->Flags;
|
ModulePtr->Flags = Module->Flags;
|
||||||
ModulePtr->Unknown2 = 0; // FIXME: load order index ??
|
ModulePtr->Index = 0; // FIXME: index ??
|
||||||
ModulePtr->Unknown3 = 0; // FIXME: ??
|
ModulePtr->Unknown = 0; // FIXME: ??
|
||||||
ModulePtr->LoadCount = Module->LoadCount;
|
ModulePtr->LoadCount = Module->LoadCount;
|
||||||
|
|
||||||
AnsiString.Length = 0;
|
AnsiString.Length = 0;
|
||||||
AnsiString.MaximumLength = 256;
|
AnsiString.MaximumLength = 256;
|
||||||
AnsiString.Buffer = ModulePtr->ModuleName;
|
AnsiString.Buffer = ModulePtr->ImageName;
|
||||||
RtlUnicodeStringToAnsiString(&AnsiString,
|
RtlUnicodeStringToAnsiString(&AnsiString,
|
||||||
&Module->FullDllName,
|
&Module->FullDllName,
|
||||||
FALSE);
|
FALSE);
|
||||||
p = strrchr(ModulePtr->ModuleName, '\\');
|
p = strrchr(ModulePtr->ImageName, '\\');
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
ModulePtr->PathLength = p - ModulePtr->ModuleName + 1;
|
ModulePtr->ModuleNameOffset = p - ModulePtr->ImageName + 1;
|
||||||
else
|
else
|
||||||
ModulePtr->PathLength = 0;
|
ModulePtr->ModuleNameOffset = 0;
|
||||||
|
|
||||||
ModulePtr++;
|
ModulePtr++;
|
||||||
ModuleInformation->ModuleCount++;
|
ModuleInformation->ModuleCount++;
|
||||||
}
|
}
|
||||||
UsedSize += sizeof(MODULE_ENTRY);
|
UsedSize += sizeof(DEBUG_MODULE_INFORMATION);
|
||||||
|
|
||||||
Entry = Entry->Flink;
|
Entry = Entry->Flink;
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ RtlpQueryRemoteProcessModules(HANDLE ProcessHandle,
|
||||||
PLIST_ENTRY pleListHead;
|
PLIST_ENTRY pleListHead;
|
||||||
PLIST_ENTRY pleCurEntry;
|
PLIST_ENTRY pleCurEntry;
|
||||||
|
|
||||||
PMODULE_ENTRY ModulePtr = NULL;
|
PDEBUG_MODULE_INFORMATION ModulePtr = NULL;
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
ULONG UsedSize = sizeof(ULONG);
|
ULONG UsedSize = sizeof(ULONG);
|
||||||
ANSI_STRING AnsiString;
|
ANSI_STRING AnsiString;
|
||||||
|
@ -217,32 +217,31 @@ RtlpQueryRemoteProcessModules(HANDLE ProcessHandle,
|
||||||
}
|
}
|
||||||
else if (ModuleInformation != NULL)
|
else if (ModuleInformation != NULL)
|
||||||
{
|
{
|
||||||
ModulePtr->Unknown0 = 0; // FIXME: ??
|
ModulePtr->Reserved[0] = ModulePtr->Reserved[1] = 0; // FIXME: ??
|
||||||
ModulePtr->Unknown1 = 0; // FIXME: ??
|
ModulePtr->Base = lmModule.BaseAddress;
|
||||||
ModulePtr->BaseAddress = lmModule.BaseAddress;
|
ModulePtr->Size = lmModule.SizeOfImage;
|
||||||
ModulePtr->SizeOfImage = lmModule.SizeOfImage;
|
|
||||||
ModulePtr->Flags = lmModule.Flags;
|
ModulePtr->Flags = lmModule.Flags;
|
||||||
ModulePtr->Unknown2 = 0; // FIXME: load order index ??
|
ModulePtr->Index = 0; // FIXME: ??
|
||||||
ModulePtr->Unknown3 = 0; // FIXME: ??
|
ModulePtr->Unknown = 0; // FIXME: ??
|
||||||
ModulePtr->LoadCount = lmModule.LoadCount;
|
ModulePtr->LoadCount = lmModule.LoadCount;
|
||||||
|
|
||||||
AnsiString.Length = 0;
|
AnsiString.Length = 0;
|
||||||
AnsiString.MaximumLength = 256;
|
AnsiString.MaximumLength = 256;
|
||||||
AnsiString.Buffer = ModulePtr->ModuleName;
|
AnsiString.Buffer = ModulePtr->ImageName;
|
||||||
RtlUnicodeStringToAnsiString(&AnsiString,
|
RtlUnicodeStringToAnsiString(&AnsiString,
|
||||||
&Unicode,
|
&Unicode,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
p = strrchr(ModulePtr->ModuleName, '\\');
|
p = strrchr(ModulePtr->ImageName, '\\');
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
ModulePtr->PathLength = p - ModulePtr->ModuleName + 1;
|
ModulePtr->ModuleNameOffset = p - ModulePtr->ImageName + 1;
|
||||||
else
|
else
|
||||||
ModulePtr->PathLength = 0;
|
ModulePtr->ModuleNameOffset = 0;
|
||||||
|
|
||||||
ModulePtr++;
|
ModulePtr++;
|
||||||
ModuleInformation->ModuleCount++;
|
ModuleInformation->ModuleCount++;
|
||||||
}
|
}
|
||||||
UsedSize += sizeof(MODULE_ENTRY);
|
UsedSize += sizeof(DEBUG_MODULE_INFORMATION);
|
||||||
|
|
||||||
/* address of the next module in the list */
|
/* address of the next module in the list */
|
||||||
pleCurEntry = lmModule.InLoadOrderModuleList.Flink;
|
pleCurEntry = lmModule.InLoadOrderModuleList.Flink;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: ppb.c,v 1.19 2004/09/29 08:41:39 weiden Exp $
|
/* $Id: ppb.c,v 1.20 2004/11/19 01:30:35 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
/* INCLUDES ****************************************************************/
|
/* INCLUDES ****************************************************************/
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
#include <windows.h>
|
||||||
#include <ntdll/ldr.h>
|
#include <ntdll/ldr.h>
|
||||||
#include <napi/teb.h>
|
#include <napi/teb.h>
|
||||||
#include <ntdll/base.h>
|
#include <ntdll/base.h>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: process.c,v 1.35 2003/09/12 17:51:48 vizzini Exp $
|
/* $Id: process.c,v 1.36 2004/11/19 01:30:35 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
/* INCLUDES ****************************************************************/
|
/* INCLUDES ****************************************************************/
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
#include <windows.h>
|
||||||
#include <napi/i386/segment.h>
|
#include <napi/i386/segment.h>
|
||||||
#include <ntdll/ldr.h>
|
#include <ntdll/ldr.h>
|
||||||
#include <ntdll/base.h>
|
#include <ntdll/base.h>
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
#include <pe.h>
|
#include <pe.h>
|
||||||
#include <internal/io.h>
|
#include <internal/io.h>
|
||||||
#include <ntdll/ldr.h>
|
|
||||||
#include <internal/module.h>
|
#include <internal/module.h>
|
||||||
|
|
||||||
#define KERNEL_MODULE_NAME L"ntoskrnl.exe"
|
#define KERNEL_MODULE_NAME L"ntoskrnl.exe"
|
||||||
|
|
|
@ -1644,7 +1644,7 @@ RtlDestroyQueryDebugBuffer(
|
||||||
|
|
||||||
typedef struct _DEBUG_MODULE_INFORMATION {
|
typedef struct _DEBUG_MODULE_INFORMATION {
|
||||||
ULONG Reserved[2];
|
ULONG Reserved[2];
|
||||||
ULONG Base;
|
PVOID Base;
|
||||||
ULONG Size;
|
ULONG Size;
|
||||||
ULONG Flags;
|
ULONG Flags;
|
||||||
USHORT Index;
|
USHORT Index;
|
||||||
|
@ -1655,7 +1655,7 @@ typedef struct _DEBUG_MODULE_INFORMATION {
|
||||||
} DEBUG_MODULE_INFORMATION, *PDEBUG_MODULE_INFORMATION;
|
} DEBUG_MODULE_INFORMATION, *PDEBUG_MODULE_INFORMATION;
|
||||||
|
|
||||||
typedef struct _DEBUG_HEAP_INFORMATION {
|
typedef struct _DEBUG_HEAP_INFORMATION {
|
||||||
ULONG Base;
|
PVOID Base;
|
||||||
ULONG Flags;
|
ULONG Flags;
|
||||||
USHORT Granularity;
|
USHORT Granularity;
|
||||||
USHORT Unknown;
|
USHORT Unknown;
|
||||||
|
|
Loading…
Reference in a new issue