//
// MusicDownloadManager::generateCustomContentURL from 0x458830 to 0x458ae8 (696 bytes)
//
// 6 xrefs:
// > MusicDownloadManager::downloadCustomSong @ 0x459c92
// > MusicDownloadManager::tryUpdateMusicLibrary @ 0x459d9e
// > MusicDownloadManager::downloadMusicLibrary @ 0x459eaa
// > MusicDownloadManager::downloadSFX @ 0x45a052
// > MusicDownloadManager::tryUpdateSFXLibrary @ 0x45a162
// > MusicDownloadManager::downloadSFXLibrary @ 0x45a26e
//
// 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 MusicDownloadManager::generateCustomContentURL(int a1, int a2, _DWORD *a3)
{
cocos2d::CCString *v4; // r0
char *CString; // r11
size_t v6; // r0
unsigned int v7; // r3
unsigned int v8; // r2
size_t v9; // r2
unsigned int v10; // r3
int i; // r5
char *v12; // r3
int v13; // r0
cocos2d::CCString *v14; // r0
char *v15; // r0
__int64 v19; // [sp+20h] [bp-E4h] BYREF
int v20; // [sp+30h] [bp-D4h] BYREF
std::string v21; // [sp+34h] [bp-D0h] BYREF
GameToolbox v22; // [sp+38h] [bp-CCh] BYREF
char *v23; // [sp+3Ch] [bp-C8h] BYREF
_BYTE v24[4]; // [sp+40h] [bp-C4h] BYREF
unsigned __int8 v25[4]; // [sp+44h] [bp-C0h] BYREF
int v26; // [sp+48h] [bp-BCh] BYREF
int v27; // [sp+4Ch] [bp-B8h] BYREF
int v28; // [sp+50h] [bp-B4h] BYREF
int v29; // [sp+54h] [bp-B0h] BYREF
int v30; // [sp+58h] [bp-ACh] BYREF
int v31; // [sp+5Ch] [bp-A8h] BYREF
int v32; // [sp+60h] [bp-A4h] BYREF
int v33; // [sp+64h] [bp-A0h] BYREF
_DWORD v34[22]; // [sp+68h] [bp-9Ch] BYREF
char v35[16]; // [sp+C0h] [bp-44h] BYREF
char v36[36]; // [sp+D0h] [bp-34h] BYREF
unsigned __int8 v37[8]; // [sp+F4h] [bp-10h] BYREF
sub_76DB0C(&v19);
GameToolbox::intToString((GameToolbox *)&v20, v19 / 1000000000 + 3600);
v34[5] = 0;
v34[4] = 0;
v34[2] = -1732584194;
v34[0] = 1732584193;
v34[1] = -271733879;
v34[3] = 271733878;
sub_776584((int)&v21, "DQIHAV8MVAUdDgBVVh0NBwQHHQEEDw8dDAQHBAdaAVNWAQkH");
GameToolbox::intToString(&v22, 57709);
cocos2d::ZipUtils::base64DecodeEnc((cocos2d::ZipUtils *)&v23, &v21, (std::string)&v22);
v4 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%s%s%s", v23, *a3, v20);
CString = (char *)cocos2d::CCString::getCString(v4);
sub_774008(&v23);
sub_774008(&v22);
sub_774008(&v21);
v34[5] = 0;
v34[4] = 0;
v34[0] = 1732584193;
v34[1] = -271733879;
v34[2] = -1732584194;
v34[3] = 271733878;
v6 = strlen(CString);
MD5::Update((MD5 *)v34, (unsigned __int8 *)CString, v6);
MD5::Encode((int)v37, (unsigned __int8 *)&v34[4], (unsigned int *)byte_8, v7);
v8 = (v34[4] >> 3) & 0x3F;
if ( v8 > 0x37 )
v9 = 120 - v8;
else
v9 = 56 - v8;
MD5::Update((MD5 *)v34, byte_AB9014, v9);
MD5::Update((MD5 *)v34, v37, 8u);
MD5::Encode((int)v35, (unsigned __int8 *)v34, (unsigned int *)&word_10, v10);
memset(v34, 0, sizeof(v34));
for ( i = 0; i != 16; ++i )
{
v12 = (char *)v34 + i;
v13 = i + 52;
sprintf((char *)v34 + 2 * v13, "%02x", (unsigned __int8)v12[88]);
}
sub_776584((int)v24, v36);
base64_encode(v25, v35, 16);
sub_776584((int)&v26, "=");
sub_776584((int)&v27, (char *)&unk_939830);
sub_456D56((int)v25, &v26, &v27);
sub_774008(&v27);
sub_774008(&v26);
sub_776584((int)&v28, "\n");
sub_776584((int)&v29, (char *)&unk_939830);
sub_456D56((int)v25, &v28, &v29);
sub_774008(&v29);
sub_774008(&v28);
sub_776584((int)&v30, "+");
sub_776584((int)&v31, "-");
sub_456D56((int)v25, &v30, &v31);
sub_774008(&v31);
sub_774008(&v30);
sub_776584((int)&v32, "/");
sub_776584((int)&v33, "_");
sub_456D56((int)v25, &v32, &v33);
sub_774008(&v33);
sub_774008(&v32);
v14 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%s%s?token=%s&expires=%s",
*(const char **)(a2 + 288),
*a3,
*(_DWORD *)v25,
v20);
v15 = (char *)cocos2d::CCString::getCString(v14);
sub_776584(a1, v15);
sub_774008(v25);
sub_774008(v24);
sub_774008(&v20);
return a1;
}