Author: fireball
Date: Thu Feb 24 12:59:52 2011
New Revision: 50892
URL:
http://svn.reactos.org/svn/reactos?rev=50892&view=rev
Log:
[RTL/DPH]
- Implement ValidateHeap API for DPH. Fixes attempts to validate DPH as a normal heap.
Modified:
trunk/reactos/lib/rtl/heap.c
trunk/reactos/lib/rtl/heap.h
trunk/reactos/lib/rtl/heappage.c
Modified: trunk/reactos/lib/rtl/heap.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/heap.c?rev=50892&a…
==============================================================================
--- trunk/reactos/lib/rtl/heap.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/heap.c [iso-8859-1] Thu Feb 24 12:59:52 2011
@@ -3707,7 +3707,9 @@
BOOLEAN HeapLocked = FALSE;
BOOLEAN HeapValid;
- // FIXME Check for special heap
+ /* Check for page heap */
+ if (Heap->ForceFlags & HEAP_FLAG_PAGE_ALLOCS)
+ return RtlpDebugPageHeapValidate(HeapPtr, Flags, Block);
/* Check signature */
if (Heap->Signature != HEAP_SIGNATURE)
Modified: trunk/reactos/lib/rtl/heap.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/heap.h?rev=50892&a…
==============================================================================
--- trunk/reactos/lib/rtl/heap.h [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/heap.h [iso-8859-1] Thu Feb 24 12:59:52 2011
@@ -435,6 +435,12 @@
ULONG UserFlagsReset,
ULONG UserFlagsSet);
+BOOLEAN
+NTAPI
+RtlpDebugPageHeapValidate(PVOID HeapPtr,
+ ULONG Flags,
+ PVOID Block);
+
SIZE_T NTAPI
RtlpPageHeapSize(HANDLE HeapPtr,
ULONG Flags,
Modified: trunk/reactos/lib/rtl/heappage.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/heappage.c?rev=508…
==============================================================================
--- trunk/reactos/lib/rtl/heappage.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/heappage.c [iso-8859-1] Thu Feb 24 12:59:52 2011
@@ -191,6 +191,10 @@
VOID NTAPI
RtlpDphReportCorruptedBlock(PDPH_HEAP_ROOT DphRoot, ULONG Reserved, PVOID Block, ULONG
ValidationInfo);
+BOOLEAN NTAPI
+RtlpDphNormalHeapValidate(PDPH_HEAP_ROOT DphRoot, ULONG Flags, PVOID BaseAddress);
+
+
VOID NTAPI
RtlpDphRaiseException(NTSTATUS Status)
{
@@ -2224,4 +2228,68 @@
return Size;
}
+BOOLEAN
+NTAPI
+RtlpDebugPageHeapValidate(PVOID HeapHandle,
+ ULONG Flags,
+ PVOID BaseAddress)
+{
+ PDPH_HEAP_ROOT DphRoot;
+ PDPH_HEAP_BLOCK Node = NULL;
+ BOOLEAN Valid = FALSE;
+
+ /* 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 */
+ if (BaseAddress)
+ Node = RtlpDphFindBusyMemory(DphRoot, BaseAddress);
+
+ if (!Node)
+ {
+ /* This block was not found in page heap, or the request is to validate all
normal heap */
+ Valid = RtlpDphNormalHeapValidate(DphRoot, Flags, BaseAddress);
+ }
+
+ /* Leave the heap lock */
+ RtlpDphPostProcessing(DphRoot);
+
+ /* Return result of a normal heap validation */
+ if (BaseAddress && !Node)
+ return Valid;
+
+ /* Otherwise return our own result */
+ if (!BaseAddress || Node) Valid = TRUE;
+
+ return Valid;
+}
+
+BOOLEAN
+NTAPI
+RtlpDphNormalHeapValidate(PDPH_HEAP_ROOT DphRoot,
+ ULONG Flags,
+ PVOID BaseAddress)
+{
+ PDPH_BLOCK_INFORMATION BlockInfo = (PDPH_BLOCK_INFORMATION)BaseAddress - 1;
+ if (!BaseAddress)
+ {
+ /* Validate all normal heap */
+ return RtlValidateHeap(DphRoot->NormalHeap, Flags, NULL);
+ }
+
+ // FIXME: Check is this a normal heap block
+ /*if (!RtlpDphIsNormalHeapBlock(DphRoot, BaseAddress, &ValidationInfo))
+ {
+ }*/
+
+ return RtlValidateHeap(DphRoot->NormalHeap, Flags, BlockInfo);
+}
+
/* EOF */