HyperDbg Debugger
Loading...
Searching...
No Matches
PoolManager.h File Reference

Headers of pool manager. More...

Go to the source code of this file.

Classes

struct  _POOL_TABLE
 Table of holding pools detail structure. More...
 
struct  _REQUEST_NEW_ALLOCATION
 Manage the requests for new allocations. More...
 

Macros

#define MaximumRequestsQueueDepth   300
 Maximum Pool Requests (while not allocated)
 
#define NumberOfPreAllocatedBuffers   10
 

Typedefs

typedef struct _POOL_TABLE POOL_TABLE
 Table of holding pools detail structure.
 
typedef struct _POOL_TABLEPPOOL_TABLE
 
typedef struct _REQUEST_NEW_ALLOCATION REQUEST_NEW_ALLOCATION
 Manage the requests for new allocations.
 
typedef struct _REQUEST_NEW_ALLOCATIONPREQUEST_NEW_ALLOCATION
 

Functions

BOOLEAN PoolManagerInitialize ()
 Initializes the Pool Manager and pre-allocate some pools.
 
VOID PoolManagerUninitialize ()
 De-allocate all the allocated pools.
 

Variables

REQUEST_NEW_ALLOCATIONg_RequestNewAllocation
 If sb wants allocation from vmx root, adds it's request to this structure.
 
volatile LONG LockForRequestAllocation
 Request allocation Spinlock.
 
volatile LONG LockForReadingPool
 Spinlock for reading pool.
 
BOOLEAN g_IsNewRequestForAllocationReceived
 We set it when there is a new allocation.
 
BOOLEAN g_IsNewRequestForDeAllocation
 We set it when there is a new allocation.
 
LIST_ENTRY g_ListOfAllocatedPoolsHead
 Create a list from all pools.
 

Detailed Description

Headers of pool manager.

Author
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Version
0.1
Date
2020-04-11

Macro Definition Documentation

◆ MaximumRequestsQueueDepth

#define MaximumRequestsQueueDepth   300

Maximum Pool Requests (while not allocated)

◆ NumberOfPreAllocatedBuffers

#define NumberOfPreAllocatedBuffers   10

Typedef Documentation

◆ POOL_TABLE

typedef struct _POOL_TABLE POOL_TABLE

Table of holding pools detail structure.

◆ PPOOL_TABLE

typedef struct _POOL_TABLE * PPOOL_TABLE

◆ PREQUEST_NEW_ALLOCATION

◆ REQUEST_NEW_ALLOCATION

Manage the requests for new allocations.

Function Documentation

◆ PoolManagerInitialize()

BOOLEAN PoolManagerInitialize ( )

Initializes the Pool Manager and pre-allocate some pools.

Returns
BOOLEAN

Initializes the Pool Manager and pre-allocate some pools.

Returns
BOOLEAN
54{
55 //
56 // Allocate global requesting variable
57 //
58 SIZE_T BufferSize = MaximumRequestsQueueDepth * sizeof(REQUEST_NEW_ALLOCATION);
59 if (!PlmgrAllocateRequestNewAllocation(BufferSize))
60 {
61 LogError("Err, insufficient memory");
62 return FALSE;
63 }
64
65 //
66 // Initialize list head
67 //
69
70 //
71 // Nothing to deallocate
72 //
74
75 //
76 // Initialized successfully
77 //
78 return TRUE;
79}
#define TRUE
Definition BasicTypes.h:55
#define FALSE
Definition BasicTypes.h:54
#define LogError(format,...)
Log in the case of error.
Definition HyperDbgHyperLogIntrinsics.h:113
BOOLEAN PlmgrAllocateRequestNewAllocation(SIZE_T NumberOfBytes)
Allocate global requesting variable.
Definition PoolManager.c:21
struct _REQUEST_NEW_ALLOCATION REQUEST_NEW_ALLOCATION
Manage the requests for new allocations.
#define MaximumRequestsQueueDepth
Maximum Pool Requests (while not allocated)
Definition PoolManager.h:22
BOOLEAN g_IsNewRequestForDeAllocation
We set it when there is a new allocation.
Definition PoolManager.h:89
LIST_ENTRY g_ListOfAllocatedPoolsHead
Create a list from all pools.
Definition PoolManager.h:95
FORCEINLINE VOID InitializeListHead(_Out_ PLIST_ENTRY ListHead)
Definition Windows.h:41

◆ PoolManagerUninitialize()

VOID PoolManagerUninitialize ( )

De-allocate all the allocated pools.

Returns
VOID

De-allocate all the allocated pools.

Returns
VOID
88{
89 PLIST_ENTRY ListTemp = 0;
91
93
94 while (&g_ListOfAllocatedPoolsHead != ListTemp->Flink)
95 {
96 ListTemp = ListTemp->Flink;
97
98 //
99 // Get the head of the record
100 //
101 PPOOL_TABLE PoolTable = (PPOOL_TABLE)CONTAINING_RECORD(ListTemp, POOL_TABLE, PoolsList);
102
103 //
104 // Free the alloocated buffer (if not already changed)
105 //
106 if (!PoolTable->AlreadyFreed)
107 {
108 PlatformMemFreePool((PVOID)PoolTable->Address);
109 }
110
111 //
112 // Unlink the PoolTable
113 //
114 RemoveEntryList(&PoolTable->PoolsList);
115
116 //
117 // Free the record itself
118 //
119 PlatformMemFreePool(PoolTable);
120 }
121
123
125}
VOID PlatformMemFreePool(PVOID BufferAddress)
Free (dellocate) a non-paged buffer.
Definition Mem.c:86
VOID PlmgrFreeRequestNewAllocation(VOID)
Definition PoolManager.c:37
volatile LONG LockForReadingPool
Spinlock for reading pool.
Definition PoolManager.h:77
struct _POOL_TABLE * PPOOL_TABLE
void SpinlockLock(volatile LONG *Lock)
Tries to get the lock and won't return until successfully get the lock.
Definition Spinlock.c:52
void SpinlockUnlock(volatile LONG *Lock)
Release the lock.
Definition Spinlock.c:158
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition Windows.h:56
Table of holding pools detail structure.
Definition PoolManager.h:34
UINT64 Address
Definition PoolManager.h:35
BOOLEAN AlreadyFreed
Definition PoolManager.h:41
LIST_ENTRY PoolsList
Definition PoolManager.h:38

Variable Documentation

◆ g_IsNewRequestForAllocationReceived

BOOLEAN g_IsNewRequestForAllocationReceived

We set it when there is a new allocation.

◆ g_IsNewRequestForDeAllocation

BOOLEAN g_IsNewRequestForDeAllocation

We set it when there is a new allocation.

◆ g_ListOfAllocatedPoolsHead

LIST_ENTRY g_ListOfAllocatedPoolsHead

Create a list from all pools.

◆ g_RequestNewAllocation

REQUEST_NEW_ALLOCATION* g_RequestNewAllocation

If sb wants allocation from vmx root, adds it's request to this structure.

◆ LockForReadingPool

volatile LONG LockForReadingPool

Spinlock for reading pool.

◆ LockForRequestAllocation

volatile LONG LockForRequestAllocation

Request allocation Spinlock.