MiDeleteSegmentPages
UINT64 __stdcall MiDeleteSegmentPages(_CONTROL_AREA *ControlArea){
_SUBSECTION *v1;
__int64 v2;
UINT64 v4;
__int64 v5;
__int64 v6;
int v7;
UINT64 v8;
unsigned __int64 v9;
INT64 CommittedPages;
unsigned __int64 v12;
struct _KPRCB *CurrentPrcb;
__int64 v14;
bool v15;
signed __int32 v16;
UINT64 DanglingPageCount;
__int64 v18;
v1 = (_SUBSECTION *)((char *)ControlArea + 128);
v2 = *((_WORD *)ControlArea + 30) & 0x3FF;
DanglingPageCount = 0i64;
v4 = 0i64;
v5 = *(_QWORD *)(qword_140C4E388 + 8 * v2);
v6 = *(_QWORD *)ControlArea;
v18 = v5;
v7 = *(_DWORD *)(v6 + 12);
while( v1 )
{
v8 = MiDeleteSubsectionPages(v1, &DanglingPageCount);
v1 = (_SUBSECTION *)*((_QWORD *)v1 + 2);
v4 += v8;
}
v9 = ExAcquireSpinLockExclusive((PEX_SPIN_LOCK)ControlArea + 18);
if( *((_QWORD *)ControlArea + 4) )
{
do
{
ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)ControlArea + 9);
__writecr8(v9);
_mm_pause();
ExAcquireSpinLockExclusive((PEX_SPIN_LOCK)ControlArea + 18);
}
while( *((_QWORD *)ControlArea + 4) );
v5 = v18;
}
ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)ControlArea + 9);
__writecr8(v9);
CommittedPages = MiGetCommittedPages(ControlArea);
if( CommittedPages )
{
if( (v7 & 0x1000) != 0 )
{
v12 = CommittedPages - DanglingPageCount;
if( (ULONG_PTR *)v5 == &MiSystemPartition )
{
CurrentPrcb = KeGetCurrentPrcb();
v14 = *((int *)CurrentPrcb + 8391);
if( (_DWORD)v14 != -1 )
{
if( v12 + v14 <= 0x100 )
{
do
{
if( v12 >= 0x80000 )
break;
v16 = _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8391, v14 + v12, v14);
v15 = (_DWORD)v14 == v16;
LODWORD(v14) = v16;
if( v15 )
goto LABEL_7;
}
while( v16 != -1 && v12 + v16 <= 0x100 );
}
if( (int)v14 > 192
&& (_DWORD)v14 != -1
&& (_DWORD)v14 == _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8391, 192, v14) )
{
v12 += (int)v14 - 192;
}
}
}
if( v12 )
_InterlockedExchangeAdd64((volatile signed __int64 *)(v5 + 7168), v12);
}
LABEL_7:
MiReturnCommit((_MI_PARTITION *)v5, CommittedPages - DanglingPageCount);
_InterlockedExchangeAdd64((volatile signed __int64 *)(v5 + 7624), -CommittedPages);
}
return v4;
}Referenced by:
MiInitializeImageExtents
MiSegmentDelete