MiInitializeTbFlush
VOID __stdcall MiInitializeTbFlush(UINT64 NumberOfPtes){
UINT64 v1;
_MMPTE *v2;
_MMPTE *v3;
unsigned __int64 v4;
UINT64 v5;
unsigned __int64 v6;
__int64 v7;
__int64 v8;
unsigned __int64 *p_Long;
UINT64 v10;
unsigned __int64 v11;
int v12;
int v13;
UINT64 v14;
UINT64 v15;
unsigned __int64 v16;
unsigned __int64 v17;
UINT64 v18;
unsigned __int64 v19;
UINT64 v20;
__int64 v21;
unsigned __int64 v22;
__int64 v23;
__int64 v24;
__int64 v25;
signed __int32 v26[8];
__int64 v27;
__int64 v28;
__int64 v29;
__int64 v30;
unsigned __int64 v31;
UINT64 NumberOfPtesa;
_MMPTE *PointerPte;
_MI_TB_FLUSH_LIST TbFlushList[48];
v28 = 0i64;
v1 = NumberOfPtes;
v29 = 0i64;
NumberOfPtesa = NumberOfPtes;
memset(TbFlushList, 0i64, 0xB8u);
v2 = MiReservePtes((_MI_SYSTEM_PTE_TYPE *)((char *)&stru_140C4DB30 + 4432), (unsigned int)v1);
PointerPte = v2;
v3 = v2;
if( v2 )
{
*(_QWORD *)&TbFlushList[6] = 0i64;
TbFlushList[2] = 20;
LODWORD(v4) = MiMakeValidPte((_XSTATE_CONFIGURATION *)v2, *(&stru_140C4DB30 + 495), 1i64);
v6 = v4;
v7 = (__int64)(((_QWORD)v3 << 25) - ((_QWORD)MmGetPteBase() << 25)) >> 16;
v8 = v7;
if( v1 )
{
p_Long = &v3->u.Long;
v10 = v1;
do
{
v11 = v6;
LOBYTE(v12) = MiPteInShadowRange((UINT64)p_Long);
if( v12 && (KeGetCurrentThread()->ApcState.Process->Flags3 & 0x1000) != 0 && (v6 & 1) != 0 )
v11 = v6 | 0x8000000000000000ui64;
*p_Long++ = v11;
v8 += 4096i64;
--v10;
}
while( v10 );
}
v13 = 0;
v14 = 0i64;
v30 = 0i64;
if( !v1 )
goto LABEL_28;
while( 1 )
{
v27 = 4i64;
v15 = v1 - v14;
v16 = 0i64;
v17 = 0i64;
v18 = (v1 - v14) >> 1;
do
{
v31 = __rdtsc();
_InterlockedOr(v26, 0);
if( v14 )
{
MiInsertTbFlushEntry(TbFlushList, (VOID *)v7, v14, 0i64);
MiFlushTbList(TbFlushList);
}
else
{
KeFlushTb(FlushKernel, FlushAllProcessors);
}
_InterlockedOr(v26, 0);
v16 += __rdtsc() - v31;
v19 = __rdtsc();
_InterlockedOr(v26, 0);
if( v18 )
{
v20 = v7 + (v14 << 12);
v21 = (v15 << 12) + v20 - 4096;
v5 = v18;
do
{
v20 += 4096i64;
v21 -= 4096i64;
--v5;
}
while( v5 );
}
_InterlockedOr(v26, 0);
v22 = __rdtsc();
v17 += (((unsigned __int64)HIDWORD(v22) << 32) | (unsigned int)v22) - v19;
--v27;
}
while( v27 );
v1 = NumberOfPtesa;
v23 = v16 >> 2;
v24 = v17 >> 2;
if( v14 )
{
if( v24 + v23 >= (unsigned __int64)(v28 + v29) )
{
v25 = v14 - 1;
if( v13 )
v25 = v30;
++v13;
v30 = v25;
if( v13 == 3 )
{
*(&stru_140C4DB30 + 52) = v25;
LABEL_24:
if( v13 == 3 )
{
LABEL_25:
MiReleasePtes(
(_MI_SYSTEM_PTE_TYPE *)((char *)&stru_140C4DB30 + 4432),
PointerPte,
(unsigned int)v1,
(_KTBFLUSH_TYPE)v5);
return;
}
LABEL_28:
*(&stru_140C4DB30 + 52) = v14;
goto LABEL_25;
}
}
else
{
v13 = 0;
}
}
else
{
v28 = v23;
v29 = v24;
}
if( ++v14 >= NumberOfPtesa )
goto LABEL_24;
}
}
}Referenced by:
MiInitializeTbFlushing