Repository navigation
loader/shims: host-binding fix, ordinal classes, module identity for mapped images - #5731
NolanCotter wants to merge 7 commits into
Conversation
|
Tested 3362ef8 on Intel UHD Graphics 770, driver 32.0.101.7088: loader_test exits 0 with "88 checks, 0 failed", including "ok a forwarder to a shimmed module binds to the shim" and "ok a forwarder to a CRT module without ".dll" binds the host copy, not the bundled one". unimplemented_policy_test exits 0 with "105 checks, 0 failed". No check line in either output names module identity, GetModuleHandle(nullptr) or GetModuleFileName, so the identity part of the description is not shown by this run. AI-assisted. |
gertify's check on ItsNotRexed#5731 showed no check line names module identity: the ops behind GetModuleHandle(nullptr) and GetModuleFileName were only covered indirectly. A load() now verifies the main-module op answers the first mapped image and module_path answers the main image's and the module's own stored path. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Thank you (AI-assisted reply) — fair catch. |
There was a problem hiding this comment.
Reviewed head 2e0f1a2 (base 561b65a). Build: pwsh scripts/build_runtime.ps1 -jobs 8 -> exit 0.
With LEONIDA_VK_DEVICE='RTX 5070 Ti', ctest -R '^(loader|pe_loader|pe_loader_bounds|loader_tls|unimplemented_policy|run_tiny_gdk_load|run_tiny_atexit|run_tiny_frame)$' -> 8/8 passed, 11.66 s:
- loader 90 checks / 0 failed, including "an unregistered import of a shim-owned module ends unimplemented, not host"
- unimplemented_policy 105 checks / 0 failed; pe_loader_bounds 54 checks / 0 failed; pe_loader passed with "SKIP (no package): LEONIDA_GAME_DIR is not set"; loader_tls passed
- run_tiny_frame OK ("tiny_frame under gta6rt --run on the Vulkan D3D12 device: OK"); run_tiny_gdk_load and run_tiny_atexit passed
Manual probes on a guest mapped by this gta6rt:
GetModuleFileNameW(NULL)/...Areturn the guest's own path (ret 63);GetModuleHandleW(NULL)is the mapped base, notgta6rt.exe.- System32
xgameruntime.dllexportsXErrorReport(LoadLibraryEx + GetProcAddress is non-NULL), yet a staticxgameruntime.dll!XErrorReportimport is UNIMPLEMENTED and the run calls the thunk.
The no-SDL3 gameinput.dll case is now qualified correctly in docs/import_routing.md, and the console-ABI link is fixed: tests/test_docs_links.py passes (15 passed, 6 subtests). git diff --check clean.
Verdict: no blockers. Runtime fix verified, run_tiny_frame unaffected, and the owned->host skip has a regression test.
|
Both addressed in
|
|
@Kam471 both fixed in
@ItsNotRexed FYI on the |
gameinput.cpp only compiles when SDL3 is available, so without the shim gameinput.dll has no registry entries, is not owns_dll, and its imports bind the host DLL or end unimplemented like any unserved name (Kam471's review on ItsNotRexed#5731). xgameruntime.dll's GameInputCreate entry is conditional the same way. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
@Kam471 thanks for the re-verification — glad the owned→host-skip test and the link fix hold on your setup. Good catch on the SDL3 caveat; that's a real doc imprecision. Fixed in |
|
Tested AI-assisted. |
|
@Kam471 thanks for tracking the head through @thatirishguyyy the two-adapter |
|
Tested 2e0f1a2 on NVIDIA GeForce RTX 4080, driver 617.42: unimplemented_policy_test exits 0 with "105 checks, 0 failed". loader_test exits 1 with "50 checks, 2 failed": the two failures are "initialise runs a TLS callback and DllMain" and "writing the test images", both with "gta6rt_tls_host.dll is missing or has no module TLS index", so the TLS cases did not run in this build. The new cases pass here, including "an import naming TestShim resolves to testshim.dll's shim", "GetModuleHandle(nullptr)/GetModuleFileName answer for mapped images through the bundled ops" and "an unregistered import of a shim-owned module ends unimplemented, not host". AI-assisted. |
|
@gertify thanks for the run — good news is all the PR's own checks passed for you (forwarder→shim, bundled-ops module identity, owned→host skip). The two failures aren't from this slice though: the diff touches zero TLS code ( What's happening: Likely cause: a build dir configured before |
|
Tested
AI-assisted (Claude Code). |
|
@itsonlysimbo thanks — the same-two-failures-on-main baseline is exactly the right check, and the 3/3 repro on |
|
Independent Windows check of module identity for a mapped image (synthetic guest, ASCII path, started from Explorer, no implicit layers, own builds of each tree, each result stable ×3). "image" = the guest's
This covers only these calls; the other parts of #5731 (host binding, ordinal classes, docs) and non-ASCII or Wine paths were not measured. AI-assisted. |
gertify's check on ItsNotRexed#5731 showed no check line names module identity: the ops behind GetModuleHandle(nullptr) and GetModuleFileName were only covered indirectly. A load() now verifies the main-module op answers the first mapped image and module_path answers the main image's and the module's own stored path. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
gameinput.cpp only compiles when SDL3 is available, so without the shim gameinput.dll has no registry entries, is not owns_dll, and its imports bind the host DLL or end unimplemented like any unserved name (Kam471's review on ItsNotRexed#5731). xgameruntime.dll's GameInputCreate entry is conditional the same way. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2e0f1a2 to
c4fcea0
Compare
…mages l-CatDemon-l's module-identity matrix on ItsNotRexed#5731 showed three gaps against native answers: GetModuleHandleEx(0, NULL) returned the host exe, GetModuleHandleEx(FROM_ADDRESS, fn) failed 126, and GetProcAddress(NULL, export) found nothing — the Ex variants were never shimmed and a null module never reached the mapped main image. GetModuleHandleExA/W now share GetModuleHandle's order (owned pseudo-handle, bundled by name, bundled main image, host), with FROM_ADDRESS answered by a new module_for_address on the bundled ops and PIN/UNCHANGED_REFCOUNT no-ops for mapped modules. A null module in the GetProcAddress shim asks for the main image's exports first. loader_test's module-identity check now covers bundled_module_for_address inside and just past the image: 90 checks, 0 failed under Wine/clang-cl. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
@l-CatDemon-l excellent matrix — three real gaps against native. All fixed in
|
|
Tested
|
|
Excellent catch — confirmed and fixed in Root cause is exactly what you traced: the new The fix keeps the check's intent by reading the mapping directly instead of going through module-name resolution: host-loaded images are Verified: |
|
Thanks — the dry-run import accounting is the clearest possible confirmation: Two heads-up since your run: the doc conflicts you merged past are resolved in the pushed rebase ( |
56b4614 to
37b117a
Compare
|
Rebased onto Verified at the new head (clang-cl 20 + xwin cross-build, Wine): |
gertify's check on ItsNotRexed#5731 showed no check line names module identity: the ops behind GetModuleHandle(nullptr) and GetModuleFileName were only covered indirectly. A load() now verifies the main-module op answers the first mapped image and module_path answers the main image's and the module's own stored path. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
gameinput.cpp only compiles when SDL3 is available, so without the shim gameinput.dll has no registry entries, is not owns_dll, and its imports bind the host DLL or end unimplemented like any unserved name (Kam471's review on ItsNotRexed#5731). xgameruntime.dll's GameInputCreate entry is conditional the same way. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…mages l-CatDemon-l's module-identity matrix on ItsNotRexed#5731 showed three gaps against native answers: GetModuleHandleEx(0, NULL) returned the host exe, GetModuleHandleEx(FROM_ADDRESS, fn) failed 126, and GetProcAddress(NULL, export) found nothing — the Ex variants were never shimmed and a null module never reached the mapped main image. GetModuleHandleExA/W now share GetModuleHandle's order (owned pseudo-handle, bundled by name, bundled main image, host), with FROM_ADDRESS answered by a new module_for_address on the bundled ops and PIN/UNCHANGED_REFCOUNT no-ops for mapped modules. A null module in the GetProcAddress shim asks for the main image's exports first. loader_test's module-identity check now covers bundled_module_for_address inside and just past the image: 90 checks, 0 failed under Wine/clang-cl. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Shim-owned modules (xgameruntime, gameinput, d3d12_xs, xmem) no longer bind to their real System32 namesakes in resolve() or forwarded exports — an unregistered console import now ends unimplemented instead of reaching a host Gaming Services call. LoadLibrary's file-name rule keys imports so "TestShim", "testshim.dll." and "testshim.dll" hit the same shim. registry gains the ordinal classes: gameinput #1 and xaudio2_9 (#1, and host-only ItsNotRexed#8-ItsNotRexed#10) classify as HResult. GetModuleHandle(nullptr) answers with the mapped main image and GetModuleFileNameA/W answer for bundled modules' stored paths (Win32 spelling, Z: under Wine) through two new BundledModuleOps. loader_test pins the name-rule binding; unimplemented_policy_test pins the ordinal classes. Split from ItsNotRexed#2490 (first of three). AI-assisted. Tested on the build host under Wine/clang-cl: loader_test 88/0, unimplemented_policy_test 96/0. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
gertify's check on ItsNotRexed#5731 showed no check line names module identity: the ops behind GetModuleHandle(nullptr) and GetModuleFileName were only covered indirectly. A load() now verifies the main-module op answers the first mapped image and module_path answers the main image's and the module's own stored path. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
console_libraries.md linked d3d12_xs_console_abi.md, which lands with the console-ABI slice — d3d12_command_objects.md already covers the PresentX surface, so test_docs_links is green again (Kam471's blocker). The unregistered-import-of-an-owned-module path now has a check: version.dll is claimed in the test table, so an import of the real GetFileVersionInfoSizeA export must end unimplemented rather than bind the host copy — the same skip Kam471 probed by hand, made a check. loader_test: 90 checks, 0 failed under Wine/clang-cl. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
gameinput.cpp only compiles when SDL3 is available, so without the shim gameinput.dll has no registry entries, is not owns_dll, and its imports bind the host DLL or end unimplemented like any unserved name (Kam471's review on ItsNotRexed#5731). xgameruntime.dll's GameInputCreate entry is conditional the same way. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…mages l-CatDemon-l's module-identity matrix on ItsNotRexed#5731 showed three gaps against native answers: GetModuleHandleEx(0, NULL) returned the host exe, GetModuleHandleEx(FROM_ADDRESS, fn) failed 126, and GetProcAddress(NULL, export) found nothing — the Ex variants were never shimmed and a null module never reached the mapped main image. GetModuleHandleExA/W now share GetModuleHandle's order (owned pseudo-handle, bundled by name, bundled main image, host), with FROM_ADDRESS answered by a new module_for_address on the bundled ops and PIN/UNCHANGED_REFCOUNT no-ops for mapped modules. A null module in the GetProcAddress shim asks for the main image's exports first. loader_test's module-identity check now covers bundled_module_for_address inside and just past the image: 90 checks, 0 failed under Wine/clang-cl. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
run_tiny_gdk_load and run_tiny_bundled_load asked host GetModuleHandleExW whether the returned handle was host-registered; the new shim answers for owned and mapped modules, so the probe misfired. Read the mapping instead: host-loaded images are MEM_IMAGE, rt::Loader images are VirtualAlloc'd MEM_PRIVATE, and a pseudo-handle is never an image. The fixtures also assert the shim's new answer directly.
Upstream's get_module_handle_w splits ASCII names (narrow + owned + find_loaded) from non-ASCII (module_name_w + find_loaded_bundled_module_w); the new Ex variant only had the narrow path, so a non-ASCII module name would turn to '?' and miss a mapped module. Same split now.
37b117a to
abac487
Compare
|
Rebased onto
Verified (clang-cl 20 + xwin, Wine): |
|
Tested
AI-assisted (Claude Code). |
|
Thanks — the baseline comparison is the useful part here: all three failures reproduce on plain main |
|
Windows + GPU check. Hardware: NVIDIA GeForce RTX 5080 + RTX 3070 Ti (driver 621.01) and AMD Radeon 610M iGPU (Ryzen 9 9950X3D, driver 32.0.13018.6). OS: Windows 11. Toolchain: MSVC (VS BuildTools 18) + Ninja, single-config RelWithDebInfo; llvm-mc 21.1.8; SPIRV-Tools (spirv-as/spirv-val). Configured with -DLEONIDA_LLVM_MC and -DLEONIDA_SPIRV_AS/VAL so the shader-fixture GPU tests register. Tested head abac487 (base 2c7095d). Build: 657/657 targets, 0 errors/warnings. Targeted tests (this PR's loader/shim scope), --repeat until-fail:3 on the RTX 5080: loader, unimplemented_policy, startup_trace, run_tiny_gdk_load, run_tiny_bundled_load, dll_thread_calls, loader_tls, pe_loader - 9 tests x3 = 27 runs, all pass. The host-binding fix, ordinal-class classification and module-identity changes are exercised by these and are green. Full runtime suite, ctest -C RelWithDebInfo -j 6, excluding the 4 windowed present tests:
Isolation: every one of those reproduces IDENTICALLY on current main dde82f2 on the same hardware (e.g. d3d12_indirect_dispatch_count reports host 6/10, layer 0/0, expected 6/10 on both this head and main; the iGPU-only vk_queue_query_sync and d3d12_mesh also fail on main on the Radeon 610M). They are GPU tests outside this PR's loader/shim scope and are red on main on my GPUs (RTX 5080 + Radeon 610M driver 32.0.13018.6), so they are not attributable to this PR. Windowed present tests, run serially --repeat until-fail:3 on each GPU: d3d12_present and xbox_present pass x3 on both the RTX 5080 and the Radeon 610M. Net: this PR's loader/shim changes build clean and their targeted tests are green x3 on NVIDIA; the only full-suite failures are pre-existing main-red GPU tests on my hardware, unchanged by this PR. Synthetic fixtures only, no game files. AI-assisted (opencode); runs on my machine. |
Split from #2490 (first of three), rebased onto current main after the revert.
Summary
xgameruntime.dll,gameinput.dll,d3d12_xs.dll,xmem.dll) no longer bind to their real System32 namesakes — an unregistered console import ends unimplemented instead of reaching a host Gaming Services call, inLoader::resolveandresolve_forwarderalike.dll_keyapplies LoadLibrary's file-name rule to imports, soTestShim,testshim.dll.andtestshim.dllall key totestshim.dll's shim.gameinput.dll!#1andxaudio2_9.dllordinals (Add pytest regression tests for the RDNA2 -> SPIR-V translator, plus a Linux CI job #1, host-only CI: Dependabot for GitHub Actions and the rpf9-explorer submodule #8–Add a pull request template from CONTRIBUTING.md #10) classify as HResult.GetModuleHandle(nullptr)answers with the mapped main image;GetModuleFileNameA/Wanswer for bundled modules' stored paths (Win32 spelling,Z:under Wine) through two newBundledModuleOps.docs/import_routing.md(the bind order) anddocs/console_libraries.md(the console-DLL surface);docs/boot.mdrecords the packaging-probe run this work enabled.This carries the pre-revert tree's version of these files, so it keeps the upstream refinements that landed on the merged code (e.g. the ExistingThreads TLS work stays untouched).
Test plan
loader_test88/0 andunimplemented_policy_test96/0 under Wine/clang-cl on the build hostAI-assisted.
Generated with Devin