- Debug pool allocator: Add support for paged pool debugging.

svn path=/trunk/; revision=40727
This commit is contained in:
Aleksey Bragin 2009-04-29 09:48:31 +00:00
parent eb036429b8
commit e6400c3f8b
3 changed files with 19 additions and 6 deletions

View file

@ -574,7 +574,7 @@ ExpAllocateDebugPool(
VOID
NTAPI
ExpFreeDebugPool(PVOID Block);
ExpFreeDebugPool(PVOID Block, BOOLEAN PagedPool);
VOID
NTAPI

View file

@ -91,7 +91,7 @@ ExpAllocateDebugPool(POOL_TYPE Type, ULONG Size, ULONG Tag, PVOID Caller, BOOLEA
VOID
NTAPI
ExpFreeDebugPool(PVOID Block)
ExpFreeDebugPool(PVOID Block, BOOLEAN PagedPool)
{
PEI_WHOLE_PAGE_HEADER Header;
PVOID ProtectedPage;
@ -111,7 +111,10 @@ ExpFreeDebugPool(PVOID Block)
MmSetPageProtect(NULL, ProtectedPage, PAGE_READWRITE);
/* Free storage */
ExFreeNonPagedPool(Header->ActualAddress);
if (PagedPool)
ExFreePagedPool(Header->ActualAddress);
else
ExFreeNonPagedPool(Header->ActualAddress);
}
/* EOF */

View file

@ -58,7 +58,12 @@ EiAllocatePool(POOL_TYPE PoolType,
{
if (KeGetCurrentIrql() > APC_LEVEL)
KeBugCheckEx(BAD_POOL_CALLER, 0x08, KeGetCurrentIrql(), PoolType, Tag);
Block = ExAllocatePagedPoolWithTag(PoolType, NumberOfBytes, Tag);
#ifdef DEBUG_PPOOL
if (ExpIsPoolTagDebuggable(Tag))
Block = ExpAllocateDebugPool(PoolType, NumberOfBytes, Tag, Caller, TRUE);
else
#endif
Block = ExAllocatePagedPoolWithTag(PoolType, NumberOfBytes, Tag);
}
else
{
@ -277,7 +282,12 @@ ExFreePoolWithTag(
(ULONG_PTR)Block);
/* Free from paged pool */
ExFreePagedPool(Block);
#ifdef DEBUG_PPOOL
if (ExpIsPoolTagDebuggable(Tag))
ExpFreeDebugPool(Block, TRUE);
else
#endif
ExFreePagedPool(Block);
}
/* Check for non-paged pool */
@ -303,7 +313,7 @@ ExFreePoolWithTag(
/* Free from non-paged pool */
#ifdef DEBUG_NPOOL
if (ExpIsPoolTagDebuggable(Tag))
ExpFreeDebugPool(Block);
ExpFreeDebugPool(Block, FALSE);
else
#endif
ExFreeNonPagedPool(Block);