MiMakeProtectionMask

NTSTATUS __stdcall MiMakeProtectionMask(UINT64 Win32Protect){
  char v1; 
  NTSTATUS result; 

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

Referenced by:

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