MmFreeLoaderBlock
VOID __fastcall MmFreeLoaderBlock(_LOADER_PARAMETER_BLOCK *LoaderBlock){
_LOADER_PARAMETER_BLOCK *v1;
__int64 *v2;
int v3;
__int64 v4;
__int64 *v5;
__int64 v6;
__int64 v7;
int v8;
_QWORD *v9;
signed __int64 v10;
INT64 v11;
UINT8 v12;
__int64 *v13;
_MMPTE *PteBase;
INT64 v15;
_QWORD *v16;
_QWORD *v17;
__int64 *v18;
_QWORD *v19;
unsigned int v20;
int v21;
_QWORD *v22;
char *v23;
UINT64 v24;
__int64 v25;
_QWORD *v26;
unsigned __int64 v27;
_MMPTE *v28;
__int64 v29;
UINT64 v30;
__int64 v31;
UINT64 v32;
char *v33;
unsigned __int64 v34;
__int64 *v35;
__int64 v36;
char *v37;
UINT64 v38;
INT64 v39;
char WsleContents;
INT64 v41;
UINT64 v42;
INT64 v43;
INT64 v44;
UINT8 v45;
INT64 a2;
UINT64 TransitionPte;
INT64 a1;
UINT64 v49;
__int64 *v50;
char *v51;
CHAR *AnyMultiplexedVm;
_QWORD *v53;
__int64 v54;
__int64 v55;
__int64 *v56;
INT64 v57;
int v58;
int v59;
__int64 v60;
v1 = KeLoaderBlock_0;
memset((INT64)&v57, 0i64);
v2 = (__int64 *)((char *)v1 + 32);
a1 = 0i64;
v3 = 0;
a2 = 0i64;
v4 = 0i64;
v56 = v2;
v5 = (__int64 *)*v2;
if( (__int64 *)*v2 != v2 )
{
do
{
v6 = v5[4];
v7 = v4;
if( v6 )
{
v8 = *((_DWORD *)v5 + 4);
v4 += v6;
if( v8 != 19 )
v4 = v7;
if( v8 == 7 || v8 == 21 || v8 == 14 )
++v3;
}
v5 = (__int64 *)*v5;
}
while( v5 != v2 );
if( v4 )
{
LODWORD(v9) = MiAllocatePool((struct _SLIST_ENTRY *)0x40);
v53 = v9;
v10 = (signed __int64)v9;
if( v9 )
{
*v9 = v4;
v60 = 0i64;
v50 = v9 + 1;
v58 = 20;
AnyMultiplexedVm = MiGetAnyMultiplexedVm(1i64);
v11 = (INT64)AnyMultiplexedVm;
v12 = MiLockWorkingSetShared((INT64)AnyMultiplexedVm);
v13 = (__int64 *)*v2;
v45 = v12;
if( (__int64 *)*v2 != v2 )
{
PteBase = MmGetPteBase();
v15 = (INT64)AnyMultiplexedVm;
do
{
if( *((_DWORD *)v13 + 4) == 19 && v13[4] )
{
v49 = 0i64;
v30 = 0i64;
v55 = v13[3];
v31 = v55;
v54 = (_QWORD)PteBase << 25;
MiPteInShadowRange((UINT64)&TransitionPte);
v32 = v49;
v33 = (char *)MmGetPfnDb() + 48 * v31;
v51 = v33;
do
{
v34 = *((_QWORD *)v33 + 1) | 0x8000000000000000ui64;
v35 = v50;
v36 = (__int64)((v34 << 25) - v54) >> 16;
*v50 = v36;
v50 = v35 + 1;
v49 = v36;
v37 = (char *)MmGetPteBase() + ((v34 >> 9) & 0x7FFFFFFFF8i64);
if( (char *)v30 != v37 )
{
if( v30 )
{
MiFlushTbList((__int64)&v57);
MiFreeRegistryPageRange(a1, a2);
MiUnlockPageTableInternal(v15, v30);
}
v30 = (UINT64)v37;
MiLockPageTableInternal(v15, (UINT64)v37, 0i64);
}
TransitionPte = MI_READ_PTE_LOCK_FREE(v34);
v38 = TransitionPte;
MiMarkPfnTradable((INT64)v33, 0i64);
WsleContents = MiGetWsleContents(v39, v36);
MiWriteWsle(v41, v36, WsleContents & 0xF0 | 0xA);
TransitionPte = MiMakeTransitionPte((v38 >> 12) & 0xFFFFFFFFFi64, 4ui64, v42);
*(_QWORD *)v34 = TransitionPte;
if( v59 )
{
v43 = a1;
v44 = a2 + 1;
}
else
{
v44 = 1i64;
v43 = v32 + v55;
a1 = v32 + v55;
}
a2 = v44;
MiInsertTbFlushEntry((INT64)&v57, v49, 1i64, 0i64);
++v32;
v33 = v51 + 48;
v51 += 48;
}
while( v32 < v13[4] );
v2 = v56;
MiFlushTbList((__int64)&v57);
MiFreeRegistryPageRange(v43, v44);
MiUnlockPageTableInternal(v15, v30);
PteBase = MmGetPteBase();
}
v13 = (__int64 *)*v13;
}
while( v13 != v2 );
v10 = (signed __int64)v53;
v11 = (INT64)AnyMultiplexedVm;
v12 = v45;
}
MiUnlockWorkingSetShared(v11, v12);
if( _InterlockedCompareExchange64(&qword_140C4EC10, v10, 0i64) )
{
qword_140C4EC10 = v10;
MmFreeBootRegistry();
}
}
}
}
LODWORD(v16) = MiAllocatePool((struct _SLIST_ENTRY *)0x40);
v17 = v16;
if( v16 )
{
v18 = (__int64 *)*v2;
v19 = v16;
if( (__int64 *)*v2 != v2 )
{
do
{
v20 = *((_DWORD *)v18 + 4);
if( v20 <= 0x15 )
{
v21 = 2113664;
if( _bittest(&v21, v20) )
{
if( v18[4] )
{
*v19 = v18[3];
v19[1] = v18[4];
v19 += 2;
}
}
}
v18 = (__int64 *)*v18;
}
while( v18 != v2 );
if( v19 != v17 )
{
v22 = v19 - 2;
if( v22 >= v17 )
{
v23 = (char *)MmGetPfnDb() + 8;
do
{
v24 = 48i64 * *v22;
v25 = v22[1];
v26 = (_QWORD *)((char *)MmGetPfnDb() + v24 + 8);
v27 = *v26 | 0x8000000000000000ui64;
while( --v25 )
{
v26 += 6;
v27 += 8i64;
if( (*v26 | 0x8000000000000000ui64) != v27 )
{
v28 = (_MMPTE *)(*(_QWORD *)&v23[v24] | 0x8000000000000000ui64);
v29 = (__int64)(v27 - (_QWORD)v28) >> 3;
MiDeleteBootRange(v28, v29, v24);
v22[1] -= v29;
*v22 += v29;
v22 += 2;
if( v29 )
goto LABEL_31;
break;
}
}
MiDeleteBootRange((_MMPTE *)(*(_QWORD *)&v23[48 * *v22] | 0x8000000000000000ui64), v22[1], v24);
LABEL_31:
v22 -= 2;
}
while( v22 >= v17 );
}
}
}
ExFreePoolWithTag(v17, 0);
}
}Referenced by:
KeInitSystem