//
// cocos2d::unzReadCurrentFile from 0x5f1c30 to 0x5f1e3e (526 bytes)
//
// 3 xrefs:
// > cocos2d::extension::AssetsManager::uncompress @ 0x5a012e
// > cocos2d::CCFileUtils::getFileDataFromZip @ 0x5de6ac
// > cocos2d::ZipFile::getFileData @ 0x5f0518
//
// 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
//
int __fastcall cocos2d::unzReadCurrentFile(cocos2d *this, void *a2, unsigned int a3, unsigned int a4)
{
int v4; // r4
unsigned __int64 v5; // r0
__int64 v6; // r0
unsigned int v7; // r5
int v8; // r5
unsigned __int64 v9; // r6
int v11; // r0
__int64 v12; // r6
__int64 v13; // r2
int v14; // r3
unsigned int v15; // r3
unsigned int v16; // r8
int v17; // r0
int v18; // r1
int v19; // r0
unsigned int v20; // r10
int v21; // r6
unsigned int v22; // r7
unsigned __int64 v23; // r8
int v24; // r0
int v25; // r0
int v26; // [sp+Ch] [bp-8h]
if ( !this )
return -102;
v4 = *((_DWORD *)this + 56);
if ( !v4 )
return -102;
if ( !*(_DWORD *)v4 )
return -100;
if ( !a3 )
return 0;
*(_DWORD *)(v4 + 16) = a2;
v5 = *(_QWORD *)(v4 + 128);
*(_DWORD *)(v4 + 20) = a3;
if ( v5 < a3 && !*(_DWORD *)(v4 + 200) )
*(_DWORD *)(v4 + 20) = v5;
v6 = *(_QWORD *)(v4 + 120);
v7 = *(_DWORD *)(v4 + 8);
if ( v6 + (unsigned __int64)v7 < a3 && *(_DWORD *)(v4 + 200) )
*(_DWORD *)(v4 + 20) = v6 + v7;
v8 = 0;
while ( *(_DWORD *)(v4 + 20) )
{
if ( !*(_DWORD *)(v4 + 8) )
{
v9 = *(_QWORD *)(v4 + 120);
if ( v9 )
{
if ( v9 > 0x3FFF )
LODWORD(v9) = 0x4000;
if ( cocos2d::call_zseek64(
v4 + 136,
*(_DWORD *)(v4 + 180),
*(_DWORD *)(v4 + 64) + *(_DWORD *)(v4 + 192),
(*(_QWORD *)(v4 + 64) + *(_QWORD *)(v4 + 192)) >> 32,
0) )
{
return -1;
}
v11 = (*(int (__fastcall **)(_DWORD, _DWORD, _DWORD, _DWORD))(v4 + 140))(
*(_DWORD *)(v4 + 164),
*(_DWORD *)(v4 + 180),
*(_DWORD *)v4,
v9);
if ( v11 != (_DWORD)v9 )
return -1;
v12 = *(_QWORD *)(v4 + 64);
v13 = *(_QWORD *)(v4 + 120);
*(_DWORD *)(v4 + 8) = v11;
*(_QWORD *)(v4 + 120) = v13 - (unsigned int)v11;
HIDWORD(v13) = *(_DWORD *)v4;
*(_QWORD *)(v4 + 64) = v12 + (unsigned int)v11;
*(_DWORD *)(v4 + 4) = HIDWORD(v13);
}
}
v14 = *(_DWORD *)(v4 + 184);
if ( v14 && !*(_DWORD *)(v4 + 200) )
{
if ( v14 != 12 )
{
v20 = *(_DWORD *)(v4 + 24);
v26 = *(_DWORD *)(v4 + 16);
v21 = inflate(v4 + 4, 2);
if ( v21 >= 0 && *(_DWORD *)(v4 + 28) )
v21 = -3;
v22 = *(_DWORD *)(v4 + 24);
v24 = *(_DWORD *)(v4 + 112);
v23 = v22 - (unsigned __int64)v20;
*(_QWORD *)(v4 + 104) += v23;
v25 = crc32(v24, v26, v23);
v8 += v22 - v20;
*(_QWORD *)(v4 + 128) -= v23;
*(_DWORD *)(v4 + 112) = v25;
if ( v21 == 1 )
return v8;
if ( v21 )
return v21;
}
}
else
{
v15 = *(_DWORD *)(v4 + 8);
if ( !v15 && !*(_QWORD *)(v4 + 120) )
return v8;
v16 = 0;
if ( v15 >= *(_DWORD *)(v4 + 20) )
v15 = *(_DWORD *)(v4 + 20);
while ( v16 != v15 )
{
*(_BYTE *)(*(_DWORD *)(v4 + 16) + v16) = *(_BYTE *)(*(_DWORD *)(v4 + 4) + v16);
++v16;
}
v17 = *(_DWORD *)(v4 + 112);
v8 += v16;
v18 = *(_DWORD *)(v4 + 16);
*(_QWORD *)(v4 + 104) += v16;
v19 = crc32(v17, v18, v16);
*(_QWORD *)(v4 + 128) -= v16;
*(_DWORD *)(v4 + 8) -= v16;
*(_DWORD *)(v4 + 20) -= v16;
*(_DWORD *)(v4 + 16) += v16;
*(_DWORD *)(v4 + 4) += v16;
*(_DWORD *)(v4 + 24) += v16;
*(_DWORD *)(v4 + 112) = v19;
}
}
return v8;
}