MiSecureVad

NTSTATUS __stdcall MiSecureVad(
        _MMVAD_SHORT *Vad,
        PVOID Address,
        UINT64 Size,
        UINT64 ProbeMode,
        _MI_VAD_EVENT_BLOCK **SecureHandle){
  int v5; 
  __int64 v6; 
  __int64 v7; 
  int v8; 
  unsigned __int64 v10; 
  unsigned __int64 v11; 
  NTSTATUS result; 
  _DWORD *v13; 
  _QWORD *v14; 
  v5 = ProbeMode;
  v6 = ((unsigned __int64)Address + Size - 1) | 0xFFF;
  v7 = (unsigned __int64)Address & 0xFFFFFFFFFFFFF000ui64;
  v8 = 1;
  if( (v5 & 1) != 0 )
    goto LABEL_5;
  v10 = ((unsigned __int64)Address + Size - 1) | 0xFFF;
  v11 = (unsigned __int64)Address & 0xFFFFFFFFFFFFF000ui64;
  if( v5 != 2 )
    v8 = 4;
  result = MiComparePteProtections((ULONG_PTR)Vad, v11, v10, v8, 0);
  if( result >= 0 )
  {
LABEL_5:
    v13 = MiAddSecureEntry((__int64)Vad, v7, v6, v5, (char)SecureHandle);
    *v14 = v13;
    return v13 == 0i64 ? 0xC000009A : 0;
  }
  return result;
}

Referenced by:

MiMapViewOfDataSection
MiMapViewOfImageSection
MiReserveUserMemory
MmSecureVirtualMemoryEx