//
// custom_ext_add from 0xfd2aa4 to 0xfd2c78 (468 bytes)
//
// 3 xrefs:
// > ssl_add_serverhello_tlsext @ 0xfd486c
// > ssl_add_clienthello_tlsext @ 0xfd71cc
// > ??> @ 0x79f30
//
// 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:15:30 +0000
//
__int64 __fastcall custom_ext_add(__int64 a1, int a2, void **a3, __int64 a4, __int64 a5)
{
__int64 v10; // x23
__int64 *v11; // x23
unsigned __int64 v12; // x0
char *v13; // x20
__int64 v14; // x21
unsigned __int64 v15; // x22
__int64 v16; // x19
unsigned __int16 *v17; // x19
__int64 (__fastcall *v18)(__int64, _QWORD, void **, size_t *, __int64, _QWORD); // x6
int v19; // w0
int v20; // w5
void (__fastcall *v21)(__int64, _QWORD, void *, _QWORD); // x4
void *v23; // [xsp+70h] [xbp+70h] BYREF
size_t v24; // [xsp+78h] [xbp+78h] BYREF
v10 = *(_QWORD *)(a1 + 328);
if ( a2 )
v11 = (__int64 *)(v10 + 424);
else
v11 = (__int64 *)(v10 + 408);
v12 = v11[1];
v13 = (char *)*a3;
if ( !v12 )
{
LABEL_19:
*a3 = v13;
return 1;
}
v14 = 0;
v15 = 0;
while ( 1 )
{
v16 = *v11;
v23 = nullptr;
v24 = 0;
v17 = (unsigned __int16 *)(v16 + v14);
if ( a2 )
{
if ( (*((_DWORD *)v17 + 1) & 1) == 0 )
goto LABEL_18;
v18 = *((__int64 (__fastcall **)(__int64, _QWORD, void **, size_t *, __int64, _QWORD))v17 + 1);
if ( !v18 )
goto LABEL_18;
}
else
{
v18 = *((__int64 (__fastcall **)(__int64, _QWORD, void **, size_t *, __int64, _QWORD))v17 + 1);
if ( !v18 )
{
if ( a4 - (__int64)v13 <= 3 )
return 0;
goto LABEL_12;
}
}
v19 = v18(a1, *v17, &v23, &v24, a5, *((_QWORD *)v17 + 3));
if ( v19 < 0 )
return 0;
if ( !v19 )
goto LABEL_17;
if ( a4 - (__int64)v13 <= 3 || a4 - (__int64)v13 - 4 < v24 )
return 0;
LABEL_12:
v13 += 4;
*(v13 - 4) = *((_BYTE *)v17 + 1);
*(v13 - 3) = *v17;
*(v13 - 2) = BYTE1(v24);
*(v13 - 1) = v24;
if ( v24 )
{
memcpy(v13, v23, v24);
v13 += v24;
}
v20 = *((_DWORD *)v17 + 1);
if ( (v20 & 2) != 0 )
OPENSSL_die((int)"assertion failed: !(meth->ext_flags & SSL_EXT_FLAG_SENT)");
v21 = *((void (__fastcall **)(__int64, _QWORD, void *, _QWORD))v17 + 2);
*((_DWORD *)v17 + 1) = v20 | 2;
if ( v21 )
v21(a1, *v17, v23, *((_QWORD *)v17 + 3));
LABEL_17:
v12 = v11[1];
LABEL_18:
++v15;
v14 += 48;
if ( v15 >= v12 )
goto LABEL_19;
}
}