//
// GJAccountManager::onBackupAccountCompleted from 0x1000d0440 to 0x1000d0703 (707 bytes)
//
// 1 xrefs:
// > GJAccountManager::handleIt @ 0x1000cf8a2
//
// 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
//
void __fastcall GJAccountManager::onBackupAccountCompleted(GJAccountManager *a1, unsigned __int8 *a2, double a3)
{
unsigned __int64 v4; // rcx
const void *v5; // rdi
char *v6; // rbx
size_t v7; // rdx
GJAccountBackupDelegate *m_backupDelegate; // rdi
cocos2d::CCString *v9; // rax
const char *CString; // r14
size_t v11; // rax
size_t v12; // r13
char *v13; // r12
size_t v14; // r14
void *v15; // r14
unsigned int v16; // eax
size_t v17; // rax
const void *v18; // rdi
size_t v19; // rdx
bool v20; // zf
char v21; // bl
GJAccountDelegate *m_accountDelegate; // rdi
GJAccountBackupDelegate *v23; // rdi
unsigned int v24; // ebx
__int64 v25; // rbx
const char *v26; // r15
GameLevelManager *v27; // rax
LocalLevelManager *v28; // rax
GJAccountBackupDelegate *v29; // rdi
GJAccountBackupDelegate *v30; // rbx
unsigned int v31; // eax
char v32; // [rsp+0h] [rbp-60h]
GJAccountManager *v33; // [rsp+8h] [rbp-58h]
const char *v34; // [rsp+10h] [rbp-50h]
size_t __s2; // [rsp+20h] [rbp-40h] BYREF
size_t v36; // [rsp+28h] [rbp-38h]
void *__p; // [rsp+30h] [rbp-30h]
GJAccountManager::removeDLFromActive(a1, "bak_account");
*(_WORD *)((char *)&__s2 + 1) = 12589;
BYTE3(__s2) = 0;
v4 = *a2 >> 1;
v5 = *((const void **)a2 + 2);
if ( (*a2 & 1) == 0 )
v5 = a2 + 1;
v6 = (char *)&__s2 + 1;
if ( (*a2 & 1) != 0 )
v4 = *((_QWORD *)a2 + 1);
v7 = 2;
if ( v4 < 2 )
v7 = v4;
if ( !((v4 != 2) | (memcmp(v5, (char *)&__s2 + 1, v7) != 0)) )
{
m_backupDelegate = a1->m_backupDelegate;
if ( m_backupDelegate )
((void (__fastcall *)(GJAccountBackupDelegate *, __int64, _QWORD))m_backupDelegate->backupAccountFailed)(
m_backupDelegate,
0xFFFFFFFFLL,
0);
return;
}
v9 = (cocos2d::CCString *)sub_1007AB580("%i", v32);
CString = cocos2d::CCString::getCString(v9);
v11 = strlen(CString);
if ( v11 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a3);
v12 = v11;
v33 = a1;
if ( v11 >= 0x17 )
{
v34 = CString;
v14 = 26;
if ( (v11 | 7) != 0x17 )
v14 = (v11 | 7) + 1;
v13 = (char *)operator new(v14);
__p = v13;
__s2 = v14 + 1;
CString = v34;
v36 = v12;
}
else
{
LOBYTE(__s2) = 2 * v11;
v13 = (char *)&__s2 + 1;
if ( !v11 )
goto LABEL_18;
}
memmove(v13, CString, v12);
LABEL_18:
v13[v12] = 0;
v15 = __p;
v16 = *a2;
if ( (v16 & 1) != 0 )
{
v17 = *((_QWORD *)a2 + 1);
v18 = *((const void **)a2 + 2);
}
else
{
v17 = v16 >> 1;
v18 = a2 + 1;
}
v19 = (unsigned __int8)__s2 >> 1;
if ( (__s2 & 1) != 0 )
{
v19 = v36;
v6 = (char *)__p;
}
v20 = v19 == v17;
if ( v19 >= v17 )
v19 = v17;
v21 = v20 & (memcmp(v18, v6, v19) == 0);
if ( (__s2 & 1) != 0 )
operator delete(v15);
if ( v21 )
{
std::string::assign((std::string *)&v33->m_password, "");
m_accountDelegate = v33->m_accountDelegate;
if ( m_accountDelegate )
((void (__fastcall *)(GJAccountDelegate *))m_accountDelegate->accountStatusChanged)(m_accountDelegate);
v23 = v33->m_backupDelegate;
if ( v23 )
((void (__fastcall *)(GJAccountBackupDelegate *, __int64, _QWORD))v23->backupAccountFailed)(v23, 4294967294LL, 0);
}
else
{
*(_WORD *)((char *)&__s2 + 1) = 49;
v24 = *a2;
if ( (v24 & 1) != 0 )
{
v25 = *((_QWORD *)a2 + 1);
v26 = *((const char **)a2 + 2);
}
else
{
v25 = v24 >> 1;
v26 = (const char *)(a2 + 1);
}
if ( ((v25 == 1) & (memcmp(v26, (char *)&__s2 + 1, v25 != 0) == 0)) != 0 || atoi(v26) >= 0 )
{
v27 = GameLevelManager::sharedState();
GameLevelManager::makeTimeStamp(v27, "bak_account");
v28 = LocalLevelManager::sharedState();
LocalLevelManager::markLevelsAsUnmodified(v28);
v29 = v33->m_backupDelegate;
if ( v29 )
((void (__fastcall *)(GJAccountBackupDelegate *))v29->backupAccountFinished)(v29);
}
else
{
v30 = v33->m_backupDelegate;
if ( v30 )
{
v31 = atoi(v26);
((void (__fastcall *)(GJAccountBackupDelegate *, __int64, _QWORD))v30->backupAccountFailed)(
v30,
4294967293LL,
v31);
}
}
}
}