MiEmptyPteBins
VOID __fastcall MiEmptyPteBins(_MI_SYSTEM_PTE_TYPE *PteInfo, CHAR *IncludeBinsNeedingFlush){
UINT64 v2;
int v4;
volatile _MI_CACHED_PTES *CachedPtes;
unsigned int v6;
unsigned int v7;
unsigned int i;
volatile signed __int64 *v9;
UINT64 v10;
int v11;
unsigned __int8 CurrentIrql;
unsigned __int64 v13;
NTSTATUS v14;
signed __int32 v15[22];
UINT64 StartBit;
int v17;
v17 = (int)IncludeBinsNeedingFlush;
v2 = 0i64;
_InterlockedOr(v15, 0);
v4 = KiTbFlushTimeStamp;
CachedPtes = PteInfo->CachedPtes;
v6 = 0;
v7 = 2 * (unsigned __int16)KeNumberNodes;
if( PteInfo != (_MI_SYSTEM_PTE_TYPE *)((char *)&stru_140C4DB30 + 4432) )
v7 = (unsigned __int16)KeNumberNodes;
if( v7 )
{
while( 2 )
{
for( i = 0; i < 8; ++i )
{
v9 = (volatile signed __int64 *)&CachedPtes->Bins[i];
v10 = *v9;
StartBit = v10;
if( (_DWORD)v10 )
{
if( (unsigned int)(v4 - v10) <= 2 )
{
if( (v10 & 1) != 0 || (v11 = 0, (unsigned int)(v4 - v10) < 2) )
v11 = 1;
}
else
{
v11 = 0;
}
if( v11 != 1 || (_DWORD)IncludeBinsNeedingFlush )
{
CurrentIrql = KeGetCurrentIrql();
__writecr8(2ui64);
if( CurrentIrql == 2 && PteInfo == (_MI_SYSTEM_PTE_TYPE *)((char *)&stru_140C4DB30 + 4432) && v6 >= v7 >> 1 )
{
__writecr8(2ui64);
return;
}
if( v10 == _InterlockedCompareExchange64(v9, 0i64, v10) )
{
_InterlockedOr(v15, 0);
if( (unsigned int)(KiTbFlushTimeStamp - StartBit) <= 2
&& ((StartBit & 1) != 0 || (unsigned int)(KiTbFlushTimeStamp - StartBit) < 2) )
{
v2 = 1i64;
}
if( PteInfo == (_MI_SYSTEM_PTE_TYPE *)((char *)&stru_140C4DB30 + 4432) && v6 >= v7 >> 1 )
{
v14 = MiReleaseLargePteMappings(PteInfo, (_MI_CACHED_PTE *)&StartBit, v2);
__writecr8(CurrentIrql);
}
else
{
LODWORD(v13) = MiReplenishBitMap(PteInfo, HIDWORD(StartBit), v2);
v14 = v13;
_InterlockedExchangeAdd64((volatile signed __int64 *)&PteInfo->TotalFreeSystemPtes, v13);
}
_InterlockedExchangeAdd(&CachedPtes->CachedPteCount, -v14);
LODWORD(IncludeBinsNeedingFlush) = v17;
v2 = 0i64;
}
else
{
--i;
}
__writecr8(CurrentIrql);
}
}
}
++CachedPtes;
if( ++v6 < v7 )
continue;
break;
}
}
}Referenced by:
MiAdjustPteBins
MiCheckProcessorPteCache
MiInsertCachedPte
MiReservePtes