[NTOS:MM] Randomly allocate from special pool

This commit is contained in:
Thomas Faber 2022-01-16 10:54:33 -05:00
parent cf373fbc57
commit 3ccbd2a842
2 changed files with 5 additions and 4 deletions

View file

@ -26,7 +26,7 @@ MM_PAGED_POOL_INFO MmPagedPoolInfo;
SIZE_T MmAllocatedNonPagedPool;
SIZE_T MmTotalNonPagedPoolQuota;
SIZE_T MmTotalPagedPoolQuota;
ULONG MmSpecialPoolTag;
ULONG MmSpecialPoolTag = 1;
ULONG MmConsumedPoolPercentage;
BOOLEAN MmProtectFreedNonPagedPool;
SLIST_HEADER MiNonPagedPoolSListHead;

View file

@ -76,18 +76,19 @@ BOOLEAN
NTAPI
MmUseSpecialPool(SIZE_T NumberOfBytes, ULONG Tag)
{
static ULONG Seed = 0x5eed1234;
/* Special pool is not suitable for allocations bigger than 1 page */
if (NumberOfBytes > (PAGE_SIZE - sizeof(POOL_HEADER)))
{
return FALSE;
}
if (MmSpecialPoolTag == '*')
if (Tag == 'enoN')
{
return TRUE;
}
return Tag == MmSpecialPoolTag;
Seed = Seed * 16807 % 0x7fffffff;
return Seed % 11 == 2;
}
BOOLEAN