MiChargeResident

_MI_RESAVAIL_CHARGE __stdcall MiChargeResident(ULONG_PTR *Partition, UINT64 NumberOfPages, UINT64 RemainderPages){
  struct _KPRCB *CurrentPrcb; 
  UINT64 CachedResidentAvailable; 
  bool v5; 
  unsigned __int32 v6; 

  if( Partition == (ULONG_PTR *)&Irp )
  {
    CurrentPrcb = KeGetCurrentPrcb();
    CachedResidentAvailable = CurrentPrcb->CachedResidentAvailable;
    while( NumberOfPages <= CachedResidentAvailable && (_DWORD)CachedResidentAvailable != -1 )
    {
      v6 = _InterlockedCompareExchange(
             (volatile signed __int32 *)&CurrentPrcb->CachedResidentAvailable,
             CachedResidentAvailable - NumberOfPages,
             CachedResidentAvailable);
      v5 = (_DWORD)CachedResidentAvailable == v6;
      CachedResidentAvailable = v6;
      if( v5 )
        return 1;
    }
  }
  return MiChargePartitionResidentAvailable((_MI_PARTITION *)Partition, NumberOfPages, RemainderPages);
}

Referenced by:

MiAcquireNonPagedResources
MiAllocatePerSessionProtos
MiChargeForWriteInProgressPage
MiChargeLargeProtoSubsection
MiConstructLoaderEntry
MiCreateLargePfnList
MiCreatePagingFileMap
MiGetCrossPartitionCloneCharges
MiGetSubsectionCharges
MiInitializeSystemWorkingSetList
MiInsertVadCharges
MiObtainFaultCharges
MiObtainSystemCharges
MiSessionCreateInternal
MmAdjustWorkingSetSizeEx
MmChargeResources
MmCreateKernelStack
MmCreateProcessAddressSpace
MmGrowKernelStackEx
MmObtainChargesToLockPagedPool
MmSetHardFaultBehavior
MmStoreChargeResidentAvailableForRead
SMKM_STORE::SmStWorker