{"type": "func", "start": 6443721140, "end": 6443721326, "name": "_free_osfhnd", "pseudocode": "// \n// _free_osfhnd from 0x1801361b4 to 0x18013626e (186 bytes)\n// \n// 2 xrefs:\n// > _close_nolock @ 0x180138c96\n// > <???> @ 0x1802034dc\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__int64 __fastcall free_osfhnd(int a1)\n{\n  __int64 v2; // rsi\n  __int64 v3; // rdi\n  __int64 v4; // rax\n  int v5; // ebx\n  DWORD v6; // ecx\n\n  if ( a1 >= 0 && a1 < (unsigned int)dword_1801F5560 )\n  {\n    v2 = (__int64)a1 >> 6;\n    v3 = 9LL * (a1 & 0x3F);\n    v4 = qword_1801F5160[v2];\n    if ( (*(_BYTE *)(v4 + 72LL * (a1 & 0x3F) + 56) & 1) != 0 && *(_QWORD *)(v4 + 72LL * (a1 & 0x3F) + 40) != -1 )\n    {\n      if ( (unsigned int)sub_180138EF0() == 1 )\n      {\n        if ( !a1 )\n        {\n          v6 = -10;\n          goto LABEL_12;\n        }\n        v5 = a1 - 1;\n        if ( !v5 )\n        {\n          v6 = -11;\n          goto LABEL_12;\n        }\n        if ( v5 == 1 )\n        {\n          v6 = -12;\nLABEL_12:\n          SetStdHandle(v6, nullptr);\n        }\n      }\n      *(_QWORD *)(qword_1801F5160[v2] + 8 * v3 + 40) = -1;\n      return 0;\n    }\n  }\n  *errno() = 9;\n  *_doserrno() = 0;\n  return 0xFFFFFFFFLL;\n}", "assembly": "; \n; _free_osfhnd from 0x1801361b4 to 0x18013626e (186 bytes)\n; \n; 2 xrefs:\n; > _close_nolock @ 0x180138c96\n; > <???> @ 0x1802034dc\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_0], rbx                                               ; +0x0, 0x1801361b4\nmov     [rsp+arg_8], rsi                                               ; +0x5, 0x1801361b9\nmov     [rsp+arg_10], rdi                                              ; +0xa, 0x1801361be\npush    r14                                                            ; +0xf, 0x1801361c3\nsub     rsp, 20h                                                       ; +0x11, 0x1801361c5\nmovsxd  rbx, ecx                                                       ; +0x15, 0x1801361c9\ntest    ecx, ecx                                                       ; +0x18, 0x1801361cc\njs      short loc_180136242                                            ; +0x1a, 0x1801361ce\ncmp     ebx, cs:dword_1801F5560                                        ; +0x1c, 0x1801361d0\njnb     short loc_180136242                                            ; +0x22, 0x1801361d6\nmov     rax, rbx                                                       ; +0x24, 0x1801361d8\nlea     r14, qword_1801F5160                                           ; +0x27, 0x1801361db\nand     eax, 3Fh                                                       ; +0x2e, 0x1801361e2\nmov     rsi, rbx                                                       ; +0x31, 0x1801361e5\nsar     rsi, 6                                                         ; +0x34, 0x1801361e8\nlea     rdi, [rax+rax*8]                                               ; +0x38, 0x1801361ec\nmov     rax, [r14+rsi*8]                                               ; +0x3c, 0x1801361f0\ntest    byte ptr [rax+rdi*8+38h], 1                                    ; +0x40, 0x1801361f4\njz      short loc_180136242                                            ; +0x45, 0x1801361f9\ncmp     qword ptr [rax+rdi*8+28h], 0FFFFFFFFFFFFFFFFh                  ; +0x47, 0x1801361fb\njz      short loc_180136242                                            ; +0x4d, 0x180136201\ncall    sub_180138EF0                                                  ; +0x4f, 0x180136203\ncmp     eax, 1                                                         ; +0x54, 0x180136208\njnz     short loc_180136234                                            ; +0x57, 0x18013620b\ntest    ebx, ebx                                                       ; +0x59, 0x18013620d\njz      short loc_180136227                                            ; +0x5b, 0x18013620f\nsub     ebx, eax                                                       ; +0x5d, 0x180136211\njz      short loc_180136220                                            ; +0x5f, 0x180136213\ncmp     ebx, eax                                                       ; +0x61, 0x180136215\njnz     short loc_180136234                                            ; +0x63, 0x180136217\nmov     ecx, 0FFFFFFF4h                                                ; +0x65, 0x180136219\njmp     short loc_18013622C                                            ; +0x6a, 0x18013621e\nmov     ecx, 0FFFFFFF5h                                                ; +0x6c, 0x180136220\njmp     short loc_18013622C                                            ; +0x71, 0x180136225\nmov     ecx, 0FFFFFFF6h; nStdHandle                                    ; +0x73, 0x180136227\nxor     edx, edx; hHandle                                              ; +0x78, 0x18013622c\ncall    cs:SetStdHandle                                                ; +0x7a, 0x18013622e\nmov     rax, [r14+rsi*8]                                               ; +0x80, 0x180136234\nor      qword ptr [rax+rdi*8+28h], 0FFFFFFFFFFFFFFFFh                  ; +0x84, 0x180136238\nxor     eax, eax                                                       ; +0x8a, 0x18013623e\njmp     short loc_180136258                                            ; +0x8c, 0x180136240\ncall    _errno                                                         ; +0x8e, 0x180136242\nmov     dword ptr [rax], 9                                             ; +0x93, 0x180136247\ncall    __doserrno                                                     ; +0x99, 0x18013624d\nand     dword ptr [rax], 0                                             ; +0x9e, 0x180136252\nor      eax, 0FFFFFFFFh                                                ; +0xa1, 0x180136255\nmov     rbx, [rsp+28h+arg_0]                                           ; +0xa4, 0x180136258\nmov     rsi, [rsp+28h+arg_8]                                           ; +0xa9, 0x18013625d\nmov     rdi, [rsp+28h+arg_10]                                          ; +0xae, 0x180136262\nadd     rsp, 20h                                                       ; +0xb3, 0x180136267\npop     r14                                                            ; +0xb7, 0x18013626b\nretn                                                                   ; +0xb9, 0x18013626d", "xrefs": ["_close_nolock @ 0x180138c96", "<???> @ 0x1802034dc"], "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"}