MiComputeDriverProtection

UINT64 __stdcall MiComputeDriverProtection(UINT64 SessionDriver, UINT64 SectionProtection){
  unsigned int v2; 
  int v4; 
  v2 = ((unsigned int)SectionProtection >> 28) & 2 | 1;
  if( (SectionProtection & 0x40000000) == 0 )
    v2 = ((unsigned int)SectionProtection >> 28) & 2;
  if( (SectionProtection & 0x80000000) != 0i64 )
  {
    v4 = v2 & 2;
    if( (_DWORD)SessionDriver == 1 )
    {
      v2 = v4 != 0 ? 7 : 5;
    }
    else
    {
      if( v4 )
        return 6;
      v2 = 4;
    }
  }
  if( !v2 )
    return 24;
  return v2;
}

Referenced by:

MiCreateKernelHalSlabRange
MiGetBootImagePageProtection
MiProtectLargeKernelHalRange
MiProtectSystemImage