//
// CONF_modules_load from 0xd81e50 to 0xd82360 (1296 bytes)
//
// 2 xrefs:
// > CONF_modules_load_file @ 0xd82794
// > ??> @ 0xbece0
//
// 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
//
__int64 __fastcall CONF_modules_load(__int64 a1, char *a2, char a3)
{
__int64 string; // x0
__int64 v6; // x1
__int64 result; // x0
__int64 v8; // x23
int v9; // w22
__int64 v10; // x27
__int64 v11; // d8
__int64 v12; // d9
__int64 v13; // x0
const char *v14; // x21
__int64 v15; // x25
char *v16; // x0
int v17; // w0
int v18; // w24
size_t v19; // x26
__int64 v20; // x20
bool v21; // cc
__int64 v22; // x1
__int64 v23; // d14
__int64 v24; // x0
__int64 v25; // x28
__int64 v26; // d15
__int64 *v27; // x0
__int64 v28; // x0
__int64 v29; // x2
__int64 *v30; // x0
__int64 *v31; // x26
__int64 v32; // x0
__int64 v33; // x2
_BOOL4 v34; // w28
int (__fastcall *v35)(__int64 *, __int64); // x2
__int64 v36; // x0
void (__fastcall *v37)(__int64 *); // x1
__int64 v38; // [xsp+A8h] [xbp+A8h]
__int64 v39; // [xsp+A8h] [xbp+A8h]
char v40; // [xsp+B0h] [xbp+B0h] BYREF
if ( !a1 )
return 1;
if ( a2 )
{
string = NCONF_get_string(a1, 0, a2);
v6 = string;
if ( string )
goto LABEL_4;
if ( (a3 & 0x20) == 0 )
goto LABEL_53;
}
string = NCONF_get_string(a1, 0, "openssl_conf");
v6 = string;
if ( !string )
{
LABEL_53:
ERR_clear_error(string);
return 1;
}
LABEL_4:
result = NCONF_get_section(a1, v6);
v8 = result;
if ( result )
{
v9 = 0;
v10 = a3 & 4;
v11 = a3 & 8;
v12 = a3 & 1;
if ( (int)OPENSSL_sk_num(result) > 0 )
{
while ( 2 )
{
v13 = OPENSSL_sk_value(v8, (unsigned int)v9);
v14 = *(const char **)(v13 + 8);
v15 = *(_QWORD *)(v13 + 16);
v16 = strrchr(v14, 46);
if ( v16 )
v17 = (_DWORD)v16 - (_DWORD)v14;
else
v17 = strlen(v14);
v18 = 0;
v19 = v17;
while ( 1 )
{
v21 = v18 < (int)OPENSSL_sk_num(qword_125D588);
v22 = (unsigned int)v18++;
if ( !v21 )
break;
v20 = OPENSSL_sk_value(qword_125D588, v22);
if ( !strncmp(*(const char **)(v20 + 8), v14, v19) )
goto LABEL_30;
}
if ( v11 )
{
if ( v10 )
goto LABEL_13;
LABEL_28:
ERR_put_error(14, 118, 113, "crypto/conf/conf_mod.c", 162);
ERR_add_error_data(2, "module=", v14);
if ( v12 )
goto LABEL_14;
return 0xFFFFFFFFLL;
}
v23 = NCONF_get_string(a1, v15, "path");
if ( !v23 )
{
v23 = (__int64)v14;
ERR_clear_error(0);
}
v24 = DSO_load(0, v23, 0, 0);
v25 = v24;
if ( v24 )
{
v26 = DSO_bind_func(v24, "OPENSSL_init");
if ( v26 )
{
v38 = DSO_bind_func(v25, "OPENSSL_finish");
if ( !qword_125D588 )
{
qword_125D588 = OPENSSL_sk_new_null(0);
if ( !qword_125D588 )
goto LABEL_26;
}
v27 = (__int64 *)CRYPTO_zalloc(48, "crypto/conf/conf_mod.c", 234);
v20 = (__int64)v27;
if ( !v27 )
goto LABEL_26;
*v27 = v25;
v28 = CRYPTO_strdup(v14, "crypto/conf/conf_mod.c", 239);
*(_QWORD *)(v20 + 16) = v26;
*(_QWORD *)(v20 + 8) = v28;
*(_QWORD *)(v20 + 24) = v38;
if ( !v28 )
{
CRYPTO_free(v20, "crypto/conf/conf_mod.c", 243);
goto LABEL_26;
}
if ( !(unsigned int)OPENSSL_sk_push(qword_125D588, v20) )
{
CRYPTO_free(*(_QWORD *)(v20 + 8), "crypto/conf/conf_mod.c", 248);
CRYPTO_free(v20, "crypto/conf/conf_mod.c", 249);
LABEL_26:
v29 = 0;
break;
}
LABEL_30:
v30 = (__int64 *)CRYPTO_malloc(40, "crypto/conf/conf_mod.c", 293);
v31 = v30;
if ( !v30 )
{
LABEL_42:
if ( !v10 )
{
ERR_put_error(14, 118, 109, "crypto/conf/conf_mod.c", 173);
BIO_snprintf(&v40, 0xDu, "%-8d", -1);
ERR_add_error_data(6, "module=", v14);
}
goto LABEL_13;
}
*v30 = v20;
v30[1] = CRYPTO_strdup(v14, "crypto/conf/conf_mod.c", 298);
v32 = CRYPTO_strdup(v15, "crypto/conf/conf_mod.c", 299);
v33 = v31[1];
v31[2] = v32;
v31[4] = 0;
v34 = v32 == 0 || v33 == 0;
if ( v34 )
{
LABEL_41:
CRYPTO_free(v33, "crypto/conf/conf_mod.c", 339);
CRYPTO_free(v31[2], "crypto/conf/conf_mod.c", 340);
CRYPTO_free(v31, "crypto/conf/conf_mod.c", 341);
goto LABEL_42;
}
v35 = *(int (__fastcall **)(__int64 *, __int64))(v20 + 16);
if ( v35 )
{
if ( v35(v31, a1) <= 0 )
{
v37 = *(void (__fastcall **)(__int64 *))(v20 + 24);
if ( !v37 )
{
LABEL_40:
v33 = v31[1];
goto LABEL_41;
}
LABEL_39:
v37(v31);
goto LABEL_40;
}
v34 = 1;
}
v36 = qword_125D590;
if ( qword_125D590 || (v36 = OPENSSL_sk_new_null(0), (qword_125D590 = v36) != 0) )
{
if ( (unsigned int)OPENSSL_sk_push(v36, v31) )
{
++v9;
++*(_DWORD *)(v20 + 32);
LABEL_15:
if ( v9 < (int)OPENSSL_sk_num(v8) )
continue;
return 1;
}
ERR_put_error(14, 115, 65, "crypto/conf/conf_mod.c", 323);
}
else
{
ERR_put_error(14, 115, 65, "crypto/conf/conf_mod.c", 317);
}
v37 = *(void (__fastcall **)(__int64 *))(v20 + 24);
if ( !v34 )
goto LABEL_40;
if ( !v37 )
{
v33 = v31[1];
goto LABEL_41;
}
goto LABEL_39;
}
v29 = 112;
}
else
{
v29 = 110;
}
break;
}
v39 = v29;
DSO_free(v25);
ERR_put_error(14, 117, v39, "crypto/conf/conf_mod.c", 220);
ERR_add_error_data(4, "module=", v14);
if ( !v10 )
goto LABEL_28;
LABEL_13:
if ( v12 )
{
LABEL_14:
++v9;
goto LABEL_15;
}
return 0xFFFFFFFFLL;
}
return 1;
}
return result;
}