//
// cocos2d::CCFileUtilsWin32::utf8Togbk from 0x18007b0e0 to 0x18007b28b (427 bytes)
//
// 11 xrefs:
// > cocos2d::CCFileUtilsWin32::addSearchPath @ 0x18007a240
// > cocos2d::CCFileUtilsWin32::fullPathForFilename @ 0x18007a2e9
// > cocos2d::CCFileUtilsWin32::getPathForFilename @ 0x18007a3b6
// > cocos2d::CCFileUtilsWin32::getPathForFilename @ 0x18007a3d1
// > cocos2d::CCFileUtilsWin32::getPathForFilename @ 0x18007a3ec
// > cocos2d::CCFileUtilsWin32::isAbsolutePath @ 0x18007ac0a
// > cocos2d::CCFileUtilsWin32::isFileExist @ 0x18007ad1a
// > cocos2d::CCFileUtilsWin32::removeSearchPath @ 0x18007afe0
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b4cf8
// > ??> @ 0x1801b4d04
//
// 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
_QWORD *__fastcall cocos2d::CCFileUtilsWin32::utf8Togbk(__int64 a1, _QWORD *a2, CHAR *a3)
{
size_t v5; // rbx
int cchWideChar; // edi
void *lpWideCharStr; // r12
int v8; // esi
void *v9; // rbp
size_t v10; // r8
const void *v11; // rdi
size_t v12; // r8
_BYTE *v13; // rax
v5 = -1;
cchWideChar = MultiByteToWideChar(0xFDE9u, 0, a3, -1, nullptr, 0);
lpWideCharStr = operator new(saturated_mul(cchWideChar + 1, 2u));
memset(lpWideCharStr, 0, 2 * cchWideChar + 2);
MultiByteToWideChar(0xFDE9u, 0, a3, -1, (LPWSTR)lpWideCharStr, cchWideChar);
v8 = WideCharToMultiByte(0, 0, (LPCWCH)lpWideCharStr, -1, nullptr, 0, nullptr, nullptr);
v9 = operator new(v8 + 1);
memset(v9, 0, v8 + 1);
WideCharToMultiByte(0, 0, (LPCWCH)lpWideCharStr, -1, (LPSTR)v9, v8, nullptr, nullptr);
*(_OWORD *)a2 = 0;
a2[2] = 0;
a2[3] = 0;
v10 = -1;
do
++v10;
while ( *((_BYTE *)v9 + v10) );
sub_18000CE60(a2, v9, v10);
v11 = a2;
if ( a2[3] > 0xFu )
v11 = (const void *)*a2;
v12 = a2[2];
if ( v12 )
{
v13 = memchr(v11, 63, v12);
if ( v13 )
{
if ( v13 - (_BYTE *)v11 != -1 )
{
do
++v5;
while ( a3[v5] );
sub_180010050((void **)a2, a3, v5);
}
}
}
j_j_free_0(v9);
j_j_free_0(lpWideCharStr);
return a2;
}