MmResourcesAvailable
UINT64 __stdcall MmResourcesAvailable(POOL_TYPE PoolType, UINT64 NumberOfBytes, _EX_POOL_PRIORITY Priority){
ULONG_PTR *v3;
unsigned int v4;
char v7;
UINT64 v8;
__int64 v9;
__int32 v10;
__int64 v11;
__int64 v12;
unsigned __int64 v13;
unsigned __int64 v14;
__int64 v15;
UINT64 v16;
UINT64 v17;
UINT64 v18;
ULONG_PTR v19;
struct _KEVENT *v20;
UINT64 v21;
_ETHREAD *CurrentThread;
struct _KEVENT *v24;
struct _KLOCK_QUEUE_HANDLE LockHandle;
v3 = &MiSystemPartition;
v4 = 0;
memset(&LockHandle, 0, sizeof(LockHandle));
v7 = PoolType;
v8 = (NumberOfBytes >> 12) + ((NumberOfBytes & 0xFFF) != 0);
v9 = *(_QWORD *)(*((_QWORD *)KeGetCurrentThread() + 23) + 1368i64);
v10 = PoolType & 1;
if( (PoolType & 1) == 0 )
{
v11 = *(_QWORD *)MiState - qword_140C4C608;
LABEL_8:
v16 = v11 << 12;
goto LABEL_9;
}
if( (PoolType & 0x20) == 0 )
{
v11 = qword_140C4EC78 - qword_140C4EC68;
goto LABEL_8;
}
v12 = *(_QWORD *)(*((_QWORD *)KeGetCurrentThread() + 23) + 1368i64);
v13 = (__int64)*(int *)(v12 + 868) << 21;
v14 = *(_QWORD *)(v12 + 184) << 12;
v15 = v13 - v14;
if( v13 <= v14 )
v15 = 0i64;
v16 = ((0x10000i64 - *(unsigned int *)(v12 + 872)) << 21) + v15;
v3 = *(ULONG_PTR **)(qword_140C4E388 + 8i64 * *(unsigned __int16 *)(v9 + 430));
LABEL_9:
v17 = NumberOfBytes + 0x80000;
if( Priority != NormalPoolPriority )
v17 = NumberOfBytes + 0x200000;
if( v17 <= v16 )
{
if( (PoolType & 1) == 0 )
goto LABEL_23;
v18 = 0i64;
v19 = v3[933];
if( v19 <= v3[777] )
v18 = v3[777] - v19;
if( v8 > v18 )
{
MiIssuePageExtendRequest((_MI_PARTITION *)v3, v8, 2ui64, 0i64);
}
else
{
LABEL_23:
if( NumberOfBytes + 10485760 < v16 || v3[866] < 0x40000 )
return 1i64;
v4 = 1;
}
}
if( (v7 & 0x20) == 0 )
{
if( v10 )
{
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
--*((_WORD *)CurrentThread + 243);
ExAcquirePushLockExclusiveEx((UINT64)&qword_140C4EC58, 0i64);
v24 = (struct _KEVENT *)v3[31];
if( !v24->Header.SignalState )
KePulseEvent(v24, 0);
if( (_InterlockedExchangeAdd64((volatile signed __int64 *)&qword_140C4EC58, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
ExfTryToWakePushLock((volatile INT64 *)&qword_140C4EC58);
KeAbPostRelease(&qword_140C4EC58);
KiLeaveGuardedRegionUnsafe((__int64)CurrentThread);
}
else
{
KeAcquireInStackQueuedSpinLock(v3 + 616, &LockHandle);
v20 = (struct _KEVENT *)v3[33];
if( !v20->Header.SignalState )
KePulseEvent(v20, 0);
KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle);
__writecr8(LockHandle.OldIrql);
}
MiFreeExcessSegments(v21);
}
return v4;
}Referenced by:
ExAllocatePoolWithTagPriority