{"type": "func", "start": 5373465360, "end": 5373466136, "name": "MusicDownloadManager::exportCustomSFXToFile", "pseudocode": "// \n// MusicDownloadManager::exportCustomSFXToFile from 0x140489310 to 0x140489618 (776 bytes)\n// \n// 3 xrefs:\n// > SFXBrowser::onExportFile @ 0x14061e0e6\n// > <???> @ 0x140928cdc\n// > <???> @ 0x140928ce8\n// \n// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!\n// \n// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA\n// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings\n// Generated at Fri, 27 Nov 2026 11:32:48 +0000\n// \n\n// Hidden C++ exception states: #wind=5\n__int64 __fastcall MusicDownloadManager::exportCustomSFXToFile(__int64 a1)\n{\n  _QWORD *v2; // rax\n  unsigned __int8 v3; // bl\n  __int64 v4; // rdx\n  __int64 v5; // rcx\n  __int64 v6; // r8\n  __int64 v7; // r9\n  __int64 v8; // rax\n  BOOL SaveFileNameA; // ebx\n  __int64 v10; // rdx\n  __int64 v11; // rcx\n  __int64 v12; // r8\n  __int64 v13; // r9\n  cocos2d::CCEGLView *v14; // rax\n  char v15; // bl\n  size_t v16; // r8\n  void *v17; // rcx\n  const char *v18; // rcx\n  FILE *v19; // rax\n  FILE *v20; // rbx\n  void **v21; // rcx\n  char *v22; // rcx\n  struct tagOFNA v24; // [rsp+30h] [rbp-D0h] BYREF\n  char Source[16]; // [rsp+D0h] [rbp-30h] BYREF\n  __m128i si128; // [rsp+E0h] [rbp-20h]\n  char *FileName[2]; // [rsp+F0h] [rbp-10h] BYREF\n  __int64 v28; // [rsp+100h] [rbp+0h]\n  unsigned __int64 v29; // [rsp+108h] [rbp+8h]\n  void *Buffer[2]; // [rsp+110h] [rbp+10h] BYREF\n  size_t ElementCount; // [rsp+120h] [rbp+20h]\n  unsigned __int64 v32; // [rsp+128h] [rbp+28h]\n  char Destination[272]; // [rsp+130h] [rbp+30h] BYREF\n\n  *(_OWORD *)Source = 0;\n  v2 = operator new(0x20u);\n  *v2 = v2;\n  v2[1] = v2;\n  v2[2] = v2;\n  *((_WORD *)v2 + 12) = 257;\n  *(_QWORD *)Source = v2;\n  MusicDownloadManager::encodeCustomSFX(a1, Buffer, Source);\n  sub_1400BD560((void **)Source, (__int64)Source);\n  if ( ElementCount )\n  {\n    *(_OWORD *)FileName = 0;\n    v29 = 15;\n    si128 = _mm_load_si128((const __m128i *)&xmmword_140836600);\n    strcpy(Source, \"customsfx.gdsfx\");\n    v28 = 0;\n    LOBYTE(FileName[0]) = 0;\n    memset(Destination, 0, 0x104u);\n    strncpy(Destination, Source, 0x103u);\n    memset(&v24.lStructSize + 1, 0, 148);\n    v24.lStructSize = 152;\n    v8 = cocos2d::CCEGLView::sharedOpenGLView(v5, v4, v6, v7);\n    v24.hwndOwner = (HWND)sub_140675620(*(_QWORD *)(v8 + 200));\n    v24.lpstrFilter = \"GD SFX Folder Files (*.gdsfx)\";\n    v24.lpstrFile = Destination;\n    v24.nMaxFile = 260;\n    v24.lpstrTitle = \"Export SFX Folders\";\n    v24.Flags = 10;\n    v24.lpstrDefExt = \"gdsfx\";\n    SaveFileNameA = GetSaveFileNameA(&v24);\n    v14 = (cocos2d::CCEGLView *)cocos2d::CCEGLView::sharedOpenGLView(v11, v10, v12, v13);\n    cocos2d::CCEGLView::clearQueuedInput(v14);\n    if ( SaveFileNameA )\n    {\n      v16 = -1;\n      do\n        ++v16;\n      while ( Destination[v16] );\n      sub_1400405A0((void **)FileName, Destination, v16);\n      v15 = 0;\n    }\n    else\n    {\n      v15 = 1;\n    }\n    if ( si128.m128i_i64[1] > 0xFuLL )\n    {\n      v17 = *(void **)Source;\n      if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )\n      {\n        v17 = *(void **)(*(_QWORD *)Source - 8LL);\n        if ( (unsigned __int64)(*(_QWORD *)Source - (_QWORD)v17 - 8LL) > 0x1F )\n          invoke_watson(nullptr, nullptr, nullptr, 0, 0);\n      }\n      j_j_free(v17);\n    }\n    if ( v15 )\n      goto LABEL_20;\n    v18 = (const char *)FileName;\n    if ( v29 > 0xF )\n      v18 = FileName[0];\n    v19 = fopen(v18, \"w\");\n    v20 = v19;\n    if ( !v19 )\n    {\nLABEL_20:\n      v3 = 0;\n    }\n    else\n    {\n      v21 = Buffer;\n      if ( v32 > 0xF )\n        v21 = (void **)Buffer[0];\n      fwrite(v21, 1u, ElementCount, v19);\n      fclose(v20);\n      v3 = 1;\n    }\n    if ( v29 > 0xF )\n    {\n      v22 = FileName[0];\n      if ( v29 + 1 >= 0x1000 )\n      {\n        v22 = *((char **)FileName[0] - 1);\n        if ( (unsigned __int64)(FileName[0] - v22 - 8) > 0x1F )\n          invoke_watson(nullptr, nullptr, nullptr, 0, 0);\n      }\n      j_j_free(v22);\n    }\n    v28 = 0;\n    v29 = 15;\n    LOBYTE(FileName[0]) = 0;\n  }\n  else\n  {\n    v3 = 0;\n  }\n  sub_14003D310((__int64)Buffer);\n  return v3;\n}", "assembly": "; \n; MusicDownloadManager::exportCustomSFXToFile from 0x140489310 to 0x140489618 (776 bytes)\n; \n; 3 xrefs:\n; > SFXBrowser::onExportFile @ 0x14061e0e6\n; > <???> @ 0x140928cdc\n; > <???> @ 0x140928ce8\n; \n; This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!\n; \n; Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA\n; Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings\n; Generated at Fri, 27 Nov 2026 11:32:48 +0000\n; \nmov     [rsp-8+arg_8], rbx                                             ; +0x0, 0x140489310\nmov     [rsp-8+arg_10], rdi                                            ; +0x5, 0x140489315\npush    rbp                                                            ; +0xa, 0x14048931a\nlea     rbp, [rsp-150h]                                                ; +0xb, 0x14048931b\nsub     rsp, 250h                                                      ; +0x13, 0x140489323\nmov     rax, cs:__security_cookie                                      ; +0x1a, 0x14048932a\nxor     rax, rsp                                                       ; +0x21, 0x140489331\nmov     [rbp+150h+var_10], rax                                         ; +0x24, 0x140489334\nmov     rbx, rcx                                                       ; +0x2b, 0x14048933b\nxorps   xmm0, xmm0                                                     ; +0x2e, 0x14048933e\nmovdqu  xmmword ptr [rbp+150h+Source], xmm0                            ; +0x31, 0x140489341\nmov     ecx, 20h ; ' '; Size                                           ; +0x36, 0x140489346\ncall    ??2@YAPEAX_K@Z; operator new(unsigned __int64)                 ; +0x3b, 0x14048934b\nmov     [rax], rax                                                     ; +0x40, 0x140489350\nmov     [rax+8], rax                                                   ; +0x43, 0x140489353\nmov     [rax+10h], rax                                                 ; +0x47, 0x140489357\nmov     word ptr [rax+18h], 101h                                       ; +0x4b, 0x14048935b\nmov     qword ptr [rbp+150h+Source], rax                               ; +0x51, 0x140489361\nlea     r8, [rbp+150h+Source]                                          ; +0x55, 0x140489365\nlea     rdx, [rbp+150h+Buffer]                                         ; +0x59, 0x140489369\nmov     rcx, rbx                                                       ; +0x5d, 0x14048936d\ncall    MusicDownloadManager__encodeCustomSFX                          ; +0x60, 0x140489370\nnop                                                                    ; +0x65, 0x140489375\nlea     rdx, [rbp+150h+Source]                                         ; +0x66, 0x140489376\nlea     rcx, [rbp+150h+Source]                                         ; +0x6a, 0x14048937a\ncall    sub_1400BD560                                                  ; +0x6e, 0x14048937e\ncmp     [rbp+150h+ElementCount], 0                                     ; +0x73, 0x140489383\njnz     short loc_140489391                                            ; +0x78, 0x140489388\nxor     bl, bl                                                         ; +0x7a, 0x14048938a\njmp     loc_1404895E8                                                  ; +0x7c, 0x14048938c\nxorps   xmm0, xmm0                                                     ; +0x81, 0x140489391\nmovups  xmmword ptr [rbp+150h+FileName], xmm0                          ; +0x84, 0x140489394\nmov     [rbp+150h+var_148], 0Fh                                        ; +0x88, 0x140489398\nmovups  xmmword ptr [rbp+150h+Source], xmm0                            ; +0x90, 0x1404893a0\nmovdqa  xmm1, cs:xmmword_140836600                                     ; +0x94, 0x1404893a4\nmovdqu  [rbp+150h+var_170], xmm1                                       ; +0x9c, 0x1404893ac\nmovsd   xmm0, cs:qword_1407B7FC8                                       ; +0xa1, 0x1404893b1\nmovsd   qword ptr [rbp+150h+Source], xmm0                              ; +0xa9, 0x1404893b9\nmov     eax, cs:dword_1407B7FD0                                        ; +0xae, 0x1404893be\nmov     dword ptr [rbp+150h+Source+8], eax                             ; +0xb4, 0x1404893c4\nmovzx   eax, cs:word_1407B7FD4                                         ; +0xb7, 0x1404893c7\nmov     word ptr [rbp+150h+Source+0Ch], ax                             ; +0xbe, 0x1404893ce\nmovzx   eax, cs:byte_1407B7FD6                                         ; +0xc2, 0x1404893d2\nmov     [rbp+150h+Source+0Eh], al                                      ; +0xc9, 0x1404893d9\nmov     [rbp+150h+Source+0Fh], 0                                       ; +0xcc, 0x1404893dc\nxor     edi, edi                                                       ; +0xd0, 0x1404893e0\nmov     [rbp+150h+var_150], rdi                                        ; +0xd2, 0x1404893e2\nmov     byte ptr [rbp+150h+FileName], dil                              ; +0xd6, 0x1404893e6\nxor     edx, edx; Val                                                  ; +0xda, 0x1404893ea\nmov     r8d, 104h; Size                                                ; +0xdc, 0x1404893ec\nlea     rcx, [rbp+150h+Destination]; void *                            ; +0xe2, 0x1404893f2\ncall    memset                                                         ; +0xe6, 0x1404893f6\nmov     r8d, 103h; Count                                               ; +0xeb, 0x1404893fb\nlea     rdx, [rbp+150h+Source]; Source                                 ; +0xf1, 0x140489401\nlea     rcx, [rbp+150h+Destination]; Destination                       ; +0xf5, 0x140489405\ncall    cs:strncpy                                                     ; +0xf9, 0x140489409\nxorps   xmm0, xmm0                                                     ; +0xff, 0x14048940f\nxor     eax, eax                                                       ; +0x102, 0x140489412\nmovups  xmmword ptr [rsp+250h+var_220+4], xmm0                         ; +0x104, 0x140489414\nmovups  xmmword ptr [rsp+250h+var_220.hInstance+4], xmm0               ; +0x109, 0x140489419\nmovups  xmmword ptr [rsp+250h+var_220.lpstrCustomFilter+4], xmm0       ; +0x10e, 0x14048941e\nmovups  xmmword ptr [rsp+250h+var_220.lpstrFile+4], xmm0               ; +0x113, 0x140489423\nmovups  xmmword ptr [rsp+250h+var_220.lpstrFileTitle+4], xmm0          ; +0x118, 0x140489428\nmovups  xmmword ptr [rbp+150h+var_220.lpstrInitialDir+4], xmm0         ; +0x11d, 0x14048942d\nmovups  xmmword ptr [rbp+150h+var_220.nFileOffset], xmm0               ; +0x121, 0x140489431\nmovups  xmmword ptr [rbp+150h+var_220.lCustData+4], xmm0               ; +0x125, 0x140489435\nmovups  xmmword ptr [rbp+150h+var_220.lpTemplateName+4], xmm0          ; +0x129, 0x140489439\nmov     [rbp+150h+var_220.FlagsEx], eax                                ; +0x12d, 0x14048943d\nmov     [rsp+250h+var_220.lStructSize], 98h                            ; +0x130, 0x140489440\ncall    cs:?sharedOpenGLView@CCEGLView@cocos2d@@SAPEAV12@XZ; cocos2d::CCEGLView::sharedOpenGLView(void) ; +0x138, 0x140489448\nmov     rcx, [rax+0C8h]                                                ; +0x13e, 0x14048944e\ncall    sub_140675620                                                  ; +0x145, 0x140489455\nmov     [rsp+250h+var_220.hwndOwner], rax                              ; +0x14a, 0x14048945a\nlea     rax, aGdSfxFolderFil; \"GD SFX Folder Files (*.gdsfx)\"          ; +0x14f, 0x14048945f\nmov     [rsp+250h+var_220.lpstrFilter], rax                            ; +0x156, 0x140489466\nlea     rax, [rbp+150h+Destination]                                    ; +0x15b, 0x14048946b\nmov     [rsp+250h+var_220.lpstrFile], rax                              ; +0x15f, 0x14048946f\nmov     [rsp+250h+var_220.nMaxFile], 104h                              ; +0x164, 0x140489474\nlea     rax, aExportSfxFolde; \"Export SFX Folders\"                     ; +0x16c, 0x14048947c\nmov     [rbp+150h+var_220.lpstrTitle], rax                             ; +0x173, 0x140489483\nmov     [rbp+150h+var_220.Flags], 0Ah                                  ; +0x177, 0x140489487\nlea     rax, aGdsfx; \"gdsfx\"                                           ; +0x17e, 0x14048948e\nmov     [rbp+150h+var_220.lpstrDefExt], rax                            ; +0x185, 0x140489495\nlea     rcx, [rsp+250h+var_220]; LPOPENFILENAMEA                       ; +0x189, 0x140489499\ncall    cs:GetSaveFileNameA                                            ; +0x18e, 0x14048949e\nmov     ebx, eax                                                       ; +0x194, 0x1404894a4\ncall    cs:?sharedOpenGLView@CCEGLView@cocos2d@@SAPEAV12@XZ; cocos2d::CCEGLView::sharedOpenGLView(void) ; +0x196, 0x1404894a6\nmov     rcx, rax                                                       ; +0x19c, 0x1404894ac\ncall    cs:?clearQueuedInput@CCEGLView@cocos2d@@QEAAXXZ; cocos2d::CCEGLView::clearQueuedInput(void) ; +0x19f, 0x1404894af\ntest    ebx, ebx                                                       ; +0x1a5, 0x1404894b5\njnz     short loc_1404894BD                                            ; +0x1a7, 0x1404894b7\nmov     bl, 1                                                          ; +0x1a9, 0x1404894b9\njmp     short loc_1404894E8                                            ; +0x1ab, 0x1404894bb\nlea     rax, [rbp+150h+Destination]                                    ; +0x1ad, 0x1404894bd\nmov     r8, 0FFFFFFFFFFFFFFFFh                                         ; +0x1b1, 0x1404894c1\nnop     dword ptr [rax+rax+00000000h]                                  ; +0x1b8, 0x1404894c8\ninc     r8; Size                                                       ; +0x1c0, 0x1404894d0\ncmp     [rax+r8], dil                                                  ; +0x1c3, 0x1404894d3\njnz     short loc_1404894D0                                            ; +0x1c7, 0x1404894d7\nlea     rdx, [rbp+150h+Destination]; Src                               ; +0x1c9, 0x1404894d9\nlea     rcx, [rbp+150h+FileName]; void *                               ; +0x1cd, 0x1404894dd\ncall    sub_1400405A0                                                  ; +0x1d1, 0x1404894e1\nxor     bl, bl                                                         ; +0x1d6, 0x1404894e6\nmov     rdx, qword ptr [rbp+150h+var_170+8]                            ; +0x1d8, 0x1404894e8\ncmp     rdx, 0Fh                                                       ; +0x1dc, 0x1404894ec\njbe     short loc_140489535                                            ; +0x1e0, 0x1404894f0\ninc     rdx                                                            ; +0x1e2, 0x1404894f2\nmov     rcx, qword ptr [rbp+150h+Source]; Block                        ; +0x1e5, 0x1404894f5\nmov     rax, rcx                                                       ; +0x1e9, 0x1404894f9\ncmp     rdx, 1000h                                                     ; +0x1ec, 0x1404894fc\njb      short loc_140489530                                            ; +0x1f3, 0x140489503\nadd     rdx, 27h ; '''                                                 ; +0x1f5, 0x140489505\nmov     rcx, [rcx-8]                                                   ; +0x1f9, 0x140489509\nsub     rax, rcx                                                       ; +0x1fd, 0x14048950d\nsub     rax, 8                                                         ; +0x200, 0x140489510\ncmp     rax, 1Fh                                                       ; +0x204, 0x140489514\njbe     short loc_140489530                                            ; +0x208, 0x140489518\nmov     [rsp+250h+Reserved], rdi; Reserved                             ; +0x20a, 0x14048951a\nxor     r9d, r9d; LineNo                                               ; +0x20f, 0x14048951f\nxor     r8d, r8d; FileName                                             ; +0x212, 0x140489522\nxor     edx, edx; FunctionName                                         ; +0x215, 0x140489525\nxor     ecx, ecx; Expression                                           ; +0x217, 0x140489527\ncall    cs:_invoke_watson                                              ; +0x219, 0x140489529\nalign 10h                                                              ; +0x21f, 0x14048952f\ncall    j_j_free                                                       ; +0x220, 0x140489530\ntest    bl, bl                                                         ; +0x225, 0x140489535\njnz     short loc_140489589                                            ; +0x227, 0x140489537\nlea     rcx, [rbp+150h+FileName]                                       ; +0x229, 0x140489539\ncmp     [rbp+150h+var_148], 0Fh                                        ; +0x22d, 0x14048953d\ncmova   rcx, [rbp+150h+FileName]; FileName                             ; +0x232, 0x140489542\nlea     rdx, Mode; \"w\"                                                 ; +0x237, 0x140489547\ncall    cs:fopen                                                       ; +0x23e, 0x14048954e\nmov     rbx, rax                                                       ; +0x244, 0x140489554\ntest    rax, rax                                                       ; +0x247, 0x140489557\njz      short loc_140489589                                            ; +0x24a, 0x14048955a\nlea     rcx, [rbp+150h+Buffer]                                         ; +0x24c, 0x14048955c\ncmp     [rbp+150h+var_128], 0Fh                                        ; +0x250, 0x140489560\ncmova   rcx, [rbp+150h+Buffer]; Buffer                                 ; +0x255, 0x140489565\nmov     r9, rax; Stream                                                ; +0x25a, 0x14048956a\nmov     r8, [rbp+150h+ElementCount]; ElementCount                      ; +0x25d, 0x14048956d\nmov     edx, 1; ElementSize                                            ; +0x261, 0x140489571\ncall    cs:fwrite                                                      ; +0x266, 0x140489576\nmov     rcx, rbx; Stream                                               ; +0x26c, 0x14048957c\ncall    cs:fclose                                                      ; +0x26f, 0x14048957f\nmov     bl, 1                                                          ; +0x275, 0x140489585\njmp     short loc_14048958B                                            ; +0x277, 0x140489587\nxor     bl, bl                                                         ; +0x279, 0x140489589\nmov     rdx, [rbp+150h+var_148]                                        ; +0x27b, 0x14048958b\ncmp     rdx, 0Fh                                                       ; +0x27f, 0x14048958f\njbe     short loc_1404895D8                                            ; +0x283, 0x140489593\ninc     rdx                                                            ; +0x285, 0x140489595\nmov     rcx, [rbp+150h+FileName]; Block                                ; +0x288, 0x140489598\nmov     rax, rcx                                                       ; +0x28c, 0x14048959c\ncmp     rdx, 1000h                                                     ; +0x28f, 0x14048959f\njb      short loc_1404895D3                                            ; +0x296, 0x1404895a6\nadd     rdx, 27h ; '''                                                 ; +0x298, 0x1404895a8\nmov     rcx, [rcx-8]                                                   ; +0x29c, 0x1404895ac\nsub     rax, rcx                                                       ; +0x2a0, 0x1404895b0\nsub     rax, 8                                                         ; +0x2a3, 0x1404895b3\ncmp     rax, 1Fh                                                       ; +0x2a7, 0x1404895b7\njbe     short loc_1404895D3                                            ; +0x2ab, 0x1404895bb\nmov     [rsp+250h+Reserved], rdi; Reserved                             ; +0x2ad, 0x1404895bd\nxor     r9d, r9d; LineNo                                               ; +0x2b2, 0x1404895c2\nxor     r8d, r8d; FileName                                             ; +0x2b5, 0x1404895c5\nxor     edx, edx; FunctionName                                         ; +0x2b8, 0x1404895c8\nxor     ecx, ecx; Expression                                           ; +0x2ba, 0x1404895ca\ncall    cs:_invoke_watson                                              ; +0x2bc, 0x1404895cc\ndb 0CCh                                                                ; +0x2c2, 0x1404895d2\ncall    j_j_free                                                       ; +0x2c3, 0x1404895d3\nmov     [rbp+150h+var_150], rdi                                        ; +0x2c8, 0x1404895d8\nmov     [rbp+150h+var_148], 0Fh                                        ; +0x2cc, 0x1404895dc\nmov     byte ptr [rbp+150h+FileName], 0                                ; +0x2d4, 0x1404895e4\nlea     rcx, [rbp+150h+Buffer]                                         ; +0x2d8, 0x1404895e8\ncall    sub_14003D310                                                  ; +0x2dc, 0x1404895ec\nmovzx   eax, bl                                                        ; +0x2e1, 0x1404895f1\nmov     rcx, [rbp+150h+var_10]                                         ; +0x2e4, 0x1404895f4\nxor     rcx, rsp; StackCookie                                          ; +0x2eb, 0x1404895fb\ncall    __security_check_cookie                                        ; +0x2ee, 0x1404895fe\nlea     r11, [rsp+250h+var_s0]                                         ; +0x2f3, 0x140489603\nmov     rbx, [r11+18h]                                                 ; +0x2fb, 0x14048960b\nmov     rdi, [r11+20h]                                                 ; +0x2ff, 0x14048960f\nmov     rsp, r11                                                       ; +0x303, 0x140489613\npop     rbp                                                            ; +0x306, 0x140489616\nretn                                                                   ; +0x307, 0x140489617", "xrefs": ["SFXBrowser::onExportFile @ 0x14061e0e6", "<???> @ 0x140928cdc", "<???> @ 0x140928ce8"], "is_objc": false, "is_32_bit": false, "is_64_bit": true, "idp_name": "pc", "bida_info": "8.3.0 @ https://github.com/Stazzical/BromaIDA", "bindings_info": "commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings"}