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:
authorAsh Hopkins <ashleighhopkins87@gmail.com>2026-11-22 11:25:05 +0000
committerAsh Hopkins <ashleighhopkins87@gmail.com>2026-11-22 12:53:32 +0000
commitd820ecfa63fa9939209e305d5f94cda59ca7f16f (patch)
tree66ef66207632527124aa192dce3552e5f51d8635 /runtime/src/pe_loader.cpp
parent41f448261e1de8a410b4d760e69a7e5656cef858 (diff)
runtime: reserve a relocation-less image's range before arm64 Wine takes it
An EXE without .reloc can only run at its ImageBase (0x140000000 by default; RT-22 asks whether the game's is one). Under arm64 Wine on macOS (CrossOver's arm64 bottles, x86-64 code under FEX) the process's own start-up allocations sit at 0x100000000 and up before gta6rt runs, so such an image failed with "preferred base is taken". gta6rt now starts itself again suspended when the image has no relocations and its range is not free, reserves [ImageBase, ImageBase + SizeOfImage) in the new process, resumes it and returns its exit code; the loader commits the image inside that reservation. LEONIDA_BASE_RESERVED tells the new process, which does not start itself again. Where the range is free at start-up (Windows, x86-64 Wine) nothing changes. tiny_game_fixed is the stand-in game linked /FIXED at 0x140000000; run_tiny_game_fixed and run_tiny_game_fixed_exit_code run it. Arm64 bottle (CrossOver Preview 20260821, M2 Max): it maps at 0x140000000 and both tests pass, --dry-run and --init exit 0; with the relaunch disabled it fails as before. The Rosetta (x86-64) bottle passes them too. The in-process loader tests that build relocation-less images (loader, pe_loader_bounds, unimplemented_policy) still fail on arm64. AI-assisted. No game files.
Diffstat (limited to 'runtime/src/pe_loader.cpp')
-rw-r--r--runtime/src/pe_loader.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/runtime/src/pe_loader.cpp b/runtime/src/pe_loader.cpp
index 1ab9c7801..387051756 100644
--- a/runtime/src/pe_loader.cpp
+++ b/runtime/src/pe_loader.cpp
@@ -14,6 +14,7 @@
14#include <vector> 14#include <vector>
15 15
16#include "../shims/shims.h" 16#include "../shims/shims.h"
17#include "base_reservation.h"
17 18
18namespace rt { 19namespace rt {
19 20
@@ -506,8 +507,11 @@ Module& Loader::map_image(const std::filesystem::path& path) {
506 by_name_[lower(m->name)] = m; 507 by_name_[lower(m->name)] = m;
507 order_.push_back(m); 508 order_.push_back(m);
508 509
509 m->base = static_cast<uint8_t*>( 510 // Inside the range gta6rt reserved for this image before the process started (base_reservation.h), else as usual.
510 VirtualAlloc(reinterpret_cast<void*>(oh.ImageBase), oh.SizeOfImage, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE)); 511 m->base = static_cast<uint8_t*>(base_reservation::commit_reserved(oh.ImageBase, oh.SizeOfImage));
512 if (!m->base)
513 m->base = static_cast<uint8_t*>(VirtualAlloc(reinterpret_cast<void*>(oh.ImageBase), oh.SizeOfImage,
514 MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE));
511 if (!m->base) { 515 if (!m->base) {
512 const auto relocs = directory(nt, IMAGE_DIRECTORY_ENTRY_BASERELOC); 516 const auto relocs = directory(nt, IMAGE_DIRECTORY_ENTRY_BASERELOC);
513 if (!relocs.Size) 517 if (!relocs.Size)