//
// sub_8B4EE0 from 0x8b4ee0 to 0x8b509c (444 bytes)
//
// 2 xrefs:
// > sub_8B509C @ 0x8b51c8
// > ??> @ 0xa3a3d0
//
// 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_8B4EE0(int a1, char *a2, int a3)
{
int data; // r5
int v7; // r0
bool v8; // zf
int v9; // r6
int v10; // r3
int v12; // r12
int v13; // r10
int v14; // r0
int v15; // r4
bool v16; // cc
int v17; // r3
int v18; // r11
int v19; // r10
size_t v20; // r12
int v21; // r4
int i; // r1
int v23; // r12
int v24; // r0
int v25; // [sp+8h] [bp-Ch]
size_t v26; // [sp+Ch] [bp-8h]
data = BIO_get_data(a1);
v7 = BIO_next(a1);
v8 = data == 0;
if ( data )
v8 = v7 == 0;
v9 = v7;
if ( v8 )
return 0;
BIO_clear_flags(a1, 15);
v12 = *(_DWORD *)(data + 4);
v13 = *(_DWORD *)data - v12;
if ( v13 <= 0 )
{
LABEL_12:
v16 = (int)a2 <= 0;
if ( a2 )
v16 = a3 <= 0;
v17 = v16;
if ( !v16 )
{
v18 = v17;
v19 = a3;
*(_DWORD *)(data + 4) = v17;
while ( 1 )
{
if ( v19 >= 4096 )
v20 = 4096;
else
v20 = v19;
v26 = v20;
if ( !EVP_CipherUpdate(*(_DWORD **)(data + 20), (char *)(data + 32), (int *)data, a2, v20) )
{
BIO_clear_flags(a1, 15);
v10 = 0;
*(_DWORD *)(data + 16) = 0;
return v10;
}
v21 = *(_DWORD *)data;
v19 -= v26;
v16 = *(_DWORD *)data <= 0;
a2 += v26;
*(_DWORD *)(data + 4) = v18;
if ( !v16 )
break;
LABEL_31:
*(_DWORD *)data = v18;
*(_DWORD *)(data + 4) = v18;
if ( v19 <= 0 )
{
BIO_copy_next_retry(a1);
return a3;
}
}
for ( i = data + 32; ; i = data + v23 + 32 )
{
v24 = BIO_write(v9, i, v21);
v21 -= v24;
if ( v24 <= 0 )
break;
v23 = v24 + *(_DWORD *)(data + 4);
*(_DWORD *)(data + 4) = v23;
if ( v21 <= 0 )
goto LABEL_31;
}
v25 = v24;
BIO_copy_next_retry(a1);
if ( v19 == a3 )
return v25;
else
return a3 - v19;
}
return 0;
}
while ( 1 )
{
v14 = BIO_write(v9, data + v12 + 32, v13);
v15 = v14;
v13 -= v14;
if ( v14 <= 0 )
break;
v12 = v14 + *(_DWORD *)(data + 4);
*(_DWORD *)(data + 4) = v12;
if ( v13 <= 0 )
goto LABEL_12;
}
BIO_copy_next_retry(a1);
return v15;
}