{"type": "func", "start": 5372126368, "end": 5372126709, "name": "MusicDownloadManager::onDownloadSFXCompleted", "pseudocode": "// \n// MusicDownloadManager::onDownloadSFXCompleted from 0x1403424a0 to 0x1403425f5 (341 bytes)\n// \n// 3 xrefs:\n// > MusicDownloadManager::downloadSFX @ 0x140342401\n// > <???> @ 0x1406d57d4\n// > <???> @ 0x1406d57e0\n// \n// This function is hookable on this platform!\n// \n// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA\n// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings\n// \n\n// Hidden C++ exception states: #wind=1\nvoid MusicDownloadManager::onDownloadSFXCompleted(\n        MusicDownloadManager *a1,\n        cocos2d::extension::CCHttpClient *a2,\n        cocos2d::extension::CCHttpResponse *a3)\n{\n  const char *Tag; // rax\n  unsigned int v6; // esi\n  cocos2d::CCString *v7; // rax\n  const char *CString; // rax\n  const char *v9; // rcx\n  FILE *v10; // rax\n  FILE *v11; // rbp\n  unsigned int i; // ebx\n  struct cocos2d::CCObject *v13; // rax\n  char *FileName[4]; // [rsp+20h] [rbp-48h] BYREF\n\n  Tag = cocos2d::extension::CCHttpRequest::getTag(a3->_pHttpRequest);\n  v6 = atoi(Tag);\n  v7 = cocos2d::CCString::createWithFormat(\"sfx_%i\", v6);\n  CString = cocos2d::CCString::getCString(v7);\n  MusicDownloadManager::removeDLFromActive(a1, CString);\n  if ( a3->_succeed )\n  {\n    MusicDownloadManager::pathForSFX((__int64)a1, FileName, v6);\n    v9 = (const char *)FileName;\n    if ( FileName[3] > (char *)0xF )\n      v9 = FileName[0];\n    v10 = fopen(v9, \"wb\");\n    v11 = v10;\n    if ( v10 )\n    {\n      fwrite(\n        a3->_responseData._Mypair._Myval2._Myfirst,\n        1u,\n        a3->_responseData._Mypair._Myval2._Mylast - a3->_responseData._Mypair._Myval2._Myfirst,\n        v10);\n      fclose(v11);\n      for ( i = 0; i < cocos2d::CCArray::count(a1->m_musicDownloadDelegates); ++i )\n      {\n        v13 = cocos2d::CCArray::objectAtIndex(a1->m_musicDownloadDelegates, i);\n        (*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)&v13[5].m_unknown2 + 48LL))(\n          *(_QWORD *)&v13[5].m_unknown2,\n          v6);\n      }\n    }\n    else\n    {\n      MusicDownloadManager::downloadSFXFailed(a1, v6, (GJSongError)0);\n    }\n    sub_14003A830((__int64)FileName);\n  }\n  else\n  {\n    MusicDownloadManager::downloadSFXFailed(\n      a1,\n      v6,\n      BYTE4(a3->_pHttpRequest->_headers._Mypair._Myval2._Myend) != 0 ? DownloadCancelled : (GJSongError)0);\n  }\n}", "assembly": "; \n; MusicDownloadManager::onDownloadSFXCompleted from 0x1403424a0 to 0x1403425f5 (341 bytes)\n; \n; 3 xrefs:\n; > MusicDownloadManager::downloadSFX @ 0x140342401\n; > <???> @ 0x1406d57d4\n; > <???> @ 0x1406d57e0\n; \n; This function is hookable on this platform!\n; \n; Using BromaIDA 8.0.0 @ https:;github.com/Stazzical/BromaIDA\n; Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https:;github.com/geode-sdk/bindings\n; \n\nmov     [rsp+arg_8], rbx                                               ; +0x0, 0x1403424a0\npush    rbp                                                            ; +0x5, 0x1403424a5\npush    rsi                                                            ; +0x6, 0x1403424a6\npush    rdi                                                            ; +0x7, 0x1403424a7\nsub     rsp, 50h                                                       ; +0x8, 0x1403424a8\nmov     rax, cs:__security_cookie                                      ; +0xc, 0x1403424ac\nxor     rax, rsp                                                       ; +0x13, 0x1403424b3\nmov     [rsp+68h+var_28], rax                                          ; +0x16, 0x1403424b6\nmov     rbx, r8                                                        ; +0x1b, 0x1403424bb\nmov     rdi, rcx                                                       ; +0x1e, 0x1403424be\nmov     rcx, [r8+38h]                                                  ; +0x21, 0x1403424c1\ncall    cs:?getTag@CCHttpRequest@extension@cocos2d@@QEAAPEBDXZ; cocos2d::extension::CCHttpRequest::getTag(void) ; +0x25, 0x1403424c5\nmov     rcx, rax; String                                               ; +0x2b, 0x1403424cb\ncall    cs:atoi                                                        ; +0x2e, 0x1403424ce\nmov     esi, eax                                                       ; +0x34, 0x1403424d4\nmov     edx, eax                                                       ; +0x36, 0x1403424d6\nlea     rcx, aSfxI; \"sfx_%i\"                                           ; +0x38, 0x1403424d8\ncall    cs:?createWithFormat@CCString@cocos2d@@SAPEAV12@PEBDZZ; cocos2d::CCString::createWithFormat(char const *,...) ; +0x3f, 0x1403424df\nmov     rcx, rax                                                       ; +0x45, 0x1403424e5\ncall    cs:?getCString@CCString@cocos2d@@QEBAPEBDXZ; cocos2d::CCString::getCString(void) ; +0x48, 0x1403424e8\nmov     rdx, rax                                                       ; +0x4e, 0x1403424ee\nmov     rcx, rdi                                                       ; +0x51, 0x1403424f1\ncall    MusicDownloadManager__removeDLFromActive                       ; +0x54, 0x1403424f4\nmov     rcx, rdi                                                       ; +0x59, 0x1403424f9\ncmp     byte ptr [rbx+40h], 0                                          ; +0x5c, 0x1403424fc\njnz     short loc_140342522                                            ; +0x60, 0x140342500\nmov     rdx, [rbx+38h]                                                 ; +0x62, 0x140342502\nmovzx   eax, byte ptr [rdx+0CCh]                                       ; +0x66, 0x140342506\nneg     al                                                             ; +0x6d, 0x14034250d\nsbb     r8d, r8d                                                       ; +0x6f, 0x14034250f\nand     r8d, 3                                                         ; +0x72, 0x140342512\nmov     edx, esi                                                       ; +0x76, 0x140342516\ncall    MusicDownloadManager__downloadSFXFailed                        ; +0x78, 0x140342518\njmp     loc_1403425DB                                                  ; +0x7d, 0x14034251d\nmov     r8d, esi                                                       ; +0x82, 0x140342522\nlea     rdx, [rsp+68h+FileName]                                        ; +0x85, 0x140342525\ncall    MusicDownloadManager__pathForSFX                               ; +0x8a, 0x14034252a\nnop                                                                    ; +0x8f, 0x14034252f\nlea     rcx, [rsp+68h+FileName]                                        ; +0x90, 0x140342530\ncmp     [rsp+68h+var_30], 0Fh                                          ; +0x95, 0x140342535\ncmova   rcx, [rsp+68h+FileName]; FileName                              ; +0x9b, 0x14034253b\nlea     rdx, Mode; \"wb\"                                                ; +0xa1, 0x140342541\ncall    cs:fopen                                                       ; +0xa8, 0x140342548\nmov     rbp, rax                                                       ; +0xae, 0x14034254e\ntest    rax, rax                                                       ; +0xb1, 0x140342551\njnz     short loc_140342565                                            ; +0xb4, 0x140342554\nxor     r8d, r8d                                                       ; +0xb6, 0x140342556\nmov     edx, esi                                                       ; +0xb9, 0x140342559\nmov     rcx, rdi                                                       ; +0xbb, 0x14034255b\ncall    MusicDownloadManager__downloadSFXFailed                        ; +0xbe, 0x14034255e\njmp     short loc_1403425D1                                            ; +0xc3, 0x140342563\nmov     rcx, [rbx+48h]; Buffer                                         ; +0xc5, 0x140342565\nmov     r8, [rbx+50h]                                                  ; +0xc9, 0x140342569\nsub     r8, rcx; ElementCount                                          ; +0xcd, 0x14034256d\nmov     r9, rbp; Stream                                                ; +0xd0, 0x140342570\nmov     edx, 1; ElementSize                                            ; +0xd3, 0x140342573\ncall    cs:fwrite                                                      ; +0xd8, 0x140342578\nmov     rcx, rbp; Stream                                               ; +0xde, 0x14034257e\ncall    cs:fclose                                                      ; +0xe1, 0x140342581\nxor     ebx, ebx                                                       ; +0xe7, 0x140342587\nmov     rcx, [rdi+150h]                                                ; +0xe9, 0x140342589\ncall    cs:?count@CCArray@cocos2d@@QEBAIXZ; cocos2d::CCArray::count(void) ; +0xf0, 0x140342590\ntest    eax, eax                                                       ; +0xf6, 0x140342596\njz      short loc_1403425D1                                            ; +0xf8, 0x140342598\nnop     word ptr [rax+rax+00h]                                         ; +0xfa, 0x14034259a\nmov     edx, ebx                                                       ; +0x100, 0x1403425a0\nmov     rcx, [rdi+150h]                                                ; +0x102, 0x1403425a2\ncall    cs:?objectAtIndex@CCArray@cocos2d@@QEAAPEAVCCObject@2@I@Z; cocos2d::CCArray::objectAtIndex(uint) ; +0x109, 0x1403425a9\nmov     rcx, [rax+140h]                                                ; +0x10f, 0x1403425af\nmov     rax, [rcx]                                                     ; +0x116, 0x1403425b6\nmov     edx, esi                                                       ; +0x119, 0x1403425b9\ncall    qword ptr [rax+30h]                                            ; +0x11b, 0x1403425bb\ninc     ebx                                                            ; +0x11e, 0x1403425be\nmov     rcx, [rdi+150h]                                                ; +0x120, 0x1403425c0\ncall    cs:?count@CCArray@cocos2d@@QEBAIXZ; cocos2d::CCArray::count(void) ; +0x127, 0x1403425c7\ncmp     ebx, eax                                                       ; +0x12d, 0x1403425cd\njb      short loc_1403425A0                                            ; +0x12f, 0x1403425cf\nlea     rcx, [rsp+68h+FileName]                                        ; +0x131, 0x1403425d1\ncall    sub_14003A830                                                  ; +0x136, 0x1403425d6\nmov     rcx, [rsp+68h+var_28]                                          ; +0x13b, 0x1403425db\nxor     rcx, rsp; StackCookie                                          ; +0x140, 0x1403425e0\ncall    __security_check_cookie                                        ; +0x143, 0x1403425e3\nmov     rbx, [rsp+68h+arg_8]                                           ; +0x148, 0x1403425e8\nadd     rsp, 50h                                                       ; +0x14d, 0x1403425ed\npop     rdi                                                            ; +0x151, 0x1403425f1\npop     rsi                                                            ; +0x152, 0x1403425f2\npop     rbp                                                            ; +0x153, 0x1403425f3\nretn                                                                   ; +0x154, 0x1403425f4", "xrefs": ["MusicDownloadManager::downloadSFX @ 0x140342401", "<???> @ 0x1406d57d4", "<???> @ 0x1406d57e0"], "is_objc": false, "is_arm32": false, "is_arm64": false, "bida_info": "8.0.0 @ https://github.com/Stazzical/BromaIDA", "bindings_info": "commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings"}