Author: fireball
Date: Thu Feb 24 09:40:07 2011
New Revision: 50888
URL:
http://svn.reactos.org/svn/reactos?rev=50888&view=rev
Log:
[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.
Modified:
trunk/reactos/lib/rtl/heappage.c
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 09:40:07 2011
@@ -2066,8 +2066,39 @@
PVOID *UserValue,
PULONG UserFlags)
{
- UNIMPLEMENTED;
- return FALSE;
+ PDPH_HEAP_ROOT DphRoot;
+ 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
@@ -2076,8 +2107,38 @@
PVOID BaseAddress,
PVOID UserValue)
{
- UNIMPLEMENTED;
- return FALSE;
+ PDPH_HEAP_ROOT DphRoot;
+ 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
@@ -2088,17 +2149,79 @@
ULONG UserFlagsReset,
ULONG UserFlagsSet)
{
- UNIMPLEMENTED;
- return FALSE;
+ PDPH_HEAP_ROOT DphRoot;
+ 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
-RtlpPageHeapSize(HANDLE HeapPtr,
+RtlpPageHeapSize(HANDLE HeapHandle,
ULONG Flags,
- PVOID Ptr)
-{
- UNIMPLEMENTED;
- return 0;
+ PVOID BaseAddress)
+{
+ PDPH_HEAP_ROOT DphRoot;
+ 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 */