MiDeleteUltraMapContext
VOID __stdcall MiDeleteUltraMapContext(INT64 a1, _XSTATE_CONFIGURATION *a2){
__int64 v3;
_QWORD *v4;
UINT64 v5;
struct _KPRCB *CurrentPrcb;
__int64 CachedResidentAvailable;
bool v8;
signed __int32 v9;
if( *(_BYTE *)(a1 + 24) )
{
v3 = 2i64;
MiGetUltraMapping((_MI_ZERO_THREAD_CONTEXT *)a1, (INT64)a2);
_InterlockedDecrement((_DWORD *)&stru_140C4DB30 + 911);
v4 = (_QWORD *)(a1 + 8);
v5 = 0i64;
do
{
if( *v4 != -1i64 )
{
MiReleaseFreshPage(&MmGetPfnDb()[*v4]);
++v5;
*v4 = -1i64;
}
++v4;
--v3;
}
while( v3 );
*(_BYTE *)(a1 + 24) = 0;
if( v5 )
{
MiReturnCommit(&Irp, v5);
CurrentPrcb = KeGetCurrentPrcb();
CachedResidentAvailable = (int)CurrentPrcb->CachedResidentAvailable;
if( (_DWORD)CachedResidentAvailable != -1 )
{
if( v5 + CachedResidentAvailable <= 0x100 )
{
do
{
if( v5 >= 0x80000 )
break;
v9 = _InterlockedCompareExchange(
(volatile signed __int32 *)&CurrentPrcb->CachedResidentAvailable,
CachedResidentAvailable + v5,
CachedResidentAvailable);
v8 = (_DWORD)CachedResidentAvailable == v9;
LODWORD(CachedResidentAvailable) = v9;
if( v8 )
return;
}
while( v9 != -1 && v5 + v9 <= 0x100 );
}
if( (int)CachedResidentAvailable > 192
&& (_DWORD)CachedResidentAvailable != -1
&& (_DWORD)CachedResidentAvailable == _InterlockedCompareExchange(
(volatile signed __int32 *)&CurrentPrcb->CachedResidentAvailable,
192,
CachedResidentAvailable) )
{
v5 += (int)CachedResidentAvailable - 192;
}
}
if( v5 )
_InterlockedExchangeAdd64((_QWORD *)&stru_140C50B28 + 883, v5);
}
}
}Referenced by:
MiDeleteUltraThreadContext
MiGetUltraMdlContext
MiReclaimUnusedUltraMdlMaps