{"type": "func", "start": 5370117488, "end": 5370118199, "name": "GameLevelManager::onGetLeaderboardScoresCompleted", "pseudocode": "// \n// GameLevelManager::onGetLeaderboardScoresCompleted from 0x140157d70 to 0x140158037 (711 bytes)\n// \n// 2 xrefs:\n// > GameLevelManager::handleIt @ 0x140143386\n// > <???> @ 0x1406ca980\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 __fastcall GameLevelManager::onGetLeaderboardScoresCompleted(GameLevelManager *a1, const void **a2, __int64 *a3)\n{\n  const char *v6; // r15\n  cocos2d::CCArray *v7; // rbx\n  int v8; // edi\n  cocos2d::CCString *v9; // rax\n  int v10; // r12d\n  cocos2d::CCString *v11; // rax\n  int v12; // eax\n  int v13; // ebx\n  const void *v14; // rcx\n  size_t v15; // r8\n  LeaderboardManagerDelegate *m_leaderboardManagerDelegate; // rcx\n  const void **v17; // rax\n  cocos2d::CCArray *Scores; // rdi\n  cocos2d::ccArray *data; // rcx\n  __int64 num; // rax\n  cocos2d::CCObject **arr; // rcx\n  cocos2d::CCObject **i; // rdx\n  int v23; // ebx\n  int v24; // ebx\n  int (__cdecl *v25)(const void *, const void *); // r9\n  int v26; // edx\n  cocos2d::ccArray *v27; // rcx\n  __int64 v28; // rax\n  cocos2d::CCObject **v29; // rcx\n  cocos2d::CCObject **j; // r8\n  LeaderboardManagerDelegate *v31; // rcx\n  char v32[32]; // [rsp+28h] [rbp-90h] BYREF\n  const void **v33; // [rsp+48h] [rbp-70h]\n  __int64 *v34; // [rsp+50h] [rbp-68h]\n  __int128 Buf2; // [rsp+58h] [rbp-60h] BYREF\n  __int64 v36; // [rsp+68h] [rbp-50h]\n  __int64 v37; // [rsp+70h] [rbp-48h]\n\n  v33 = a2;\n  v34 = a3;\n  v6 = (const char *)a3;\n  if ( (unsigned __int64)a3[3] > 0xF )\n    v6 = (const char *)*a3;\n  GameLevelManager::removeDLFromActive(a1, v6);\n  v7 = sub_140140F70(a3, \"_\");\n  v8 = 0;\n  if ( cocos2d::CCArray::count(v7) == 3 )\n  {\n    v9 = cocos2d::CCArray::stringAtIndex(v7, 1u);\n    v10 = cocos2d::CCString::intValue(v9);\n  }\n  else\n  {\n    v10 = 0;\n  }\n  if ( cocos2d::CCArray::count(v7) == 3 )\n  {\n    v11 = cocos2d::CCArray::stringAtIndex(v7, 2u);\n    v12 = cocos2d::CCString::intValue(v11);\n  }\n  else\n  {\n    v12 = 0;\n  }\n  v13 = 0;\n  if ( v10 != 3 )\n    v13 = v12;\n  Buf2 = 0;\n  v36 = 2;\n  v37 = 15;\n  strcpy((char *)&Buf2, \"-1\");\n  v14 = a2;\n  if ( (unsigned __int64)a2[3] > 0xF )\n    v14 = *a2;\n  v15 = (size_t)a2[2];\n  if ( v15 > 2 )\n    v15 = 2;\n  if ( !memcmp(v14, &Buf2, v15) && a2[2] == (const void *)2 )\n  {\n    m_leaderboardManagerDelegate = a1->m_leaderboardManagerDelegate;\n    if ( m_leaderboardManagerDelegate )\n      m_leaderboardManagerDelegate->loadLeaderboardFailed(m_leaderboardManagerDelegate, v6);\n  }\n  else\n  {\n    v17 = (const void **)sub_14003BDB0((__int64)v32, (__int64)a2);\n    LOBYTE(v8) = v10 == 3;\n    Scores = (cocos2d::CCArray *)GameLevelManager::createAndGetScores((__int64)a1, v17, v8);\n    if ( cocos2d::CCArray::count(Scores) )\n    {\n      if ( v13 )\n      {\n        if ( Scores )\n        {\n          data = Scores->data;\n          num = data->num;\n          if ( (_DWORD)num )\n          {\n            arr = data->arr;\n            for ( i = &arr[num - 1]; arr <= i; ++arr )\n            {\n              if ( !*arr )\n                break;\n              (*arr)[16].m_nTag = v13;\n            }\n          }\n        }\n      }\n    }\n    if ( cocos2d::CCArray::count(Scores) && v10 == 4 )\n    {\n      v23 = v13 - 1;\n      if ( v23 )\n      {\n        v24 = v23 - 1;\n        if ( v24 )\n          v25 = v24 == 1\n              ? (int (__cdecl *)(const void *, const void *))sub_140142B00\n              : (int (__cdecl *)(const void *, const void *))sub_140142A00;\n        else\n          v25 = (int (__cdecl *)(const void *, const void *))sub_140142AD0;\n      }\n      else\n      {\n        v25 = (int (__cdecl *)(const void *, const void *))sub_140142AA0;\n      }\n      qsort(Scores->data->arr, Scores->data->num, 8u, v25);\n      v26 = 1;\n      if ( Scores )\n      {\n        v27 = Scores->data;\n        v28 = v27->num;\n        if ( (_DWORD)v28 )\n        {\n          v29 = v27->arr;\n          for ( j = &v29[v28 - 1]; v29 <= j; ++v29 )\n          {\n            if ( !*v29 )\n              break;\n            (*v29)[7].m_uReference = v26++;\n          }\n        }\n      }\n    }\n    Buf2 = 0;\n    v36 = 1;\n    v37 = 15;\n    LOWORD(Buf2) = 32;\n    GameLevelManager::storeSearchResult(a1, (__int64)Scores, &Buf2, v6);\n    v31 = a1->m_leaderboardManagerDelegate;\n    if ( v31 )\n      v31->loadLeaderboardFinished(v31, Scores, v6);\n  }\n  sub_14003A830((__int64)a2);\n  sub_14003A830((__int64)a3);\n}", "assembly": "; \n; GameLevelManager::onGetLeaderboardScoresCompleted from 0x140157d70 to 0x140158037 (711 bytes)\n; \n; 2 xrefs:\n; > GameLevelManager::handleIt @ 0x140143386\n; > <???> @ 0x1406ca980\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\npush    rbx                                                            ; +0x0, 0x140157d70\npush    rsi                                                            ; +0x2, 0x140157d72\npush    rdi                                                            ; +0x3, 0x140157d73\npush    r12                                                            ; +0x4, 0x140157d74\npush    r13                                                            ; +0x6, 0x140157d76\npush    r14                                                            ; +0x8, 0x140157d78\npush    r15                                                            ; +0xa, 0x140157d7a\nsub     rsp, 80h                                                       ; +0xc, 0x140157d7c\nmov     rax, cs:__security_cookie                                      ; +0x13, 0x140157d83\nxor     rax, rsp                                                       ; +0x1a, 0x140157d8a\nmov     [rsp+0B8h+var_40], rax                                         ; +0x1d, 0x140157d8d\nmov     rsi, r8                                                        ; +0x22, 0x140157d92\nmov     r14, rdx                                                       ; +0x25, 0x140157d95\nmov     r13, rcx                                                       ; +0x28, 0x140157d98\nmov     [rsp+0B8h+var_70], rdx                                         ; +0x2b, 0x140157d9b\nmov     [rsp+0B8h+var_68], r8                                          ; +0x30, 0x140157da0\nmov     r15, r8                                                        ; +0x35, 0x140157da5\ncmp     qword ptr [r8+18h], 0Fh                                        ; +0x38, 0x140157da8\njbe     short loc_140157DB2                                            ; +0x3d, 0x140157dad\nmov     r15, [r8]                                                      ; +0x3f, 0x140157daf\nmov     rdx, r15                                                       ; +0x42, 0x140157db2\ncall    GameLevelManager__removeDLFromActive                           ; +0x45, 0x140157db5\nlea     rdx, asc_140537224; \"_\"                                        ; +0x4a, 0x140157dba\nmov     rcx, rsi                                                       ; +0x51, 0x140157dc1\ncall    sub_140140F70                                                  ; +0x54, 0x140157dc4\nmov     rbx, rax                                                       ; +0x59, 0x140157dc9\nmov     rcx, rax                                                       ; +0x5c, 0x140157dcc\ncall    cs:?count@CCArray@cocos2d@@QEBAIXZ; cocos2d::CCArray::count(void) ; +0x5f, 0x140157dcf\nxor     edi, edi                                                       ; +0x65, 0x140157dd5\ncmp     eax, 3                                                         ; +0x67, 0x140157dd7\njnz     short loc_140157DF6                                            ; +0x6a, 0x140157dda\nlea     edx, [rdi+1]                                                   ; +0x6c, 0x140157ddc\nmov     rcx, rbx                                                       ; +0x6f, 0x140157ddf\ncall    cs:?stringAtIndex@CCArray@cocos2d@@QEAAPEAVCCString@2@I@Z; cocos2d::CCArray::stringAtIndex(uint) ; +0x72, 0x140157de2\nmov     rcx, rax                                                       ; +0x78, 0x140157de8\ncall    cs:?intValue@CCString@cocos2d@@QEBAHXZ; cocos2d::CCString::intValue(void) ; +0x7b, 0x140157deb\nmov     r12d, eax                                                      ; +0x81, 0x140157df1\njmp     short loc_140157DF9                                            ; +0x84, 0x140157df4\nmov     r12d, edi                                                      ; +0x86, 0x140157df6\nmov     rcx, rbx                                                       ; +0x89, 0x140157df9\ncall    cs:?count@CCArray@cocos2d@@QEBAIXZ; cocos2d::CCArray::count(void) ; +0x8c, 0x140157dfc\nmov     edx, 2                                                         ; +0x92, 0x140157e02\ncmp     eax, 3                                                         ; +0x97, 0x140157e07\njnz     short loc_140157E25                                            ; +0x9a, 0x140157e0a\nmov     rcx, rbx                                                       ; +0x9c, 0x140157e0c\ncall    cs:?stringAtIndex@CCArray@cocos2d@@QEAAPEAVCCString@2@I@Z; cocos2d::CCArray::stringAtIndex(uint) ; +0x9f, 0x140157e0f\nmov     rcx, rax                                                       ; +0xa5, 0x140157e15\ncall    cs:?intValue@CCString@cocos2d@@QEBAHXZ; cocos2d::CCString::intValue(void) ; +0xa8, 0x140157e18\nmov     edx, 2                                                         ; +0xae, 0x140157e1e\njmp     short loc_140157E27                                            ; +0xb3, 0x140157e23\nmov     eax, edi                                                       ; +0xb5, 0x140157e25\nmov     ebx, edi                                                       ; +0xb7, 0x140157e27\ncmp     r12d, 3                                                        ; +0xb9, 0x140157e29\ncmovnz  ebx, eax                                                       ; +0xbd, 0x140157e2d\nxorps   xmm0, xmm0                                                     ; +0xc0, 0x140157e30\nmovups  [rsp+0B8h+Buf2], xmm0                                          ; +0xc3, 0x140157e33\nmov     [rsp+0B8h+var_50], rdx                                         ; +0xc8, 0x140157e38\nmov     [rsp+0B8h+var_48], 0Fh                                         ; +0xcd, 0x140157e3d\nmov     eax, 312Dh                                                     ; +0xd6, 0x140157e46\nmov     word ptr [rsp+0B8h+Buf2], ax                                   ; +0xdb, 0x140157e4b\nmov     byte ptr [rsp+0B8h+Buf2+2], dil                                ; +0xe0, 0x140157e50\nmov     rcx, r14                                                       ; +0xe5, 0x140157e55\ncmp     qword ptr [r14+18h], 0Fh                                       ; +0xe8, 0x140157e58\njbe     short loc_140157E62                                            ; +0xed, 0x140157e5d\nmov     rcx, [r14]; Buf1                                               ; +0xef, 0x140157e5f\nmov     r8, [r14+10h]                                                  ; +0xf2, 0x140157e62\ncmp     r8, 2                                                          ; +0xf6, 0x140157e66\ncmova   r8, rdx; Size                                                  ; +0xfa, 0x140157e6a\nlea     rdx, [rsp+0B8h+Buf2]; Buf2                                     ; +0xfe, 0x140157e6e\ncall    memcmp                                                         ; +0x103, 0x140157e73\ntest    eax, eax                                                       ; +0x108, 0x140157e78\njnz     short loc_140157EA1                                            ; +0x10a, 0x140157e7a\ncmp     qword ptr [r14+10h], 2                                         ; +0x10c, 0x140157e7c\njnz     short loc_140157EA1                                            ; +0x111, 0x140157e81\nmov     rcx, [r13+308h]                                                ; +0x113, 0x140157e83\ntest    rcx, rcx                                                       ; +0x11a, 0x140157e8a\njz      loc_140158006                                                  ; +0x11d, 0x140157e8d\nmov     rax, [rcx]                                                     ; +0x123, 0x140157e93\nmov     rdx, r15                                                       ; +0x126, 0x140157e96\ncall    qword ptr [rax+18h]                                            ; +0x129, 0x140157e99\njmp     loc_140158006                                                  ; +0x12c, 0x140157e9c\nmov     rdx, r14                                                       ; +0x131, 0x140157ea1\nlea     rcx, [rsp+0B8h+var_90]                                         ; +0x134, 0x140157ea4\ncall    sub_14003BDB0                                                  ; +0x139, 0x140157ea9\ncmp     r12d, 3                                                        ; +0x13e, 0x140157eae\nsetz    dil                                                            ; +0x142, 0x140157eb2\nmov     r8d, edi                                                       ; +0x146, 0x140157eb6\nmov     rdx, rax                                                       ; +0x149, 0x140157eb9\nmov     rcx, r13                                                       ; +0x14c, 0x140157ebc\ncall    GameLevelManager__createAndGetScores                           ; +0x14f, 0x140157ebf\nmov     rdi, rax                                                       ; +0x154, 0x140157ec4\nmov     rcx, rax                                                       ; +0x157, 0x140157ec7\ncall    cs:?count@CCArray@cocos2d@@QEBAIXZ; cocos2d::CCArray::count(void) ; +0x15a, 0x140157eca\ntest    eax, eax                                                       ; +0x160, 0x140157ed0\njz      short loc_140157F0F                                            ; +0x162, 0x140157ed2\ntest    ebx, ebx                                                       ; +0x164, 0x140157ed4\njz      short loc_140157F0F                                            ; +0x166, 0x140157ed6\ntest    rdi, rdi                                                       ; +0x168, 0x140157ed8\njz      short loc_140157F0F                                            ; +0x16b, 0x140157edb\nmov     rcx, [rdi+38h]                                                 ; +0x16d, 0x140157edd\nmov     eax, [rcx]                                                     ; +0x171, 0x140157ee1\ntest    eax, eax                                                       ; +0x173, 0x140157ee3\njz      short loc_140157F0F                                            ; +0x175, 0x140157ee5\nmov     rcx, [rcx+10h]                                                 ; +0x177, 0x140157ee7\nlea     rdx, [rax-1]                                                   ; +0x17b, 0x140157eeb\nlea     rdx, [rcx+rdx*8]                                               ; +0x17f, 0x140157eef\ncmp     rcx, rdx                                                       ; +0x183, 0x140157ef3\nja      short loc_140157F0F                                            ; +0x186, 0x140157ef6\nmov     rax, [rcx]                                                     ; +0x188, 0x140157ef8\ntest    rax, rax                                                       ; +0x18b, 0x140157efb\njz      short loc_140157F0F                                            ; +0x18e, 0x140157efe\nmov     [rax+390h], ebx                                                ; +0x190, 0x140157f00\nadd     rcx, 8                                                         ; +0x196, 0x140157f06\ncmp     rcx, rdx                                                       ; +0x19a, 0x140157f0a\njbe     short loc_140157EF8                                            ; +0x19d, 0x140157f0d\nmov     rcx, rdi                                                       ; +0x19f, 0x140157f0f\ncall    cs:?count@CCArray@cocos2d@@QEBAIXZ; cocos2d::CCArray::count(void) ; +0x1a2, 0x140157f12\ntest    eax, eax                                                       ; +0x1a8, 0x140157f18\njz      loc_140157FB9                                                  ; +0x1aa, 0x140157f1a\ncmp     r12d, 4                                                        ; +0x1b0, 0x140157f20\njnz     loc_140157FB9                                                  ; +0x1b4, 0x140157f24\nmov     rax, [rdi+38h]                                                 ; +0x1ba, 0x140157f2a\nmov     edx, [rax]; NumOfElements                                      ; +0x1be, 0x140157f2e\nmov     rcx, [rax+10h]; Base                                           ; +0x1c0, 0x140157f30\nsub     ebx, 1                                                         ; +0x1c4, 0x140157f34\njz      short loc_140157F63                                            ; +0x1c7, 0x140157f37\nsub     ebx, 1                                                         ; +0x1c9, 0x140157f39\njz      short loc_140157F5A                                            ; +0x1cc, 0x140157f3c\nlea     r8d, [r12+4]                                                   ; +0x1ce, 0x140157f3e\ncmp     ebx, 1                                                         ; +0x1d3, 0x140157f43\njz      short loc_140157F51                                            ; +0x1d6, 0x140157f46\nlea     r9, sub_140142A00                                              ; +0x1d8, 0x140157f48\njmp     short loc_140157F70                                            ; +0x1df, 0x140157f4f\nlea     r9, sub_140142B00                                              ; +0x1e1, 0x140157f51\njmp     short loc_140157F70                                            ; +0x1e8, 0x140157f58\nlea     r9, sub_140142AD0                                              ; +0x1ea, 0x140157f5a\njmp     short loc_140157F6A                                            ; +0x1f1, 0x140157f61\nlea     r9, sub_140142AA0; CompareFunction                             ; +0x1f3, 0x140157f63\nmov     r8d, 8; SizeOfElements                                         ; +0x1fa, 0x140157f6a\ncall    cs:qsort                                                       ; +0x200, 0x140157f70\nmov     edx, 1                                                         ; +0x206, 0x140157f76\ntest    rdi, rdi                                                       ; +0x20b, 0x140157f7b\njz      short loc_140157FB9                                            ; +0x20e, 0x140157f7e\nmov     rcx, [rdi+38h]                                                 ; +0x210, 0x140157f80\nmov     eax, [rcx]                                                     ; +0x214, 0x140157f84\ntest    eax, eax                                                       ; +0x216, 0x140157f86\njz      short loc_140157FB9                                            ; +0x218, 0x140157f88\nmov     rcx, [rcx+10h]                                                 ; +0x21a, 0x140157f8a\nlea     r8, [rax-1]                                                    ; +0x21e, 0x140157f8e\nlea     r8, [rcx+r8*8]                                                 ; +0x222, 0x140157f92\ncmp     rcx, r8                                                        ; +0x226, 0x140157f96\nja      short loc_140157FB9                                            ; +0x229, 0x140157f99\nnop     dword ptr [rax+rax+00h]                                        ; +0x22b, 0x140157f9b\nmov     rax, [rcx]                                                     ; +0x230, 0x140157fa0\ntest    rax, rax                                                       ; +0x233, 0x140157fa3\njz      short loc_140157FB9                                            ; +0x236, 0x140157fa6\nmov     [rax+19Ch], edx                                                ; +0x238, 0x140157fa8\ninc     edx                                                            ; +0x23e, 0x140157fae\nadd     rcx, 8                                                         ; +0x240, 0x140157fb0\ncmp     rcx, r8                                                        ; +0x244, 0x140157fb4\njbe     short loc_140157FA0                                            ; +0x247, 0x140157fb7\nxorps   xmm0, xmm0                                                     ; +0x249, 0x140157fb9\nmovups  [rsp+0B8h+Buf2], xmm0                                          ; +0x24c, 0x140157fbc\nmov     [rsp+0B8h+var_50], 1                                           ; +0x251, 0x140157fc1\nmov     [rsp+0B8h+var_48], 0Fh                                         ; +0x25a, 0x140157fca\nmov     word ptr [rsp+0B8h+Buf2], 20h ; ' '                            ; +0x263, 0x140157fd3\nmov     r9, r15                                                        ; +0x26a, 0x140157fda\nlea     r8, [rsp+0B8h+Buf2]                                            ; +0x26d, 0x140157fdd\nmov     rdx, rdi                                                       ; +0x272, 0x140157fe2\nmov     rcx, r13                                                       ; +0x275, 0x140157fe5\ncall    GameLevelManager__storeSearchResult                            ; +0x278, 0x140157fe8\nmov     rcx, [r13+308h]                                                ; +0x27d, 0x140157fed\ntest    rcx, rcx                                                       ; +0x284, 0x140157ff4\njz      short loc_140158006                                            ; +0x287, 0x140157ff7\nmov     rax, [rcx]                                                     ; +0x289, 0x140157ff9\nmov     r8, r15                                                        ; +0x28c, 0x140157ffc\nmov     rdx, rdi                                                       ; +0x28f, 0x140157fff\ncall    qword ptr [rax+10h]                                            ; +0x292, 0x140158002\nnop                                                                    ; +0x295, 0x140158005\nmov     rcx, r14                                                       ; +0x296, 0x140158006\ncall    sub_14003A830                                                  ; +0x299, 0x140158009\nnop                                                                    ; +0x29e, 0x14015800e\nmov     rcx, rsi                                                       ; +0x29f, 0x14015800f\ncall    sub_14003A830                                                  ; +0x2a2, 0x140158012\nmov     rcx, [rsp+0B8h+var_40]                                         ; +0x2a7, 0x140158017\nxor     rcx, rsp; StackCookie                                          ; +0x2ac, 0x14015801c\ncall    __security_check_cookie                                        ; +0x2af, 0x14015801f\nadd     rsp, 80h                                                       ; +0x2b4, 0x140158024\npop     r15                                                            ; +0x2bb, 0x14015802b\npop     r14                                                            ; +0x2bd, 0x14015802d\npop     r13                                                            ; +0x2bf, 0x14015802f\npop     r12                                                            ; +0x2c1, 0x140158031\npop     rdi                                                            ; +0x2c3, 0x140158033\npop     rsi                                                            ; +0x2c4, 0x140158034\npop     rbx                                                            ; +0x2c5, 0x140158035\nretn                                                                   ; +0x2c6, 0x140158036", "xrefs": ["GameLevelManager::handleIt @ 0x140143386", "<???> @ 0x1406ca980"], "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"}