//
// sub_FF6CA8 from 0xff6ca8 to 0xff6fa0 (760 bytes)
//
// 1 xrefs:
// > ??> @ 0x13ff9d8
//
// 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:48 +0000
//
__int64 __fastcall sub_FF6CA8(__int64 a1, int a2, __int64 off, char *a4)
{
FILE *v6; // x4
__int64 result; // x0
__int64 v8; // x20
FILE *v9; // x0
unsigned int *v10; // x0
char v11; // [xsp+38h] [xbp+38h]
char v12; // [xsp+38h] [xbp+38h]
char v13; // [xsp+48h] [xbp+48h] BYREF
v6 = *(FILE **)(a1 + 48);
if ( a2 == 11 )
{
fflush(*(FILE **)(a1 + 48));
return 1;
}
if ( a2 <= 11 )
{
if ( a2 == 3 )
return ftell(*(FILE **)(a1 + 48));
if ( a2 > 3 )
{
if ( a2 == 8 )
return *(int *)(a1 + 28);
if ( a2 == 9 )
{
*(_DWORD *)(a1 + 28) = off;
return 1;
}
return 0;
}
if ( a2 != 1 )
{
if ( a2 == 2 )
return feof(*(FILE **)(a1 + 48));
return 0;
}
return fseek(*(FILE **)(a1 + 48), off, 0);
}
if ( a2 == 107 )
{
if ( a4 )
*(_QWORD *)a4 = v6;
return 1;
}
if ( a2 <= 107 )
{
result = 1;
if ( a2 == 12 )
return result;
if ( a2 == 106 )
{
if ( *(_DWORD *)(a1 + 28) && *(_DWORD *)(a1 + 24) )
{
if ( v6 )
{
v11 = off;
fclose(v6);
*(_DWORD *)(a1 + 32) = 0;
LOBYTE(off) = v11;
}
}
result = 1;
*(_DWORD *)(a1 + 28) = off & 1;
*(_QWORD *)(a1 + 48) = a4;
*(_DWORD *)(a1 + 24) = 1;
return result;
}
return 0;
}
if ( a2 == 128 )
return fseek(*(FILE **)(a1 + 48), off, 0);
if ( a2 == 133 )
return ftell(*(FILE **)(a1 + 48));
if ( a2 != 108 )
return 0;
if ( *(_DWORD *)(a1 + 28) )
{
if ( *(_DWORD *)(a1 + 24) && v6 )
{
v12 = off;
fclose(v6);
*(_QWORD *)(a1 + 48) = 0;
LOBYTE(off) = v12;
*(_DWORD *)(a1 + 32) = 0;
}
*(_DWORD *)(a1 + 24) = 0;
}
*(_DWORD *)(a1 + 28) = off & 1;
if ( (off & 8) != 0 )
{
if ( (off & 2) != 0 )
OPENSSL_strlcpy(&v13, "a+", 4);
else
OPENSSL_strlcpy(&v13, &byte_120B870, 4);
}
else if ( (off & 6) == 6 )
{
OPENSSL_strlcpy(&v13, "r+", 4);
}
else if ( (off & 4) != 0 )
{
OPENSSL_strlcpy(&v13, "w", 4);
}
else
{
v8 = off & 2;
if ( (off & 2) == 0 )
{
ERR_put_error(32, 116, 101, "crypto/bio/bss_file.c", 279);
return v8;
}
OPENSSL_strlcpy(&v13, "r", 4);
}
v9 = openssl_fopen(a4, &v13);
if ( v9 )
{
*(_QWORD *)(a1 + 48) = v9;
*(_DWORD *)(a1 + 24) = 1;
BIO_clear_flags(a1, 0);
return 1;
}
else
{
v10 = (unsigned int *)__errno();
ERR_put_error(2, 1, *v10, "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;
}
}