{"type": "func", "start": 5372128320, "end": 5372128707, "name": "MusicDownloadManager::onDownloadSFXLibraryCompleted", "pseudocode": "// \n// MusicDownloadManager::onDownloadSFXLibraryCompleted from 0x140342c40 to 0x140342dc3 (387 bytes)\n// \n// 2 xrefs:\n// > MusicDownloadManager::downloadSFXLibrary @ 0x140342b70\n// > <???> @ 0x1406d5810\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=2\nvoid MusicDownloadManager::onDownloadSFXLibraryCompleted(\n        MusicDownloadManager *a1,\n        cocos2d::extension::CCHttpClient *a2,\n        cocos2d::extension::CCHttpResponse *a3)\n{\n  void *v5; // rcx\n  const char *v6; // rcx\n  FILE *v7; // rax\n  FILE *v8; // rsi\n  void *Block[2]; // [rsp+20h] [rbp-58h] BYREF\n  __int64 v10; // [rsp+30h] [rbp-48h]\n  unsigned __int64 v11; // [rsp+38h] [rbp-40h]\n  char *FileName[4]; // [rsp+40h] [rbp-38h] BYREF\n\n  Block[1] = nullptr;\n  v10 = 8;\n  v11 = 15;\n  Block[0] = (void *)0x6C5F7866735F6C64LL;\n  cocos2d::CCDictionary::removeObjectForKey(a1->m_activeDownloads, Block);\n  if ( v11 > 0xF )\n  {\n    v5 = Block[0];\n    if ( v11 + 1 >= 0x1000 )\n    {\n      v5 = *((void **)Block[0] - 1);\n      if ( (unsigned __int64)((char *)Block[0] - (char *)v5 - 8) > 0x1F )\n        invalid_parameter_noinfo_noreturn();\n    }\n    j_j_free(v5);\n  }\n  if ( a3 && a3->_succeed )\n  {\n    MusicDownloadManager::pathForSFXFolder((__int64)a1, FileName, 0);\n    sub_140041270(FileName, \"sfxlibrary.dat\", 0xEu);\n    v6 = (const char *)FileName;\n    if ( FileName[3] > (char *)0xF )\n      v6 = FileName[0];\n    v7 = fopen(v6, \"wb\");\n    v8 = v7;\n    if ( v7 )\n    {\n      fwrite(\n        a3->_responseData._Mypair._Myval2._Myfirst,\n        1u,\n        a3->_responseData._Mypair._Myval2._Mylast - a3->_responseData._Mypair._Myval2._Myfirst,\n        v7);\n      fclose(v8);\n      MusicDownloadManager::parseSFXLibrary(a1);\n      MusicDownloadManager::musicActionFinished(a1, (GJMusicAction)1);\n    }\n    else\n    {\n      MusicDownloadManager::musicActionFailed(a1, (GJMusicAction)1);\n    }\n    sub_14003A830((__int64)FileName);\n  }\n  else\n  {\n    MusicDownloadManager::musicActionFailed(a1, (GJMusicAction)1);\n  }\n}", "assembly": "; \n; MusicDownloadManager::onDownloadSFXLibraryCompleted from 0x140342c40 to 0x140342dc3 (387 bytes)\n; \n; 2 xrefs:\n; > MusicDownloadManager::downloadSFXLibrary @ 0x140342b70\n; > <???> @ 0x1406d5810\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, 0x140342c40\nmov     [rsp+arg_18], rsi                                              ; +0x5, 0x140342c45\npush    rdi                                                            ; +0xa, 0x140342c4a\nsub     rsp, 70h                                                       ; +0xb, 0x140342c4b\nmov     rax, cs:__security_cookie                                      ; +0xf, 0x140342c4f\nxor     rax, rsp                                                       ; +0x16, 0x140342c56\nmov     [rsp+78h+var_18], rax                                          ; +0x19, 0x140342c59\nmov     rdi, r8                                                        ; +0x1e, 0x140342c5e\nmov     rbx, rcx                                                       ; +0x21, 0x140342c61\nxorps   xmm0, xmm0                                                     ; +0x24, 0x140342c64\nmovups  xmmword ptr [rsp+78h+Block], xmm0                              ; +0x27, 0x140342c67\nmov     [rsp+78h+var_48], 8                                            ; +0x2c, 0x140342c6c\nmov     [rsp+78h+var_40], 0Fh                                          ; +0x35, 0x140342c75\nmov     rax, 6C5F7866735F6C64h                                         ; +0x3e, 0x140342c7e\nmov     [rsp+78h+Block], rax                                           ; +0x48, 0x140342c88\nmov     byte ptr [rsp+78h+Block+8], 0                                  ; +0x4d, 0x140342c8d\nlea     rdx, [rsp+78h+Block]                                           ; +0x52, 0x140342c92\nmov     rcx, [rcx+148h]                                                ; +0x57, 0x140342c97\ncall    cs:?removeObjectForKey@CCDictionary@cocos2d@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z; cocos2d::CCDictionary::removeObjectForKey(std::string const &) ; +0x5e, 0x140342c9e\nnop                                                                    ; +0x64, 0x140342ca4\nmov     rdx, [rsp+78h+var_40]                                          ; +0x65, 0x140342ca5\ncmp     rdx, 0Fh                                                       ; +0x6a, 0x140342caa\njbe     short loc_140342CE5                                            ; +0x6e, 0x140342cae\ninc     rdx                                                            ; +0x70, 0x140342cb0\nmov     rcx, [rsp+78h+Block]; Block                                    ; +0x73, 0x140342cb3\nmov     rax, rcx                                                       ; +0x78, 0x140342cb8\ncmp     rdx, 1000h                                                     ; +0x7b, 0x140342cbb\njb      short loc_140342CE0                                            ; +0x82, 0x140342cc2\nadd     rdx, 27h ; '''                                                 ; +0x84, 0x140342cc4\nmov     rcx, [rcx-8]                                                   ; +0x88, 0x140342cc8\nsub     rax, rcx                                                       ; +0x8c, 0x140342ccc\nadd     rax, 0FFFFFFFFFFFFFFF8h                                        ; +0x8f, 0x140342ccf\ncmp     rax, 1Fh                                                       ; +0x93, 0x140342cd3\njbe     short loc_140342CE0                                            ; +0x97, 0x140342cd7\ncall    cs:_invalid_parameter_noinfo_noreturn                          ; +0x99, 0x140342cd9\nalign 20h                                                              ; +0x9f, 0x140342cdf\ncall    j_j_free                                                       ; +0xa0, 0x140342ce0\ntest    rdi, rdi                                                       ; +0xa5, 0x140342ce5\njz      loc_140342D97                                                  ; +0xa8, 0x140342ce8\ncmp     byte ptr [rdi+40h], 0                                          ; +0xae, 0x140342cee\njz      loc_140342D97                                                  ; +0xb2, 0x140342cf2\nxor     r8d, r8d                                                       ; +0xb8, 0x140342cf8\nlea     rdx, [rsp+78h+FileName]                                        ; +0xbb, 0x140342cfb\nmov     rcx, rbx                                                       ; +0xc0, 0x140342d00\ncall    MusicDownloadManager__pathForSFXFolder                         ; +0xc3, 0x140342d03\nnop                                                                    ; +0xc8, 0x140342d08\nmov     r8d, 0Eh; Size                                                 ; +0xc9, 0x140342d09\nlea     rdx, aSfxlibraryDat; \"sfxlibrary.dat\"                          ; +0xcf, 0x140342d0f\nlea     rcx, [rsp+78h+FileName]; Src                                   ; +0xd6, 0x140342d16\ncall    sub_140041270                                                  ; +0xdb, 0x140342d1b\nlea     rcx, [rsp+78h+FileName]                                        ; +0xe0, 0x140342d20\ncmp     [rsp+78h+var_20], 0Fh                                          ; +0xe5, 0x140342d25\ncmova   rcx, [rsp+78h+FileName]; FileName                              ; +0xeb, 0x140342d2b\nlea     rdx, Mode; \"wb\"                                                ; +0xf1, 0x140342d31\ncall    cs:fopen                                                       ; +0xf8, 0x140342d38\nmov     rsi, rax                                                       ; +0xfe, 0x140342d3e\ntest    rax, rax                                                       ; +0x101, 0x140342d41\njnz     short loc_140342D53                                            ; +0x104, 0x140342d44\nlea     edx, [rax+1]                                                   ; +0x106, 0x140342d46\nmov     rcx, rbx                                                       ; +0x109, 0x140342d49\ncall    MusicDownloadManager__musicActionFailed                        ; +0x10c, 0x140342d4c\njmp     short loc_140342D8B                                            ; +0x111, 0x140342d51\nmov     rcx, [rdi+48h]; Buffer                                         ; +0x113, 0x140342d53\nmov     r8, [rdi+50h]                                                  ; +0x117, 0x140342d57\nsub     r8, rcx; ElementCount                                          ; +0x11b, 0x140342d5b\nmov     r9, rsi; Stream                                                ; +0x11e, 0x140342d5e\nmov     edx, 1; ElementSize                                            ; +0x121, 0x140342d61\ncall    cs:fwrite                                                      ; +0x126, 0x140342d66\nmov     rcx, rsi; Stream                                               ; +0x12c, 0x140342d6c\ncall    cs:fclose                                                      ; +0x12f, 0x140342d6f\nmov     rcx, rbx                                                       ; +0x135, 0x140342d75\ncall    MusicDownloadManager__parseSFXLibrary                          ; +0x138, 0x140342d78\nmov     edx, 1                                                         ; +0x13d, 0x140342d7d\nmov     rcx, rbx                                                       ; +0x142, 0x140342d82\ncall    MusicDownloadManager__musicActionFinished                      ; +0x145, 0x140342d85\nnop                                                                    ; +0x14a, 0x140342d8a\nlea     rcx, [rsp+78h+FileName]                                        ; +0x14b, 0x140342d8b\ncall    sub_14003A830                                                  ; +0x150, 0x140342d90\njmp     short loc_140342DA4                                            ; +0x155, 0x140342d95\nmov     edx, 1                                                         ; +0x157, 0x140342d97\nmov     rcx, rbx                                                       ; +0x15c, 0x140342d9c\ncall    MusicDownloadManager__musicActionFailed                        ; +0x15f, 0x140342d9f\nmov     rcx, [rsp+78h+var_18]                                          ; +0x164, 0x140342da4\nxor     rcx, rsp; StackCookie                                          ; +0x169, 0x140342da9\ncall    __security_check_cookie                                        ; +0x16c, 0x140342dac\nlea     r11, [rsp+78h+var_8]                                           ; +0x171, 0x140342db1\nmov     rbx, [r11+18h]                                                 ; +0x176, 0x140342db6\nmov     rsi, [r11+28h]                                                 ; +0x17a, 0x140342dba\nmov     rsp, r11                                                       ; +0x17e, 0x140342dbe\npop     rdi                                                            ; +0x181, 0x140342dc1\nretn                                                                   ; +0x182, 0x140342dc2", "xrefs": ["MusicDownloadManager::downloadSFXLibrary @ 0x140342b70", "<???> @ 0x1406d5810"], "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"}