MiReturnFaultCharges

VOID __stdcall MiReturnFaultCharges(_MI_PARTITION *Partition, UINT64 NumberOfPages, UINT64 ChargeFlags){
  char v3; 
  unsigned __int64 v4; 
  struct _KPRCB *CurrentPrcb; 
  __int64 v6; 
  bool v7; 
  signed __int32 v8; 
  v3 = ChargeFlags;
  v4 = NumberOfPages;
  if( Partition == (_MI_PARTITION *)&MiSystemPartition )
  {
    CurrentPrcb = KeGetCurrentPrcb();
    v6 = *((int *)CurrentPrcb + 8391);
    if( (_DWORD)v6 != -1 )
    {
      if( NumberOfPages + v6 <= 0x100 )
      {
        do
        {
          if( NumberOfPages >= 0x80000 )
            break;
          v8 = _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8391, v6 + NumberOfPages, v6);
          v7 = (_DWORD)v6 == v8;
          LODWORD(v6) = v8;
          if( v7 )
            goto LABEL_6;
        }
        while( v8 != -1 && NumberOfPages + v8 <= 0x100 );
      }
      if( (int)v6 > 192
        && (_DWORD)v6 != -1
        && (_DWORD)v6 == _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8391, 192, v6) )
      {
        v4 = NumberOfPages + (int)v6 - 192;
      }
    }
  }
  if( v4 )
    _InterlockedExchangeAdd64((volatile signed __int64 *)Partition + 896, v4);
LABEL_6:
  if( (v3 & 1) != 0 )
    MiReturnCommit(Partition, NumberOfPages);
}

Referenced by:

MiFreeReadListPages
MiGetPageForHeader
MiMigratePfn
MiObtainFaultCharges
MiPfPrepareReadList
MiPfPrepareSequentialReadList
MiPfPutPagesInTransition
MiPrivateFixup
MiResolveMappedFileFault
MiResolvePageFileFault
MiSwitchToTransition