//
// sub_7D2AE8 from 0x7d2ae8 to 0x7d2de8 (768 bytes)
//
// 1 xrefs:
// > ??> @ 0xa307f0
//
// 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_7D2AE8(_DWORD *a1, int a2, int off, char *a4)
{
int v5; // r0
int v7; // r3
bool v8; // zf
int v10; // r3
bool v11; // zf
FILE *v12; // r7
_DWORD *v13; // r0
char v14; // [sp+Ch] [bp-10h]
char v15; // [sp+Ch] [bp-10h]
char v16[8]; // [sp+14h] [bp-8h] BYREF
v5 = a1[8];
if ( a2 == 11 )
{
fflush((FILE *)v5);
return 1;
}
if ( a2 <= 11 )
{
if ( a2 == 3 )
return ftell((FILE *)v5);
if ( a2 > 3 )
{
if ( a2 == 8 )
return a1[4];
if ( a2 == 9 )
{
a1[4] = off;
return 1;
}
return 0;
}
if ( a2 != 1 )
{
if ( a2 == 2 )
return (*(_WORD *)(v5 + 12) & 0x20) != 0;
return 0;
}
return fseek((FILE *)v5, off, 0);
}
if ( a2 == 107 )
{
if ( a4 )
{
*(_DWORD *)a4 = v5;
return 1;
}
return 1;
}
if ( a2 <= 107 )
{
if ( a2 != 12 )
{
if ( a2 == 106 )
{
if ( a1[4] )
{
v7 = a1[3];
v8 = v7 == 0;
if ( v7 )
v8 = v5 == 0;
if ( !v8 )
{
v14 = off;
fclose((FILE *)v5);
LOBYTE(off) = v14;
a1[5] = 0;
}
}
a1[4] = off & 1;
a1[8] = a4;
a1[3] = 1;
return 1;
}
return 0;
}
return 1;
}
if ( a2 == 128 )
return fseek((FILE *)v5, off, 0);
if ( a2 == 133 )
return ftell((FILE *)v5);
if ( a2 != 108 )
return 0;
if ( a1[4] )
{
v10 = a1[3];
v11 = v10 == 0;
if ( v10 )
v11 = v5 == 0;
if ( !v11 )
{
v15 = off;
fclose((FILE *)v5);
LOBYTE(off) = v15;
a1[8] = 0;
a1[5] = 0;
}
a1[3] = 0;
}
a1[4] = off & 1;
if ( (off & 8) != 0 )
{
if ( (off & 2) != 0 )
OPENSSL_strlcpy(v16, "a+", 4);
else
OPENSSL_strlcpy(v16, "a", 4);
}
else if ( (off & 6) == 6 )
{
OPENSSL_strlcpy(v16, "r+", 4);
}
else if ( (off & 4) != 0 )
{
OPENSSL_strlcpy(v16, "w", 4);
}
else
{
if ( (off & 2) == 0 )
{
ERR_put_error(32, 116, 101, "crypto/bio/bss_file.c", 279);
return 0;
}
OPENSSL_strlcpy(v16, "r", 4);
}
v12 = openssl_fopen(a4, v16);
if ( v12 )
{
a1[8] = v12;
a1[3] = 1;
BIO_clear_flags((int)a1, 0);
return 1;
}
else
{
v13 = (_DWORD *)_errno();
ERR_put_error(2, 1, *v13, "crypto/bio/bss_file.c", 291);
ERR_add_error_data(5, "fopen('", a4);
ERR_put_error(32, 116, 2, "crypto/bio/bss_file.c", 293);
return 0;
}
}