//
// ssl_update_cache from 0x799150 to 0x79923c (236 bytes)
//
// 3 xrefs:
// > tls_finish_handshake @ 0x7a68c8
// > tls_finish_handshake @ 0x7a695c
// > ??> @ 0x5c04c
//
// 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
//
_DWORD *__fastcall ssl_update_cache(_DWORD *result, int a2)
{
_DWORD *v2; // r5
unsigned int v4; // r4
int v5; // r7
int v6; // r4
int v7; // r4
int v8; // r4
int v9; // r3
time_t v10; // r1
if ( !*(_DWORD *)(result[60] + 56) )
return result;
v2 = result;
result = (_DWORD *)result[111];
v4 = result[8];
v5 = a2 & v4;
if ( (a2 & v4) != 0 && !v2[30] )
{
if ( (v4 & 0x200) != 0 )
{
LABEL_6:
if ( result[10] )
{
SSL_SESSION_up_ref(v2[60]);
result = (_DWORD *)(*(int (__fastcall **)(_DWORD *, _DWORD))(v2[111] + 40))(v2, v2[60]);
if ( !result )
result = (_DWORD *)SSL_SESSION_free(v2[60]);
}
goto LABEL_9;
}
result = (_DWORD *)SSL_CTX_add_session();
if ( result )
{
result = (_DWORD *)v2[111];
goto LABEL_6;
}
}
LABEL_9:
v6 = (v4 >> 7) ^ 1;
if ( a2 == v5 )
v7 = v6 & 1;
else
v7 = 0;
if ( v7 )
{
v8 = v2[111];
if ( (a2 & 1) != 0 )
v9 = *(unsigned __int8 *)(v8 + 60);
else
v9 = *(unsigned __int8 *)(v8 + 72);
if ( v9 == 255 )
{
v10 = time(nullptr);
return (_DWORD *)SSL_CTX_flush_sessions(v8, v10);
}
}
return result;
}