{"type": "func", "start": 5369170304, "end": 5369170638, "name": "GameToolbox::gen_random", "pseudocode": "// \n// GameToolbox::gen_random from 0x140070980 to 0x140070ace (334 bytes)\n// \n// 11 xrefs:\n// > GameLevelManager::createNewLevel @ 0x14021c117\n// > sub_140222BE0 @ 0x140222c34\n// > GameLevelManager::writePlatformerSaveJournal @ 0x1402234f4\n// > GameLevelManager::replayPlatformerSaveJournal @ 0x1402239a1\n// > GJGameLevel::dataLoaded @ 0x140268eb6\n// > GJGameLevel::encodeWithCoder @ 0x14026a4c8\n// > GJMultiplayerManager::uploadComment @ 0x1403913b5\n// > LevelEditorLayer::doAutoSave @ 0x1404092fb\n// > LevelEditorLayer::doAutoBackup @ 0x14040984d\n// > LocalLevelManager::tryRecoverAutoSaves @ 0x14046d588\n// > <???> @ 0x140911804\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:25:49 +0000\n// \n\n// Hidden C++ exception states: #wind=2\nvoid **__fastcall GameToolbox::gen_random(void **Src, unsigned int a2)\n{\n  __int64 v2; // rdi\n  unsigned int v4; // eax\n  unsigned __int64 i; // r8\n  unsigned __int64 v6; // rdx\n\n  v2 = a2;\n  if ( dword_14090C0CC > *(_DWORD *)(*(_QWORD *)NtCurrentTeb()->ThreadLocalStoragePointer + 4LL) )\n  {\n    sub_140677B5C(&dword_14090C0CC);\n    if ( dword_14090C0CC == -1 )\n    {\n      v4 = std::_Random_device();\n      dword_14090D454 = -1;\n      dword_14090C0D4 = v4;\n      for ( i = 1; i < 0x270; ++i )\n      {\n        v4 = i + 1812433253 * (v4 ^ (v4 >> 30));\n        dword_14090C0D0[i + 1] = v4;\n      }\n      dword_14090C0D0[0] = 624;\n      Init_thread_footer(&dword_14090C0CC);\n    }\n  }\n  *(_OWORD *)Src = 0;\n  Src[2] = nullptr;\n  Src[3] = (void *)15;\n  *(_BYTE *)Src = 0;\n  sub_140059AB0(Src, (int)v2);\n  if ( (int)v2 > 0 )\n  {\n    do\n    {\n      v6 = 62LL * (unsigned int)sub_1400768C0(dword_14090C0D0);\n      if ( (unsigned int)v6 <= 3 )\n      {\n        do\n          v6 = 62LL * (unsigned int)sub_1400768C0(dword_14090C0D0);\n        while ( (unsigned int)v6 < 4 );\n      }\n      sub_14003DBD0(Src, a0123456789abcd[(HIDWORD(v6) - 0x80000000) ^ 0xFFFFFFFF80000000uLL]);\n      --v2;\n    }\n    while ( v2 );\n  }\n  return Src;\n}", "assembly": "; \n; GameToolbox::gen_random from 0x140070980 to 0x140070ace (334 bytes)\n; \n; 11 xrefs:\n; > GameLevelManager::createNewLevel @ 0x14021c117\n; > sub_140222BE0 @ 0x140222c34\n; > GameLevelManager::writePlatformerSaveJournal @ 0x1402234f4\n; > GameLevelManager::replayPlatformerSaveJournal @ 0x1402239a1\n; > GJGameLevel::dataLoaded @ 0x140268eb6\n; > GJGameLevel::encodeWithCoder @ 0x14026a4c8\n; > GJMultiplayerManager::uploadComment @ 0x1403913b5\n; > LevelEditorLayer::doAutoSave @ 0x1404092fb\n; > LevelEditorLayer::doAutoBackup @ 0x14040984d\n; > LocalLevelManager::tryRecoverAutoSaves @ 0x14046d588\n; > <???> @ 0x140911804\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:25:49 +0000\n; \nmov     [rsp+arg_8], rbx                                               ; +0x0, 0x140070980\nmov     [rsp+arg_10], rbp                                              ; +0x5, 0x140070985\nmov     [rsp+arg_0], rcx                                               ; +0xa, 0x14007098a\npush    rsi                                                            ; +0xf, 0x14007098f\npush    rdi                                                            ; +0x10, 0x140070990\npush    r14                                                            ; +0x11, 0x140070991\nsub     rsp, 30h                                                       ; +0x13, 0x140070993\nmov     edi, edx                                                       ; +0x17, 0x140070997\nmov     rbx, rcx                                                       ; +0x19, 0x140070999\nxor     ebp, ebp                                                       ; +0x1c, 0x14007099c\nmov     [rsp+48h+var_28], ebp                                          ; +0x1e, 0x14007099e\nmov     ecx, 4                                                         ; +0x22, 0x1400709a2\nmov     rax, gs:58h                                                    ; +0x27, 0x1400709a7\nmov     rax, [rax]                                                     ; +0x30, 0x1400709b0\nlea     rsi, dword_14090C0D0                                           ; +0x33, 0x1400709b3\nmov     eax, [rcx+rax]                                                 ; +0x3a, 0x1400709ba\ncmp     cs:dword_14090C0CC, eax                                        ; +0x3d, 0x1400709bd\njle     short loc_140070A37                                            ; +0x43, 0x1400709c3\nlea     rcx, dword_14090C0CC                                           ; +0x45, 0x1400709c5\ncall    sub_140677B5C                                                  ; +0x4c, 0x1400709cc\ncmp     cs:dword_14090C0CC, 0FFFFFFFFh                                 ; +0x51, 0x1400709d1\njnz     short loc_140070A37                                            ; +0x58, 0x1400709d8\ncall    cs:?_Random_device@std@@YAIXZ; std::_Random_device(void)       ; +0x5a, 0x1400709da\nmov     cs:dword_14090D454, 0FFFFFFFFh                                 ; +0x60, 0x1400709e0\nmov     cs:dword_14090C0D4, eax                                        ; +0x6a, 0x1400709ea\nmov     r8d, 1                                                         ; +0x70, 0x1400709f0\nnop     word ptr [rax+rax+00000000h]                                   ; +0x76, 0x1400709f6\nmov     edx, eax                                                       ; +0x80, 0x140070a00\nshr     edx, 1Eh                                                       ; +0x82, 0x140070a02\nxor     edx, eax                                                       ; +0x85, 0x140070a05\nimul    eax, edx, 6C078965h                                            ; +0x87, 0x140070a07\nadd     eax, r8d                                                       ; +0x8d, 0x140070a0d\nmov     [rsi+r8*4+4], eax                                              ; +0x90, 0x140070a10\ninc     r8                                                             ; +0x95, 0x140070a15\ncmp     r8, 270h                                                       ; +0x98, 0x140070a18\njb      short loc_140070A00                                            ; +0x9f, 0x140070a1f\nmov     cs:dword_14090C0D0, 270h                                       ; +0xa1, 0x140070a21\nlea     rcx, dword_14090C0CC                                           ; +0xab, 0x140070a2b\ncall    _Init_thread_footer                                            ; +0xb2, 0x140070a32\nxorps   xmm0, xmm0                                                     ; +0xb7, 0x140070a37\nmovups  xmmword ptr [rbx], xmm0                                        ; +0xba, 0x140070a3a\nmov     [rbx+10h], rbp                                                 ; +0xbd, 0x140070a3d\nmov     qword ptr [rbx+18h], 0Fh                                       ; +0xc1, 0x140070a41\nmov     byte ptr [rbx], 0                                              ; +0xc9, 0x140070a49\nmov     [rsp+48h+var_28], 1                                            ; +0xcc, 0x140070a4c\nmovsxd  rdx, edi                                                       ; +0xd4, 0x140070a54\nmov     rcx, rbx; Src                                                  ; +0xd7, 0x140070a57\ncall    sub_140059AB0                                                  ; +0xda, 0x140070a5a\ntest    edi, edi                                                       ; +0xdf, 0x140070a5f\njle     short loc_140070AB7                                            ; +0xe1, 0x140070a61\nmov     ebp, 80000000h                                                 ; +0xe3, 0x140070a63\nlea     r14, a0123456789abcd; \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabc\"... ; +0xe8, 0x140070a68\nnop                                                                    ; +0xef, 0x140070a6f\nmov     rcx, rsi                                                       ; +0xf0, 0x140070a70\ncall    sub_1400768C0                                                  ; +0xf3, 0x140070a73\nmov     ecx, eax                                                       ; +0xf8, 0x140070a78\nimul    rdx, rcx, 3Eh ; '>'                                            ; +0xfa, 0x140070a7a\ncmp     edx, 3                                                         ; +0xfe, 0x140070a7e\nja      short loc_140070A96                                            ; +0x101, 0x140070a81\nmov     rcx, rsi                                                       ; +0x103, 0x140070a83\ncall    sub_1400768C0                                                  ; +0x106, 0x140070a86\nmov     ecx, eax                                                       ; +0x10b, 0x140070a8b\nimul    rdx, rcx, 3Eh ; '>'                                            ; +0x10d, 0x140070a8d\ncmp     edx, 4                                                         ; +0x111, 0x140070a91\njb      short loc_140070A83                                            ; +0x114, 0x140070a94\nshr     rdx, 20h                                                       ; +0x116, 0x140070a96\nsub     rdx, rbp                                                       ; +0x11a, 0x140070a9a\nxor     rdx, 0FFFFFFFF80000000h                                        ; +0x11d, 0x140070a9d\nmovzx   edx, byte ptr [rdx+r14]                                        ; +0x124, 0x140070aa4\nmov     rcx, rbx; Src                                                  ; +0x129, 0x140070aa9\ncall    sub_14003DBD0                                                  ; +0x12c, 0x140070aac\nsub     rdi, 1                                                         ; +0x131, 0x140070ab1\njnz     short loc_140070A70                                            ; +0x135, 0x140070ab5\nmov     rax, rbx                                                       ; +0x137, 0x140070ab7\nmov     rbx, [rsp+48h+arg_8]                                           ; +0x13a, 0x140070aba\nmov     rbp, [rsp+48h+arg_10]                                          ; +0x13f, 0x140070abf\nadd     rsp, 30h                                                       ; +0x144, 0x140070ac4\npop     r14                                                            ; +0x148, 0x140070ac8\npop     rdi                                                            ; +0x14a, 0x140070aca\npop     rsi                                                            ; +0x14b, 0x140070acb\nretn                                                                   ; +0x14c, 0x140070acc\ndb 0CCh                                                                ; +0x14d, 0x140070acd", "xrefs": ["GameLevelManager::createNewLevel @ 0x14021c117", "sub_140222BE0 @ 0x140222c34", "GameLevelManager::writePlatformerSaveJournal @ 0x1402234f4", "GameLevelManager::replayPlatformerSaveJournal @ 0x1402239a1", "GJGameLevel::dataLoaded @ 0x140268eb6", "GJGameLevel::encodeWithCoder @ 0x14026a4c8", "GJMultiplayerManager::uploadComment @ 0x1403913b5", "LevelEditorLayer::doAutoSave @ 0x1404092fb", "LevelEditorLayer::doAutoBackup @ 0x14040984d", "LocalLevelManager::tryRecoverAutoSaves @ 0x14046d588", "<???> @ 0x140911804"], "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"}