MmReleaseResourceCharge
VOID __fastcall MmReleaseResourceCharge(UINT64 a1, CHAR a2, INT64 a3){
struct _KPRCB *CurrentPrcb;
unsigned __int64 v4;
__int64 v5;
bool v6;
signed __int32 v7;
signed __int32 v8;
if( (a2 & 2) == 0 )
goto LABEL_2;
if( (_DWORD)a3 )
{
if( (_DWORD)a3 != 1 )
goto LABEL_2;
CurrentPrcb = KeGetCurrentPrcb();
v4 = a1;
v5 = *((int *)CurrentPrcb + 8391);
if( (_DWORD)v5 != -1 )
{
if( v5 + a1 <= 0x100 )
{
do
{
if( a1 >= 0x80000 )
break;
v8 = _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8391, v5 + a1, v5);
v6 = (_DWORD)v5 == v8;
LODWORD(v5) = v8;
if( v6 )
goto LABEL_2;
}
while( v8 != -1 && a1 + v8 <= 0x100 );
}
goto LABEL_11;
}
}
else
{
CurrentPrcb = KeGetCurrentPrcb();
v4 = a1;
v5 = *((int *)CurrentPrcb + 8391);
if( (_DWORD)v5 != -1 )
{
if( v5 + a1 <= 0x100 )
{
do
{
if( a1 >= 0x80000 )
break;
v7 = _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8391, v5 + a1, v5);
v6 = (_DWORD)v5 == v7;
LODWORD(v5) = v7;
if( v6 )
goto LABEL_2;
}
while( v7 != -1 && a1 + v7 <= 0x100 );
}
LABEL_11:
if( (int)v5 > 192
&& (_DWORD)v5 != -1
&& (_DWORD)v5 == _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8391, 192, v5) )
{
v4 = a1 + (int)v5 - 192;
}
}
}
if( v4 )
_InterlockedExchangeAdd64(&qword_140C526C0, v4);
LABEL_2:
if( (a2 & 1) != 0 )
MiReturnCommit((_MI_PARTITION *)&MiSystemPartition, a1);
}Referenced by:
MmChargeResources
SmAcquireReleaseCharges