MiReturnResident
NTSTATUS __stdcall MiReturnResident(INT64 a1, UINT64 a2){
_MI_PARTITION *v2;
struct _KPRCB *CurrentPrcb;
__int64 CachedResidentAvailable;
bool v5;
v2 = &Irp;
if( (_MI_PARTITION *)a1 == &Irp )
{
CurrentPrcb = KeGetCurrentPrcb();
CachedResidentAvailable = (int)CurrentPrcb->CachedResidentAvailable;
if( (_DWORD)CachedResidentAvailable != -1 )
{
for( ; a2 + CachedResidentAvailable <= 0x100; LODWORD(v2) = a2 + (_DWORD)v2 )
{
if( a2 >= 0x80000 )
break;
LODWORD(v2) = _InterlockedCompareExchange(
(volatile signed __int32 *)&CurrentPrcb->CachedResidentAvailable,
CachedResidentAvailable + a2,
CachedResidentAvailable);
v5 = (_DWORD)CachedResidentAvailable == (_DWORD)v2;
CachedResidentAvailable = (int)v2;
if( v5 )
return(int)v2;
if( (_DWORD)v2 == -1 )
break;
}
if( (int)CachedResidentAvailable > 192 && (_DWORD)CachedResidentAvailable != -1 )
{
LODWORD(v2) = _InterlockedCompareExchange(
(volatile signed __int32 *)&CurrentPrcb->CachedResidentAvailable,
192,
CachedResidentAvailable);
if( (_DWORD)CachedResidentAvailable == (_DWORD)v2 )
{
LODWORD(v2) = CachedResidentAvailable - 192;
a2 += (int)CachedResidentAvailable - 192;
}
}
}
}
if( a2 )
_InterlockedExchangeAdd64((volatile signed __int64 *)(a1 + 7168), a2);
return(int)v2;
}Referenced by:
MiChargeLargeProtoSubsection
MiCreatePagingFileMap
MiDereferenceSessionFinal
MiFreeInitializationCode
MiFreePartitionPhysicalPages
MiInsertVadCharges
MiMarkBootGuardPage
MiReleaseVadEventBlocks
MiRemoveVadCharges
MiReturnSystemImageCommitment
MmCleanProcessAddressSpace
MmCreateProcessAddressSpace
MmDeleteProcessAddressSpace
MmReturnChargesToLockPagedPool