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:
authorDea7hsmiles <188018312+dea7hsmiless@users.noreply.github.com>2026-11-21 13:02:45 -0800
committerDea7hsmiles <188018312+dea7hsmiless@users.noreply.github.com>2026-11-21 13:20:30 -0800
commit8d8ebee38415c28abcf29d23710be7c57b3e268b (patch)
tree3324e411301ab638215785f07b3574ab75d64a6d /runtime/src/pe_loader.cpp
parent4e390e0871d7265e629b51aca8ff99a15a6a6845 (diff)
Loader: resolve forwarders to shimmed modules through the shim registry
A forwarder target is resolved through game_dir and System32, but not through shims::find, so a forwarder to xmem or d3d12_xs became an unimplemented thunk. Check the normalized module name against the shim registry first, as a direct import already does. A synthetic shim table and a forwarder-to-shim test cover it.
Diffstat (limited to 'runtime/src/pe_loader.cpp')
-rw-r--r--runtime/src/pe_loader.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/runtime/src/pe_loader.cpp b/runtime/src/pe_loader.cpp
index a0198c033..c04594c27 100644
--- a/runtime/src/pe_loader.cpp
+++ b/runtime/src/pe_loader.cpp
@@ -281,6 +281,16 @@ void* Loader::resolve_forwarder(const std::string& spec, Binding& binding, int d
281 auto dot = spec.rfind('.'); 281 auto dot = spec.rfind('.');
282 if (dot == std::string::npos || dot == 0 || dot + 1 >= spec.size()) return nullptr; 282 if (dot == std::string::npos || dot == 0 || dot + 1 >= spec.size()) return nullptr;
283 const std::string module = spec.substr(0, dot), symbol = spec.substr(dot + 1); 283 const std::string module = spec.substr(0, dot), symbol = spec.substr(dot + 1);
284
285 // A forwarder can name a module the loader shims. Shims take precedence over a bundled or host copy, exactly as
286 // they do for a direct import in resolve(); without this, a forwarded xmem or d3d12_xs call becomes a failure thunk.
287 std::string shim_key = lower(module);
288 if (shim_key.size() < 4 || shim_key.compare(shim_key.size() - 4, 4, ".dll") != 0) shim_key += ".dll";
289 if (void* p = shims::find(shim_key, symbol)) {
290 binding = Binding::Shim;
291 return p;
292 }
293
284 const bool by_ordinal = symbol.size() > 1 && symbol[0] == '#'; 294 const bool by_ordinal = symbol.size() > 1 && symbol[0] == '#';
285 uint32_t ordinal = 0; 295 uint32_t ordinal = 0;
286 if (by_ordinal) { 296 if (by_ordinal) {