https://git.reactos.org/?p=reactos.git;a=commitdiff;h=21647e2c4ecf2bb71e642ee5023133cc9641013f

commit 21647e2c4ecf2bb71e642ee5023133cc9641013f
Author:     Timo Kreuzer <[email protected]>
AuthorDate: Mon Nov 25 19:32:06 2019 +0100
Commit:     Timo Kreuzer <[email protected]>
CommitDate: Mon Nov 25 19:32:06 2019 +0100

    [NTOS] Revert pool debugging code
    
    Revert "[NTOS] On DBG builds, fill pool allocations with 0xCD and freed 
pool with 0xDD"
    This reverts commit 24f240be8a5f7b09a0c122f40384fc63576accfa.
    
    Revert "[NTOS] Add compile time option to trace callers of pool allocations"
    This reverts commit 8b20755040754506f3f12a30857f8edc5bf83f33.
    
    Revert "WIP"
    This reverts commit 8cfd5c601f354625a11ee097984cda0c90f93889.
---
 ntoskrnl/mm/ARM3/expool.c | 87 +++++++----------------------------------------
 ntoskrnl/mm/ARM3/pool.c   | 20 ++---------
 2 files changed, 15 insertions(+), 92 deletions(-)

diff --git a/ntoskrnl/mm/ARM3/expool.c b/ntoskrnl/mm/ARM3/expool.c
index bbf6e407f09..bccb0e9bbdd 100644
--- a/ntoskrnl/mm/ARM3/expool.c
+++ b/ntoskrnl/mm/ARM3/expool.c
@@ -22,10 +22,6 @@
 
 #define POOL_BIG_TABLE_ENTRY_FREE 0x1
 
-/* DEBUGGING 
******************************************************************/
-
-//#define DBG_NUMBER_OF_FRAMES_TO_CAPTURE 5
-
 typedef struct _POOL_DPC_CONTEXT
 {
     PPOOL_TRACKER_TABLE PoolTrackTable;
@@ -1851,14 +1847,9 @@ ExReturnPoolQuota(IN PVOID P)
  */
 PVOID
 NTAPI
-#ifdef DBG_NUMBER_OF_FRAMES_TO_CAPTURE
-ExAllocatePoolWithTagInternal(
-#else
-ExAllocatePoolWithTag(
-#endif
-    _In_ POOL_TYPE PoolType,
-    _In_ SIZE_T NumberOfBytes,
-    _In_ ULONG Tag)
+ExAllocatePoolWithTag(IN POOL_TYPE PoolType,
+                      IN SIZE_T NumberOfBytes,
+                      IN ULONG Tag)
 {
     PPOOL_DESCRIPTOR PoolDesc;
     PLIST_ENTRY ListHead;
@@ -1868,7 +1859,6 @@ ExAllocatePoolWithTag(
     ULONG OriginalType;
     PKPRCB Prcb = KeGetCurrentPrcb();
     PGENERAL_LOOKASIDE LookasideList;
-    PVOID Allocation;
 
     //
     // Some sanity checks
@@ -1908,13 +1898,10 @@ ExAllocatePoolWithTag(
             if (MmUseSpecialPool(NumberOfBytes, Tag))
             {
                 //
-                // Try to allocate using special pool (initialized with random 
byte)
+                // Try to allocate using special pool
                 //
-                Allocation = MmAllocateSpecialPool(NumberOfBytes, Tag, 
PoolType, 2);
-                if (Allocation != NULL)
-                {
-                    return Allocation;
-                }
+                Entry = MmAllocateSpecialPool(NumberOfBytes, Tag, PoolType, 2);
+                if (Entry) return Entry;
             }
         }
     }
@@ -1935,8 +1922,8 @@ ExAllocatePoolWithTag(
         //
         // Allocate pages for it
         //
-        Allocation = MiAllocatePoolPages(OriginalType, NumberOfBytes);
-        if (Allocation == NULL)
+        Entry = MiAllocatePoolPages(OriginalType, NumberOfBytes);
+        if (!Entry)
         {
 #if DBG
             //
@@ -2008,7 +1995,7 @@ ExAllocatePoolWithTag(
         // Add a tag for the big page allocation and switch to the generic 
"BIG"
         // tag if we failed to do so, then insert a tracker for this alloation.
         //
-        if (!ExpAddTagForBigPages(Allocation,
+        if (!ExpAddTagForBigPages(Entry,
                                   Tag,
                                   (ULONG)BYTES_TO_PAGES(NumberOfBytes),
                                   OriginalType))
@@ -2016,10 +2003,7 @@ ExAllocatePoolWithTag(
             Tag = ' GIB';
         }
         ExpInsertPoolTracker(Tag, ROUND_TO_PAGES(NumberOfBytes), OriginalType);
-#if DBG
-        RtlFillMemory(Allocation, NumberOfBytes, 0xCD);
-#endif
-        return Allocation;
+        return Entry;
     }
 
     //
@@ -2089,11 +2073,7 @@ ExAllocatePoolWithTag(
             Entry->PoolTag = Tag;
             (POOL_FREE_BLOCK(Entry))->Flink = NULL;
             (POOL_FREE_BLOCK(Entry))->Blink = NULL;
-            Allocation = POOL_FREE_BLOCK(Entry);
-#if DBG
-            RtlFillMemory(Allocation, NumberOfBytes, 0xCD);
-#endif
-            return Allocation;
+            return POOL_FREE_BLOCK(Entry);
         }
     }
 
@@ -2277,11 +2257,7 @@ ExAllocatePoolWithTag(
             Entry->PoolTag = Tag;
             (POOL_FREE_BLOCK(Entry))->Flink = NULL;
             (POOL_FREE_BLOCK(Entry))->Blink = NULL;
-            Allocation = POOL_FREE_BLOCK(Entry);
-#if DBG
-            RtlFillMemory(Allocation, NumberOfBytes, 0xCD);
-#endif
-            return Allocation;
+            return POOL_FREE_BLOCK(Entry);
         }
     } while (++ListHead != &PoolDesc->ListHeads[POOL_LISTS_PER_PAGE]);
 
@@ -2424,37 +2400,8 @@ ExAllocatePoolWithTag(
     //
     ExpCheckPoolBlocks(Entry);
     Entry->PoolTag = Tag;
-    Allocation = POOL_FREE_BLOCK(Entry);
-
-    return Allocation;
-}
-
-#ifdef DBG_NUMBER_OF_FRAMES_TO_CAPTURE
-PVOID
-NTAPI
-ExAllocatePoolWithTag(
-    _In_ POOL_TYPE PoolType,
-    _In_ SIZE_T NumberOfBytes,
-    _In_ ULONG Tag)
-{
-    SIZE_T FullSize;
-    PVOID Allocation, *DbgData;
-
-    /* Allocate a larger chunk to add the debug data */
-    FullSize = NumberOfBytes + (DBG_NUMBER_OF_FRAMES_TO_CAPTURE + 2) * 
sizeof(PVOID);
-    Allocation = ExAllocatePoolWithTagInternal(PoolType, FullSize, Tag);
-    if (Allocation == NULL)
-    {
-        return NULL;
-    }
-
-    /* Append the debug data, separated by a '####' */
-    DbgData = ALIGN_UP_POINTER_BY((PUCHAR)Allocation + NumberOfBytes, 
sizeof(PVOID));
-    DbgData[0] = (PVOID)(ULONG_PTR)'####';
-    RtlWalkFrameChain(&DbgData[1], DBG_NUMBER_OF_FRAMES_TO_CAPTURE, 0);
-    return Allocation;
+    return POOL_FREE_BLOCK(Entry);
 }
-#endif
 
 /*
  * @implemented
@@ -2597,10 +2544,6 @@ ExFreePoolWithTag(IN PVOID P,
             Tag &= ~PROTECTED_POOL;
         }
 
-#if DBG
-        RtlFillMemory(P, PageCount * PAGE_SIZE, 0xDD);
-#endif
-
         //
         // Check block tag
         //
@@ -2726,10 +2669,6 @@ ExFreePoolWithTag(IN PVOID P,
         }
     }
 
-#if DBG
-    RtlFillMemory(P, BlockSize * POOL_BLOCK_SIZE - sizeof(*Entry), 0xDD);
-#endif
-
     //
     // Is this allocation small enough to have come from a lookaside list?
     //
diff --git a/ntoskrnl/mm/ARM3/pool.c b/ntoskrnl/mm/ARM3/pool.c
index afafcf823ec..5d6554bad75 100644
--- a/ntoskrnl/mm/ARM3/pool.c
+++ b/ntoskrnl/mm/ARM3/pool.c
@@ -665,9 +665,6 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
         //
         // Return the allocation address to the caller
         //
-#if DBG
-        RtlFillMemoryUlong(BaseVa, ROUND_TO_PAGES(SizeInBytes), 0xABABABAB);
-#endif
         return BaseVa;
     }
 
@@ -677,13 +674,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
     if ((SizeInPages == 1) && (ExQueryDepthSList(&MiNonPagedPoolSListHead)))
     {
         BaseVa = InterlockedPopEntrySList(&MiNonPagedPoolSListHead);
-        if (BaseVa)
-        {
-#if DBG
-            RtlFillMemoryUlong(BaseVa, ROUND_TO_PAGES(SizeInBytes), 
0xABABABAB);
-#endif
-            return BaseVa;
-        }
+        if (BaseVa) return BaseVa;
     }
 
     //
@@ -811,9 +802,6 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
                 // Release the nonpaged pool lock, and return the allocation
                 //
                 KeReleaseQueuedSpinLock(LockQueueMmNonPagedPoolLock, OldIrql);
-#if DBG
-                RtlFillMemoryUlong(BaseVa, ROUND_TO_PAGES(SizeInBytes), 
0xABABABAB);
-#endif
                 return BaseVa;
             }
 
@@ -909,11 +897,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
     //
     // Return the address
     //
-    BaseVa = MiPteToAddress(StartPte);
-#if DBG
-    RtlFillMemoryUlong(BaseVa, ROUND_TO_PAGES(SizeInBytes), 0xABABABAB);
-#endif
-    return BaseVa;
+    return MiPteToAddress(StartPte);
 }
 
 ULONG

Reply via email to