Author: fireball
Date: Thu Apr 30 13:09:03 2009
New Revision: 40750

URL: http://svn.reactos.org/svn/reactos?rev=40750&view=rev
Log:
- Make debug pool return 8-bytes aligned pointers. The padding area (up to 7 
bytes) is not being checked for overruns now. ReactOS fully boots and works 
with this change and a debug pool.

Modified:
    trunk/reactos/ntoskrnl/mm/dbgpool.c

Modified: trunk/reactos/ntoskrnl/mm/dbgpool.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/dbgpool.c?rev=40750&r1=40749&r2=40750&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/dbgpool.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/dbgpool.c [iso-8859-1] Thu Apr 30 13:09:03 2009
@@ -24,12 +24,23 @@
 NTAPI
 ExpIsPoolTagDebuggable(ULONG Tag)
 {
+#if 0
     if (Tag == TAG('C', 'a', 'l', 'l')) return FALSE;
     if (Tag == TAG('D', 'r', 'i', 'v')) return FALSE;
     if (Tag == TAG('D', 'e', 'v', 'i')) return FALSE;
     if (Tag == TAG('A', 'd', 'a', 'p')) return FALSE;
 
-    return FALSE;//TRUE;
+    if (Tag == TAG('S', 'e', 'S', 'd')) return FALSE;
+    if (Tag == TAG('O', 'b', 'D', 'i')) return FALSE;
+    if (Tag == TAG('O', 'b', 'N', 'm')) return FALSE;
+    if (Tag == TAG('O', 'b', 'N', 'D')) return FALSE;
+    if (Tag == TAG('O', 'b', 't', 'b')) return FALSE;
+    if (Tag == TAG('O', 'b', 'S', 'c')) return FALSE;
+    //if (Tag == TAG('S', 'e', 'S', 'i')) return FALSE;
+    //if (Tag == TAG('S', 'e', 'A', 'c')) return FALSE;
+#endif
+
+    return TRUE;
 }
 
 
@@ -37,11 +48,15 @@
 NTAPI
 ExpAllocateDebugPool(POOL_TYPE Type, ULONG Size, ULONG Tag, PVOID Caller, 
BOOLEAN EndOfPage)
 {
-    ULONG UserSize = Size + sizeof(EI_WHOLE_PAGE_HEADER);
-    ULONG TotalSize = UserSize + 2*PAGE_SIZE;
+    ULONG UserSize, TotalSize, AlignedSize;
     ULONG_PTR UserData, GuardArea;
     PEI_WHOLE_PAGE_HEADER Header;
     ULONG_PTR Buffer;
+
+    /* Calculate sizes */
+    AlignedSize = ROUND_UP(Size, MM_POOL_ALIGNMENT);
+    UserSize = AlignedSize + sizeof(EI_WHOLE_PAGE_HEADER);
+    TotalSize = UserSize + 2*PAGE_SIZE;
 
     /* Right now we support only end-of-page allocations */
     ASSERT(EndOfPage);
@@ -70,13 +85,13 @@
     GuardArea = PAGE_ROUND_DOWN(Buffer + TotalSize - PAGE_SIZE + 1);
 
     /* Calculate user data and header pointers */
-    UserData = GuardArea - Size;
+    UserData = GuardArea - AlignedSize;
     Header = (PEI_WHOLE_PAGE_HEADER)(UserData - sizeof(EI_WHOLE_PAGE_HEADER));
 
     /* Fill out the header */
     Header->ActualAddress = (PVOID)Buffer;
     Header->Tag = Tag;
-    Header->Size = Size;
+    Header->Size = AlignedSize;
 
     /* Protect the guard page */
     MmSetPageProtect(NULL, (PVOID)GuardArea, PAGE_NOACCESS);

Reply via email to