[NTOS]: Missed a bunch of codepaths, protected pool "should" work now.

svn path=/trunk/; revision=48650
This commit is contained in:
Sir Richard 2010-08-29 19:27:58 +00:00
parent cf28a01e5e
commit b85ab20f13
2 changed files with 35 additions and 10 deletions

View file

@ -435,6 +435,9 @@ typedef struct _MMFREE_POOL_ENTRY
struct _MMFREE_POOL_ENTRY *Owner; struct _MMFREE_POOL_ENTRY *Owner;
} MMFREE_POOL_ENTRY, *PMMFREE_POOL_ENTRY; } MMFREE_POOL_ENTRY, *PMMFREE_POOL_ENTRY;
/* Signature of a freed block */
#define MM_FREE_POOL_SIGNATURE 'ARM3'
/* Paged pool information */ /* Paged pool information */
typedef struct _MM_PAGED_POOL_INFO typedef struct _MM_PAGED_POOL_INFO
{ {

View file

@ -615,6 +615,13 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
NextEntry = NextHead->Flink; NextEntry = NextHead->Flink;
while (NextEntry != NextHead) while (NextEntry != NextHead)
{ {
/* Is freed non paged pool enabled */
if (MmProtectFreedNonPagedPool)
{
/* We need to be able to touch this page, unprotect it */
MiUnProtectFreeNonPagedPool(NextEntry, 0);
}
// //
// Grab the entry and see if it can handle our allocation // Grab the entry and see if it can handle our allocation
// //
@ -632,9 +639,9 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
BaseVa = (PVOID)((ULONG_PTR)FreeEntry + BaseVa = (PVOID)((ULONG_PTR)FreeEntry +
(FreeEntry->Size << PAGE_SHIFT)); (FreeEntry->Size << PAGE_SHIFT));
// /* Remove the item from the list, depending if pool is protected */
// This is not a free page segment anymore MmProtectFreedNonPagedPool ?
// MiProtectedPoolRemoveEntryList(&FreeEntry->List) :
RemoveEntryList(&FreeEntry->List); RemoveEntryList(&FreeEntry->List);
// //
@ -642,13 +649,21 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
// //
if (FreeEntry->Size != 0) if (FreeEntry->Size != 0)
{ {
// /* Check which list to insert this entry into */
// Insert it back into a different list, based on its pages
//
i = FreeEntry->Size - 1; i = FreeEntry->Size - 1;
if (i >= MI_MAX_FREE_PAGE_LISTS) i = MI_MAX_FREE_PAGE_LISTS - 1; if (i >= MI_MAX_FREE_PAGE_LISTS) i = MI_MAX_FREE_PAGE_LISTS - 1;
InsertTailList (&MmNonPagedPoolFreeListHead[i],
&FreeEntry->List); /* Insert the entry into the free list head, check for prot. pool */
MmProtectFreedNonPagedPool ?
MiProtectedPoolInsertList(&MmNonPagedPoolFreeListHead[i], &FreeEntry->List, TRUE) :
InsertTailList(&MmNonPagedPoolFreeListHead[i], &FreeEntry->List);
/* Is freed non paged pool protected? */
if (MmProtectFreedNonPagedPool)
{
/* Protect the freed pool! */
MiProtectFreeNonPagedPool(FreeEntry, FreeEntry->Size);
}
} }
// //
@ -698,6 +713,13 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
// Try the next free page entry // Try the next free page entry
// //
NextEntry = FreeEntry->List.Flink; NextEntry = FreeEntry->List.Flink;
/* Is freed non paged pool protected? */
if (MmProtectFreedNonPagedPool)
{
/* Protect the freed pool! */
MiProtectFreeNonPagedPool(FreeEntry, FreeEntry->Size);
}
} }
} while (++NextHead < LastHead); } while (++NextHead < LastHead);