MiMakeProtectionMask

UINT64 __stdcall MiMakeProtectionMask(UINT64 Win32Protect){
  char v1; 
  UINT64 result; 
  if( (unsigned int)Win32Protect >= 0x800 )
    return 0xFFFFFFFFi64;
  if( (Win32Protect & 0xF) != 0 )
  {
    if( (Win32Protect & 0xF0) != 0 )
      return 0xFFFFFFFFi64;
    v1 = *((_BYTE *)MmUserProtectionToMask1 + (Win32Protect & 0xF));
  }
  else
  {
    if( !((unsigned __int8)Win32Protect >> 4) )
      return 0xFFFFFFFFi64;
    v1 = *((_BYTE *)MmUserProtectionToMask2 + ((unsigned __int8)Win32Protect >> 4));
  }
  result = (unsigned int)v1;
  if( (_DWORD)result == -1 )
    return 0xFFFFFFFFi64;
  if( (Win32Protect & 0x700) == 0 )
    return result;
  if( (Win32Protect & 0x100) != 0 )
  {
    if( (_DWORD)result != 24 && (Win32Protect & 0x600) == 0 )
    {
      result = (unsigned int)result | 0x10;
      goto LABEL_14;
    }
    return 0xFFFFFFFFi64;
  }
LABEL_14:
  if( (Win32Protect & 0x200) != 0 )
  {
    if( (_DWORD)result != 24 && (Win32Protect & 0x400) == 0 )
      return(unsigned int)result | 8;
    return 0xFFFFFFFFi64;
  }
  if( (Win32Protect & 0x400) != 0 )
  {
    if( (_DWORD)result != 24 && (result & 2) == 0 )
      return(unsigned int)result | 0x18;
    return 0xFFFFFFFFi64;
  }
  return result;
}

Referenced by:

MiAllocateVirtualMemory
MiCommitExistingVad
MiCopyPagesIntoEnclave
MiInitializeCreateSectionPacket
MiInitializePoolCommitPacket
MiLoadDataIntoVsmEnclave
MiMapViewOfSection
MiMapViewOfSectionCommon
MiSetProtectionOnSection
MiValidateAllocationType
MmAllocateContiguousNodeMemory
MmAllocateSecureKernelPages
MmMapIoSpaceEx
MmMapMdl
MmProtectMdlSystemAddress
MmProtectPool
MmProtectVirtualMemory
MmSetAddressRangeModifiedEx
MmSetPageProtection
MmUpdateSlabRangeProtection
NtProtectVirtualMemory