mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:45:53 +01:00
[PR #1565] loader: a run-time LoadLibrary takes the LEONIDA_COMPAT_DIR module too (RT-COMPAT-DIR-RUNTIME-LOADS) #1589
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1589
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1565
Author: @Mike7581
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:rt-compat-dir-runtime-loads📝 Commits (2)
582e14dloader: a run-time LoadLibrary takes the LEONIDA_COMPAT_DIR module too2cca47bloader: compat run-time loads honour LoadLibraryEx flags and Windows-loaded dependencies📊 Changes
8 files changed (+496 additions, -37 deletions)
View changed files
📝
runtime/CMakeLists.txt(+1 -0)📝
runtime/README.md(+9 -2)📝
runtime/shims/library_loader.cpp(+50 -7)📝
runtime/shims/registry.cpp(+22 -0)📝
runtime/shims/shims.h(+11 -0)📝
runtime/src/pe_loader.cpp(+137 -24)📝
runtime/src/pe_loader.h(+17 -1)📝
runtime/test/loader_test.cpp(+249 -3)📄 Description
Claimed in the coordination issue as: RT-COMPAT-DIR-RUNTIME-LOADS (#1562, since #14 is at the 2,500-comment cap)
What and why
LEONIDA_COMPAT_DIRonly applied to static imports (runtime/README.md: "a run-timeLoadLibraryof the same name does not yet"). A mapped image'sLoadLibraryof a module the folder holds got the shim's pseudo-handle instead of the drop-in DLL, andGetProcAddresson the compat DLL's real handle looked the name up in the shim of the same module name first. One console module could then be served half by the drop-in and half by the shim, which the static step exists to prevent.Now
shims::BundledModuleOpsgainscompat_module/owns_compat_handle, answered byrt::Loaderfrom the samecompat_handle()its static step (resolve_compat) uses, so both get oneHMODULEper module. Inshims/library_loader.cpp:LoadLibrary*checks the compat folder before the shim registry and the bundled package DLLs;GetModuleHandle*answers a compat module's handle once loaded and NULL before (never the shim's pseudo-handle);GetProcAddresson a compat handle gives only that DLL's exports;FreeLibraryon it returns TRUE and keeps it loaded (it is the Loader's reference, static imports may be bound through it; compat modules already stay for the process lifetime).A compat file Windows refuses fails that
LoadLibrarywith Windows' error (logged) instead of throwing into the title.runtime/README.mdis updated.Tested
loader_testnow linksshims/library_loader.cppand gainstest_compat_runtime_loads, eight cases with a synthetic drop-in DLL and the test shim module: without the folder the shim still answers; with it,GetModuleHandleis NULL before the load,LoadLibraryWreturns the compat DLL,GetModuleHandle(with and without.dll) returns it after,GetProcAddressgivesAnswer(42) and not the shim'sF, a static import in the same Loader binds to the same export,FreeLibrarykeeps it loaded, and a file Windows refuses (error 193) fails the load without the shim or a throw.loader: 103 ok, 0 FAIL.ctest: 376/377; the one failure isws2_offlineunder-j 4(loopback bind failures; it failed the same way here on a run without this change), which passes 3/3 run alone.GPUs tested: n/a (CPU only). Built with MSVC (VS 2022 Build Tools 17.14) + Ninja via
scripts\build_runtime.ps1, Windows 11 Pro 10.0.26200.AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.