ExpAllocateHandleTable
_HANDLE_TABLE *__stdcall ExpAllocateHandleTable(PVOID Process, UINT8 DoInit){
size_t v4;
VOID **PoolWithTag;
__int64 v6;
_QWORD *v7;
_HANDLE_TABLE_ENTRY *LowLevelTable;
_HANDLE_TABLE_ENTRY *v9;
_HANDLE_TABLE *result;
v4 = (ExpFreeListCount + 1) << 6;
PoolWithTag = ExAllocatePoolWithTag(5ui64, v4, 1651794511i64);
if( !PoolWithTag )
return 0i64;
if( Process && PsChargeProcessPagedPoolQuota((_EPROCESS *)Process, 0x80ui64) < 0 )
{
ExFreePoolWithTag(PoolWithTag, 0x6274624Fu);
return 0i64;
}
memset(PoolWithTag, 0i64, v4);
PoolWithTag[2] = Process;
v6 = (unsigned int)ExpFreeListCount;
*((_DWORD *)PoolWithTag + 10) = KeGetCurrentThread()->ApcState.Process->UniqueProcessId;
if( (_DWORD)v6 )
{
v7 = PoolWithTag + 8;
do
{
*v7 = 0i64;
v7 += 8;
--v6;
}
while( v6 );
}
LowLevelTable = ExpAllocateLowLevelTable((_HANDLE_TABLE *)PoolWithTag, 0i64);
v9 = LowLevelTable;
if( !LowLevelTable )
{
ExFreePoolWithTag(PoolWithTag, 0x6274624Fu);
if( Process )
PsReturnProcessPagedPoolQuota((ULONG_PTR)Process, 0x80u);
return 0i64;
}
ExpInsertLowLevelTableIntoFreeList(
(_HANDLE_TABLE *)PoolWithTag,
LowLevelTable,
(_HANDLE_TABLE_FREE_LIST *)PoolWithTag + 1,
DoInit);
PoolWithTag[1] = v9;
if( Process )
*((_BYTE *)PoolWithTag + 44) |= 0x10u;
PoolWithTag[7] = 0i64;
result = (_HANDLE_TABLE *)PoolWithTag;
PoolWithTag[6] = 0i64;
return result;
}Referenced by:
ExDupHandleTable