MiFastLockLeafPageTable

INT64 __stdcall MiFastLockLeafPageTable(INT64 AnyMultiplexedVm, UINT64 StartingAddress){
  int v2; 
  int v5; 
  __int64 v6; 
  __int64 v7; 
  BOOL v8; 
  _MMPTE *PdeBase; 
  unsigned __int64 v10; 
  UINT64 v11; 
  _MMPTE *PteBase; 
  __int64 v13; 
  int v15; 
  v5 = 0;
  v6 = *(_BYTE *)(AnyMultiplexedVm + 184) & 7;
  if( (unsigned __int8)(v6 - 1) > 2u && (_BYTE)v6 != 7 )
  {
    if( (_BYTE)v6 == 5 )
    {
      if( StartingAddress >= qword_140C4F848 && StartingAddress < qword_140C4F848 + 0x100000000000i64 )
        return 0i64;
      goto LABEL_5;
    }
    if( !(_BYTE)v6 )
LABEL_5:
      v5 = 1;
  }
  v7 = *((_QWORD *)KeGetCurrentPrcb() + 4095);
  if( (MiFlags & 0x1000000) == 0 || !v7 || *(_DWORD *)(v7 + 12480) )
    return 0i64;
  *(_DWORD *)(v7 + 12480) = 1;
  v15 = 0;
  v8 = 0;
  PdeBase = MmGetPdeBase();
  v10 = (unsigned __int64)PdeBase + ((StartingAddress >> 18) & 0x3FFFFFF8);
  v11 = v10;
  PteBase = MmGetPteBase();
  if( !v5 )
    goto LABEL_13;
  v13 = *(_QWORD *)((char *)PteBase + ((v10 >> 9) & 0x7FFFFFFFF8i64));
  if( (v13 & 1) != 0 )
  {
    if( (v13 & 0x80u) != 0i64 )
    {
      v15 = 3;
      v11 = (UINT64)PdeBase + ((v10 >> 18) & 0x3FFFFFF8);
    }
LABEL_13:
    while( (*(_QWORD *)v11 & 1) != 0 )
    {
      if( (*(_QWORD *)v11 & 0x80u) == 0i64 )
      {
        v8 = MiLockPageTableInternal(AnyMultiplexedVm, v11, (UINT8 *)(v2 | 2u)) != 0;
        goto LABEL_20;
      }
      v15 = 2;
      v11 = (UINT64)PteBase + ((v11 >> 9) & 0x7FFFFFFFF8i64);
    }
    v8 = 0;
  }
LABEL_20:
  --*(_DWORD *)(v7 + 12480);
  if( v8 && v15 )
  {
    if( v15 == 3 )
      v10 = (unsigned __int64)PteBase + ((v10 >> 9) & 0x7FFFFFFFF8i64);
    if( (MI_READ_PTE_LOCK_FREE(v10) & 0x81) == 0x81 )
    {
      if( v15 == 3 )
        return 3;
      else
        return 2;
    }
    else
    {
      MiUnlockPageTableInternal(AnyMultiplexedVm, v11);
      return 0;
    }
  }
  return v8;
}

Referenced by:

MiClearNonPagedPtes
MiCommitExistingVad
MiCountSharedPages
MiDecommitPages
MiDeletePagablePteRange
MiGetNextPageTable
MiLockPageLeafPageTable
MiLockPoolCommitPageTable
MiMakeHyperRangeAccessible
MiMakeSystemAddressValid
MiMoveDirtyBitsToPfns
MiQueryAddressState
MiSetProtectionOnSection
MiSynchronizeSystemVa
MiUserFault