{"type": "func", "start": 6443742420, "end": 6443742659, "name": "copy_environment<wchar_t>", "pseudocode": "// \n// copy_environment<wchar_t> from 0x18013b4d4 to 0x18013b5c3 (239 bytes)\n// \n// 3 xrefs:\n// > common_set_variable_in_environment_nolock<wchar_t> @ 0x18013b13e\n// > common_set_variable_in_environment_nolock<wchar_t> @ 0x18013b18c\n// > <???> @ 0x1802038f0\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_BYTE *__fastcall copy_environment<wchar_t>(const wchar_t **a1)\n{\n  const wchar_t **v1; // rdi\n  __int64 v3; // rcx\n  const wchar_t **i; // rax\n  _BYTE *v5; // rbx\n  const wchar_t *v6; // rax\n  signed __int64 v7; // r14\n  __int64 v8; // rsi\n  wchar_t *v9; // rcx\n\n  v1 = a1;\n  if ( !a1 )\n    return nullptr;\n  v3 = 0;\n  for ( i = v1; *i; ++i )\n    ++v3;\n  v5 = calloc_base(v3 + 1, 8u);\n  if ( !v5 )\nLABEL_15:\n    abort();\n  v6 = *v1;\n  if ( *v1 )\n  {\n    v7 = v5 - (_BYTE *)v1;\n    do\n    {\n      v8 = -1;\n      do\n        ++v8;\n      while ( v6[v8] );\n      *(const wchar_t **)((char *)v1 + v7) = (const wchar_t *)calloc_base(v8 + 1, 2u);\n      free_base(nullptr);\n      v9 = *(wchar_t **)((char *)v1 + v7);\n      if ( !v9 )\n        goto LABEL_15;\n      if ( wcscpy_s(v9, v8 + 1, *v1) )\n        invoke_watson(nullptr, nullptr, nullptr, 0, 0);\n      v6 = *++v1;\n    }\n    while ( *v1 );\n  }\n  free_base(nullptr);\n  return v5;\n}", "assembly": "; \n; copy_environment<wchar_t> from 0x18013b4d4 to 0x18013b5c3 (239 bytes)\n; \n; 3 xrefs:\n; > common_set_variable_in_environment_nolock<wchar_t> @ 0x18013b13e\n; > common_set_variable_in_environment_nolock<wchar_t> @ 0x18013b18c\n; > <???> @ 0x1802038f0\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     rax, rsp                                                       ; +0x0, 0x18013b4d4\nmov     [rax+8], rbx                                                   ; +0x3, 0x18013b4d7\nmov     [rax+10h], rbp                                                 ; +0x7, 0x18013b4db\nmov     [rax+18h], rsi                                                 ; +0xb, 0x18013b4df\nmov     [rax+20h], rdi                                                 ; +0xf, 0x18013b4e3\npush    r14                                                            ; +0x13, 0x18013b4e7\nsub     rsp, 30h                                                       ; +0x15, 0x18013b4e9\nxor     ebp, ebp                                                       ; +0x19, 0x18013b4ed\nmov     rdi, rcx                                                       ; +0x1b, 0x18013b4ef\ntest    rcx, rcx                                                       ; +0x1e, 0x18013b4f2\njnz     short loc_18013B514                                            ; +0x21, 0x18013b4f5\nxor     eax, eax                                                       ; +0x23, 0x18013b4f7\nmov     rbx, [rsp+38h+arg_0]                                           ; +0x25, 0x18013b4f9\nmov     rbp, [rsp+38h+arg_8]                                           ; +0x2a, 0x18013b4fe\nmov     rsi, [rsp+38h+arg_10]                                          ; +0x2f, 0x18013b503\nmov     rdi, [rsp+38h+arg_18]                                          ; +0x34, 0x18013b508\nadd     rsp, 30h                                                       ; +0x39, 0x18013b50d\npop     r14                                                            ; +0x3d, 0x18013b511\nretn                                                                   ; +0x3f, 0x18013b513\nmov     rcx, rbp                                                       ; +0x40, 0x18013b514\nmov     rax, rdi                                                       ; +0x43, 0x18013b517\ncmp     [rdi], rbp                                                     ; +0x46, 0x18013b51a\njz      short loc_18013B52B                                            ; +0x49, 0x18013b51d\ninc     rcx                                                            ; +0x4b, 0x18013b51f\nlea     rax, [rax+8]                                                   ; +0x4e, 0x18013b522\ncmp     [rax], rbp                                                     ; +0x52, 0x18013b526\njnz     short loc_18013B51F                                            ; +0x55, 0x18013b529\ninc     rcx; Count                                                     ; +0x57, 0x18013b52b\nmov     edx, 8; Size                                                   ; +0x5a, 0x18013b52e\ncall    _calloc_base                                                   ; +0x5f, 0x18013b533\nmov     rbx, rax                                                       ; +0x64, 0x18013b538\ntest    rax, rax                                                       ; +0x67, 0x18013b53b\njz      short loc_18013B5BD                                            ; +0x6a, 0x18013b53e\nmov     rax, [rdi]                                                     ; +0x6c, 0x18013b540\ntest    rax, rax                                                       ; +0x6f, 0x18013b543\njz      short loc_18013B599                                            ; +0x72, 0x18013b546\nmov     r14, rbx                                                       ; +0x74, 0x18013b548\nsub     r14, rdi                                                       ; +0x77, 0x18013b54b\nor      rsi, 0FFFFFFFFFFFFFFFFh                                        ; +0x7a, 0x18013b54e\ninc     rsi                                                            ; +0x7e, 0x18013b552\ncmp     [rax+rsi*2], bp                                                ; +0x81, 0x18013b555\njnz     short loc_18013B552                                            ; +0x85, 0x18013b559\nmov     edx, 2; Size                                                   ; +0x87, 0x18013b55b\nlea     rcx, [rsi+1]; Count                                            ; +0x8c, 0x18013b560\ncall    _calloc_base                                                   ; +0x90, 0x18013b564\nxor     ecx, ecx; Block                                                ; +0x95, 0x18013b569\nmov     [r14+rdi], rax                                                 ; +0x97, 0x18013b56b\ncall    _free_base                                                     ; +0x9b, 0x18013b56f\nmov     rcx, [r14+rdi]; Destination                                    ; +0xa0, 0x18013b574\ntest    rcx, rcx                                                       ; +0xa4, 0x18013b578\njz      short loc_18013B5BD                                            ; +0xa7, 0x18013b57b\nmov     r8, [rdi]; Source                                              ; +0xa9, 0x18013b57d\nlea     rdx, [rsi+1]; SizeInWords                                      ; +0xac, 0x18013b580\ncall    wcscpy_s                                                       ; +0xb0, 0x18013b584\ntest    eax, eax                                                       ; +0xb5, 0x18013b589\njnz     short loc_18013B5A8                                            ; +0xb7, 0x18013b58b\nadd     rdi, 8                                                         ; +0xb9, 0x18013b58d\nmov     rax, [rdi]                                                     ; +0xbd, 0x18013b591\ntest    rax, rax                                                       ; +0xc0, 0x18013b594\njnz     short loc_18013B54E                                            ; +0xc3, 0x18013b597\nxor     ecx, ecx; Block                                                ; +0xc5, 0x18013b599\ncall    _free_base                                                     ; +0xc7, 0x18013b59b\nmov     rax, rbx                                                       ; +0xcc, 0x18013b5a0\njmp     loc_18013B4F9                                                  ; +0xcf, 0x18013b5a3\nxor     r9d, r9d; LineNo                                               ; +0xd4, 0x18013b5a8\nmov     [rsp+38h+Reserved], rbp; Reserved                              ; +0xd7, 0x18013b5ab\nxor     r8d, r8d; FileName                                             ; +0xdc, 0x18013b5b0\nxor     edx, edx; FunctionName                                         ; +0xdf, 0x18013b5b3\nxor     ecx, ecx; Expression                                           ; +0xe1, 0x18013b5b5\ncall    _invoke_watson                                                 ; +0xe3, 0x18013b5b7\ndb 0CCh                                                                ; +0xe8, 0x18013b5bc\ncall    abort                                                          ; +0xe9, 0x18013b5bd\ndb 0CCh                                                                ; +0xee, 0x18013b5c2", "xrefs": ["common_set_variable_in_environment_nolock<wchar_t> @ 0x18013b13e", "common_set_variable_in_environment_nolock<wchar_t> @ 0x18013b18c", "<???> @ 0x1802038f0"], "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"}