diff options
| author | AlxcBTW <187763517+AlxcBTW@users.noreply.github.com> | 2026-11-22 01:46:33 +0100 |
|---|---|---|
| committer | AlxcBTW <187763517+AlxcBTW@users.noreply.github.com> | 2026-11-22 01:46:33 +0100 |
| commit | bcb9f6d5f24363a2ea9fc1e18c7538d39ea4d622 (patch) | |
| tree | 229f22fcf89d9540426e230bab25dd2659017065 /runtime/src/pe_loader.h | |
| parent | 91b36cf86cb92a95836eed8af73abc0671a61e31 (diff) | |
runtime: LEONIDA_UNIMPLEMENTED=log|fail|stop policy for imports with no binding
An unimplemented import used to return 0 silently, which is S_OK for an
HRESULT function with its out parameters never written. The thunk now passes
the caller's return address and rcx/rdx/r8/r9 to a shared stub, and
LEONIDA_UNIMPLEMENTED picks the behaviour:
- log (default): exactly as before.
- fail: E_NOTIMPL for imports known to return HRESULT (D3D12Create*/Serialize*,
CreateDXGIFactory*, XGameRuntimeInitialize, and the GDK XAsync/XTaskQueue/
XUser/XStore/XGameSave/XPackage/XGameUi families minus their documented
void/bool/int functions), 0 otherwise.
- stop: print the import, the caller as module+RVA and the four argument
registers, then break under a debugger or exit with code 3.
--dry-run now counts unimplemented imports by return class. The stub zeroes
xmm0 and has unwind info, so float callers and debuggers are unaffected.
unimplemented_policy_test builds a synthetic image and checks all three modes.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/pe_loader.h')
| -rw-r--r-- | runtime/src/pe_loader.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/runtime/src/pe_loader.h b/runtime/src/pe_loader.h index 6946f1cc0..ebcf411ec 100644 --- a/runtime/src/pe_loader.h +++ b/runtime/src/pe_loader.h | |||
| @@ -60,7 +60,11 @@ struct Module { | |||
| 60 | 60 | ||
| 61 | class Loader { | 61 | class Loader { |
| 62 | public: | 62 | public: |
| 63 | explicit Loader(std::filesystem::path game_dir) : game_dir_(std::move(game_dir)) {} | 63 | // Also registers the module list with the shim registry, so an unimplemented import called under |
| 64 | // LEONIDA_UNIMPLEMENTED=stop can name the module and RVA of its caller. | ||
| 65 | explicit Loader(std::filesystem::path game_dir); | ||
| 66 | Loader(const Loader&) = delete; | ||
| 67 | Loader& operator=(const Loader&) = delete; | ||
| 64 | // Restores the TLS slot for the calling thread. Destroy the Loader on the thread | 68 | // Restores the TLS slot for the calling thread. Destroy the Loader on the thread |
| 65 | // that called load() while any mapped TLS module is still live. | 69 | // that called load() while any mapped TLS module is still live. |
| 66 | ~Loader(); | 70 | ~Loader(); |