//
// RAND_write_file from 0xdcf9b4 to 0xdcfac4 (272 bytes)
//
// 1 xrefs:
// > ??> @ 0x85e78
//
// 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 RAND_write_file(const char *a1)
{
__int64 result; // x0
int v3; // w0
FILE *v4; // x20
int v5; // w21
int v6; // w22
_BYTE v7[16]; // [xsp+30h] [xbp+30h] BYREF
__int16 v8; // [xsp+40h] [xbp+40h]
_BYTE v9[1024]; // [xsp+B0h] [xbp+B0h] BYREF
if ( stat(a1, (struct stat *)v7) == -1 || (result = 1, (v8 & 0xB000) != 0x2000) )
{
if ( (v3 = open(a1, 65, 384), v3 != -1) && (v4 = fdopen(v3, "wb")) != nullptr
|| (v4 = openssl_fopen(a1, "wb"), result = 0, v4) )
{
chmod(a1, 0x180u);
v5 = RAND_bytes((__int64)v9, 1024);
v6 = fwrite(v9, 1u, 0x400u, v4);
fclose(v4);
OPENSSL_cleanse(v9, 0x400u);
result = 0xFFFFFFFFLL;
if ( v5 > 0 )
{
if ( v6 < 0 )
return 0;
else
return (unsigned int)v6;
}
}
}
return result;
}