BgkInitialize

INT64 __fastcall BgkInitialize(_LOADER_PARAMETER_BLOCK *LoaderBlock, UINT64 Phase){
  unsigned int v2; 
  INT64 result; 
  UINT64 v5; 
  void *Interface; 
  int v7; 
  int v8; 
  int v9; 
  v9 = 0;
  v2 = Phase;
  if( !LoaderBlock )
    return 3221225473i64;
  if( (_DWORD)Phase == 1 )
  {
    if( byte_140C508E0 )
      return 0i64;
    return 3221225473i64;
  }
  if( !(_DWORD)Phase )
  {
    BgkDestroy();
    qword_140C53CF0 = 0i64;
    BgkpLockBgfxCodeSection();
  }
  result = BgLibraryInitialize(*(VOID **)(*((_QWORD *)LoaderBlock + 30) + 288i64), v2);
  if( (int)result >= 0 )
  {
    if( !v2 )
    {
      Interface = BgConsoleGetInterface(v5);
      ConsoleInterface = Interface;
      if( Interface )
        (*(void(__fastcall **)(_QWORD, __int64, _QWORD, _QWORD))Interface)(
          (unsigned int)InitConsoleFlags,
          4291217094i64,
          (unsigned int)dword_140CF5080,
          0i64);
      v7 = ((__int64(__fastcall *)(__int64, __int64, int *, int *))off_140C00A68[0])(9i64, 4i64, &dword_140CF2320, &v9);
      v8 = dword_140CF2320;
      if( v7 < 0 )
        v8 = 2;
      dword_140CF2320 = v8;
    }
    byte_140C508E0 = 1;
    byte_140C508E1 = 1;
    BgkpTryEnableConsole();
    return 0i64;
  }
  return result;
}

Referenced by:

InbvDriverInitialize