MiObtainFaultCharges
UINT64 __stdcall MiObtainFaultCharges(_MI_PARTITION *Partition, UINT64 DesiredPageCount, UINT64 Flags){
char v3;
unsigned int v4;
struct _KPRCB *CurrentPrcb;
unsigned __int64 v7;
bool v8;
unsigned __int32 v9;
unsigned int v10;
INT64 v12;
v3 = Flags;
v4 = DesiredPageCount;
while( 1 )
{
if( Partition == (_MI_PARTITION *)&MiSystemPartition )
{
CurrentPrcb = KeGetCurrentPrcb();
v7 = *((unsigned int *)CurrentPrcb + 8391);
if( v4 <= v7 )
{
do
{
if( (_DWORD)v7 == -1 )
break;
v9 = _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8391, v7 - v4, v7);
v8 = (_DWORD)v7 == v9;
LODWORD(v7) = v9;
if( v8 )
goto LABEL_6;
}
while( v4 <= (unsigned __int64)v9 );
}
}
v12 = 1i64;
if( v4 != 1 )
v12 = 1024i64;
if( (unsigned int)MiChargePartitionResidentAvailable((INT64)Partition, v4, v12) )
break;
v4 >>= 1;
if( !v4 )
goto LABEL_23;
}
LABEL_6:
if( v4 )
goto LABEL_7;
LABEL_23:
if( (v3 & 2) == 0 )
return 0i64;
v4 = 1;
MiChargeResident((ULONG_PTR *)Partition, 1ui64, 0xFFFFFFFFi64);
LABEL_7:
if( (v3 & 1) == 0 )
return v4;
v10 = v4;
while( (unsigned int)MiChargeCommit(Partition, v10, 1ui64) != 1 )
{
v10 >>= 1;
if( !v10 )
{
if( (v3 & 2) != 0 )
{
v10 = 1;
MiChargeCommit(Partition, 1ui64, 4ui64);
}
break;
}
}
if( v10 != v4 )
MiReturnFaultCharges(Partition, v4 - v10, 0i64);
return v10;
}Referenced by:
MiGetPageForHeader
MiMigratePfn
MiPfPrepareReadList
MiPfPrepareSequentialReadList
MiPfPutPagesInTransition
MiPickClusterForMappedFileFault
MiPrivateFixup
MiResolveMappedFileFault
MiResolvePageFileFault
MiSwitchToTransition