MiClearPartitionPageBitMap
VOID __stdcall MiClearPartitionPageBitMap(_MI_PARTITION *Partition, _RTL_AVL_TREE *PageRoot){
_ETHREAD *CurrentThread;
UINT64 v5;
KIRQL v6;
_RTL_BALANCED_NODE *Root;
_QWORD *Children;
unsigned __int64 v9;
_QWORD *v10;
__int64 v11;
_QWORD *v12;
_ETHREAD *v13;
unsigned int SessionId;
char v15;
int v16;
unsigned __int64 v17;
bool v18;
__int64 v19;
__int64 v20;
__int128 v21;
__int64 v22;
unsigned __int64 v23;
__int128 v24;
__int64 v25;
int v26;
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
v25 = 0i64;
v22 = 0i64;
v23 = 0i64;
--*((_WORD *)CurrentThread + 243);
v21 = (unsigned __int64)Partition;
v24 = 0i64;
v5 = (UINT64)Partition + 192;
ExAcquirePushLockExclusiveEx((UINT64)Partition + 192, 0i64);
v6 = ExAcquireSpinLockExclusive((PEX_SPIN_LOCK)Partition + 50);
Root = PageRoot->Root;
Children = 0i64;
v9 = v6;
while( Root )
{
Children = Root->Children;
Root = Root->Children[0];
}
while( Children )
{
v10 = (_QWORD *)Children[1];
v11 = (__int64)Children;
v12 = Children;
if( v10 )
{
do
{
Children = v10;
v10 = (_QWORD *)*v10;
}
while( v10 );
}
else
{
while( 1 )
{
Children = (_QWORD *)(Children[2] & 0xFFFFFFFFFFFFFFFCui64);
if( !Children || (_QWORD *)*Children == v12 )
break;
v12 = Children;
}
}
MiActOnPartitionNodePages(v11, 7u, (__int16 **)&v21);
}
ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)Partition + 25);
__writecr8(v9);
MiFreePartitionTree((unsigned __int64)Partition, &v23, 0, 1);
if( (_InterlockedExchangeAdd64((volatile signed __int64 *)v5, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
ExfTryToWakePushLock((volatile INT64 *)v5);
v26 = 0;
v13 = (_ETHREAD *)KeGetCurrentThread();
if( (unsigned int)MiGetSystemRegionType(v5) == 1 )
SessionId = MmGetSessionIdEx(*((_QWORD *)v13 + 23));
else
SessionId = -1;
--*((_WORD *)v13 + 243);
v15 = ++*((_BYTE *)v13 + 794);
v16 = (*((char *)v13 + 792) | *((char *)v13 + 870)) ^ 0x3F;
while( 1 )
{
v18 = !_BitScanReverse((unsigned int *)&v19, v16);
if( v18 )
goto LABEL_25;
v17 = *((_QWORD *)v13 + 100) + 96 * v19;
v16 &= ~(1 << v19);
if( (*(_BYTE *)(v17 + 26) & 1) != 0
&& (*(_DWORD *)(v17 + 32) & 1) == 0
&& (*(_QWORD *)(v17 + 32) & 0x7FFFFFFFFFFFFFFCi64) == (v5 & 0x7FFFFFFFFFFFFFFCi64)
&& *(_DWORD *)(v17 + 40) == SessionId )
{
*(_BYTE *)(v17 + 26) &= ~1u;
if( *(_QWORD *)(v17 + 32) )
break;
}
}
if( !v17 )
{
LABEL_25:
if( (*((_DWORD *)v13 + 30) & 0x10000) == 0 )
KeBugCheckEx(0x162u, (ULONG_PTR)v13, v5, SessionId, 0i64);
goto LABEL_32;
}
*(_BYTE *)(v17 + 32) |= 2u;
if( *(__int64 *)(v17 + 32) < 0 )
KiAbEntryRemoveFromTree(v17);
v26 = *(_DWORD *)(v17 + 88) & 0x1FFFF;
*(_DWORD *)(v17 + 88) &= 0xFFFE0000;
*(_BYTE *)(v17 + 25) &= ~1u;
*(_QWORD *)(v17 + 32) = 0i64;
v20 = (__int64)(v17 - *((_QWORD *)v13 + 100)) / 96;
if( v15 == 1 )
*((_BYTE *)v13 + 792) |= 1 << v20;
else
_InterlockedOr8((volatile signed __int8 *)v13 + 870, 1 << v20);
LABEL_32:
--*((_BYTE *)v13 + 794);
KiAbThreadRemoveBoosts((ULONG_PTR)v13, v5, (unsigned int *)&v26);
v18 = (*((_WORD *)v13 + 243))++ == 0xFFFF;
if( v18 && *((_ETHREAD **)v13 + 19) != (_ETHREAD *)((char *)v13 + 152) )
KiCheckForKernelApcDelivery();
KiLeaveGuardedRegionUnsafe((__int64)CurrentThread);
}Referenced by:
MiInsertPartitionPages