KseShimDatabaseBootInitialize

INT64 __fastcall KseShimDatabaseBootInitialize(VOID *DbAddress, UINT64 DbSize){
  void *v2; 
  unsigned int v3; 
  unsigned int v4; 
  void *v5; 
  unsigned int v6; 
  int v8; 
  __int64 v10; 
  __int64 v11; 
  __int64 v12; 
  v4 = v3;
  v5 = v2;
  v6 = DbSize;
  if( KsepShimDbDuringBoot )
  {
    v10 = ((unsigned __int8)_InterlockedExchangeAdd(&KsepHistoryErrorsIndex, 1u) + 1) & 0x3F;
    KsepHistoryErrors[2 * v10 + 1] = -1073740768;
    KsepHistoryErrors[2 * v10] = 590051;
    if( (KsepDebugFlag & 4) != 0 )
      RtlAssert("KsepShimDbDuringBoot == FALSE", "minkernel\\ntos\\kshim\\ksesdb.c", 0xE3u, 0i64);
  }
  if( KsepShimDbHandle )
  {
    v11 = ((unsigned __int8)_InterlockedExchangeAdd(&KsepHistoryErrorsIndex, 1u) + 1) & 0x3F;
    KsepHistoryErrors[2 * v11 + 1] = -1073740768;
    KsepHistoryErrors[2 * v11] = 590052;
    if( (KsepDebugFlag & 4) != 0 )
      RtlAssert("KsepShimDbHandle == NULL", "minkernel\\ntos\\kshim\\ksesdb.c", 0xE4u, 0i64);
  }
  KsepShimDbLock = 0i64;
  KsepShimDbHandle = 0i64;
  KsepShimDbDuringBoot = 1;
  memset((INT64)&KsepShimDb, 0i64);
  if( DbAddress && v6 )
  {
    v8 = KsepSdbBootInitialize(DbAddress, v6);
    if( v8 >= 0 )
    {
      if( v5 && v4 )
      {
        if( (int)KsepSdbBootInitialize(v5, v4) < 0 )
        {
          v12 = ((unsigned __int8)_InterlockedExchangeAdd(&KsepHistoryErrorsIndex, 1u) + 1) & 0x3F;
          KsepHistoryErrors[2 * v12 + 1] = v8;
          KsepHistoryErrors[2 * v12] = 590110;
          if( (KsepDebugFlag & 2) != 0 )
            KsepDebugPrint(1i64, "KSE: KsepSdbBootInitialize failed for patch SDB!\n");
          KsepLogError(1, "KSE: KsepSdbBootInitialize failed for patch SDB!\n");
        }
        else if( dword_140C2ACD0 >= (unsigned int)dword_140C2AD08 )
        {
          KsepSdbBootRelease((INT64)&qword_140C2ACD8);
        }
      }
      ++KsepShimDbRefCount;
      v8 = 0;
      KsepShimDbHandle = (__int64)&KsepShimDb;
    }
  }
  else
  {
    return(unsigned int)-1073741823;
  }
  return(unsigned int)v8;
}

Referenced by:

KseInitialize