BgpBcInitializeCriticalMode

__int64 __fastcall BgpBcInitializeCriticalMode(__int64 a1, int a2){
  int v3; 
  PCWSTR v4; 
  WCHAR *Message; 
  WCHAR v6; 
  WCHAR *v7; 
  WCHAR v8; 
  WCHAR *v9; 
  WCHAR v10; 
  WCHAR *v11; 
  WCHAR v12; 
  WCHAR *v13; 
  WCHAR v14; 
  WCHAR *v15; 
  WCHAR v16; 
  WCHAR *v17; 
  WCHAR v18; 
  WCHAR *v19; 
  WCHAR v20; 
  WCHAR *v21; 
  WCHAR v22; 
  WCHAR *v23; 
  WCHAR v24; 
  WCHAR *v25; 
  WCHAR v26; 
  WCHAR *v27; 
  WCHAR v28; 
  WCHAR *v29; 
  WCHAR v30; 
  WCHAR *v31; 
  WCHAR v32; 
  WCHAR v33; 
  WCHAR v34; 
  int ProgressMessages; 
  WCHAR v36; 
  WCHAR v37; 
  __int64 v38; 
  __int64 v39; 
  int v40; 
  __int64 *v41; 
  __int64 v42; 
  unsigned int *v43; 
  UINT64 v44; 
  __int64 v45; 
  __int64 v47; 
  unsigned __int64 v48; 
  int v49; 
  UINT64 Size[2]; 
  int v51[2]; 
  __int128 v52; 
  PCWSTR v53; 
  PCWSTR SourceString; 
  PCWSTR v55; 
  v47 = 0i64;
  v53 = 0i64;
  v48 = 0i64;
  v49 = 0;
  v3 = *(_DWORD *)(a1 + 120);
  *(_OWORD *)Size = 0i64;
  v52 = 0i64;
  if( (v3 & 0x400000) != 0 )
  {
    dword_140C13310 |= 0x400000u;
  }
  else
  {
    if( (v3 & 0x2000000) != 0 )
      BcpDisplayParameters = 1;
    v4 = 0i64;
    SourceString = 0i64;
    v55 = 0i64;
    if( a2 != -1 )
    {
      Message = BcpFindMessage(0xC1008001ui64);
      RtlInitUnicodeString((PUNICODE_STRING)&stru_140C53B10, Message, v6);
      v7 = BcpFindMessage(0xC1008008ui64);
      RtlInitUnicodeString(&stru_140C53B30, v7, v8);
      v9 = BcpFindMessage(0x41008009ui64);
      RtlInitUnicodeString((PUNICODE_STRING)&stru_140C53B40, v9, v10);
      v11 = BcpFindMessage(0x41008010ui64);
      RtlInitUnicodeString(&stru_140C53B50, v11, v12);
      v13 = BcpFindMessage(0x41008011ui64);
      RtlInitUnicodeString(&stru_140C53B60, v13, v14);
      v15 = BcpFindMessage(0xC1008003ui64);
      RtlInitUnicodeString((PUNICODE_STRING)&stru_140C53B20, v15, v16);
      v17 = BcpFindMessage(0x41008014ui64);
      RtlInitUnicodeString((PUNICODE_STRING)&stru_140C53BB0, v17, v18);
      v19 = BcpFindMessage(0x41008015ui64);
      RtlInitUnicodeString((PUNICODE_STRING)&stru_140C53BC0, v19, v20);
      v21 = BcpFindMessage(0x41008016ui64);
      RtlInitUnicodeString((PUNICODE_STRING)&stru_140C53BD0, v21, v22);
      v23 = BcpFindMessage(0x41008018ui64);
      RtlInitUnicodeString((PUNICODE_STRING)&stru_140C53BE0, v23, v24);
      v25 = BcpFindMessage(0x41008017ui64);
      RtlInitUnicodeString(&stru_140C53BF0, v25, v26);
      v27 = BcpFindMessage(0x41008019ui64);
      RtlInitUnicodeString(&stru_140C53C00, v27, v28);
      v29 = BcpFindMessage(0x41008020ui64);
      RtlInitUnicodeString(&stru_140C53C10, v29, v30);
      v31 = BcpFindMessage(0x41008021ui64);
      RtlInitUnicodeString((PUNICODE_STRING)&stru_140C53C20, v31, v32);
      if( (int)BcpGetProgressMessages(0xC1008012ui64, (WCHAR **)&SourceString, (WCHAR **)&v53) >= 0 )
      {
        RtlInitUnicodeString(&stru_140C53B70, SourceString, v33);
        RtlInitUnicodeString(&stru_140C53B80, v53, v34);
        ProgressMessages = BcpGetProgressMessages(0xC1008013ui64, (WCHAR **)&v55, (WCHAR **)&v53);
        v4 = v55;
        if( ProgressMessages >= 0 )
        {
          RtlInitUnicodeString((PUNICODE_STRING)&stru_140C53B90, v55, v36);
          RtlInitUnicodeString((PUNICODE_STRING)&stru_140C53BA0, v53, v37);
          if( *BcpFindMessage(0x41008006ui64) == 48 )
            dword_140C13310 |= 0x20000u;
          v40 = *(_DWORD *)(a1 + 120);
          v41 = qword_140C10E80;
          v51[1] = -1;
          v51[0] = (v40 & 0x10000000) != 0 ? -14389468 : -16746538;
LABEL_10:
          v42 = 0i64;
          v43 = (unsigned int *)v41;
          while( (int)BgpFoDetermineFontInformation(*v43, v38, v39, &v47, (unsigned int *)&v52 + 2, (__int64 **)&v52) >= 0 )
          {
            ++v42;
            *v43++ = DWORD2(v52);
            if( v42 >= 4 )
            {
              v41 += 9;
              if( (__int64)v41 < (__int64)&qword_140C10FE8 )
                goto LABEL_10;
              HIDWORD(v52) = 0;
              if( (int)BcpGetMaxResourceProfile((__int64)v51, Size) >= 0 )
              {
                v44 = Size[0];
                LODWORD(v45) = BgpFwAllocateMemory(Size[0]);
                if( v45 )
                {
                  qword_140C13270 = 0i64;
                  BcpWorkspace = v45;
                  v48 = __PAIR64__(HIDWORD(v47), Size[1]);
                  qword_140C13268 = v44;
                  qword_140C53C30 = BgpDisplayCharacterGetContext((__int64)v51, (int *)&v48, 3);
                  if( qword_140C53C30 )
                  {
                    dword_140C13310 |= 0x10u;
                    return 0i64;
                  }
                }
              }
              break;
            }
          }
        }
      }
      if( SourceString )
        BgpFwFreeMemory(SourceString);
      if( v4 )
        BgpFwFreeMemory(v4);
      if( qword_140C53C30 )
        BgpDisplayCharacterDestroyContext(qword_140C53C30);
    }
  }
  return 0i64;
}

Referenced by:

BgpFwLibraryInitialize