//
// lws_create_context from 0xe35714 to 0xe35a24 (784 bytes)
//
// 2 xrefs:
// > cocos2d::extension::WebSocket::onSubThreadStarted @ 0xd200ac
// > ??> @ 0x9cfb8
//
// This function is hookable on this platform (idp: arm, 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 13:09:57 +0000
//
__int64 __fastcall lws_create_context(int *a1)
{
__int64 v2; // x0
__int64 v3; // x19
int v4; // w0
__int64 v5; // x5
__int64 v6; // x4
int v7; // w0
int v8; // w3
int v9; // w1
int v10; // w2
__int64 v11; // x0
char *v12; // x1
int v13; // w0
__int64 v14; // x0
void (__fastcall *i)(_QWORD *, __int64, _QWORD, _QWORD, _QWORD); // x5
__int64 v16; // x0
int v17; // w1
_QWORD v19[27]; // [xsp+38h] [xbp+38h] BYREF
lws_log(4, "Initial logging level %d\n", dword_154A3EC);
lws_log(4, "Libwebsockets version: %s\n", "1.6.0 782bf10");
lws_log(4, "IPV6 not compiled in\n");
v2 = lws_log(4, "libev support not compiled in\n");
if ( (unsigned int)lws_plat_context_early_init(v2) )
return 0;
v3 = sub_E35A68(4664);
if ( v3 )
{
v4 = *a1;
v5 = *((_QWORD *)a1 + 2);
v6 = *((_QWORD *)a1 + 4);
*(_BYTE *)(v3 + 40) = 0;
*(_DWORD *)(v3 + 24) = v4;
v7 = a1[30];
v8 = a1[25];
v9 = a1[28];
*(_QWORD *)(v3 + 32) = *((_QWORD *)a1 + 1);
memset(v19, 0, 208);
v10 = a1[29];
*(_DWORD *)(v3 + 4556) = 0;
*(_QWORD *)(v3 + 4584) = v5;
*(_QWORD *)(v3 + 4608) = v6;
*(_DWORD *)(v3 + 424) = 0;
*(_DWORD *)(v3 + 428) = v8;
*(_DWORD *)(v3 + 4572) = v9;
*(_DWORD *)(v3 + 4580) = v7;
*(_DWORD *)(v3 + 4576) = v10;
v19[26] = 0;
v19[0] = v3;
if ( v7 || v9 <= 0 )
{
*(_DWORD *)(v3 + 20) = 1024;
lws_log(4, " ctx mem: %u bytes\n", 21048);
v11 = sub_E35A68(8LL * *(int *)(v3 + 20));
*(_QWORD *)v3 = v11;
if ( v11 )
{
if ( !(unsigned int)lws_plat_init(v3, a1) )
{
lws_context_init_extensions(a1, v3);
*(_QWORD *)(v3 + 4616) = *((_QWORD *)a1 + 13);
strcpy((char *)(v3 + 168), "unknown");
lws_server_get_canonical_hostname(v3, a1);
v12 = *((char **)a1 + 10);
if ( v12 )
{
v13 = a1[22];
if ( v13 )
*(_DWORD *)(v3 + 424) = v13;
}
else
{
v12 = getenv("http_proxy");
if ( !v12 )
{
LABEL_11:
lws_log(4, " per-conn mem: %u + %u headers + protocol rx buf\n", 216, 2126);
if ( !(unsigned int)sub_E38FC8(a1, v3) )
{
lws_plat_drop_app_privileges(a1);
v14 = *((_QWORD *)a1 + 2);
*(_DWORD *)(v3 + 4592) = 0;
for ( i = *(void (__fastcall **)(_QWORD *, __int64, _QWORD, _QWORD, _QWORD))(v14 + 8);
i;
i = *(void (__fastcall **)(_QWORD *, __int64, _QWORD, _QWORD, _QWORD))(v16 + 48LL * v17 + 8) )
{
i(v19, 27, 0, 0, 0);
v16 = *((_QWORD *)a1 + 2);
v17 = *(_DWORD *)(v3 + 4592) + 1;
*(_DWORD *)(v3 + 4592) = v17;
}
if ( *a1 == -1 )
{
if ( (sub_E3A6F8(v3, 0, 1, 0, 0) & 0x80000000) == 0 )
return v3;
}
else if ( (sub_E3A6F8(v3, 0, 0, 0, 0) & 0x80000000) == 0 )
{
return v3;
}
}
goto LABEL_18;
}
}
lws_set_proxy(v3, v12);
goto LABEL_11;
}
}
else
{
lws_log(1, "OOM allocating %d fds\n", *(_DWORD *)(v3 + 20));
}
LABEL_18:
lws_context_destroy(v3);
return 0;
}
lws_log(1, "info->ka_interval can't be 0 if ka_time used\n");
return 0;
}
else
{
lws_log(1, "No memory for websocket context\n");
return 0;
}
}