BiAddStoreFromFile

INT64 __fastcall BiAddStoreFromFile(INT64 a1, CHAR a2, _QWORD *a3){
  unsigned int v4; 
  int v5; 
  int v8; 
  int v9; 
  PVOID v10; 
  __int64 v12; 
  UINT64 Length; 
  HANDLE ParentHandle; 
  PVOID v15; 
  PVOID Handle; 
  __int16 Dst[12]; 
  Handle = 0i64;
  v4 = 0;
  ParentHandle = 0i64;
  v5 = 0;
  v15 = 0i64;
  while( 1 )
  {
    swprintf_s((WCHAR *)Dst, 0xCui64, (WCHAR *)L"BCD%08d");
    v8 = BiLoadHive((WCHAR *)Dst, a1, &ParentHandle);
    if( v8 >= 0 )
      break;
    if( v8 != -1073741790 )
    {
      BiLogMessage();
      goto LABEL_11;
    }
    if( BiDoesHiveKeyExist((PWCHAR)Dst) )
      v4 = 0;
    else
      ++v4;
    if( v4 >= 0xA )
    {
      BiLogMessage();
      goto LABEL_20;
    }
    if( (unsigned int)++v5 > 0x5F5E0FF )
    {
      BiLogMessage();
      v8 = -1073741823;
      goto LABEL_20;
    }
  }
  BiLogMessage();
  if( (a2 & 1) == 0
    || (v8 = BiCreateKey(ParentHandle, (WCHAR *)L"Objects", 0x20019ui64, 0i64, &v15, 0i64), v8 >= 0)
    && (BiCloseKey(v15),
        v15 = 0i64,
        v8 = BiCreateKey(ParentHandle, (WCHAR *)L"Description", 0x20019ui64, 0i64, &v15, 0i64),
        v8 >= 0) )
  {
    v9 = BiOpenKey(ParentHandle, (WCHAR *)L"Description", 0x2001Fui64, &Handle);
    v10 = Handle;
    v8 = v9;
    if( v9 < 0 )
    {
      if( v9 == -1073741772 )
      {
        BiLogMessage();
        v8 = -1073741476;
      }
    }
    else
    {
      LODWORD(Length) = 24;
      v8 = BiSetRegistryValue(Handle, (WCHAR *)L"KeyName", 0i64, 1ui64, Dst, Length);
      if( v8 >= 0 )
      {
        *a3 = ParentHandle;
        goto LABEL_7;
      }
    }
    BiLogMessage();
LABEL_7:
    if( v10 )
      BiCloseKey(v10);
    goto LABEL_9;
  }
  BiLogMessage();
LABEL_9:
  if( v15 )
    BiCloseKey(v15);
LABEL_11:
  if( v8 >= 0 )
    return(unsigned int)v8;
LABEL_20:
  if( ParentHandle )
  {
    BiCloseKey(ParentHandle);
    v12 = -1i64;
    do
      ++v12;
    while( Dst[v12] );
    BiUnloadHiveByName((PWCHAR)Dst, (unsigned int)(2 * v12 + 2), 0);
  }
  return(unsigned int)v8;
}

Referenced by:

BiLoadSystemStore