//
// ENGINE_ctrl from 0xa0af74 to 0xa0b390 (1052 bytes)
//
// 10 xrefs:
// > sub_8539B8 @ 0x854176
// > ENGINE_cmd_is_executable @ 0xa0b3e0
// > ENGINE_ctrl_cmd @ 0xa0b46c
// > ENGINE_ctrl_cmd @ 0xa0b48c
// > ENGINE_ctrl_cmd_string @ 0xa0b564
// > ENGINE_ctrl_cmd_string @ 0xa0b598
// > ENGINE_ctrl_cmd_string @ 0xa0b720
// > ENGINE_ctrl_cmd_string @ 0xa0b748
// > ENGINE_ctrl_cmd_string @ 0xa0b790
// > ??> @ 0x681ec
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:07:43 +0000
//
int __fastcall ENGINE_ctrl(_DWORD *a1, int a2, unsigned int a3, const char *a4, int a5)
{
int v9; // r10
int v10; // r4
_BOOL4 v11; // r4
int result; // r0
bool v13; // zf
unsigned int *v14; // lr
unsigned int v15; // r2
unsigned int v16; // r3
bool v17; // cc
int v18; // r3
int v19; // r1
int v20; // r12
bool v21; // cc
unsigned int *v22; // r1
char *v23; // r4
size_t v24; // r0
char *v25; // r3
unsigned int v26; // r1
const char *v27; // r0
unsigned int *v28; // r1
const char *v29; // r0
const char *v30; // r4
int v31; // r1
unsigned int v32; // r3
unsigned int *v33; // r1
_DWORD *v34; // r3
_DWORD *v35; // r6
int v36; // r4
int v37; // r5
int v38; // r3
if ( !a1 )
{
ERR_put_error(38, 142, 67, "crypto/engine/eng_ctrl.c", 137);
return 0;
}
CRYPTO_THREAD_write_lock(global_engine_lock);
v9 = a1[20];
CRYPTO_THREAD_unlock(global_engine_lock);
v10 = a1[14];
v11 = v10 != 0;
if ( v9 <= 0 )
{
ERR_put_error(38, 142, 130, "crypto/engine/eng_ctrl.c", 145);
return 0;
}
if ( a2 == 10 )
return v11;
if ( a2 < 10 || a2 > 18 )
{
if ( v11 )
return ((int (__fastcall *)(_DWORD *, int, unsigned int, const char *, int))a1[14])(a1, a2, a3, a4, a5);
ERR_put_error(38, 142, 120, "crypto/engine/eng_ctrl.c", 179);
return v11;
}
if ( v11 )
{
result = a1[19] & 2;
if ( result )
return ((int (__fastcall *)(_DWORD *, int, unsigned int, const char *, int))a1[14])(a1, a2, a3, a4, a5);
if ( a2 == 11 )
{
v34 = (_DWORD *)a1[18];
if ( v34 && *v34 )
{
if ( v34[1] )
return *v34;
else
return 0;
}
}
else
{
v13 = a2 == 17;
if ( a2 != 17 )
v13 = (a2 & 0xFFFFFFFD) == 13;
if ( !v13 || a4 )
{
if ( a2 == 13 )
{
v35 = (_DWORD *)a1[18];
if ( v35 && *v35 && v35[1] )
{
v36 = a1[18];
v37 = 0;
while ( strcmp(*(const char **)(v36 + 4), a4) )
{
v38 = *(_DWORD *)(v36 + 16);
++v37;
v36 += 16;
if ( !v38 || !*(_DWORD *)(v36 + 4) )
goto LABEL_65;
}
return v35[4 * v37];
}
else
{
LABEL_65:
ERR_put_error(38, 172, 137, "crypto/engine/eng_ctrl.c", 85);
return -1;
}
}
else
{
v14 = (unsigned int *)a1[18];
if ( !v14 )
goto LABEL_34;
v15 = *v14;
if ( *v14 )
{
v16 = v14[1];
v17 = v16 != 0;
if ( v16 )
v17 = a3 > v15;
if ( v17 )
{
v18 = a1[18];
v19 = 0;
do
{
v15 = *(_DWORD *)(v18 + 16);
++v19;
if ( !v15 )
break;
v20 = *(_DWORD *)(v18 + 20);
v18 += 16;
v21 = v20 != 0;
if ( v20 )
v21 = a3 > v15;
}
while ( v21 );
}
else
{
v19 = 0;
}
}
else
{
v19 = 0;
}
if ( v15 == a3 )
{
switch ( a2 )
{
case 12:
v31 = v19 + 1;
v32 = v14[4 * v31];
v33 = &v14[4 * v31];
if ( v32 )
{
if ( v33[1] )
return v32;
else
return 0;
}
return result;
case 14:
v29 = (const char *)v14[4 * v19 + 1];
return strlen(v29);
case 15:
v30 = (const char *)v14[4 * v19 + 1];
v24 = strlen(v30);
v25 = (char *)v30;
goto LABEL_39;
case 16:
v28 = &v14[4 * v19];
if ( v28[2] )
{
v29 = (const char *)v28[2];
return strlen(v29);
}
return result;
case 17:
v22 = &v14[4 * v19];
v23 = (char *)v22[2];
if ( v23 )
{
v24 = strlen((const char *)v22[2]);
v25 = v23;
LABEL_39:
v26 = v24 + 1;
v27 = a4;
}
else
{
v27 = a4;
v26 = 1;
v25 = &byte_BF4ECA;
}
result = BIO_snprintf(v27, v26, "%s", v25);
break;
case 18:
return v14[4 * v19 + 3];
}
}
else
{
LABEL_34:
ERR_put_error(38, 172, 138, "crypto/engine/eng_ctrl.c", 97);
return -1;
}
}
}
else
{
ERR_put_error(38, 172, 67, "crypto/engine/eng_ctrl.c", 77);
return -1;
}
}
}
else
{
ERR_put_error(38, 142, 120, "crypto/engine/eng_ctrl.c", 166);
return -1;
}
return result;
}