upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/pe_loader.cpp
diff options
context:
space:
mode:
authorSHAURYASANYAL3 <shauryasanya.21jun@gmail.com>2026-11-22 11:55:36 +0530
committerSHAURYASANYAL3 <shauryasanya.21jun@gmail.com>2026-11-22 12:19:06 +0530
commit16e759141996df21526249ad2ae8b744c9bc54fc (patch)
treecd73b381d4dba9b715437dcb379991e055799379 /runtime/src/pe_loader.cpp
parent48ad23f0262452b6c3d09db98941bfedb8e9684d (diff)
runtime: thunk deduplication, XGameRuntime shims, PE loader long paths, and drive-root packaging
Diffstat (limited to 'runtime/src/pe_loader.cpp')
-rw-r--r--runtime/src/pe_loader.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/runtime/src/pe_loader.cpp b/runtime/src/pe_loader.cpp
index ef6fab7a8..d865e4179 100644
--- a/runtime/src/pe_loader.cpp
+++ b/runtime/src/pe_loader.cpp
@@ -77,9 +77,20 @@ struct TlsHostModule {
77 77
78TlsHostModule load_tls_host() { 78TlsHostModule load_tls_host() {
79 TlsHostModule host; 79 TlsHostModule host;
80 wchar_t exe[MAX_PATH] = {}; 80 // Dynamic buffer loop for paths that exceed MAX_PATH
81 if (!GetModuleFileNameW(nullptr, exe, MAX_PATH)) return host; 81 std::wstring exe_path;
82 const std::filesystem::path path = std::filesystem::path(exe).parent_path() / L"gta6rt_tls_host.dll"; 82 DWORD size = MAX_PATH;
83 while (true) {
84 exe_path.resize(size);
85 DWORD len = GetModuleFileNameW(nullptr, exe_path.data(), size);
86 if (len == 0) return host;
87 if (len < size - 1) {
88 exe_path.resize(len);
89 break;
90 }
91 size *= 2;
92 }
93 const std::filesystem::path path = std::filesystem::path(exe_path).parent_path() / L"gta6rt_tls_host.dll";
83 // The helper is linked with the static CRT (/MT), so it needs only system DLLs. Restricting the dependency search 94 // The helper is linked with the static CRT (/MT), so it needs only system DLLs. Restricting the dependency search
84 // to System32 keeps a game-supplied vcruntime next to the executable from being picked up. 95 // to System32 keeps a game-supplied vcruntime next to the executable from being picked up.
85 host.module = LoadLibraryExW(path.c_str(), nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); 96 host.module = LoadLibraryExW(path.c_str(), nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);