//
// sub_645094 from 0x645094 to 0x64517c (232 bytes)
//
// 0 xrefs:
//
// 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
//
int __fastcall sub_645094(int *a1, int a2, int a3, int a4, _DWORD *a5)
{
int v5; // r8
int v7; // r4
int *v11; // r4
int v12; // r0
int *v13; // r4
int v14; // r2
int result; // r0
int error; // r0
int v17; // r4
_DWORD *v18; // r0
unsigned int v19; // r0
int v20; // r5
int *v21; // r3
char v22[260]; // [sp+0h] [bp-104h] BYREF
v5 = 2 * a2;
v7 = 3 * a2;
ERR_clear_error();
v11 = &a1[2 * v7];
v12 = v11[117];
v13 = v11 + 116;
if ( a4 < 0 )
v14 = 0x7FFFFFFF;
else
v14 = a4;
result = SSL_write(v12, a3, v14);
if ( result <= 0 )
{
error = SSL_get_error(v13[1], result);
switch ( error )
{
case 1:
v19 = ERR_get_error(error);
if ( HIBYTE(v19) == 20 && (v19 & 0xFFF) == 0x80 && (v21 = &a1[2 * v5 + 2 * a2], v21[114] == 2) && v21[126] == 2 )
{
sub_644FD8(v22, 120);
sub_6180F8(*a1, "Error: %s does not support double SSL tunneling.", v22);
}
else
{
v20 = *a1;
ERR_error_string_n(v19, v22, 256);
sub_6180F8(v20, "SSL_write() error: %s", v22);
}
goto LABEL_9;
case 2:
case 3:
result = -1;
*a5 = 81;
return result;
case 5:
v17 = *a1;
v18 = (_DWORD *)_errno();
sub_6180F8(v17, "SSL_write() returned SYSCALL, errno = %d", *v18);
goto LABEL_9;
default:
sub_6180F8(*a1, "SSL_write() return error %d", error);
LABEL_9:
*a5 = 55;
result = -1;
break;
}
}
else
{
*a5 = 0;
}
return result;
}