MiClearNonPagedPtes

__int64 __fastcall MiClearNonPagedPtes(ULONG_PTR LeafVa, __int64 a2, unsigned int a3, unsigned int a4){
  char v8; 
  CHAR *AnyMultiplexedVm; 
  ULONG_PTR v10; 
  __int64 v11; 
  __int64 v12; 
  unsigned __int64 *v13; 
  UINT64 v14; 
  __int64 v15; 
  unsigned __int64 v16; 
  __int64 v17; 
  unsigned __int64 v18; 
  UINT64 v20[2]; 
  __int128 v21; 
  __int16 BugCheckParameter2; 
  unsigned __int8 BugCheckParameter2_3; 
  UINT8 BugCheckParameter2_6; 
  CHAR *v25; 
  ULONG_PTR v26; 
  ULONG_PTR v27; 
  NTSTATUS(__stdcall *v28)(PVOID); 
  INT64(__fastcall *v29)(INT64); 
  int *p_result; 
  int result; 
  __int16 result_4; 
  __int64 v33; 
  __int64 v34; 
  __int64 v35; 
  _MMPFN *PfnList; 
  _MMPFN *v37; 
  unsigned int v38; 
  unsigned int v39; 
  unsigned int v40; 
  memset((INT64)&BugCheckParameter2, 0i64);
  memset((INT64)&result, 0i64);
  v8 = 0;
  AnyMultiplexedVm = MiGetAnyMultiplexedVm(5i64);
  v26 = LeafVa;
  BugCheckParameter2 = 2183;
  v38 = a3;
  v28 = MiDeleteNonPagedPoolPte;
  v10 = (a2 << 12) + LeafVa - 1;
  v27 = v10;
  v29 = MiDeleteNonPagedPoolTail;
  v39 = a4;
  p_result = &result;
  v33 = 20i64;
  result = v11;
  result_4 = v11;
  v34 = v11;
  v35 = v11;
  v25 = AnyMultiplexedVm;
  BugCheckParameter2_6 = MiLockWorkingSetShared((INT64)AnyMultiplexedVm);
  if( LeafVa <= v10 )
  {
    do
    {
      *(_OWORD *)v20 = 0i64;
      v21 = 0i64;
      if( !(unsigned int)MiFastLockLeafPageTable((INT64)AnyMultiplexedVm, LeafVa) )
        break;
      MiFillPteHierarchy(LeafVa, v20);
      v13 = (unsigned __int64 *)v20[v12];
      v14 = v20[(int)v12 - 1];
      MiFillPteHierarchy(v10, v20);
      v16 = v20[v15];
      if( v16 > (v14 & 0xFFFFFFFFFFFFF000ui64 | 0xFF8) )
        v16 = v14 & 0xFFFFFFFFFFFFF000ui64 | 0xFF8;
      while( v14 <= v16 )
      {
        MiDeleteNonPagedPoolPte(&BugCheckParameter2);
        v17 = (unsigned int)BugCheckParameter2_3 + 1;
        BugCheckParameter2_3 = 0;
        v14 += 8 * v17;
      }
      MiDeleteNonPagedPoolTail((INT64)&BugCheckParameter2);
      v18 = *v13;
      MiPteInShadowRange((UINT64)v13);
      if( (*((_QWORD *)MmGetPfnDb() + 6 * ((v18 >> 12) & 0xFFFFFFFFFi64) + 3) & 0x3FFFFFFFFFFFFFFFi64) == 1 )
        v8 = 1;
      MiUnlockPageTableInternal((INT64)AnyMultiplexedVm, (UINT64)v13);
      LeafVa = MiGetLeafVa(v14);
    }
    while( LeafVa <= v10 );
    if( !v8 )
    {
      if( LeafVa > v10 )
        goto LABEL_13;
      v26 = LeafVa;
    }
    MiWalkPageTables((INT64)&BugCheckParameter2);
  }
LABEL_13:
  MiUnlockWorkingSetShared((INT64)AnyMultiplexedVm, BugCheckParameter2_6);
  if( PfnList )
    MiReturnPhysicalPoolPages(PfnList);
  if( v37 )
    MiReturnPhysicalPoolPages(v37);
  return v40;
}

Referenced by:

MiCommitPoolMemory
MmFreePoolMemory
MmFreeSecurePoolMemory