mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 03:54:02 +00:00
[RTL/DPH]
- Implement ValidateHeap API for DPH. Fixes attempts to validate DPH as a normal heap. svn path=/trunk/; revision=50892
This commit is contained in:
parent
098228ac32
commit
8383b6b33d
3 changed files with 77 additions and 1 deletions
|
@ -3707,7 +3707,9 @@ BOOLEAN NTAPI RtlValidateHeap(
|
|||
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)
|
||||
|
|
|
@ -435,6 +435,12 @@ RtlpPageHeapSetUserFlags(PVOID HeapHandle,
|
|||
ULONG UserFlagsReset,
|
||||
ULONG UserFlagsSet);
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
RtlpDebugPageHeapValidate(PVOID HeapPtr,
|
||||
ULONG Flags,
|
||||
PVOID Block);
|
||||
|
||||
SIZE_T NTAPI
|
||||
RtlpPageHeapSize(HANDLE HeapPtr,
|
||||
ULONG Flags,
|
||||
|
|
|
@ -191,6 +191,10 @@ RtlpDphIsNormalFreeHeapBlock(PVOID Block, PULONG ValidationInformation, BOOLEAN
|
|||
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 @@ RtlpPageHeapSize(HANDLE HeapHandle,
|
|||
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 */
|
||||
|
|
Loading…
Reference in a new issue