MiChargeForWriteInProgressPage
__int64 __fastcall MiChargeForWriteInProgressPage(__int64 a1, char a2){
unsigned __int64 v3;
unsigned int v5;
unsigned int v6;
struct _KPRCB *CurrentPrcb;
__int64 v9;
bool v10;
signed __int32 v11;
v3 = 1i64;
v5 = (a2 & 2) != 0 ? 0xFFFFFFFC : 0;
v6 = MiChargeResident((ULONG_PTR *)a1, 1ui64, (unsigned int)-((a2 & 2) != 0));
if( v6 )
{
if( (a2 & 1) == 0 || (unsigned int)MiChargeCommit((_MI_PARTITION *)a1, 1ui64, v5 + 8) )
return v6;
if( (ULONG_PTR *)a1 != &MiSystemPartition )
goto LABEL_17;
CurrentPrcb = KeGetCurrentPrcb();
v9 = *((int *)CurrentPrcb + 8391);
if( (_DWORD)v9 == -1 )
goto LABEL_17;
if( (unsigned __int64)(v9 + 1) <= 0x100 )
{
do
{
v11 = _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8391, v9 + 1, v9);
v10 = (_DWORD)v9 == v11;
LODWORD(v9) = v11;
if( v10 )
return 0i64;
}
while( v11 != -1 && (unsigned __int64)(v11 + 1i64) <= 0x100 );
}
if( (int)v9 > 192
&& (_DWORD)v9 != -1
&& (_DWORD)v9 == _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8391, 192, v9) )
{
v3 = (int)v9 - 192 + 1i64;
}
if( v3 )
LABEL_17:
_InterlockedExchangeAdd64((volatile signed __int64 *)(a1 + 7168), v3);
}
return 0i64;
}Referenced by:
MiAllocateModWriterEntry
MiReferencePageForModifiedWrite