//
// cocos2d::CCFileUtilsWin32::getWritablePath2 from 0x18007a520 to 0x18007a6e3 (451 bytes)
//
// 4 xrefs:
// > ??> @ 0x1801010f0
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b4ca4
// > ??> @ 0x1801b4cb0
//
// 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
//
// Hidden C++ exception states: #wind=1
void **__fastcall cocos2d::CCFileUtilsWin32::getWritablePath2(__int64 a1, void **a2)
{
size_t v3; // r8
_BYTE *v4; // rdx
unsigned __int64 v5; // r10
unsigned __int64 v6; // r9
_BYTE *i; // rcx
__int64 v8; // rcx
size_t v9; // r8
const void *v10; // rdx
unsigned __int64 v11; // rdx
_QWORD *v12; // rcx
unsigned __int64 v13; // rax
void *v14; // rcx
void *Block[2]; // [rsp+30h] [rbp-148h] BYREF
__int128 v17; // [rsp+40h] [rbp-138h]
CHAR Filename[272]; // [rsp+50h] [rbp-128h] BYREF
GetModuleFileNameA(nullptr, Filename, 0x105u);
*(_OWORD *)a2 = 0;
a2[2] = nullptr;
a2[3] = nullptr;
v3 = -1;
do
++v3;
while ( Filename[v3] );
sub_18000CE60(a2, Filename, v3);
v4 = a2;
v5 = (unsigned __int64)a2[3];
if ( v5 > 0xF )
v4 = *a2;
v6 = (unsigned __int64)a2[2];
if ( v6 )
{
for ( i = &v4[v6 - 1]; *i != 92; --i )
{
if ( i == v4 )
goto LABEL_11;
}
v8 = i - v4;
}
else
{
LABEL_11:
v8 = -1;
}
*(_OWORD *)Block = 0;
v17 = 0;
v9 = v8 + 1;
if ( v6 < v8 + 1 )
v9 = v6;
v10 = a2;
if ( v5 > 0xF )
v10 = *a2;
sub_18000CE60(Block, v10, v9);
if ( a2 == Block )
{
v13 = *((_QWORD *)&v17 + 1);
}
else
{
v11 = (unsigned __int64)a2[3];
if ( v11 > 0xF )
{
v12 = *a2;
if ( v11 + 1 >= 0x1000 )
{
if ( (unsigned __int64)v12 - *(v12 - 1) - 8 > 0x1F )
goto LABEL_27;
v12 = (_QWORD *)*(v12 - 1);
}
j_j_free_0(v12);
}
v13 = 15;
*(_BYTE *)a2 = 0;
*(_OWORD *)a2 = *(_OWORD *)Block;
*((_OWORD *)a2 + 1) = v17;
LOBYTE(Block[0]) = 0;
}
if ( v13 > 0xF )
{
v14 = Block[0];
if ( v13 + 1 >= 0x1000 )
{
v14 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v14 - 8) > 0x1F )
LABEL_27:
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v14);
}
return a2;
}