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:
authorDominik <55330408+Dom-in@users.noreply.github.com>2026-11-22 14:59:38 +0000
committerDominik <55330408+Dom-in@users.noreply.github.com>2026-11-22 15:26:25 +0000
commit56fd84b2740f92a04154da8b1d8b90f10920b3ff (patch)
treedca180c119a37a95805e30be896271f8ab872c30 /runtime/src/pe_loader.cpp
parent4eb6155d3ac4f9d3fadb0d095c4ce13e76783615 (diff)
pe_loader: a forwarded CRT export binds the host copy, as a direct import does
resolve_forwarder checked prefer_host_copy() on the bare forwarder module name, but forwarder strings normally leave out ".dll" ("MSVCP140.?foo") and the host-copy list is named with it. So a bundled module forwarding to one of the CRT DLLs the package ships (vcruntime140, msvcp140, concrt140, ...) mapped the Xbox build of that DLL from the game folder instead of the host's, unlike a direct import of the same symbol. It now uses shim_key, the name with ".dll" the function already builds for the shim lookup. loader_test: a fake bundled vcruntime140.dll plus a provider forwarding "vcruntime140.memset" binds to the host memset and never maps the fake (fails before the change: the import ends unimplemented). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/pe_loader.cpp')
-rw-r--r--runtime/src/pe_loader.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/runtime/src/pe_loader.cpp b/runtime/src/pe_loader.cpp
index 387051756..c55520571 100644
--- a/runtime/src/pe_loader.cpp
+++ b/runtime/src/pe_loader.cpp
@@ -709,10 +709,12 @@ void* Loader::resolve_forwarder(const std::string& spec, Binding& binding, int d
709 } 709 }
710 } 710 }
711 711
712 // shim_key, not the bare module name: forwarder strings usually leave out ".dll" ("MSVCP140.?foo"), and the host
713 // CRT copies are named with it, so a forwarded CRT symbol must skip the bundled Xbox build as a direct import does.
712 const std::filesystem::path candidates[] = {game_dir_ / module, game_dir_ / (module + ".dll")}; 714 const std::filesystem::path candidates[] = {game_dir_ / module, game_dir_ / (module + ".dll")};
713 for (const auto& candidate : candidates) { 715 for (const auto& candidate : candidates) {
714 std::error_code ec; 716 std::error_code ec;
715 if (prefer_host_copy(lower(module)) || !std::filesystem::exists(candidate, ec)) continue; 717 if (prefer_host_copy(shim_key) || !std::filesystem::exists(candidate, ec)) continue;
716 Module& dep = load(candidate); 718 Module& dep = load(candidate);
717 if (auto it = dep.exports.find(symbol); it != dep.exports.end()) { 719 if (auto it = dep.exports.find(symbol); it != dep.exports.end()) {
718 binding = Binding::Module; 720 binding = Binding::Module;