MiChargeForWriteInProgressPage
_MI_RESAVAIL_CHARGE __stdcall MiChargeForWriteInProgressPage(_MI_PARTITION *Partition, UINT64 Flags){
char v2;
unsigned __int64 v3;
unsigned int v5;
_MI_RESAVAIL_CHARGE v6;
struct _KPRCB *CurrentPrcb;
__int64 CachedResidentAvailable;
bool v10;
signed __int32 v11;
v2 = Flags;
v3 = 1i64;
v5 = (Flags & 2) != 0 ? 0xFFFFFFFC : 0;
v6 = MiChargeResident((ULONG_PTR *)&Partition->Core.PartitionId, 1ui64, (unsigned int)-((Flags & 2) != 0));
if( v6 )
{
if( (v2 & 1) == 0 || MiChargeCommit(Partition, 1ui64, v5 + 8) )
return v6;
if( Partition != &Irp )
goto LABEL_17;
CurrentPrcb = KeGetCurrentPrcb();
CachedResidentAvailable = (int)CurrentPrcb->CachedResidentAvailable;
if( (_DWORD)CachedResidentAvailable == -1 )
goto LABEL_17;
if( (unsigned __int64)(CachedResidentAvailable + 1) <= 0x100 )
{
do
{
v11 = _InterlockedCompareExchange(
(volatile signed __int32 *)&CurrentPrcb->CachedResidentAvailable,
CachedResidentAvailable + 1,
CachedResidentAvailable);
v10 = (_DWORD)CachedResidentAvailable == v11;
LODWORD(CachedResidentAvailable) = v11;
if( v10 )
return 0;
}
while( v11 != -1 && (unsigned __int64)(v11 + 1i64) <= 0x100 );
}
if( (int)CachedResidentAvailable > 192
&& (_DWORD)CachedResidentAvailable != -1
&& (_DWORD)CachedResidentAvailable == _InterlockedCompareExchange(
(volatile signed __int32 *)&CurrentPrcb->CachedResidentAvailable,
192,
CachedResidentAvailable) )
{
v3 = (int)CachedResidentAvailable - 192 + 1i64;
}
if( v3 )
LABEL_17:
_InterlockedExchangeAdd64((volatile signed __int64 *)&Partition->Vp.ResidentAvailablePages, v3);
}
return 0;
}Referenced by:
MiAllocateModWriterEntry
MiReferencePageForModifiedWrite