BgpTxtCreateRegion

__int64 __fastcall BgpTxtCreateRegion(_DWORD *a1, _DWORD *a2, _OWORD *a3, _QWORD *a4, char a5){
  __int64 v7; 
  __int64 v8; 
  int TextMetrics; 
  INT64 v10; 
  INT64 v11; 
  _OWORD *v12; 
  unsigned int *v13; 
  int v14; 
  int v15; 
  bool v16; 
  int v18; 
  VOID *v19; 
  INT64 v20; 
  __int64 v21; 
  VOID *FontHandle; 
  __int64 v23; 
  int v24[6]; 
  __int64 a2a; 
  _OWORD *v26; 
  _QWORD *v27; 
  v27 = a4;
  v26 = a3;
  FontHandle = 0i64;
  a2a = 0i64;
  v7 = 0i64;
  *a4 = 0i64;
  v8 = 0i64;
  v20 = 0i64;
  TextMetrics = 0;
  v21 = 0i64;
  if( a1 )
  {
    if( a2 )
    {
      v23 = *(_QWORD *)BgpGetResolution(v24);
      if( *a1 <= (unsigned int)v23 && a1[1] <= HIDWORD(v23) )
      {
        LODWORD(v10) = BgpFwAllocateMemory(0x48ui64);
        v11 = v10;
        if( !v10 )
        {
          TextMetrics = -1073741801;
          goto LABEL_23;
        }
        memset(v10, 0i64);
        v12 = v26;
        if( v26 )
        {
          v13 = (unsigned int *)(v11 + 40);
          *(_OWORD *)(v11 + 40) = *v26;
          *(_QWORD *)(v11 + 56) = *((_QWORD *)v12 + 2);
        }
        else
        {
          TextMetrics = BgpFoGetFontHandle(0i64, &FontHandle);
          if( TextMetrics < 0 )
            goto LABEL_34;
          *(_DWORD *)(v11 + 44) = -1;
          v13 = (unsigned int *)(v11 + 40);
          *(_DWORD *)(v11 + 40) = 0;
          v19 = FontHandle;
          *(_DWORD *)(v11 + 60) = 0;
          *(_QWORD *)(v11 + 48) = v19;
          *(_DWORD *)(v11 + 56) = 18;
        }
        if( (a5 & 1) != 0 )
          goto LABEL_14;
        TextMetrics = BgpFoGetTextMetrics((INT64)v13, &a2a);
        if( TextMetrics >= 0 )
        {
          if( a2[1] < HIDWORD(a2a) )
            a2[1] = HIDWORD(a2a);
          if( *a2 < (unsigned int)a2a )
            *a2 = a2a;
LABEL_14:
          if( *a2 + *a1 > (unsigned int)v23 || (unsigned int)(a1[1] + a2[1]) > HIDWORD(v23) )
          {
            TextMetrics = -1073741811;
            goto LABEL_22;
          }
          if( (a5 & 2) == 0 )
          {
            v18 = BgpGxRectangleCreate(a2, 32, &v20);
            v7 = v20;
            TextMetrics = v18;
            if( v18 < 0 )
              goto LABEL_30;
            BgpGxFillRectangle(v20, *v13);
          }
          if( (a5 & 9) == 0 )
            goto LABEL_20;
          v14 = BgpGxRectangleCreate(a2, 32, &v21);
          v8 = v21;
          TextMetrics = v14;
          if( v14 >= 0 )
          {
            *(_QWORD *)(v11 + 32) = v21;
LABEL_20:
            *(_QWORD *)v11 = *(_QWORD *)a1;
            *(_QWORD *)(v11 + 8) = *(_QWORD *)a2;
            v15 = a2[2];
            *(_DWORD *)(v11 + 68) = 0;
            v16 = (a5 & 4) == 0;
            *(_DWORD *)(v11 + 16) = v15;
            *(_QWORD *)(v11 + 24) = v7;
            *(_DWORD *)(v11 + 64) = 1;
            if( !v16 )
              *(_DWORD *)(v11 + 64) = 5;
LABEL_22:
            if( TextMetrics >= 0 )
            {
LABEL_23:
              *v27 = v11;
              return(unsigned int)TextMetrics;
            }
          }
LABEL_30:
          if( v7 )
            BgpGxRectangleDestroy(v7);
          if( v8 )
            BgpGxRectangleDestroy(v8);
        }
LABEL_34:
        BgpFwFreeMemory(v11);
        goto LABEL_23;
      }
    }
  }
  return 3221225485i64;
}

Referenced by:

AnFwConfigureProgressResources
BgpDisplayCharacterGetContext
ResFwConfigureDisplayStringResources