MiProcessKernelCfgImageLoadConfig

__int64 __fastcall MiProcessKernelCfgImageLoadConfig(__int64 a1, __int64 a2){
  __int64 v5; 
  __int64 v6; 
  void(__fastcall **v7)(uintptr_t); 
  int v8; 
  _QWORD *v9; 
  int v10; 
  UINT64 Size; 
  LODWORD(Size) = 0;
  if( (MiFlags & 0x80000) == 0 )
    return 0i64;
  LODWORD(v5) = RtlImageDirectoryEntryToData(*(PVOID *)(a1 + 48), 1u, 0xAu, &Size);
  v6 = v5;
  if( !v5 )
    return 0i64;
  if( *(_DWORD *)v5 < 0x78u || (v7 = *(void(__fastcall ***)(uintptr_t))(v5 + 112)) == 0i64 )
  {
LABEL_14:
    if( *(_DWORD *)v6 >= 0x80u )
    {
      v9 = *(_QWORD **)(v6 + 120);
      if( v9 )
      {
        if( a2 )
        {
          MiSetImageProtection((_KLDR_DATA_TABLE_ENTRY *)a1, *(VOID **)(v6 + 120), 8ui64, 4ui64);
          if( !v10 )
          {
            MiLogStrongCodeDriverLoadFailure("CfgUnwritableLoadConfig", a1);
            dword_140C4C958 = 104;
            return 3221225595i64;
          }
        }
        *v9 = &guard_dispatch_icall;
        if( a2 && *(_QWORD *)(a2 + 16) )
          MiSetImageProtection((_KLDR_DATA_TABLE_ENTRY *)a1, v9, 8ui64, 0x100ui64);
      }
    }
    if( *(_DWORD *)v6 >= 0xC0u && (*(_DWORD *)(v6 + 144) & 0x10000) != 0 )
    {
      if( *(_QWORD *)(v6 + 184) )
        MiCheckForDiscardableLongJumpTable(a1, v6);
    }
    return 0i64;
  }
  if( !a2 || (MiSetImageProtection((_KLDR_DATA_TABLE_ENTRY *)a1, *(VOID **)(v5 + 112), 8ui64, 4ui64), v8) )
  {
    *v7 = guard_check_icall;
    if( a2 && *(_QWORD *)(a2 + 16) )
      MiSetImageProtection((_KLDR_DATA_TABLE_ENTRY *)a1, v7, 8ui64, 0x100ui64);
    goto LABEL_14;
  }
  MiLogStrongCodeDriverLoadFailure("CfgUnwritableLoadConfig", a1);
  dword_140C4C958 = 103;
  return 3221225595i64;
}

Referenced by:

MiInitializeKernelCfg
MiProcessLoadConfigForDriver