//
// sub_1800DF7C0 from 0x1800df7c0 to 0x1800e004d (2189 bytes)
//
// 3 xrefs:
// > sub_1800DEF70 @ 0x1800defdf
// > ??> @ 0x18014c6c8
// > ??> @ 0x1801c5070
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:22:36 +0000
//
__int64 __fastcall sub_1800DF7C0(__int64 a1, _DWORD *a2, int *a3)
{
unsigned int v3; // r13d
unsigned int v5; // r14d
int v6; // eax
int v7; // edi
char *v8; // rax
int v9; // ecx
char *v10; // r15
__int64 v11; // r12
int v12; // esi
char *v13; // rdi
__int64 v14; // rdx
HDC v15; // rcx
__int64 v16; // rax
__int64 v17; // rax
__int64 v18; // rax
int *v19; // rcx
__int64 v20; // rax
__int64 v21; // rax
int v22; // eax
__int64 v23; // rax
int v24; // eax
__int64 v25; // rax
int v26; // eax
__int64 v27; // rax
int v28; // eax
__int64 v29; // rax
int v30; // eax
__int64 v31; // rax
int v32; // eax
__int64 v33; // rax
int v34; // eax
__int64 v35; // rax
int v36; // eax
__int64 v37; // rax
int v38; // eax
__int64 v39; // rax
int v40; // eax
__int64 v41; // rax
int v42; // eax
__int64 v43; // rax
int v44; // eax
__int64 v45; // rax
__int64 v46; // rax
int v47; // eax
__int64 v48; // rax
__int64 v49; // rax
char dwFlags; // cl
int *v51; // rax
unsigned int v52; // ebx
int v55; // [rsp+3Ch] [rbp-C4h]
struct tagPIXELFORMATDESCRIPTOR ppfd; // [rsp+50h] [rbp-B0h] BYREF
_OWORD v59[5]; // [rsp+80h] [rbp-80h] BYREF
int v60; // [rsp+D0h] [rbp-30h]
int v61; // [rsp+D4h] [rbp-2Ch]
int v62; // [rsp+D8h] [rbp-28h]
_DWORD v63[40]; // [rsp+120h] [rbp+20h] BYREF
v3 = 0;
v5 = 0;
v6 = DescribePixelFormat(*(HDC *)(a1 + 632), 1, 0x28u, nullptr);
v7 = v6;
v55 = v6;
if ( dword_1801B61C4 )
{
v5 = 22;
v59[0] = _mm_load_si128((const __m128i *)&xmmword_180128030);
v59[2] = _mm_load_si128((const __m128i *)&xmmword_180128050);
v59[1] = _mm_load_si128((const __m128i *)&xmmword_180128040);
v59[4] = _mm_load_si128((const __m128i *)&xmmword_180128070);
v59[3] = _mm_load_si128((const __m128i *)&xmmword_180128060);
v60 = 8210;
v61 = 8209;
if ( dword_1801B61B8 )
{
v62 = 8258;
v5 = 23;
}
if ( *a2 != 196609 )
{
if ( !dword_1801B61B4 )
goto LABEL_11;
*((_DWORD *)v59 + v5) = 12445;
goto LABEL_10;
}
if ( dword_1801B61BC || dword_1801B61C0 )
{
*((_DWORD *)v59 + v5) = 8361;
LABEL_10:
++v5;
}
}
LABEL_11:
v8 = (char *)calloc(v6, 0x48u);
v9 = 0;
v10 = v8;
if ( v7 > 0 )
{
v11 = 0;
while ( 1 )
{
v12 = v9 + 1;
v13 = &v10[72 * v11];
v14 = (unsigned int)(v9 + 1);
v15 = *(HDC *)(a1 + 632);
if ( dword_1801B61C4 )
{
if ( !(unsigned int)qword_1801B6190(v15, v14, 0, v5, v59, v63) )
{
sub_1800E1AF0(65544, "WGL: Failed to retrieve pixel format attributes");
goto LABEL_146;
}
v16 = 0;
if ( !v5 )
{
LABEL_28:
sub_1800E1AF0(65544, "WGL: Unknown pixel format attribute requested");
LABEL_29:
v19 = a3;
goto LABEL_30;
}
while ( *((_DWORD *)v59 + v16) != 8208 )
{
if ( ++v16 >= v5 )
goto LABEL_28;
}
if ( !v63[v16] )
goto LABEL_29;
v17 = 0;
while ( *((_DWORD *)v59 + v17) != 8193 )
{
if ( ++v17 >= v5 )
goto LABEL_28;
}
if ( !v63[v17] )
goto LABEL_29;
v18 = 0;
while ( *((_DWORD *)v59 + v18) != 8211 )
{
if ( ++v18 >= v5 )
goto LABEL_28;
}
if ( v63[v18] != 8235 )
goto LABEL_29;
v20 = 0;
while ( *((_DWORD *)v59 + v20) != 8195 )
{
if ( ++v20 >= v5 )
{
sub_1800E1AF0(65544, "WGL: Unknown pixel format attribute requested");
goto LABEL_38;
}
}
if ( v63[v20] == 8229 )
goto LABEL_29;
LABEL_38:
v21 = 0;
while ( *((_DWORD *)v59 + v21) != 8209 )
{
if ( ++v21 >= v5 )
{
sub_1800E1AF0(65544, "WGL: Unknown pixel format attribute requested");
v22 = 0;
goto LABEL_43;
}
}
v22 = v63[v21];
LABEL_43:
v19 = a3;
if ( v22 == a3[14] )
{
v23 = 0;
while ( *((_DWORD *)v59 + v23) != 8213 )
{
if ( ++v23 >= v5 )
{
sub_1800E1AF0(65544, "WGL: Unknown pixel format attribute requested");
v24 = 0;
goto LABEL_49;
}
}
v24 = v63[v23];
LABEL_49:
*(_DWORD *)v13 = v24;
v25 = 0;
while ( *((_DWORD *)v59 + v25) != 8215 )
{
if ( ++v25 >= v5 )
{
sub_1800E1AF0(65544, "WGL: Unknown pixel format attribute requested");
v26 = 0;
goto LABEL_54;
}
}
v26 = v63[v25];
LABEL_54:
*((_DWORD *)v13 + 1) = v26;
v27 = 0;
while ( *((_DWORD *)v59 + v27) != 8217 )
{
if ( ++v27 >= v5 )
{
sub_1800E1AF0(65544, "WGL: Unknown pixel format attribute requested");
v28 = 0;
goto LABEL_59;
}
}
v28 = v63[v27];
LABEL_59:
*((_DWORD *)v13 + 2) = v28;
v29 = 0;
while ( *((_DWORD *)v59 + v29) != 8219 )
{
if ( ++v29 >= v5 )
{
sub_1800E1AF0(65544, "WGL: Unknown pixel format attribute requested");
v30 = 0;
goto LABEL_64;
}
}
v30 = v63[v29];
LABEL_64:
*((_DWORD *)v13 + 3) = v30;
v31 = 0;
while ( *((_DWORD *)v59 + v31) != 8226 )
{
if ( ++v31 >= v5 )
{
sub_1800E1AF0(65544, "WGL: Unknown pixel format attribute requested");
v32 = 0;
goto LABEL_69;
}
}
v32 = v63[v31];
LABEL_69:
*((_DWORD *)v13 + 4) = v32;
v33 = 0;
while ( *((_DWORD *)v59 + v33) != 8227 )
{
if ( ++v33 >= v5 )
{
sub_1800E1AF0(65544, "WGL: Unknown pixel format attribute requested");
v34 = 0;
goto LABEL_74;
}
}
v34 = v63[v33];
LABEL_74:
*((_DWORD *)v13 + 5) = v34;
v35 = 0;
while ( *((_DWORD *)v59 + v35) != 8222 )
{
if ( ++v35 >= v5 )
{
sub_1800E1AF0(65544, "WGL: Unknown pixel format attribute requested");
v36 = 0;
goto LABEL_79;
}
}
v36 = v63[v35];
LABEL_79:
*((_DWORD *)v13 + 6) = v36;
v37 = 0;
while ( *((_DWORD *)v59 + v37) != 8223 )
{
if ( ++v37 >= v5 )
{
sub_1800E1AF0(65544, "WGL: Unknown pixel format attribute requested");
v38 = 0;
goto LABEL_84;
}
}
v38 = v63[v37];
LABEL_84:
*((_DWORD *)v13 + 7) = v38;
v39 = 0;
while ( *((_DWORD *)v59 + v39) != 8224 )
{
if ( ++v39 >= v5 )
{
sub_1800E1AF0(65544, "WGL: Unknown pixel format attribute requested");
v40 = 0;
goto LABEL_89;
}
}
v40 = v63[v39];
LABEL_89:
*((_DWORD *)v13 + 8) = v40;
v41 = 0;
while ( *((_DWORD *)v59 + v41) != 8225 )
{
if ( ++v41 >= v5 )
{
sub_1800E1AF0(65544, "WGL: Unknown pixel format attribute requested");
v42 = 0;
goto LABEL_94;
}
}
v42 = v63[v41];
LABEL_94:
*((_DWORD *)v13 + 9) = v42;
v43 = 0;
while ( *((_DWORD *)v59 + v43) != 8228 )
{
if ( ++v43 >= v5 )
{
sub_1800E1AF0(65544, "WGL: Unknown pixel format attribute requested");
v44 = 0;
goto LABEL_99;
}
}
v44 = v63[v43];
LABEL_99:
*((_DWORD *)v13 + 10) = v44;
v45 = 0;
while ( *((_DWORD *)v59 + v45) != 8210 )
{
if ( ++v45 >= v5 )
{
sub_1800E1AF0(65544, "WGL: Unknown pixel format attribute requested");
goto LABEL_105;
}
}
if ( v63[v45] )
*((_DWORD *)v13 + 11) = 1;
LABEL_105:
if ( dword_1801B61B8 )
{
v46 = 0;
while ( *((_DWORD *)v59 + v46) != 8258 )
{
if ( ++v46 >= v5 )
{
sub_1800E1AF0(65544, "WGL: Unknown pixel format attribute requested");
v47 = 0;
goto LABEL_111;
}
}
v47 = v63[v46];
LABEL_111:
*((_DWORD *)v13 + 12) = v47;
}
if ( *a2 == 196609 )
{
if ( dword_1801B61BC || dword_1801B61C0 )
{
v48 = 0;
while ( *((_DWORD *)v59 + v48) != 8361 )
{
if ( ++v48 >= v5 )
goto LABEL_118;
}
if ( v63[v48] )
{
++v3;
*((_QWORD *)v13 + 8) = v12;
++v11;
*((_DWORD *)v13 + 13) = 1;
goto LABEL_29;
}
}
}
else if ( dword_1801B61B4 )
{
v49 = 0;
while ( *((_DWORD *)v59 + v49) != 12445 )
{
if ( ++v49 >= v5 )
{
LABEL_118:
sub_1800E1AF0(65544, "WGL: Unknown pixel format attribute requested");
++v3;
*((_QWORD *)v13 + 8) = v12;
++v11;
goto LABEL_29;
}
}
if ( v63[v49] == 12425 )
{
++v3;
*((_QWORD *)v13 + 8) = v12;
++v11;
*((_DWORD *)v13 + 13) = 1;
goto LABEL_29;
}
}
LABEL_137:
++v3;
*((_QWORD *)v13 + 8) = v12;
++v11;
goto LABEL_29;
}
}
else
{
if ( !DescribePixelFormat(v15, v14, 0x28u, &ppfd) )
{
sub_1800E1AF0(65544, "WGL: Failed to describe pixel format");
goto LABEL_146;
}
dwFlags = ppfd.dwFlags;
if ( (ppfd.dwFlags & 4) == 0
|| (ppfd.dwFlags & 0x20) == 0
|| (ppfd.dwFlags & 0x1000) == 0 && (ppfd.dwFlags & 0x40) != 0
|| ppfd.iPixelType )
{
goto LABEL_29;
}
if ( (ppfd.dwFlags & 1) == a3[14] )
{
*(_DWORD *)v13 = ppfd.cRedBits;
*((_DWORD *)v13 + 1) = ppfd.cGreenBits;
*((_DWORD *)v13 + 2) = ppfd.cBlueBits;
*((_DWORD *)v13 + 3) = ppfd.cAlphaBits;
*((_DWORD *)v13 + 4) = ppfd.cDepthBits;
*((_DWORD *)v13 + 5) = ppfd.cStencilBits;
*((_DWORD *)v13 + 6) = ppfd.cAccumRedBits;
*((_DWORD *)v13 + 7) = ppfd.cAccumGreenBits;
*((_DWORD *)v13 + 8) = ppfd.cAccumBlueBits;
*((_DWORD *)v13 + 9) = ppfd.cAccumAlphaBits;
*((_DWORD *)v13 + 10) = ppfd.cAuxBuffers;
if ( (dwFlags & 2) != 0 )
*((_DWORD *)v13 + 11) = 1;
goto LABEL_137;
}
v19 = a3;
}
LABEL_30:
if ( v12 >= v55 )
{
if ( !v3 )
break;
v51 = sub_1800D6EF0(v19, (__int64)v10, v3);
if ( !v51 )
{
sub_1800DB260(0x10009u, "WGL: Failed to find a suitable pixel format");
goto LABEL_146;
}
v52 = v51[16];
free(v10);
return v52;
}
v9 = v12;
}
}
sub_1800DB260(0x10006u, "WGL: The driver does not appear to support OpenGL");
LABEL_146:
free(v10);
return 0;
}