PspReturnQuota
signed __int64 __fastcall PspReturnQuota(char *a1, void *a2, _PS_RESOURCE_TYPE a3, unsigned __int64 a4){
char *v5;
__int64 v6;
void *v9;
char v10;
volatile signed __int64 *v11;
unsigned __int64 v12;
unsigned __int64 v13;
char *BugCheckParameter4;
unsigned __int64 v15;
signed __int64 v16;
bool v17;
signed __int64 result;
unsigned __int64 *v19;
unsigned __int64 v20;
UINT64 v21;
v5 = a1;
v6 = (__int64)(int)a3 << 7;
v9 = (void *)(int)a3;
v10 = PspResourceFlags[8 * a3];
v11 = (volatile signed __int64 *)&a1[v6];
_m_prefetchw(&a1[v6]);
v12 = *(_QWORD *)&a1[v6];
v13 = *(_QWORD *)&a1[v6 + 64];
if( *(_QWORD *)&a1[v6 + 80] )
{
if( v13 > v12 )
{
v19 = (unsigned __int64 *)&qword_140C1DF68[7 * a3];
v20 = *v19;
if( v13 - v12 > *v19 )
{
if( v20 > a4 )
v20 = a4;
if( v13 == _InterlockedCompareExchange64(v11 + 8, v13 - v20, v13)
&& _InterlockedExchangeAdd64(v11 + 9, v20) + v20 > *v19 )
{
v21 = _InterlockedExchange64(v11 + 9, 0i64);
if( v21 )
PspReturnResourceQuota(a3, (_PSP_QUOTA_ENTRY *)&a1[v6], v21, 0i64);
}
}
}
}
BugCheckParameter4 = (char *)a4;
while( 1 )
{
do
{
if( (unsigned __int64)BugCheckParameter4 >= v12 )
{
v15 = v12;
v16 = 0i64;
}
else
{
v15 = (unsigned __int64)BugCheckParameter4;
v16 = v12 - (_QWORD)BugCheckParameter4;
}
result = _InterlockedCompareExchange64(v11, v16, v12);
v17 = v12 == result;
v12 = result;
}
while( !v17 );
BugCheckParameter4 -= v15;
if( !BugCheckParameter4 )
break;
if( v5 == (char *)&unk_140C537C0 )
KeBugCheckEx(0x21u, a2, v9, (PVOID)a4, BugCheckParameter4);
v5 = (char *)&unk_140C537C0;
v11 = (volatile signed __int64 *)((char *)&unk_140C537C0 + v6);
_m_prefetchw((char *)&unk_140C537C0 + v6);
v12 = *(_QWORD *)((char *)&unk_140C537C0 + v6);
}
if( a2 )
{
if( (v10 & 4) != 0 )
_InterlockedExchangeAdd64((volatile signed __int64 *)a2 + (_QWORD)v9 + 142, -(__int64)a4);
}
return result;
}Referenced by:
ExFreeHeapPool
ObpFreeObject
ObpIncrementHandleCountEx
PsChargeSharedPoolQuota
PsReturnPoolQuota
PsReturnProcessNonPagedPoolQuota
PsReturnProcessPageFileQuota
PsReturnProcessPagedPoolQuota
PsReturnProcessQuota
PsReturnSharedPoolQuota