//
// GameLevelManager::uploadFriendRequest from 0x140160590 to 0x140160993 (1027 bytes)
//
// 2 xrefs:
// > ShareCommentLayer::onShare @ 0x14048e356
// > ??> @ 0x1406cab48
//
// 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
char __fastcall GameLevelManager::uploadFriendRequest(GameLevelManager *a1, int a2, const char *a3)
{
__int64 v6; // rax
__int64 v7; // rbx
void *v8; // rcx
cocos2d::CCString *v9; // rax
const char *CString; // rax
const char *v11; // rdi
size_t v12; // rbx
size_t v13; // r8
__int64 v14; // r14
void *v15; // rcx
size_t v17; // r8
__int64 v18; // rax
void *v19; // rcx
__int64 v20; // rcx
const char *v21; // r14
cocos2d::CCString *v22; // rax
const char *v23; // rax
cocos2d::CCString *v24; // rax
char *v25; // rax
size_t v26; // r8
size_t v27; // r8
_QWORD *v28; // rdx
__int128 v29; // [rsp+48h] [rbp-81h] BYREF
__int64 v30; // [rsp+58h] [rbp-71h]
__int64 v31; // [rsp+60h] [rbp-69h]
__int128 v32; // [rsp+68h] [rbp-61h] BYREF
__int64 v33; // [rsp+78h] [rbp-51h]
__int64 v34; // [rsp+80h] [rbp-49h]
__int128 *v35; // [rsp+88h] [rbp-41h]
const char *v36; // [rsp+98h] [rbp-31h]
void *Block[2]; // [rsp+A0h] [rbp-29h] BYREF
__int128 v38; // [rsp+B0h] [rbp-19h]
_QWORD Src[4]; // [rsp+C0h] [rbp-9h] BYREF
v36 = a3;
v6 = sub_14003BDB0((__int64)&v29, (__int64)a3);
v7 = v6;
if ( *(_QWORD *)(v6 + 16) )
{
cocos2d::ZipUtils::base64URLEncode(Block, v6);
}
else
{
*(_OWORD *)Block = 0;
v38 = 0;
*(_OWORD *)Block = *(_OWORD *)v6;
v38 = *(_OWORD *)(v6 + 16);
*(_QWORD *)(v6 + 16) = 0;
*(_QWORD *)(v6 + 24) = 15;
*(_BYTE *)v6 = 0;
}
sub_14003A830(v7);
sub_140051590((__int64)a3, (__int64)Block);
if ( *((_QWORD *)&v38 + 1) > 0xFu )
{
v8 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v38 + 1) + 1LL) >= 0x1000 )
{
v8 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v8 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v8);
}
v9 = cocos2d::CCString::createWithFormat("friendReq_%i", a2);
CString = cocos2d::CCString::getCString(v9);
v11 = CString;
*(_OWORD *)Block = 0;
v38 = 0;
v12 = -1;
v13 = -1;
do
++v13;
while ( CString[v13] );
sub_14003A930(Block, CString, v13);
v14 = cocos2d::CCDictionary::objectForKey(a1->m_friendReqAndUserBlocks, Block);
if ( *((_QWORD *)&v38 + 1) > 0xFu )
{
v15 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v38 + 1) + 1LL) >= 0x1000 )
{
v15 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v15 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v15);
}
if ( v14 )
{
sub_14003A830((__int64)a3);
return 0;
}
else
{
*(_OWORD *)Block = 0;
v38 = 0;
v17 = -1;
do
++v17;
while ( v11[v17] );
sub_14003A930(Block, v11, v17);
v18 = cocos2d::CCNode::create();
cocos2d::CCDictionary::setObject(a1->m_friendReqAndUserBlocks, v18, Block);
if ( *((_QWORD *)&v38 + 1) > 0xFu )
{
v19 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v38 + 1) + 1LL) >= 0x1000 )
{
v19 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v19 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v19);
}
GameLevelManager::makeTimeStamp(a1, v11);
GameLevelManager::getBasePostString(v20, Src);
v21 = a3;
if ( *((_QWORD *)a3 + 3) > 0xFu )
v21 = *(const char **)a3;
v22 = cocos2d::CCString::createWithFormat("%c%s%s%c%c%s", 87, "mfd", "2893", 103, 98, (const char *)&word_140531E88);
v23 = cocos2d::CCString::getCString(v22);
v24 = cocos2d::CCString::createWithFormat("&toAccountID=%i&comment=%s&secret=%s", a2, v21, v23);
v25 = (char *)cocos2d::CCString::getCString(v24);
v26 = -1;
do
++v26;
while ( v25[v26] );
sub_140041270(Src, v25, v26);
v35 = &v29;
v32 = 0;
v33 = 0;
v34 = 0;
v27 = -1;
do
++v27;
while ( v11[v27] );
sub_14003A930(&v32, v11, v27);
v28 = Src;
if ( Src[3] > 0xFu )
v28 = (_QWORD *)Src[0];
v29 = 0;
v30 = 0;
v31 = 0;
do
++v12;
while ( *((_BYTE *)v28 + v12) );
sub_14003A930(&v29, v28, v12);
*(_OWORD *)Block = 0;
*(_QWORD *)&v38 = 0;
*((_QWORD *)&v38 + 1) = 15;
Block[0] = sub_14003AA10(0x40u);
*(_QWORD *)&v38 = 60;
*((_QWORD *)&v38 + 1) = 63;
strcpy((char *)Block[0], "https://www.boomlings.com/database/uploadFriendRequest20.php");
GameLevelManager::ProcessHttpRequest(a1, (__int64)Block, (const char *)&v29, (const char *)&v32, 29);
sub_14003A830((__int64)Src);
sub_14003A830((__int64)a3);
return 1;
}
}