{"type": "func", "start": 5372120016, "end": 5372120438, "name": "MusicDownloadManager::onDownloadMusicLibraryCompleted", "pseudocode": "// \n// MusicDownloadManager::onDownloadMusicLibraryCompleted from 0x140340bd0 to 0x140340d76 (422 bytes)\n// \n// 2 xrefs:\n// > MusicDownloadManager::downloadMusicLibrary @ 0x140340af2\n// > <???> @ 0x1406d5774\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::onDownloadMusicLibraryCompleted(\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  cocos2d::CCDictionary *m_musicObjects; // rcx\n  void *Block[2]; // [rsp+20h] [rbp-58h] BYREF\n  __int64 v11; // [rsp+30h] [rbp-48h]\n  unsigned __int64 v12; // [rsp+38h] [rbp-40h]\n  char *FileName[4]; // [rsp+40h] [rbp-38h] BYREF\n\n  Block[1] = (void *)27743;\n  v11 = 10;\n  v12 = 15;\n  Block[0] = (void *)0x636973756D5F6C64LL;\n  cocos2d::CCDictionary::removeObjectForKey(a1->m_activeDownloads, Block);\n  if ( v12 > 0xF )\n  {\n    v5 = Block[0];\n    if ( v12 + 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::pathForSongFolder((__int64)a1, FileName, 0);\n    sub_140041270(FileName, \"musiclibrary.dat\", 0x10u);\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      && (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::parseMusicLibrary(a1),\n          (m_musicObjects = a1->m_musicObjects) != nullptr)\n      && cocos2d::CCDictionary::count(m_musicObjects) )\n    {\n      MusicDownloadManager::musicActionFinished(a1, UpdateMusicLibrary|0x1);\n    }\n    else\n    {\n      MusicDownloadManager::musicActionFailed(a1, UpdateMusicLibrary|0x1);\n    }\n    sub_14003A830((__int64)FileName);\n  }\n  else\n  {\n    MusicDownloadManager::musicActionFailed(a1, UpdateMusicLibrary|0x1);\n  }\n}", "assembly": "; \n; MusicDownloadManager::onDownloadMusicLibraryCompleted from 0x140340bd0 to 0x140340d76 (422 bytes)\n; \n; 2 xrefs:\n; > MusicDownloadManager::downloadMusicLibrary @ 0x140340af2\n; > <???> @ 0x1406d5774\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, 0x140340bd0\nmov     [rsp+arg_18], rsi                                              ; +0x5, 0x140340bd5\npush    rdi                                                            ; +0xa, 0x140340bda\nsub     rsp, 70h                                                       ; +0xb, 0x140340bdb\nmov     rax, cs:__security_cookie                                      ; +0xf, 0x140340bdf\nxor     rax, rsp                                                       ; +0x16, 0x140340be6\nmov     [rsp+78h+var_18], rax                                          ; +0x19, 0x140340be9\nmov     rdi, r8                                                        ; +0x1e, 0x140340bee\nmov     rbx, rcx                                                       ; +0x21, 0x140340bf1\nxorps   xmm0, xmm0                                                     ; +0x24, 0x140340bf4\nmovups  xmmword ptr [rsp+78h+Block], xmm0                              ; +0x27, 0x140340bf7\nmov     [rsp+78h+var_48], 0Ah                                          ; +0x2c, 0x140340bfc\nmov     [rsp+78h+var_40], 0Fh                                          ; +0x35, 0x140340c05\nmovsd   xmm0, cs:qword_1405AC7D8                                       ; +0x3e, 0x140340c0e\nmovsd   [rsp+78h+Block], xmm0                                          ; +0x46, 0x140340c16\nmovzx   eax, cs:word_1405AC7E0                                         ; +0x4c, 0x140340c1c\nmov     word ptr [rsp+78h+Block+8], ax                                 ; +0x53, 0x140340c23\nmov     byte ptr [rsp+78h+Block+0Ah], 0                                ; +0x58, 0x140340c28\nlea     rdx, [rsp+78h+Block]                                           ; +0x5d, 0x140340c2d\nmov     rcx, [rcx+148h]                                                ; +0x62, 0x140340c32\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 &) ; +0x69, 0x140340c39\nnop                                                                    ; +0x6f, 0x140340c3f\nmov     rdx, [rsp+78h+var_40]                                          ; +0x70, 0x140340c40\ncmp     rdx, 0Fh                                                       ; +0x75, 0x140340c45\njbe     short loc_140340C80                                            ; +0x79, 0x140340c49\ninc     rdx                                                            ; +0x7b, 0x140340c4b\nmov     rcx, [rsp+78h+Block]; Block                                    ; +0x7e, 0x140340c4e\nmov     rax, rcx                                                       ; +0x83, 0x140340c53\ncmp     rdx, 1000h                                                     ; +0x86, 0x140340c56\njb      short loc_140340C7B                                            ; +0x8d, 0x140340c5d\nadd     rdx, 27h ; '''                                                 ; +0x8f, 0x140340c5f\nmov     rcx, [rcx-8]                                                   ; +0x93, 0x140340c63\nsub     rax, rcx                                                       ; +0x97, 0x140340c67\nadd     rax, 0FFFFFFFFFFFFFFF8h                                        ; +0x9a, 0x140340c6a\ncmp     rax, 1Fh                                                       ; +0x9e, 0x140340c6e\njbe     short loc_140340C7B                                            ; +0xa2, 0x140340c72\ncall    cs:_invalid_parameter_noinfo_noreturn                          ; +0xa4, 0x140340c74\ndb 0CCh                                                                ; +0xaa, 0x140340c7a\ncall    j_j_free                                                       ; +0xab, 0x140340c7b\ntest    rdi, rdi                                                       ; +0xb0, 0x140340c80\njz      loc_140340D4A                                                  ; +0xb3, 0x140340c83\ncmp     byte ptr [rdi+40h], 0                                          ; +0xb9, 0x140340c89\njz      loc_140340D4A                                                  ; +0xbd, 0x140340c8d\nxor     r8d, r8d                                                       ; +0xc3, 0x140340c93\nlea     rdx, [rsp+78h+FileName]                                        ; +0xc6, 0x140340c96\nmov     rcx, rbx                                                       ; +0xcb, 0x140340c9b\ncall    MusicDownloadManager__pathForSongFolder                        ; +0xce, 0x140340c9e\nnop                                                                    ; +0xd3, 0x140340ca3\nmov     r8d, 10h; Size                                                 ; +0xd4, 0x140340ca4\nlea     rdx, aMusiclibraryDa; \"musiclibrary.dat\"                       ; +0xda, 0x140340caa\nlea     rcx, [rsp+78h+FileName]; Src                                   ; +0xe1, 0x140340cb1\ncall    sub_140041270                                                  ; +0xe6, 0x140340cb6\nlea     rcx, [rsp+78h+FileName]                                        ; +0xeb, 0x140340cbb\ncmp     [rsp+78h+var_20], 0Fh                                          ; +0xf0, 0x140340cc0\ncmova   rcx, [rsp+78h+FileName]; FileName                              ; +0xf6, 0x140340cc6\nlea     rdx, Mode; \"wb\"                                                ; +0xfc, 0x140340ccc\ncall    cs:fopen                                                       ; +0x103, 0x140340cd3\nmov     rsi, rax                                                       ; +0x109, 0x140340cd9\ntest    rax, rax                                                       ; +0x10c, 0x140340cdc\njz      short loc_140340D30                                            ; +0x10f, 0x140340cdf\nmov     rcx, [rdi+48h]; Buffer                                         ; +0x111, 0x140340ce1\nmov     r8, [rdi+50h]                                                  ; +0x115, 0x140340ce5\nsub     r8, rcx; ElementCount                                          ; +0x119, 0x140340ce9\nmov     r9, rax; Stream                                                ; +0x11c, 0x140340cec\nmov     edx, 1; ElementSize                                            ; +0x11f, 0x140340cef\ncall    cs:fwrite                                                      ; +0x124, 0x140340cf4\nmov     rcx, rsi; Stream                                               ; +0x12a, 0x140340cfa\ncall    cs:fclose                                                      ; +0x12d, 0x140340cfd\nmov     rcx, rbx                                                       ; +0x133, 0x140340d03\ncall    MusicDownloadManager__parseMusicLibrary                        ; +0x136, 0x140340d06\nmov     rcx, [rbx+1B0h]                                                ; +0x13b, 0x140340d0b\ntest    rcx, rcx                                                       ; +0x142, 0x140340d12\njz      short loc_140340D30                                            ; +0x145, 0x140340d15\ncall    cs:?count@CCDictionary@cocos2d@@QEAAIXZ; cocos2d::CCDictionary::count(void) ; +0x147, 0x140340d17\ntest    eax, eax                                                       ; +0x14d, 0x140340d1d\njz      short loc_140340D30                                            ; +0x14f, 0x140340d1f\nmov     edx, 7                                                         ; +0x151, 0x140340d21\nmov     rcx, rbx                                                       ; +0x156, 0x140340d26\ncall    MusicDownloadManager__musicActionFinished                      ; +0x159, 0x140340d29\njmp     short loc_140340D3E                                            ; +0x15e, 0x140340d2e\nmov     edx, 7                                                         ; +0x160, 0x140340d30\nmov     rcx, rbx                                                       ; +0x165, 0x140340d35\ncall    MusicDownloadManager__musicActionFailed                        ; +0x168, 0x140340d38\nnop                                                                    ; +0x16d, 0x140340d3d\nlea     rcx, [rsp+78h+FileName]                                        ; +0x16e, 0x140340d3e\ncall    sub_14003A830                                                  ; +0x173, 0x140340d43\njmp     short loc_140340D57                                            ; +0x178, 0x140340d48\nmov     edx, 7                                                         ; +0x17a, 0x140340d4a\nmov     rcx, rbx                                                       ; +0x17f, 0x140340d4f\ncall    MusicDownloadManager__musicActionFailed                        ; +0x182, 0x140340d52\nmov     rcx, [rsp+78h+var_18]                                          ; +0x187, 0x140340d57\nxor     rcx, rsp; StackCookie                                          ; +0x18c, 0x140340d5c\ncall    __security_check_cookie                                        ; +0x18f, 0x140340d5f\nlea     r11, [rsp+78h+var_8]                                           ; +0x194, 0x140340d64\nmov     rbx, [r11+18h]                                                 ; +0x199, 0x140340d69\nmov     rsi, [r11+28h]                                                 ; +0x19d, 0x140340d6d\nmov     rsp, r11                                                       ; +0x1a1, 0x140340d71\npop     rdi                                                            ; +0x1a4, 0x140340d74\nretn                                                                   ; +0x1a5, 0x140340d75", "xrefs": ["MusicDownloadManager::downloadMusicLibrary @ 0x140340af2", "<???> @ 0x1406d5774"], "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"}