//
// cocos2d::CCTextureCache::addImage from 0x1800a73a0 to 0x1800a7f1c (2940 bytes)
//
// 24 xrefs:
// > cocos2d::CCAtlasNode::create @ 0x180001a16
// > cocos2d::CCAtlasNode::initWithTileFile @ 0x180001d8e
// > cocos2d::CCLabelAtlas::initWithString @ 0x18004657e
// > cocos2d::CCLabelBMFont::initWithString @ 0x180048a6d
// > cocos2d::CCLabelBMFont::setFntFile @ 0x18004c633
// > cocos2d::CCMotionStreak::create @ 0x18005cc52
// > cocos2d::CCMotionStreak::initWithFade @ 0x18005d0b6
// > cocos2d::CCParticleBatchNode::create @ 0x18006136d
// > cocos2d::CCParticleBatchNode::initWithFile @ 0x1800616c6
// > cocos2d::CCParticleSystem::initWithDictionary @ 0x1800686fc
// > cocos2d::CCAnimation::addSpriteFrameWithFileName @ 0x1800899ce
// > cocos2d::CCSprite::initWithFile @ 0x18008baee
// > cocos2d::CCSprite::initWithFile @ 0x18008bb86
// > cocos2d::CCSpriteBatchNode::create @ 0x18008e2ca
// > cocos2d::CCSpriteBatchNode::initWithFile @ 0x18008e626
// > cocos2d::CCSpriteFrame::getTexture @ 0x18008fbc6
// > cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile @ 0x180091306
// > cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile @ 0x180091783
// > cocos2d::CCTextureAtlas::create @ 0x1800a61c9
// > cocos2d::CCTextureAtlas::initWithFile @ 0x1800a6586
// > cocos2d::CCTextureCache::reloadTexture @ 0x1800a975c
// > cocos2d::CCTMXLayer::initWithTilesetInfo @ 0x1800ac1db
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b7e18
//
// 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=6
struct cocos2d::CCTexture2D *__fastcall cocos2d::CCTextureCache::addImage(
cocos2d::CCTextureCache *this,
char *a2,
unsigned __int8 a3)
{
struct cocos2d::CCTexture2D *v5; // rdi
struct cocos2d::CCImage *v6; // r14
struct cocos2d::CCFileUtils *v7; // rax
void **v8; // r8
__int64 v9; // rbx
void *v10; // rcx
void *v11; // rcx
void **v12; // rdx
char *v13; // rcx
void **v14; // rsi
void **v15; // rax
unsigned __int64 v16; // rcx
unsigned __int64 v17; // r15
unsigned __int64 v18; // r13
unsigned __int64 v19; // rbx
size_t v20; // rax
void *v21; // rax
void *v22; // rcx
char *v23; // rax
void **v24; // rbx
__int128 *v25; // r12
size_t v26; // rax
void *v27; // rax
unsigned int v28; // esi
__int64 v29; // rdx
__int128 *v30; // rbx
_BYTE *v31; // rbx
__int128 *v32; // rax
__int128 *v33; // rbx
char *v34; // r9
__int64 v35; // rcx
unsigned __int8 v36; // al
int v37; // eax
__int128 *v38; // rbx
char *v39; // r9
__int64 v40; // rcx
unsigned __int8 v41; // al
int v42; // eax
const char *v43; // rdx
enum cocos2d::CCImage::EImageFormat v44; // ebx
__int128 *v45; // rsi
char *v46; // r9
__int64 v47; // rcx
unsigned __int8 v48; // al
int v49; // eax
char *v50; // rdx
__int128 *v51; // rsi
char *v52; // r9
__int64 v53; // rcx
unsigned __int8 v54; // al
int v55; // eax
__int128 *v56; // rsi
char *v57; // r9
__int64 v58; // rcx
unsigned __int8 v59; // al
int v60; // eax
__int128 *v61; // rsi
char *v62; // r9
__int64 v63; // rcx
unsigned __int8 v64; // al
int v65; // eax
__int128 *v66; // rsi
char *v67; // r9
__int64 v68; // rcx
unsigned __int8 v69; // al
int v70; // eax
__int128 *v71; // rsi
char *v72; // r9
__int64 v73; // rcx
unsigned __int8 v74; // al
int v75; // eax
cocos2d::CCImage *v76; // rax
const char *v77; // rdx
cocos2d::CCTexture2D *v78; // rax
cocos2d::CCTexture2D *v79; // rbx
void **v80; // rdx
void *v81; // rcx
char *v82; // rax
char *v83; // rcx
void *v84; // rcx
struct cocos2d::CCTexture2D *v86; // [rsp+20h] [rbp-79h]
void *Src[2]; // [rsp+38h] [rbp-61h] BYREF
__int128 v89; // [rsp+48h] [rbp-51h]
char *v90[2]; // [rsp+58h] [rbp-41h] BYREF
unsigned __int64 v91; // [rsp+68h] [rbp-31h]
unsigned __int64 v92; // [rsp+70h] [rbp-29h]
__int128 v93; // [rsp+78h] [rbp-21h] BYREF
unsigned __int64 v94; // [rsp+88h] [rbp-11h]
__int64 v95; // [rsp+90h] [rbp-9h]
void *Block[3]; // [rsp+98h] [rbp-1h] BYREF
unsigned __int64 v97; // [rsp+B0h] [rbp+17h]
v5 = nullptr;
v6 = nullptr;
sub_180005910(Src, a2);
v7 = cocos2d::CCFileUtils::sharedFileUtils();
v8 = Src;
if ( *((_QWORD *)&v89 + 1) > 0xFu )
v8 = (void **)Src[0];
v9 = ((__int64 (__fastcall *)(struct cocos2d::CCFileUtils *, void **, void **, _QWORD))v7->createCCArrayWithContentsOfFile)(
v7,
Block,
v8,
a3);
if ( Src != (void **)v9 )
{
if ( *((_QWORD *)&v89 + 1) > 0xFu )
{
v10 = Src[0];
if ( (unsigned __int64)(*((_QWORD *)&v89 + 1) + 1LL) >= 0x1000 )
{
v10 = *((void **)Src[0] - 1);
if ( (unsigned __int64)((char *)Src[0] - (char *)v10 - 8) > 0x1F )
LABEL_12:
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v10);
}
*(_QWORD *)&v89 = 0;
*((_QWORD *)&v89 + 1) = 15;
LOBYTE(Src[0]) = 0;
*(_OWORD *)Src = *(_OWORD *)v9;
v89 = *(_OWORD *)(v9 + 16);
*(_QWORD *)(v9 + 16) = 0;
*(_QWORD *)(v9 + 24) = 15;
*(_BYTE *)v9 = 0;
}
if ( v97 > 0xF )
{
v11 = Block[0];
if ( v97 + 1 >= 0x1000 )
{
v11 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v11 - 8) > 0x1F )
goto LABEL_12;
}
j_j_free_0(v11);
}
if ( (_QWORD)v89 )
{
v12 = Src;
if ( *((_QWORD *)&v89 + 1) > 0xFu )
v12 = (void **)Src[0];
sub_180005910(v90, v12);
v86 = (struct cocos2d::CCTexture2D *)cocos2d::CCDictionary::objectForKey(
(__int64)this->m_pTextures,
(unsigned __int8 *)v90);
if ( v92 > 0xF )
{
v13 = v90[0];
if ( v92 + 1 >= 0x1000 )
{
v13 = *((char **)v90[0] - 1);
if ( (unsigned __int64)(v90[0] - v13 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v13);
}
if ( v86 )
{
LABEL_207:
v5 = v86;
goto LABEL_208;
}
*(_OWORD *)v90 = 0;
v91 = 0;
v92 = 0;
v14 = Src;
v15 = (void **)Src[0];
v16 = *((_QWORD *)&v89 + 1);
if ( *((_QWORD *)&v89 + 1) > 0xFu )
v14 = (void **)Src[0];
v17 = v89;
v18 = 0x7FFFFFFFFFFFFFFFLL;
if ( (unsigned __int64)v89 > 0x7FFFFFFFFFFFFFFFLL )
std::vector::_Xlen();
v92 = 15;
if ( (unsigned __int64)v89 <= 0xF )
{
v91 = v89;
*(_OWORD *)v90 = *(_OWORD *)v14;
goto LABEL_41;
}
v19 = v89 | 0xF;
if ( ((unsigned __int64)v89 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
if ( v19 < 0x16 )
v19 = 22;
if ( v19 + 1 < 0x1000 )
{
if ( v19 == -1 )
v23 = nullptr;
else
v23 = (char *)operator new(v19 + 1);
LABEL_40:
v90[0] = v23;
v91 = v17;
v92 = v19;
memcpy(v23, v14, v17 + 1);
v16 = *((_QWORD *)&v89 + 1);
v17 = v89;
v15 = (void **)Src[0];
LABEL_41:
v93 = 0;
v94 = 0;
v95 = 0;
v24 = Src;
if ( v16 > 0xF )
v24 = v15;
if ( v17 > 0x7FFFFFFFFFFFFFFFLL )
std::vector::_Xlen();
if ( v17 <= 0xF )
{
v94 = v17;
v18 = 15;
v95 = 15;
v93 = *(_OWORD *)v24;
v25 = (__int128 *)v93;
LABEL_59:
v28 = 0;
if ( v17 )
{
v29 = 0;
do
{
v30 = &v93;
if ( v18 > 0xF )
v30 = v25;
v31 = (char *)v30 + v29;
v32 = &v93;
if ( v18 > 0xF )
v32 = v25;
*v31 = tolower(*((char *)v32 + v29));
v29 = ++v28;
v17 = v94;
v18 = v95;
v25 = (__int128 *)v93;
}
while ( v28 < v94 );
}
v33 = &v93;
if ( v18 > 0xF )
v33 = v25;
if ( v17 >= 4 )
{
v34 = (char *)memchr(v33, 46, v17 - 3);
if ( v34 )
{
while ( 1 )
{
v35 = 0;
while ( 1 )
{
v36 = v34[v35++];
if ( v36 != aPvr[v35 - 1] )
break;
if ( v35 == 4 )
{
v37 = 0;
goto LABEL_75;
}
}
v37 = v36 < (unsigned __int8)aPvr[v35 - 1] ? -1 : 1;
LABEL_75:
if ( !v37 )
break;
v34 = (char *)memchr(v34 + 1, 46, (char *)v33 + v17 - 3 - (v34 + 1));
if ( !v34 )
goto LABEL_77;
}
if ( v34 - (char *)v33 != -1 )
{
v43 = (const char *)v90;
if ( v92 > 0xF )
v43 = v90[0];
v86 = cocos2d::CCTextureCache::addPVRImage(this, v43);
goto LABEL_195;
}
}
}
LABEL_77:
v38 = &v93;
if ( v18 > 0xF )
v38 = v25;
if ( v17 >= 4 )
{
v39 = (char *)memchr(v38, 46, v17 - 3);
if ( v39 )
{
while ( 1 )
{
v40 = 0;
while ( 1 )
{
v41 = v39[v40++];
if ( v41 != aPkm[v40 - 1] )
break;
if ( v40 == 4 )
{
v42 = 0;
goto LABEL_90;
}
}
v42 = v41 < (unsigned __int8)aPkm[v40 - 1] ? -1 : 1;
LABEL_90:
if ( !v42 )
break;
v39 = (char *)memchr(v39 + 1, 46, (char *)v38 + v17 - 3 - (v39 + 1));
if ( !v39 )
goto LABEL_92;
}
if ( v39 - (char *)v38 != -1 )
{
v50 = (char *)v90;
if ( v92 > 0xF )
v50 = v90[0];
v86 = cocos2d::CCTextureCache::addETCImage(this, v50);
goto LABEL_195;
}
}
}
LABEL_92:
v44 = kFmtUnKnown;
v45 = &v93;
if ( v18 > 0xF )
v45 = v25;
if ( v17 >= 4 )
{
v46 = (char *)memchr(v45, 46, v17 - 3);
if ( v46 )
{
while ( 1 )
{
v47 = 0;
while ( 1 )
{
v48 = v46[v47++];
if ( v48 != aPng[v47 - 1] )
break;
if ( v47 == 4 )
{
v49 = 0;
goto LABEL_105;
}
}
v49 = v48 < (unsigned __int8)aPng[v47 - 1] ? -1 : 1;
LABEL_105:
if ( !v49 )
break;
v46 = (char *)memchr(v46 + 1, 46, (char *)v45 + v17 - 3 - (v46 + 1));
if ( !v46 )
goto LABEL_107;
}
if ( v46 - (char *)v45 != -1 )
{
v44 = kFmtPng;
goto LABEL_175;
}
}
}
LABEL_107:
v51 = &v93;
if ( v18 > 0xF )
v51 = v25;
if ( v17 < 4 )
goto LABEL_122;
v52 = (char *)memchr(v51, 46, v17 - 3);
if ( !v52 )
goto LABEL_122;
while ( 1 )
{
v53 = 0;
while ( 1 )
{
v54 = v52[v53++];
if ( v54 != aJpg[v53 - 1] )
break;
if ( v53 == 4 )
{
v55 = 0;
goto LABEL_118;
}
}
v55 = v54 < (unsigned __int8)aJpg[v53 - 1] ? -1 : 1;
LABEL_118:
if ( !v55 )
break;
v52 = (char *)memchr(v52 + 1, 46, (char *)v51 + v17 - 3 - (v52 + 1));
if ( !v52 )
goto LABEL_122;
}
if ( v52 - (char *)v51 == -1 )
{
LABEL_122:
v56 = &v93;
if ( v18 > 0xF )
v56 = v25;
if ( v17 < 5 )
goto LABEL_133;
v57 = (char *)memchr(v56, 46, v17 - 4);
if ( !v57 )
goto LABEL_133;
while ( 1 )
{
v58 = 0;
while ( 1 )
{
v59 = v57[v58++];
if ( v59 != aJpeg[v58 - 1] )
break;
if ( v58 == 5 )
{
v60 = 0;
goto LABEL_131;
}
}
v60 = v59 < (unsigned __int8)aJpeg[v58 - 1] ? -1 : 1;
LABEL_131:
if ( !v60 )
break;
v57 = (char *)memchr(v57 + 1, 46, (char *)v56 + v17 - 4 - (v57 + 1));
if ( !v57 )
goto LABEL_133;
}
if ( v57 - (char *)v56 == -1 )
{
LABEL_133:
v61 = &v93;
if ( v18 > 0xF )
v61 = v25;
if ( v17 < 4 )
goto LABEL_148;
v62 = (char *)memchr(v61, 46, v17 - 3);
if ( !v62 )
goto LABEL_148;
while ( 1 )
{
v63 = 0;
while ( 1 )
{
v64 = v62[v63++];
if ( v64 != aTif[v63 - 1] )
break;
if ( v63 == 4 )
{
v65 = 0;
goto LABEL_144;
}
}
v65 = v64 < (unsigned __int8)aTif[v63 - 1] ? -1 : 1;
LABEL_144:
if ( !v65 )
break;
v62 = (char *)memchr(v62 + 1, 46, (char *)v61 + v17 - 3 - (v62 + 1));
if ( !v62 )
goto LABEL_148;
}
if ( v62 - (char *)v61 == -1 )
{
LABEL_148:
v66 = &v93;
if ( v18 > 0xF )
v66 = v25;
if ( v17 < 5 )
goto LABEL_159;
v67 = (char *)memchr(v66, 46, v17 - 4);
if ( !v67 )
goto LABEL_159;
while ( 1 )
{
v68 = 0;
while ( 1 )
{
v69 = v67[v68++];
if ( v69 != aTiff[v68 - 1] )
break;
if ( v68 == 5 )
{
v70 = 0;
goto LABEL_157;
}
}
v70 = v69 < (unsigned __int8)aTiff[v68 - 1] ? -1 : 1;
LABEL_157:
if ( !v70 )
break;
v67 = (char *)memchr(v67 + 1, 46, (char *)v66 + v17 - 4 - (v67 + 1));
if ( !v67 )
goto LABEL_159;
}
if ( v67 - (char *)v66 == -1 )
{
LABEL_159:
v71 = &v93;
if ( v18 > 0xF )
v71 = v25;
if ( v17 >= 5 )
{
v72 = (char *)memchr(v71, 46, v17 - 4);
if ( v72 )
{
while ( 1 )
{
v73 = 0;
while ( 1 )
{
v74 = v72[v73++];
if ( v74 != aWebp[v73 - 1] )
break;
if ( v73 == 5 )
{
v75 = 0;
goto LABEL_170;
}
}
v75 = v74 < (unsigned __int8)aWebp[v73 - 1] ? -1 : 1;
LABEL_170:
if ( !v75 )
break;
v72 = (char *)memchr(v72 + 1, 46, (char *)v71 + v17 - 4 - (v72 + 1));
if ( !v72 )
goto LABEL_175;
}
if ( v72 - (char *)v71 != -1 )
v44 = kFmtWebp;
}
}
goto LABEL_175;
}
}
v44 = kFmtTiff;
LABEL_175:
v76 = (cocos2d::CCImage *)operator new(0x50u);
if ( v76 )
v6 = cocos2d::CCImage::CCImage(v76);
else
v6 = nullptr;
if ( v6 )
{
v77 = (const char *)v90;
if ( v92 > 0xF )
v77 = v90[0];
if ( (unsigned __int8)cocos2d::CCImage::initWithImageFile(v6, v77, v44) )
{
v78 = (cocos2d::CCTexture2D *)operator new(0x68u);
v79 = v78 ? cocos2d::CCTexture2D::CCTexture2D(v78) : nullptr;
v86 = v79;
if ( v79 )
{
if ( cocos2d::CCTexture2D::initWithImage(v79, v6) )
{
v80 = Src;
if ( *((_QWORD *)&v89 + 1) > 0xFu )
v80 = (void **)Src[0];
sub_180005910(Block, v80);
cocos2d::CCDictionary::setObject((__int64)this->m_pTextures, v79, (unsigned __int8 *)Block);
if ( v97 > 0xF )
{
v81 = Block[0];
if ( v97 + 1 >= 0x1000 )
{
v81 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v81 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v81);
}
cocos2d::CCObject::release(v79);
}
}
}
}
LABEL_195:
if ( v18 > 0xF )
{
v82 = (char *)v25;
if ( v18 + 1 >= 0x1000 )
{
v25 = *((__int128 **)v25 - 1);
if ( (unsigned __int64)(v82 - (char *)v25 - 8) > 0x1F )
LABEL_198:
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v25);
}
if ( v92 > 0xF )
{
v83 = v90[0];
if ( v92 + 1 >= 0x1000 )
{
v83 = *((char **)v90[0] - 1);
if ( (unsigned __int64)(v90[0] - v83 - 8) > 0x1F )
LABEL_203:
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v83);
}
v91 = 0;
v92 = 15;
LOBYTE(v90[0]) = 0;
if ( v6 )
cocos2d::CCObject::release(v6);
goto LABEL_207;
}
}
v44 = kFmtJpg;
goto LABEL_175;
}
v95 = 15;
if ( (v17 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
v18 = v17 | 0xF;
if ( (v17 | 0xF) < 0x16 )
v18 = 22;
if ( v18 + 1 < 0x1000 )
{
if ( v18 == -1 )
v25 = nullptr;
else
v25 = (__int128 *)operator new(v18 + 1);
LABEL_58:
*(_QWORD *)&v93 = v25;
v94 = v17;
v95 = v18;
memcpy(v25, v24, v17 + 1);
goto LABEL_59;
}
v26 = v18 + 40;
if ( v18 + 40 < v18 + 1 )
Concurrency::cancel_current_task();
}
else
{
v26 = 0x8000000000000027uLL;
}
v27 = operator new(v26);
if ( !v27 )
goto LABEL_198;
v25 = (__int128 *)(((unsigned __int64)v27 + 39) & 0xFFFFFFFFFFFFFFE0uLL);
*((_QWORD *)v25 - 1) = v27;
goto LABEL_58;
}
v20 = v19 + 40;
if ( v19 + 40 < v19 + 1 )
Concurrency::cancel_current_task();
}
else
{
v19 = 0x7FFFFFFFFFFFFFFFLL;
v20 = 0x8000000000000027uLL;
}
v21 = operator new(v20);
v22 = v21;
if ( !v21 )
goto LABEL_203;
v23 = (char *)(((unsigned __int64)v21 + 39) & 0xFFFFFFFFFFFFFFE0uLL);
*((_QWORD *)v23 - 1) = v22;
goto LABEL_40;
}
LABEL_208:
if ( *((_QWORD *)&v89 + 1) > 0xFu )
{
v84 = Src[0];
if ( (unsigned __int64)(*((_QWORD *)&v89 + 1) + 1LL) >= 0x1000 )
{
v84 = *((void **)Src[0] - 1);
if ( (unsigned __int64)((char *)Src[0] - (char *)v84 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v84);
}
return v5;
}