MiObtainSystemCharges

NTSTATUS __stdcall MiObtainSystemCharges(_MI_PARTITION *Partition, UINT64 QuotaCharge, INT64 a3){
  int v3; 
  UINT64 v6; 
  _MM_SESSION_SPACE *Session; 

  v3 = a3;
  if( !MiChargeCommit(Partition, QuotaCharge, 1ui64) )
    return 0;
  v6 = 128i64;
  if( v3 != 2 )
    v6 = 0i64;
  if( MiChargeResident((ULONG_PTR *)&Partition->Core.PartitionId, QuotaCharge, v6) == MiChargeFailed )
  {
    MiReturnCommit(Partition, QuotaCharge);
    return 0;
  }
  if( v3 == 1 || v3 == 11 )
  {
    Session = KeGetCurrentThread()->ApcState.Process->Session;
    _InterlockedExchangeAdd64((volatile signed __int64 *)Session + 6, QuotaCharge);
    _InterlockedExchangeAdd64((volatile signed __int64 *)Session + 5, QuotaCharge);
  }
  else if( v3 != 2 )
  {
    if( v3 == 4 )
      _InterlockedExchangeAdd64((_QWORD *)&stru_140C4DB30 + 573, QuotaCharge);
    else
      _InterlockedExchangeAdd64((_QWORD *)&stru_140C4DB30 + 570, QuotaCharge);
  }
  return 1;
}

Referenced by:

MiGetLargePagesForSystemMapping
MiGetPageTablePages