//
// sub_1800DEF70 from 0x1800def70 to 0x1800df3e3 (1139 bytes)
//
// 2 xrefs:
// > sub_1800D7E10 @ 0x1800d7e69
// > ??> @ 0x1801c5028
//
// 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_1800DEF70(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v3; // rax
__int64 v4; // rbp
HDC DC; // rax
int v9; // eax
int v10; // esi
int v11; // edx
int v12; // eax
int v13; // ecx
int v14; // r9d
int v15; // ecx
int v16; // eax
int v17; // r8d
int v18; // eax
__int64 v19; // rcx
__int64 v20; // rax
__int64 v21; // rcx
int v22; // ecx
__int64 v23; // rax
int v24; // edx
__int64 v25; // rax
__int64 v26; // rax
__int64 v27; // rcx
__int64 v28; // rax
int v29; // edx
__int64 v30; // rax
__int64 v31; // rax
int v32; // edx
__int64 v33; // rax
__int64 v34; // rcx
__int64 v35; // rax
DWORD LastError; // eax
const char *v37; // rdx
__int64 v38; // rax
struct tagPIXELFORMATDESCRIPTOR ppfd; // [rsp+20h] [rbp-F8h] BYREF
int v41[40]; // [rsp+50h] [rbp-C8h] BYREF
int v42; // [rsp+54h] [rbp-C4h]
v3 = *(_QWORD *)(a2 + 40);
v4 = 0;
if ( v3 )
v4 = *(_QWORD *)(v3 + 640);
DC = GetDC(*(HWND *)(a1 + 880));
*(_QWORD *)(a1 + 632) = DC;
if ( DC )
{
v9 = sub_1800DF7C0(a1, a2, a3);
v10 = v9;
if ( !v9 )
return 0;
if ( !DescribePixelFormat(*(HDC *)(a1 + 632), v9, 0x28u, &ppfd) )
{
sub_1800E1AF0(65544, "WGL: Failed to retrieve PFD for selected pixel format");
return 0;
}
if ( !SetPixelFormat(*(HDC *)(a1 + 632), v10, &ppfd) )
{
sub_1800E1AF0(65544, "WGL: Failed to set selected pixel format");
return 0;
}
if ( *(_DWORD *)a2 == 196609 )
{
if ( *(_DWORD *)(a2 + 16) && !dword_1801B61C8 )
{
sub_1800DB260(
0x10007u,
"WGL: A forward compatible OpenGL context requested but WGL_ARB_create_context is unavailable");
return 0;
}
if ( *(_DWORD *)(a2 + 28) && !dword_1801B61CC )
{
sub_1800DB260(0x10007u, "WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable");
return 0;
}
}
else if ( !dword_1801B61C8 || !dword_1801B61CC || !dword_1801B61D0 )
{
sub_1800DB260(0x10006u, "WGL: OpenGL ES requested but WGL_ARB_create_context_es2_profile is unavailable");
return 0;
}
if ( !dword_1801B61C8 )
{
v38 = qword_1801B6150(*(_QWORD *)(a1 + 632));
*(_QWORD *)(a1 + 640) = v38;
if ( !v38 )
{
sub_1800E1AF0(65543, "WGL: Failed to create OpenGL context");
return 0;
}
if ( v4 && !(unsigned int)qword_1801B6180(v4, v38) )
{
sub_1800E1AF0(65544, "WGL: Failed to enable sharing with specified OpenGL context");
return 0;
}
LABEL_72:
*(_QWORD *)(a1 + 584) = sub_1800E0100;
*(_QWORD *)(a1 + 592) = sub_1800E0170;
*(_QWORD *)(a1 + 600) = sub_1800E0200;
*(_QWORD *)(a1 + 608) = sub_1800E0080;
*(_QWORD *)(a1 + 616) = sub_1800E00D0;
*(_QWORD *)(a1 + 624) = sub_1800E0050;
return 1;
}
v11 = 0;
v12 = 0;
if ( *(_DWORD *)a2 == 196609 )
{
v13 = *(_DWORD *)(a2 + 28);
v12 = *(_DWORD *)(a2 + 16) != 0 ? 2 : 0;
if ( v13 == 204801 )
{
v14 = 1;
}
else
{
v14 = 0;
if ( v13 == 204802 )
v14 = 2;
}
}
else
{
v14 = 4;
}
v15 = v12 | 1;
if ( !*(_DWORD *)(a2 + 20) )
v15 = v12;
v16 = *(_DWORD *)(a2 + 32);
v17 = v15;
if ( !v16 || !dword_1801B61D4 )
{
LABEL_38:
v18 = *(_DWORD *)(a2 + 36);
if ( v18 && dword_1801B61DC )
{
if ( v18 == 217090 )
{
v19 = (unsigned int)(v11 + 1);
v41[v11] = 8343;
v41[v19] = 0;
LABEL_44:
v11 = v19 + 1;
goto LABEL_45;
}
if ( v18 == 217089 )
{
v19 = (unsigned int)(v11 + 1);
v41[v11] = 8343;
v41[v19] = 8344;
goto LABEL_44;
}
}
LABEL_45:
if ( *(_DWORD *)(a2 + 24) && dword_1801B61D8 )
{
v20 = (unsigned int)v11;
v21 = (unsigned int)(v11 + 1);
v11 += 2;
v41[v20] = 12723;
v41[v21] = 1;
}
v22 = *(_DWORD *)(a2 + 8);
if ( v22 != 1 || *(_DWORD *)(a2 + 12) )
{
v23 = (unsigned int)v11;
v24 = v11 + 1;
v41[v23] = 8337;
v25 = v24++;
v41[v25] = v22;
v26 = v24++;
v27 = v24;
v11 = v24 + 1;
v41[v26] = 8338;
v41[v27] = *(_DWORD *)(a2 + 12);
}
if ( v17 )
{
v28 = v11;
v29 = v11 + 1;
v41[v28] = 8340;
v30 = v29;
v11 = v29 + 1;
v41[v30] = v17;
}
if ( v14 )
{
v31 = v11;
v32 = v11 + 1;
v41[v31] = 37158;
v33 = v32;
v11 = v32 + 1;
v41[v33] = v14;
}
v34 = *(_QWORD *)(a1 + 632);
*(_QWORD *)&v41[v11] = 0;
v35 = qword_1801B61A8(v34, v4, v41);
*(_QWORD *)(a1 + 640) = v35;
if ( !v35 )
{
LastError = GetLastError();
switch ( LastError )
{
case 0xC0072095:
v37 = "WGL: Driver does not support OpenGL version %i.%i";
if ( *(_DWORD *)a2 != 196609 )
v37 = "WGL: Driver does not support OpenGL ES version %i.%i";
sub_1800DB260(0x10007u, v37, *(unsigned int *)(a2 + 8), *(unsigned int *)(a2 + 12));
break;
case 0xC0072096:
sub_1800DB260(0x10007u, "WGL: Driver does not support the requested OpenGL profile");
break;
case 0xC0072054:
sub_1800DB260(0x10004u, "WGL: The share context is not compatible with the requested context");
break;
default:
if ( *(_DWORD *)a2 == 196609 )
sub_1800DB260(0x10007u, "WGL: Failed to create OpenGL context");
else
sub_1800DB260(0x10007u, "WGL: Failed to create OpenGL ES context");
break;
}
return 0;
}
goto LABEL_72;
}
if ( v16 == 200705 )
{
v42 = 33377;
}
else
{
if ( v16 != 200706 )
{
LABEL_37:
v17 = v15 | 4;
goto LABEL_38;
}
v42 = 33362;
}
v11 = 2;
v41[0] = 33366;
goto LABEL_37;
}
sub_1800DB260(0x10008u, "WGL: Failed to retrieve DC for window");
return 0;
}