//
// sub_D777D0 from 0xd777d0 to 0xd77b58 (904 bytes)
//
// 1 xrefs:
// > ??> @ 0x11223f8
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __fastcall sub_D777D0(__int64 a1, int a2, __int64 a3, unsigned __int16 *a4)
{
__int64 v5; // x19
__int64 v7; // x21
__int64 v9; // x3
__int64 v10; // x3
int v11; // w0
unsigned int v12; // w0
int v13; // w0
int v14; // w0
__int64 v15; // x23
v5 = a3;
v7 = *(_QWORD *)(a1 + 48);
if ( a2 == 15 )
{
v5 = 1;
*(_QWORD *)a4 = *(_QWORD *)(v7 + 48);
return v5;
}
if ( a2 <= 15 )
{
if ( a2 == 9 )
{
*(_DWORD *)(a1 + 28) = a3;
return 1;
}
else if ( a2 > 9 )
{
v5 = 1;
if ( a2 != 11 )
{
if ( a2 != 12 )
return 0;
v9 = *(_QWORD *)(v7 + 8);
if ( v9 )
BIO_ctrl((__int64)a4, 0x64u, 0, v9);
v10 = *(_QWORD *)(v7 + 16);
if ( v10 )
BIO_ctrl((__int64)a4, 0x64u, 1, v10);
v5 = 1;
BIO_int_ctrl((__int64)a4, 0x64u, 3, *(_DWORD *)(v7 + 4));
BIO_ctrl((__int64)a4, 0x9Bu, *(int *)(v7 + 24), 0);
BIO_callback_ctrl((__int64)a4, 0xEu, *(_QWORD *)(v7 + 48));
}
}
else if ( a2 == 1 )
{
*(_DWORD *)v7 = 1;
v14 = *(_DWORD *)(a1 + 40);
if ( v14 != -1 )
{
BIO_closesocket(v14);
*(_DWORD *)(a1 + 40) = -1;
}
v5 = 0;
BIO_ADDRINFO_free(*(struct addrinfo **)(v7 + 32));
*(_QWORD *)(v7 + 32) = 0;
*(_DWORD *)(a1 + 32) = 0;
}
else
{
if ( a2 != 8 )
return 0;
return *(int *)(a1 + 28);
}
}
else
{
if ( a2 == 102 )
{
v11 = *(_DWORD *)(v7 + 24);
if ( a3 )
v12 = v11 | 8;
else
v12 = v11 & 0xFFFFFFF7;
v5 = 1;
*(_DWORD *)(v7 + 24) = v12;
return v5;
}
if ( a2 <= 102 )
{
if ( a2 == 100 )
{
if ( a4 )
{
*(_DWORD *)(a1 + 24) = 1;
if ( a3 )
{
switch ( a3 )
{
case 1LL:
CRYPTO_free(*(_QWORD *)(v7 + 16), "crypto/bio/bss_conn.c", 411);
*(_QWORD *)(v7 + 16) = CRYPTO_strdup(a4, "crypto/bio/bss_conn.c", 412);
break;
case 2LL:
v5 = 1;
*(_QWORD *)(v7 + 8) = BIO_ADDR_hostname_string(a4, 1);
*(_QWORD *)(v7 + 16) = BIO_ADDR_service_string(a4, 1);
BIO_ADDRINFO_free(*(struct addrinfo **)(v7 + 32));
*(_QWORD *)(v7 + 32) = 0;
*(_QWORD *)(v7 + 40) = 0;
break;
case 3LL:
v5 = 1;
*(_DWORD *)(v7 + 4) = *(_DWORD *)a4;
break;
default:
return 0;
}
}
else
{
v15 = *(_QWORD *)(v7 + 16);
CRYPTO_free(*(_QWORD *)(v7 + 8), "crypto/bio/bss_conn.c", 402);
*(_QWORD *)(v7 + 8) = v5;
v5 = (int)BIO_parse_hostserv((const char *)a4, (__int64 *)(v7 + 8), (__int64 *)(v7 + 16), v5);
if ( *(_QWORD *)(v7 + 16) != v15 )
CRYPTO_free(v15, "crypto/bio/bss_conn.c", 409);
}
}
else
{
return 1;
}
}
else
{
if ( a2 != 101 )
return 0;
v5 = 1;
if ( *(_DWORD *)v7 != 5 )
return (int)sub_D773BC(a1, *(unsigned int **)(a1 + 48));
}
}
else
{
switch ( a2 )
{
case 123:
if ( !a4 )
return 0;
switch ( a3 )
{
case 0LL:
v5 = 1;
*(_QWORD *)a4 = *(_QWORD *)(v7 + 8);
return v5;
case 1LL:
*(_QWORD *)a4 = *(_QWORD *)(v7 + 16);
return v5;
case 2LL:
v5 = 1;
*(_QWORD *)a4 = BIO_ADDRINFO_address(*(_QWORD *)(v7 + 40));
return v5;
}
if ( a3 != 3 )
return 0;
v13 = BIO_ADDRINFO_family(*(_QWORD *)(v7 + 40));
switch ( v13 )
{
case 2:
return 4;
case 10:
return 6;
case 0:
return *(int *)(v7 + 4);
}
break;
case 155:
*(_DWORD *)(v7 + 24) = a3;
return 1;
case 105:
if ( *(_DWORD *)(a1 + 24) )
{
if ( a4 )
*(_DWORD *)a4 = *(_DWORD *)(a1 + 40);
return *(int *)(a1 + 40);
}
break;
default:
return 0;
}
return -1;
}
}
return v5;
}