//
// TXT_DB_read from 0xde0ea0 to 0xde11b0 (784 bytes)
//
// 2 xrefs:
// > SRP_VBASE_init @ 0xddf9dc
// > ??> @ 0x49e90
//
// 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
//
void *__fastcall TXT_DB_read(__int64 a1, int a2)
{
size_t *v4; // x0
__int64 v5; // x19
_QWORD *v7; // x0
void *v8; // x21
_QWORD *v9; // x0
void *v10; // x0
void *v11; // x0
__int64 v12; // x0
int v13; // w20
signed int v14; // w23
int v15; // s8
_BYTE *v16; // x22
const char *v17; // x0
__int64 v18; // x3
_QWORD *v19; // x0
_BOOL4 v20; // w5
_BYTE *v21; // x2
int v22; // w1
__int64 v23; // x3
int v24; // w4
_BYTE *v25; // x6
_BYTE *v26; // x4
_BYTE *v27; // x4
v4 = (size_t *)BUF_MEM_new();
v5 = (__int64)v4;
if ( !v4
|| !BUF_MEM_grow(v4, 0x200u)
|| (v7 = CRYPTO_malloc(&dword_40, (__int64)"crypto/txt_db/txt_db.c", 37), (v8 = v7) == nullptr) )
{
BUF_MEM_free(v5);
return nullptr;
}
*(_DWORD *)v7 = a2;
v7[2] = 0;
v7[3] = 0;
v9 = OPENSSL_sk_new_null();
*((_QWORD *)v8 + 1) = v9;
if ( !v9 )
goto LABEL_29;
v10 = CRYPTO_malloc((void *)(8LL * a2), (__int64)"crypto/txt_db/txt_db.c", 44);
*((_QWORD *)v8 + 2) = v10;
if ( !v10 )
goto LABEL_29;
v11 = CRYPTO_malloc((void *)(8LL * a2), (__int64)"crypto/txt_db/txt_db.c", 46);
*((_QWORD *)v8 + 3) = v11;
if ( !v11 )
goto LABEL_29;
if ( a2 > 0 )
{
v12 = 0;
do
{
*(_QWORD *)(*((_QWORD *)v8 + 2) + v12) = 0;
*(_QWORD *)(*((_QWORD *)v8 + 3) + v12) = 0;
v12 += 8;
}
while ( v12 != 8 * ((unsigned int)(a2 - 1) + 1LL) );
}
v13 = 0;
v14 = 512;
*(_BYTE *)(*(_QWORD *)(v5 + 8) + 511LL) = 0;
v15 = a2 + 1;
do
{
if ( !v13 )
goto LABEL_25;
v14 += 512;
if ( !BUF_MEM_grow_clean((size_t *)v5, v14) )
goto LABEL_29;
*(_BYTE *)(*(_QWORD *)(v5 + 8) + v13) = 0;
BIO_gets(a1, *(_QWORD *)(v5 + 8) + v13, v14 - v13);
v16 = *(_BYTE **)(v5 + 8);
v17 = &v16[v13];
if ( !*v17 )
goto LABEL_34;
LABEL_15:
v13 += strlen(v17);
v18 = v13 - 1LL;
}
while ( v16[v18] != 10 );
v16[v18] = 0;
v19 = CRYPTO_malloc((void *)(v15 * 8 + v13), (__int64)"crypto/txt_db/txt_db.c", 75);
if ( !v19 )
goto LABEL_29;
v20 = 0;
v21 = &v19[v15];
*v19 = v21;
v22 = 1;
v23 = *(_QWORD *)(v5 + 8) + 1LL;
while ( 1 )
{
v24 = *(unsigned __int8 *)(v23 - 1);
v25 = (_BYTE *)v23;
if ( !*(_BYTE *)(v23 - 1) )
break;
if ( v24 != 9 )
goto LABEL_20;
if ( v20 )
{
--v21;
LABEL_20:
*v21 = v24;
v20 = v24 == 92;
++v21;
++v23;
}
else
{
*v21 = 0;
v26 = ++v21;
if ( v22 >= a2 )
goto LABEL_22;
v19[v22] = v26;
++v23;
++v22;
}
}
v25 = (_BYTE *)(v23 - 1);
v26 = v21;
LABEL_22:
*v26 = 0;
v27 = v26 + 1;
if ( v22 != a2 || (v13 = (unsigned __int8)*v25, *v25) )
{
*((_QWORD *)v8 + 4) = 6;
goto LABEL_29;
}
v19[a2] = v27;
if ( !(unsigned int)OPENSSL_sk_push(*((int **)v8 + 1), (__int64)v19) )
{
LABEL_29:
BUF_MEM_free(v5);
OPENSSL_sk_free(*((void ***)v8 + 1));
CRYPTO_free(*((void **)v8 + 2), (__int64)"crypto/txt_db/txt_db.c", 120);
CRYPTO_free(*((void **)v8 + 3), (__int64)"crypto/txt_db/txt_db.c", 121);
CRYPTO_free(v8, (__int64)"crypto/txt_db/txt_db.c", 122);
return nullptr;
}
LABEL_25:
while ( 1 )
{
**(_BYTE **)(v5 + 8) = 0;
BIO_gets(a1, *(_QWORD *)(v5 + 8), v14);
v16 = *(_BYTE **)(v5 + 8);
if ( !*v16 )
break;
if ( *v16 != 35 )
{
v17 = *(const char **)(v5 + 8);
goto LABEL_15;
}
}
LABEL_34:
BUF_MEM_free(v5);
return v8;
}