mirror of
https://github.com/reactos/reactos.git
synced 2024-09-12 22:02:18 +00:00
Replaced RtlAllocateHeap with NtAllocateVirtualMemory.
svn path=/trunk/; revision=10493
This commit is contained in:
parent
ca0c109cec
commit
486bb2502f
|
@ -23,17 +23,26 @@
|
||||||
* FILE: lib/ntdll/rtl/dbgbuffer.c
|
* FILE: lib/ntdll/rtl/dbgbuffer.c
|
||||||
* PROGRAMER: James Tabor
|
* PROGRAMER: James Tabor
|
||||||
* Fixme: Add Process and Thread event pair support.
|
* Fixme: Add Process and Thread event pair support.
|
||||||
* Fix Heap support.
|
* Start Locks and Heap support.
|
||||||
|
* Test: Create remote thread to help query remote
|
||||||
|
* processes and use view mapping to read them.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
#include <ntos/types.h>
|
#include <ntos/types.h>
|
||||||
#include <napi/teb.h>
|
#include <napi/teb.h>
|
||||||
#include <ntdll/rtl.h>
|
#include <ntdll/rtl.h>
|
||||||
|
#include <ntdll/ldr.h>
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
#include <rosrtl/thread.h>
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -43,14 +52,25 @@ PDEBUG_BUFFER STDCALL
|
||||||
RtlCreateQueryDebugBuffer(IN ULONG Size,
|
RtlCreateQueryDebugBuffer(IN ULONG Size,
|
||||||
IN BOOLEAN EventPair)
|
IN BOOLEAN EventPair)
|
||||||
{
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
PDEBUG_BUFFER Buf = NULL;
|
PDEBUG_BUFFER Buf = NULL;
|
||||||
|
ULONG SectionSize = 100 * PAGE_SIZE;
|
||||||
|
|
||||||
if (Size < sizeof(DEBUG_BUFFER))
|
Status = NtAllocateVirtualMemory( NtCurrentProcess(),
|
||||||
|
(PVOID)&Buf,
|
||||||
|
0,
|
||||||
|
&SectionSize,
|
||||||
|
MEM_COMMIT,
|
||||||
|
PAGE_READWRITE);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
Size = sizeof(DEBUG_BUFFER);
|
return NULL;
|
||||||
}
|
}
|
||||||
Buf = (PDEBUG_BUFFER) RtlAllocateHeap(RtlGetProcessHeap(), 0, Size);
|
|
||||||
memset(Buf, 0, Size);
|
Buf->SectionBase = Buf;
|
||||||
|
Buf->SectionSize = SectionSize;
|
||||||
|
|
||||||
|
DPRINT("RtlCQDB: BA: %x BS: %d\n", Buf->SectionBase, Buf->SectionSize);
|
||||||
|
|
||||||
return Buf;
|
return Buf;
|
||||||
}
|
}
|
||||||
|
@ -63,18 +83,17 @@ RtlDestroyQueryDebugBuffer(IN PDEBUG_BUFFER Buf)
|
||||||
{
|
{
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
if (NULL != Buf) {
|
if (NULL != Buf)
|
||||||
if (NULL != Buf->ModuleInformation)
|
{
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buf->ModuleInformation);
|
Status = NtFreeVirtualMemory( NtCurrentProcess(),
|
||||||
|
(PVOID)&Buf,
|
||||||
if (NULL != Buf->HeapInformation)
|
&Buf->SectionSize,
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buf->HeapInformation);
|
MEM_RELEASE);
|
||||||
|
}
|
||||||
if (NULL != Buf->LockInformation)
|
if (!NT_SUCCESS(Status))
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buf->LockInformation);
|
{
|
||||||
|
DPRINT1("RtlDQDB: Failed to free VM!\n");
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buf);
|
}
|
||||||
}
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,37 +108,53 @@ RtlQueryProcessDebugInformation(IN ULONG ProcessId,
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
Buf->InfoClassMask = DebugInfoMask;
|
Buf->InfoClassMask = DebugInfoMask;
|
||||||
|
Buf->SizeOfInfo = 0;
|
||||||
|
|
||||||
|
DPRINT("QueryProcessDebugInformation Start\n");
|
||||||
|
|
||||||
if (DebugInfoMask & PDI_MODULES)
|
if (DebugInfoMask & PDI_MODULES)
|
||||||
{
|
{
|
||||||
PDEBUG_MODULE_INFORMATION info =
|
PMODULE_INFORMATION Mp;
|
||||||
RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(DEBUG_MODULE_INFORMATION));
|
ULONG MSize;
|
||||||
memset(info, 0, sizeof(DEBUG_MODULE_INFORMATION));
|
|
||||||
Buf->ModuleInformation = info;
|
Mp = (PMODULE_INFORMATION)(Buf + sizeof(DEBUG_BUFFER) + Buf->SizeOfInfo);
|
||||||
|
MSize = sizeof(MODULE_INFORMATION);
|
||||||
|
Buf->ModuleInformation = Mp;
|
||||||
|
Buf->SizeOfInfo = Buf->SizeOfInfo + MSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DebugInfoMask & PDI_HEAPS)
|
if (DebugInfoMask & PDI_HEAPS)
|
||||||
{
|
{
|
||||||
PDEBUG_HEAP_INFORMATION info =
|
PDEBUG_HEAP_INFORMATION Hp;
|
||||||
RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(DEBUG_HEAP_INFORMATION));
|
ULONG HSize;
|
||||||
memset(info, 0, sizeof(DEBUG_HEAP_INFORMATION));
|
|
||||||
|
|
||||||
|
Hp = (PDEBUG_HEAP_INFORMATION)(Buf + sizeof(DEBUG_BUFFER) + Buf->SizeOfInfo);
|
||||||
|
HSize = sizeof(DEBUG_HEAP_INFORMATION);
|
||||||
if (DebugInfoMask & PDI_HEAP_TAGS)
|
if (DebugInfoMask & PDI_HEAP_TAGS)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
if (DebugInfoMask & PDI_HEAP_BLOCKS)
|
if (DebugInfoMask & PDI_HEAP_BLOCKS)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
Buf->HeapInformation = info;
|
Buf->HeapInformation = Hp;
|
||||||
|
Buf->SizeOfInfo = Buf->SizeOfInfo + HSize;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DebugInfoMask & PDI_LOCKS)
|
if (DebugInfoMask & PDI_LOCKS)
|
||||||
{
|
{
|
||||||
PDEBUG_LOCK_INFORMATION info =
|
PDEBUG_LOCK_INFORMATION Lp;
|
||||||
RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(DEBUG_LOCK_INFORMATION));
|
ULONG LSize;
|
||||||
memset(info, 0, sizeof(DEBUG_LOCK_INFORMATION));
|
|
||||||
Buf->LockInformation = info;
|
Lp = (PDEBUG_LOCK_INFORMATION)(Buf + sizeof(DEBUG_BUFFER) + Buf->SizeOfInfo);
|
||||||
|
LSize = sizeof(DEBUG_LOCK_INFORMATION);
|
||||||
|
Buf->LockInformation = Lp;
|
||||||
|
Buf->SizeOfInfo = Buf->SizeOfInfo + LSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DPRINT("QueryProcessDebugInformation end \n");
|
||||||
|
DPRINT("QueryDebugInfo : %d\n", Buf->SizeOfInfo);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue