Unify naming convention for pool tracking structures
This commit is contained in:
@@ -224,13 +224,13 @@ typedef struct _POOL_HEADER
|
|||||||
} POOL_HEADER, *PPOOL_HEADER;
|
} POOL_HEADER, *PPOOL_HEADER;
|
||||||
|
|
||||||
/* Pool descriptor structure definition */
|
/* Pool descriptor structure definition */
|
||||||
typedef struct _POOL_TRACKER_BIG_ALLOCATIONS
|
typedef struct _POOL_TRACKING_BIG_ALLOCATIONS
|
||||||
{
|
{
|
||||||
ULONG NumberOfPages;
|
ULONG NumberOfPages;
|
||||||
PVOID QuotaObject;
|
PVOID QuotaObject;
|
||||||
ULONG Tag;
|
ULONG Tag;
|
||||||
PVOID VirtualAddress;
|
PVOID VirtualAddress;
|
||||||
} POOL_TRACKER_BIG_ALLOCATIONS, *PPOOL_TRACKER_BIG_ALLOCATIONS;
|
} POOL_TRACKING_BIG_ALLOCATIONS, *PPOOL_TRACKING_BIG_ALLOCATIONS;
|
||||||
|
|
||||||
/* Pool tracking table structure definition */
|
/* Pool tracking table structure definition */
|
||||||
typedef struct _POOL_TRACKING_TABLE
|
typedef struct _POOL_TRACKING_TABLE
|
||||||
|
|||||||
@@ -313,7 +313,7 @@ typedef struct _PECOFF_IMAGE_VXD_HEADER PECOFF_IMAGE_VXD_HEADER, *PPECOFF_IMAGE_
|
|||||||
typedef struct _PHYSICAL_MEMORY_DESCRIPTOR PHYSICAL_MEMORY_DESCRIPTOR, *PPHYSICAL_MEMORY_DESCRIPTOR;
|
typedef struct _PHYSICAL_MEMORY_DESCRIPTOR PHYSICAL_MEMORY_DESCRIPTOR, *PPHYSICAL_MEMORY_DESCRIPTOR;
|
||||||
typedef struct _PHYSICAL_MEMORY_RUN PHYSICAL_MEMORY_RUN, *PPHYSICAL_MEMORY_RUN;
|
typedef struct _PHYSICAL_MEMORY_RUN PHYSICAL_MEMORY_RUN, *PPHYSICAL_MEMORY_RUN;
|
||||||
typedef struct _POOL_HEADER POOL_HEADER, *PPOOL_HEADER;
|
typedef struct _POOL_HEADER POOL_HEADER, *PPOOL_HEADER;
|
||||||
typedef struct _POOL_TRACKER_BIG_ALLOCATIONS POOL_TRACKER_BIG_ALLOCATIONS, *PPOOL_TRACKER_BIG_ALLOCATIONS;
|
typedef struct _POOL_TRACKING_BIG_ALLOCATIONS POOL_TRACKING_BIG_ALLOCATIONS, *PPOOL_TRACKING_BIG_ALLOCATIONS;
|
||||||
typedef struct _POOL_TRACKING_TABLE POOL_TRACKING_TABLE, *PPOOL_TRACKING_TABLE;
|
typedef struct _POOL_TRACKING_TABLE POOL_TRACKING_TABLE, *PPOOL_TRACKING_TABLE;
|
||||||
typedef struct _PROCESSOR_IDENTITY PROCESSOR_IDENTITY, *PPROCESSOR_IDENTITY;
|
typedef struct _PROCESSOR_IDENTITY PROCESSOR_IDENTITY, *PPROCESSOR_IDENTITY;
|
||||||
typedef struct _PROCESSOR_POWER_STATE PROCESSOR_POWER_STATE, *PPROCESSOR_POWER_STATE;
|
typedef struct _PROCESSOR_POWER_STATE PROCESSOR_POWER_STATE, *PPROCESSOR_POWER_STATE;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace MM
|
|||||||
STATIC SIZE_T AllocationsTrackingTableMask;
|
STATIC SIZE_T AllocationsTrackingTableMask;
|
||||||
STATIC SIZE_T AllocationsTrackingTableSize;
|
STATIC SIZE_T AllocationsTrackingTableSize;
|
||||||
STATIC ULONG BigAllocationsInUse;
|
STATIC ULONG BigAllocationsInUse;
|
||||||
STATIC PPOOL_TRACKER_BIG_ALLOCATIONS BigAllocationsTrackingTable;
|
STATIC PPOOL_TRACKING_BIG_ALLOCATIONS BigAllocationsTrackingTable;
|
||||||
STATIC SIZE_T BigAllocationsTrackingTableHash;
|
STATIC SIZE_T BigAllocationsTrackingTableHash;
|
||||||
STATIC KSPIN_LOCK BigAllocationsTrackingTableLock;
|
STATIC KSPIN_LOCK BigAllocationsTrackingTableLock;
|
||||||
STATIC SIZE_T BigAllocationsTrackingTableSize;
|
STATIC SIZE_T BigAllocationsTrackingTableSize;
|
||||||
|
|||||||
@@ -603,7 +603,7 @@ XTAPI
|
|||||||
BOOLEAN
|
BOOLEAN
|
||||||
MM::Allocator::ExpandBigAllocationsTable(VOID)
|
MM::Allocator::ExpandBigAllocationsTable(VOID)
|
||||||
{
|
{
|
||||||
PPOOL_TRACKER_BIG_ALLOCATIONS NewTable, OldTable;
|
PPOOL_TRACKING_BIG_ALLOCATIONS NewTable, OldTable;
|
||||||
SIZE_T AllocationBytes, OldSize, NewSize;
|
SIZE_T AllocationBytes, OldSize, NewSize;
|
||||||
ULONG Hash, HashMask, Index;
|
ULONG Hash, HashMask, Index;
|
||||||
XTSTATUS Status;
|
XTSTATUS Status;
|
||||||
@@ -624,17 +624,17 @@ MM::Allocator::ExpandBigAllocationsTable(VOID)
|
|||||||
NewSize = OldSize * 2;
|
NewSize = OldSize * 2;
|
||||||
|
|
||||||
/* Ensure the new capacity does not result in fractional memory pages */
|
/* Ensure the new capacity does not result in fractional memory pages */
|
||||||
NewSize = ROUND_DOWN(NewSize, MM_PAGE_SIZE / sizeof(POOL_TRACKER_BIG_ALLOCATIONS));
|
NewSize = ROUND_DOWN(NewSize, MM_PAGE_SIZE / sizeof(POOL_TRACKING_BIG_ALLOCATIONS));
|
||||||
|
|
||||||
/* Check if calculating the total byte size would cause an integer overflow */
|
/* Check if calculating the total byte size would cause an integer overflow */
|
||||||
if(NewSize > ((~(SIZE_T)0) / sizeof(POOL_TRACKER_BIG_ALLOCATIONS)))
|
if(NewSize > ((~(SIZE_T)0) / sizeof(POOL_TRACKING_BIG_ALLOCATIONS)))
|
||||||
{
|
{
|
||||||
/* Abort expansion to prevent allocating a truncated memory block */
|
/* Abort expansion to prevent allocating a truncated memory block */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compute the size required for the newly expanded tracking table */
|
/* Compute the size required for the newly expanded tracking table */
|
||||||
AllocationBytes = NewSize * sizeof(POOL_TRACKER_BIG_ALLOCATIONS);
|
AllocationBytes = NewSize * sizeof(POOL_TRACKING_BIG_ALLOCATIONS);
|
||||||
|
|
||||||
/* Allocate the required memory */
|
/* Allocate the required memory */
|
||||||
Status = AllocatePages(NonPagedPool, AllocationBytes, (PVOID*)&NewTable);
|
Status = AllocatePages(NonPagedPool, AllocationBytes, (PVOID*)&NewTable);
|
||||||
@@ -1379,7 +1379,7 @@ MM::Allocator::InitializeBigAllocationsTracking(VOID)
|
|||||||
while(TRUE)
|
while(TRUE)
|
||||||
{
|
{
|
||||||
/* Prevent integer overflow when calculating the required byte size for the table */
|
/* Prevent integer overflow when calculating the required byte size for the table */
|
||||||
if((BigAllocationsTrackingTableSize + 1) > (MAXULONG_PTR / sizeof(POOL_TRACKER_BIG_ALLOCATIONS)))
|
if((BigAllocationsTrackingTableSize + 1) > (MAXULONG_PTR / sizeof(POOL_TRACKING_BIG_ALLOCATIONS)))
|
||||||
{
|
{
|
||||||
/* Halve the requested entry count and restart the evaluation */
|
/* Halve the requested entry count and restart the evaluation */
|
||||||
BigAllocationsTrackingTableSize >>= 1;
|
BigAllocationsTrackingTableSize >>= 1;
|
||||||
@@ -1388,7 +1388,7 @@ MM::Allocator::InitializeBigAllocationsTracking(VOID)
|
|||||||
|
|
||||||
/* Attempt to allocate physical memory for the table */
|
/* Attempt to allocate physical memory for the table */
|
||||||
Status = AllocatePages(NonPagedPool,
|
Status = AllocatePages(NonPagedPool,
|
||||||
BigAllocationsTrackingTableSize * sizeof(POOL_TRACKER_BIG_ALLOCATIONS),
|
BigAllocationsTrackingTableSize * sizeof(POOL_TRACKING_BIG_ALLOCATIONS),
|
||||||
(PVOID*)&BigAllocationsTrackingTable);
|
(PVOID*)&BigAllocationsTrackingTable);
|
||||||
|
|
||||||
/* Check if the allocation succeeded */
|
/* Check if the allocation succeeded */
|
||||||
@@ -1412,7 +1412,7 @@ MM::Allocator::InitializeBigAllocationsTracking(VOID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Zero the entire memory used by the table */
|
/* Zero the entire memory used by the table */
|
||||||
RtlZeroMemory(BigAllocationsTrackingTable, BigAllocationsTrackingTableSize * sizeof(POOL_TRACKER_BIG_ALLOCATIONS));
|
RtlZeroMemory(BigAllocationsTrackingTable, BigAllocationsTrackingTableSize * sizeof(POOL_TRACKING_BIG_ALLOCATIONS));
|
||||||
|
|
||||||
/* Iterate through the newly allocated table */
|
/* Iterate through the newly allocated table */
|
||||||
for(Index = 0; Index < BigAllocationsTrackingTableSize; Index++)
|
for(Index = 0; Index < BigAllocationsTrackingTableSize; Index++)
|
||||||
@@ -1429,7 +1429,7 @@ MM::Allocator::InitializeBigAllocationsTracking(VOID)
|
|||||||
|
|
||||||
/* Register the allocation in the tracking table */
|
/* Register the allocation in the tracking table */
|
||||||
RegisterAllocationTag(SIGNATURE32('M', 'M', 'g', 'r'),
|
RegisterAllocationTag(SIGNATURE32('M', 'M', 'g', 'r'),
|
||||||
SIZE_TO_PAGES(BigAllocationsTrackingTableSize * sizeof(POOL_TRACKER_BIG_ALLOCATIONS)),
|
SIZE_TO_PAGES(BigAllocationsTrackingTableSize * sizeof(POOL_TRACKING_BIG_ALLOCATIONS)),
|
||||||
NonPagedPool);
|
NonPagedPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1560,7 +1560,7 @@ MM::Allocator::RegisterBigAllocationTag(IN PVOID VirtualAddress,
|
|||||||
IN ULONG Pages,
|
IN ULONG Pages,
|
||||||
IN MMPOOL_TYPE PoolType)
|
IN MMPOOL_TYPE PoolType)
|
||||||
{
|
{
|
||||||
PPOOL_TRACKER_BIG_ALLOCATIONS Entry;
|
PPOOL_TRACKING_BIG_ALLOCATIONS Entry;
|
||||||
BOOLEAN Inserted, RequiresExpansion;
|
BOOLEAN Inserted, RequiresExpansion;
|
||||||
ULONG Hash, StartHash;
|
ULONG Hash, StartHash;
|
||||||
|
|
||||||
@@ -1766,7 +1766,7 @@ MM::Allocator::UnregisterBigAllocationTag(IN PVOID VirtualAddress,
|
|||||||
ULONG Hash, StartHash;
|
ULONG Hash, StartHash;
|
||||||
ULONG PoolTag;
|
ULONG PoolTag;
|
||||||
BOOLEAN Found;
|
BOOLEAN Found;
|
||||||
PPOOL_TRACKER_BIG_ALLOCATIONS Entry;
|
PPOOL_TRACKING_BIG_ALLOCATIONS Entry;
|
||||||
|
|
||||||
/* Initialize default state */
|
/* Initialize default state */
|
||||||
Found = FALSE;
|
Found = FALSE;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ SIZE_T MM::Allocator::AllocationsTrackingTableSize;
|
|||||||
ULONG MM::Allocator::BigAllocationsInUse;
|
ULONG MM::Allocator::BigAllocationsInUse;
|
||||||
|
|
||||||
/* Pointer to the hash table for tracking page-aligned memory */
|
/* Pointer to the hash table for tracking page-aligned memory */
|
||||||
PPOOL_TRACKER_BIG_ALLOCATIONS MM::Allocator::BigAllocationsTrackingTable;
|
PPOOL_TRACKING_BIG_ALLOCATIONS MM::Allocator::BigAllocationsTrackingTable;
|
||||||
|
|
||||||
/* Bitmask used for fast modulo arithmetic during hash bucket lookups */
|
/* Bitmask used for fast modulo arithmetic during hash bucket lookups */
|
||||||
SIZE_T MM::Allocator::BigAllocationsTrackingTableHash;
|
SIZE_T MM::Allocator::BigAllocationsTrackingTableHash;
|
||||||
|
|||||||
Reference in New Issue
Block a user