//
// EditorSFXManager::importFromString from 0x1008ecdd0 to 0x1008ecfe0 (528 bytes)
//
// 2 xrefs:
// > sub_1008ED2F0 @ 0x1008ed428
// > sub_1008EDE10 @ 0x1008edf97
//
// 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 12:37:54 +0000
//
__int64 __fastcall EditorSFXManager::importFromString(_QWORD *a1, unsigned __int8 *a2, _DWORD *a3, std::string *a4)
{
unsigned int v6; // eax
std::string::size_type v7; // rax
size_t v8; // r12
unsigned __int128 v9; // kr00_16
unsigned int v10; // r14d
char *v11; // r15
size_t v12; // r13
__int128 __dst; // [rsp+10h] [rbp-60h] BYREF
char *data; // [rsp+20h] [rbp-50h]
std::string v16; // [rsp+30h] [rbp-40h] BYREF
v6 = *a2;
if ( (v6 & 1) != 0 )
{
if ( *((_QWORD *)a2 + 1) )
goto LABEL_3;
}
else if ( v6 >> 1 )
{
LABEL_3:
cocos2d::ZipUtils::decompressString(&v16, (char *)a2, 0, 0);
if ( (*(_BYTE *)&v16.__r_.__value_.__s.0 & 1) != 0 )
{
if ( v16.__r_.__value_.__l.__size_ )
goto LABEL_5;
}
else if ( *(_BYTE *)&v16.__r_.__value_.__l.0 >> 1 )
{
LABEL_5:
v7 = std::string::find(&v16, 59, 0);
if ( v7 == -1 )
{
if ( (*(_BYTE *)&v16.__r_.__value_.__s.0 & 1) != 0 )
{
sub_10001AD30(&__dst, v16.__r_.__value_.__l.__data_, v16.__r_.__value_.__l.__size_);
}
else
{
data = v16.__r_.__value_.__l.__data_;
__dst = *(_OWORD *)&v16.__r_.__value_.__l.0;
}
LABEL_31:
if ( (__dst & 1) != 0 )
{
if ( (unsigned int)(atoi(data) - 3) > 0xFFFFFFFD )
{
LABEL_33:
v10 = EditorSFXManager::deserializeAll(a1, &v16, *a3 == 0);
if ( (unsigned __int8)v10 | (a4 == nullptr) )
goto LABEL_39;
std::string::assign(a4, "Parse error.");
LABEL_38:
v10 = 0;
LABEL_39:
if ( (__dst & 1) != 0 )
operator delete(data);
LABEL_41:
if ( (*(_BYTE *)&v16.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v16.__r_.__value_.__l.__data_);
return v10;
}
}
else if ( (unsigned int)(atoi((const char *)&__dst + 1) - 3) > 0xFFFFFFFD )
{
goto LABEL_33;
}
if ( a4 )
std::string::assign(a4, "Invalid or corrupt share string.");
goto LABEL_38;
}
v8 = v7;
if ( (*(_BYTE *)&v16.__r_.__value_.__s.0 & 1) != 0 )
v9 = *(_OWORD *)&v16.__r_.__value_.__r.__words[1];
else
v9 = __PAIR128__((std::string *)((char *)&v16.__r_.__value_.__l.0 + 1), *(_BYTE *)&v16.__r_.__value_.__l.0 >> 1);
if ( (unsigned __int64)v9 < v7 )
v8 = v9;
if ( v8 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
if ( v8 >= 0x17 )
{
v12 = 26;
if ( (v8 | 7) != 0x17 )
v12 = (v8 | 7) + 1;
v11 = (char *)operator new(v12);
data = v11;
*(_QWORD *)&__dst = v12 | 1;
*((_QWORD *)&__dst + 1) = v8;
}
else
{
LOBYTE(__dst) = 2 * v8;
v11 = (char *)&__dst + 1;
if ( !v8 )
goto LABEL_29;
}
memmove(v11, *((const void **)&v9 + 1), v8);
LABEL_29:
v11[v8] = 0;
goto LABEL_31;
}
if ( a4 )
std::string::assign(a4, "Invalid or corrupt share string.");
v10 = 0;
goto LABEL_41;
}
if ( a4 )
std::string::assign(a4, "Empty string.");
return 0;
}