[RTL/DPH]

- Implement user flags/values and HeapSize APIs in debug page heap (nearly the same code in all three functions). With these done, DPH core features are complete. Some debugging is still needed.

svn path=/trunk/; revision=50888
This commit is contained in:
Aleksey Bragin 2011-02-24 09:40:07 +00:00
parent 353147d2cc
commit 947127151c

View file

@ -2066,8 +2066,39 @@ RtlpPageHeapGetUserInfo(PVOID HeapHandle,
PVOID *UserValue, PVOID *UserValue,
PULONG UserFlags) PULONG UserFlags)
{ {
UNIMPLEMENTED; PDPH_HEAP_ROOT DphRoot;
return FALSE; PDPH_HEAP_BLOCK Node;
/* Get a pointer to the heap root */
DphRoot = RtlpDphPointerFromHandle(HeapHandle);
if (!DphRoot) return FALSE;
/* Add heap flags */
Flags |= DphRoot->HeapFlags;
/* Acquire the heap lock */
RtlpDphPreProcessing(DphRoot, Flags);
/* Find busy memory */
Node = RtlpDphFindBusyMemory(DphRoot, BaseAddress);
if (!Node)
{
/* This block was not found in page heap, try a normal heap instead */
//RtlpDphNormalHeapGetUserInfo();
ASSERT(FALSE);
return FALSE;
}
/* Get user values and flags and store them in user provided pointers */
if (UserValue) *UserValue = Node->UserValue;
if (UserFlags) *UserFlags = Node->UserFlags;
/* Leave the heap lock */
RtlpDphPostProcessing(DphRoot);
/* Return success */
return TRUE;
} }
BOOLEAN NTAPI BOOLEAN NTAPI
@ -2076,8 +2107,38 @@ RtlpPageHeapSetUserValue(PVOID HeapHandle,
PVOID BaseAddress, PVOID BaseAddress,
PVOID UserValue) PVOID UserValue)
{ {
UNIMPLEMENTED; PDPH_HEAP_ROOT DphRoot;
return FALSE; PDPH_HEAP_BLOCK Node;
/* Get a pointer to the heap root */
DphRoot = RtlpDphPointerFromHandle(HeapHandle);
if (!DphRoot) return FALSE;
/* Add heap flags */
Flags |= DphRoot->HeapFlags;
/* Acquire the heap lock */
RtlpDphPreProcessing(DphRoot, Flags);
/* Find busy memory */
Node = RtlpDphFindBusyMemory(DphRoot, BaseAddress);
if (!Node)
{
/* This block was not found in page heap, try a normal heap instead */
//RtlpDphNormalHeapSetUserValue();
ASSERT(FALSE);
return FALSE;
}
/* Get user values and flags and store them in user provided pointers */
Node->UserValue = UserValue;
/* Leave the heap lock */
RtlpDphPostProcessing(DphRoot);
/* Return success */
return TRUE;
} }
BOOLEAN BOOLEAN
@ -2088,17 +2149,79 @@ RtlpPageHeapSetUserFlags(PVOID HeapHandle,
ULONG UserFlagsReset, ULONG UserFlagsReset,
ULONG UserFlagsSet) ULONG UserFlagsSet)
{ {
UNIMPLEMENTED; PDPH_HEAP_ROOT DphRoot;
return FALSE; PDPH_HEAP_BLOCK Node;
/* Get a pointer to the heap root */
DphRoot = RtlpDphPointerFromHandle(HeapHandle);
if (!DphRoot) return FALSE;
/* Add heap flags */
Flags |= DphRoot->HeapFlags;
/* Acquire the heap lock */
RtlpDphPreProcessing(DphRoot, Flags);
/* Find busy memory */
Node = RtlpDphFindBusyMemory(DphRoot, BaseAddress);
if (!Node)
{
/* This block was not found in page heap, try a normal heap instead */
//RtlpDphNormalHeapSetUserFlags();
ASSERT(FALSE);
return FALSE;
}
/* Get user values and flags and store them in user provided pointers */
Node->UserFlags &= ~(UserFlagsReset);
Node->UserFlags |= UserFlagsSet;
/* Leave the heap lock */
RtlpDphPostProcessing(DphRoot);
/* Return success */
return TRUE;
} }
SIZE_T NTAPI SIZE_T NTAPI
RtlpPageHeapSize(HANDLE HeapPtr, RtlpPageHeapSize(HANDLE HeapHandle,
ULONG Flags, ULONG Flags,
PVOID Ptr) PVOID BaseAddress)
{ {
UNIMPLEMENTED; PDPH_HEAP_ROOT DphRoot;
return 0; PDPH_HEAP_BLOCK Node;
SIZE_T Size;
/* Get a pointer to the heap root */
DphRoot = RtlpDphPointerFromHandle(HeapHandle);
if (!DphRoot) return -1;
/* Add heap flags */
Flags |= DphRoot->HeapFlags;
/* Acquire the heap lock */
RtlpDphPreProcessing(DphRoot, Flags);
/* Find busy memory */
Node = RtlpDphFindBusyMemory(DphRoot, BaseAddress);
if (!Node)
{
/* This block was not found in page heap, try a normal heap instead */
//RtlpDphNormalHeapSize();
ASSERT(FALSE);
return -1;
}
/* Get heap block size */
Size = Node->nUserRequestedSize;
/* Leave the heap lock */
RtlpDphPostProcessing(DphRoot);
/* Return user requested size */
return Size;
} }
/* EOF */ /* EOF */