MiEnableNewPfns
VOID __stdcall MiEnableNewPfns(UINT64 StartPage, UINT64 LastPage){
unsigned int v2;
UINT64 v3;
_BOOL4 v5;
unsigned __int64 v6;
_BOOL8 v7;
__int64 v8;
unsigned __int64 v9;
_MMPFN *v10;
unsigned __int64 v11;
char v12;
unsigned __int8 v13;
NTSTATUS v14;
unsigned int v15;
_MMPFN *PfnDb;
unsigned int v17;
_MMPFN *v18;
unsigned __int64 v19;
INT64 v20;
UINT64 v21;
struct _KPRCB *CurrentPrcb;
__int64 CachedResidentAvailable;
bool v24;
signed __int32 v25;
PVOID ClientIdentificationAddress;
unsigned int ClientIdentificationAddressa;
UINT64 v28;
__int128 v29;
__int64 v30;
v30 = 0i64;
v3 = StartPage;
v5 = (v2 & 0x100) == 0;
v29 = 0i64;
v6 = LastPage - StartPage;
v28 = LastPage - StartPage;
v7 = (v2 & 0x100) == 0;
if( (v2 & 0x1800) != 0 )
{
v8 = (v2 >> 11) & 1;
ClientIdentificationAddressa = MiDetermineNewPfnHeatState(v7);
v9 = MiLargePageSizes[v8];
v10 = &MmGetPfnDb()[v3];
v11 = v6 / v9;
if( v6 / v9 )
{
v12 = ~(_BYTE)v8 & 3;
do
{
MiLockPageInline(v10);
*((_BYTE *)&v10->u3 + 2) = v5 | *(_BYTE *)(&v10->u3 + 1) & 0xF8;
v10->ViewCount = v12 | v10->ViewCount & 0xFC;
MiSetFreeZeroPfnCold((PDRIVER_OBJECT)v10, (PVOID)ClientIdentificationAddressa);
v30 = v13;
*(_QWORD *)&v29 = v3;
*((_QWORD *)&v29 + 1) = v5;
MiInsertLargePageInNodeList((__int64)&v29);
v10 += v9;
v3 += v9;
--v11;
}
while( v11 );
v6 = v28;
}
}
else
{
v14 = MiDetermineNewPfnHeatState(v7);
PfnDb = MmGetPfnDb();
v17 = v15 | 0x400;
if( !v14 )
v17 = v15;
v18 = &PfnDb[v3];
while( v3 < LastPage )
{
v19 = MiLockPageInline(v18);
MiInsertPageInFreeOrZeroedList(v3, v17, v20, v21, (UINT64)ClientIdentificationAddress, v28);
_InterlockedAnd64(&v18->u2.Lock, 0x7FFFFFFFFFFFFFFFui64);
__writecr8(v19);
++v3;
++v18;
}
}
CurrentPrcb = KeGetCurrentPrcb();
CachedResidentAvailable = (int)CurrentPrcb->CachedResidentAvailable;
if( (_DWORD)CachedResidentAvailable != -1 )
{
if( v6 + CachedResidentAvailable <= 0x100 )
{
do
{
if( v6 >= 0x80000 )
break;
v25 = _InterlockedCompareExchange(
(volatile signed __int32 *)&CurrentPrcb->CachedResidentAvailable,
v6 + CachedResidentAvailable,
CachedResidentAvailable);
v24 = (_DWORD)CachedResidentAvailable == v25;
LODWORD(CachedResidentAvailable) = v25;
if( v24 )
return;
}
while( v25 != -1 && v6 + v25 <= 0x100 );
}
if( (int)CachedResidentAvailable > 192
&& (_DWORD)CachedResidentAvailable != -1
&& (_DWORD)CachedResidentAvailable == _InterlockedCompareExchange(
(volatile signed __int32 *)&CurrentPrcb->CachedResidentAvailable,
192,
CachedResidentAvailable) )
{
v6 += (int)CachedResidentAvailable - 192;
}
}
if( v6 )
_InterlockedExchangeAdd64((_QWORD *)&stru_140C50B28 + 883, v6);
}Referenced by:
MiAddPhysicalMemory