diff options
Diffstat (limited to 'runtime/src/pe_loader.cpp')
| -rw-r--r-- | runtime/src/pe_loader.cpp | 10 |
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) { |