MiObtainFaultCharges
NTSTATUS __fastcall MiObtainFaultCharges(_MI_PARTITION *Partition, UINT64 NumberOfPages, CHAR a3){
unsigned int v4;
struct _KPRCB *CurrentPrcb;
unsigned __int64 CachedResidentAvailable;
bool v8;
unsigned __int32 v9;
unsigned int v10;
UINT64 v12;
v4 = NumberOfPages;
while( 1 )
{
if( Partition == &Irp )
{
CurrentPrcb = KeGetCurrentPrcb();
CachedResidentAvailable = CurrentPrcb->CachedResidentAvailable;
if( v4 <= CachedResidentAvailable )
{
do
{
if( (_DWORD)CachedResidentAvailable == -1 )
break;
v9 = _InterlockedCompareExchange(
(volatile signed __int32 *)&CurrentPrcb->CachedResidentAvailable,
CachedResidentAvailable - v4,
CachedResidentAvailable);
v8 = (_DWORD)CachedResidentAvailable == v9;
LODWORD(CachedResidentAvailable) = v9;
if( v8 )
goto LABEL_6;
}
while( v4 <= (unsigned __int64)v9 );
}
}
v12 = 1i64;
if( v4 != 1 )
v12 = 1024i64;
if( MiChargePartitionResidentAvailable(Partition, v4, v12) )
break;
v4 >>= 1;
if( !v4 )
goto LABEL_23;
}
LABEL_6:
if( v4 )
goto LABEL_7;
LABEL_23:
if( (a3 & 2) == 0 )
return 0;
v4 = 1;
MiChargeResident((ULONG_PTR *)&Partition->Core.PartitionId, 1ui64, 0xFFFFFFFFui64);
LABEL_7:
if( (a3 & 1) == 0 )
return v4;
v10 = v4;
while( MiChargeCommit(Partition, v10, 1ui64) != 1 )
{
v10 >>= 1;
if( !v10 )
{
if( (a3 & 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