//
// ObjectManager::replaceAllOccurencesOfString from 0x14007cd70 to 0x14007d483 (1811 bytes)
//
// 3 xrefs:
// > ObjectManager::loadCopiedSets @ 0x14007cb9e
// > ObjectManager::replaceAllOccurencesOfString @ 0x14007d151
// > ??> @ 0x140911e28
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// 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 11:25:54 +0000
//
// Hidden C++ exception states: #wind=9
cocos2d::CCObject *__fastcall ObjectManager::replaceAllOccurencesOfString(
cocos2d::CCString *a1,
cocos2d::CCString *a2,
struct cocos2d::CCDictionary *a3)
{
cocos2d::CCString *v4; // rsi
cocos2d::CCString *v5; // r14
const char *CString; // rax
size_t v7; // r8
const char *v8; // rax
size_t v9; // r8
cocos2d::CCObject *v10; // r13
cocos2d::CCArray *v11; // r12
unsigned int i; // r15d
cocos2d::CCString *v13; // rax
char *v14; // rdi
char *v15; // rbx
char *v16; // rax
_QWORD *v17; // rax
size_t v18; // r8
size_t v19; // r8
void **v20; // rdx
void **v21; // rcx
unsigned __int64 v22; // rsi
size_t v23; // r8
size_t v24; // r14
int v25; // ebx
size_t v26; // r8
__int64 v27; // rbx
size_t v28; // r8
cocos2d::CCArray *v29; // r15
unsigned int v30; // r14d
__m128i si128; // xmm6
size_t v32; // rdi
cocos2d::CCString *v33; // rsi
const char *v34; // rax
size_t v35; // r8
cocos2d::CCString *v36; // rbx
void *v37; // rcx
__int64 v38; // rbx
const char *v39; // rax
size_t v40; // r8
const char *v41; // rax
unsigned __int64 v42; // rbx
size_t v43; // r8
__int128 *v44; // r9
void **v45; // rcx
unsigned __int64 v46; // rax
unsigned __int64 v47; // rbx
char *v48; // r9
void **v49; // rdx
size_t v50; // r8
__int64 v51; // rbx
void *v52; // rcx
const char *v53; // rax
size_t v54; // r8
void *v55; // rcx
void *v56; // rcx
void *Buf2[2]; // [rsp+40h] [rbp-C0h] BYREF
size_t Size[2]; // [rsp+50h] [rbp-B0h]
void *Buf1[2]; // [rsp+60h] [rbp-A0h] BYREF
unsigned __int64 v63; // [rsp+70h] [rbp-90h]
unsigned __int64 v64; // [rsp+78h] [rbp-88h]
__int128 v65; // [rsp+80h] [rbp-80h] BYREF
__int128 v66; // [rsp+90h] [rbp-70h]
__int128 v67; // [rsp+A0h] [rbp-60h] BYREF
size_t v68; // [rsp+B0h] [rbp-50h]
unsigned __int64 v69; // [rsp+B8h] [rbp-48h]
__int128 v70; // [rsp+C0h] [rbp-40h] BYREF
unsigned __int64 v71; // [rsp+D0h] [rbp-30h]
unsigned __int64 v72; // [rsp+D8h] [rbp-28h]
_QWORD v73[4]; // [rsp+E0h] [rbp-20h] BYREF
v4 = a2;
v5 = a1;
CString = cocos2d::CCString::getCString(a1);
v70 = 0;
v71 = 0;
v72 = 0;
v7 = -1;
do
++v7;
while ( CString[v7] );
sub_14003D230(&v70, CString, v7);
v8 = cocos2d::CCString::getCString(v4);
v67 = 0;
v68 = 0;
v69 = 0;
v9 = -1;
do
++v9;
while ( v8[v9] );
sub_14003D230(&v67, v8, v9);
v10 = cocos2d::CCDictionary::createWithDictionary(a3);
cocos2d::CCObject::retain(v10);
v11 = cocos2d::CCDictionary::allKeys(v10);
for ( i = 0; i < cocos2d::CCArray::count(v11); v5 = a1 )
{
v13 = cocos2d::CCArray::objectAtIndex(v11, i);
v14 = (char *)cocos2d::CCString::getCString(v13);
v15 = (char *)cocos2d::CCString::getCString(v4);
v16 = (char *)cocos2d::CCString::getCString(v5);
v17 = sub_14004DEC0(v73, v14, v16, v15);
if ( v17[3] > 0xFu )
v17 = (_QWORD *)*v17;
*(_OWORD *)Buf1 = 0;
v63 = 0;
v64 = 0;
v18 = -1;
do
++v18;
while ( *((_BYTE *)v17 + v18) );
sub_14003D230(Buf1, v17, v18);
sub_14003D310((__int64)v73);
*(_OWORD *)Buf2 = 0;
Size[0] = 0;
Size[1] = 0;
v19 = -1;
do
++v19;
while ( v14[v19] );
sub_14003D230(Buf2, v14, v19);
v20 = Buf2;
if ( Size[1] > 0xF )
v20 = (void **)Buf2[0];
v21 = Buf1;
if ( v64 > 0xF )
v21 = (void **)Buf1[0];
v22 = v63;
v23 = v63;
v24 = Size[0];
if ( Size[0] < v63 )
v23 = Size[0];
v25 = memcmp(v21, v20, v23);
if ( !v25 )
{
if ( v22 >= v24 )
v25 = v22 > v24;
else
v25 = -1;
}
sub_14003D310((__int64)Buf2);
if ( v25 )
{
v65 = 0;
v66 = 0;
v26 = -1;
do
++v26;
while ( v14[v26] );
sub_14003D230(&v65, v14, v26);
v27 = cocos2d::CCDictionary::objectForKey(v10, &v65);
sub_14003D310((__int64)&v65);
cocos2d::CCDictionary::setObject(v10, v27, Buf1);
v65 = 0;
v66 = 0;
v28 = -1;
do
++v28;
while ( v14[v28] );
sub_14003D230(&v65, v14, v28);
cocos2d::CCDictionary::removeObjectForKey(v10, &v65);
sub_14003D310((__int64)&v65);
}
sub_14003D310((__int64)Buf1);
++i;
v4 = a2;
}
v29 = cocos2d::CCDictionary::allKeys(v10);
v30 = 0;
if ( cocos2d::CCArray::count(v29) )
{
si128 = _mm_load_si128((const __m128i *)&::Size);
v32 = v68;
do
{
v33 = cocos2d::CCArray::objectAtIndex(v29, v30);
v34 = cocos2d::CCString::getCString(v33);
*(_OWORD *)Buf2 = 0;
*(_OWORD *)Size = 0;
v35 = -1;
do
++v35;
while ( v34[v35] );
sub_14003D230(Buf2, v34, v35);
v36 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(v10, Buf2);
if ( Size[1] > 0xF )
{
v37 = Buf2[0];
if ( Size[1] + 1 >= 0x1000 )
{
v37 = *((void **)Buf2[0] - 1);
if ( (unsigned __int64)((char *)Buf2[0] - (char *)v37 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v37);
}
*(__m128i *)Size = si128;
LOBYTE(Buf2[0]) = 0;
if ( _RTDynamicCast(
v36,
0,
&cocos2d::CCObject `RTTI Type Descriptor',
&cocos2d::CCDictionary `RTTI Type Descriptor',
0) )
{
v38 = ObjectManager::replaceAllOccurencesOfString(a1, a2, v36);
v39 = cocos2d::CCString::getCString(v33);
v65 = 0;
v66 = 0;
v40 = -1;
do
++v40;
while ( v39[v40] );
sub_14003D230(&v65, v39, v40);
cocos2d::CCDictionary::setObject(v10, v38, &v65);
sub_14003D310((__int64)&v65);
}
else if ( v36 )
{
v41 = cocos2d::CCString::getCString(v36);
*(_OWORD *)Buf1 = 0;
v42 = 0;
v63 = 0;
v64 = 0;
v43 = -1;
do
++v43;
while ( v41[v43] );
sub_14003D230(Buf1, v41, v43);
while ( 1 )
{
v44 = &v70;
if ( v72 > 0xF )
v44 = (__int128 *)v70;
v45 = Buf1;
if ( v64 > 0xF )
v45 = (void **)Buf1[0];
v46 = sub_14003EFB0((__int64)v45, v63, v42, (__int64)v44, v71);
v47 = v46;
if ( v46 == -1 )
break;
v48 = (char *)&v67;
if ( v69 > 0xF )
v48 = (char *)v67;
sub_140045CE0(Buf1, v46, v71, v48, v32);
v32 = v68;
v42 = v68 + v47;
}
v49 = Buf1;
if ( v64 > 0xF )
v49 = (void **)Buf1[0];
*(_OWORD *)Buf2 = 0;
*(_OWORD *)Size = 0;
v50 = -1;
do
++v50;
while ( *((_BYTE *)v49 + v50) );
sub_14003D230(Buf2, v49, v50);
v51 = cocos2d::CCString::create(Buf2);
if ( Size[1] > 0xF )
{
v52 = Buf2[0];
if ( Size[1] + 1 >= 0x1000 )
{
v52 = *((void **)Buf2[0] - 1);
if ( (unsigned __int64)((char *)Buf2[0] - (char *)v52 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v52);
}
*(__m128i *)Size = si128;
LOBYTE(Buf2[0]) = 0;
v53 = cocos2d::CCString::getCString(v33);
v65 = 0;
v66 = 0;
v54 = -1;
do
++v54;
while ( v53[v54] );
sub_14003D230(&v65, v53, v54);
cocos2d::CCDictionary::setObject(v10, v51, &v65);
if ( *((_QWORD *)&v66 + 1) > 0xFu )
{
v55 = (void *)v65;
if ( (unsigned __int64)(*((_QWORD *)&v66 + 1) + 1LL) >= 0x1000 )
{
v55 = *(void **)(v65 - 8);
if ( (unsigned __int64)(v65 - (_QWORD)v55 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v55);
}
if ( v64 > 0xF )
{
v56 = Buf1[0];
if ( v64 + 1 >= 0x1000 )
{
v56 = *((void **)Buf1[0] - 1);
if ( (unsigned __int64)((char *)Buf1[0] - (char *)v56 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v56);
}
}
++v30;
}
while ( v30 < cocos2d::CCArray::count(v29) );
}
sub_14003D310((__int64)&v67);
sub_14003D310((__int64)&v70);
return v10;
}