mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:45:54 +01:00
[PR #1461] library_loader: shim GetModuleFileNameA/W and GetModuleHandle(NULL) (RT-LIBLOADER-MODULE-FILENAME) #1490
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#1490
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/1461
Author: @piyonchu
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:pr/libloader-module-filename📝 Commits (1)
bada1aflibrary_loader: shim GetModuleFileNameA/W and GetModuleHandle(NULL) (RT-LIBLOADER-MODULE-FILENAME)📊 Changes
7 files changed (+337 additions, -19 deletions)
View changed files
📝
runtime/CMakeLists.txt(+21 -0)📝
runtime/shims/library_loader.cpp(+84 -19)📝
runtime/shims/registry.cpp(+13 -0)📝
runtime/shims/shims.h(+5 -0)📝
runtime/src/pe_loader.cpp(+34 -0)📝
runtime/src/pe_loader.h(+4 -0)➕
runtime/test/library_loader_test.cpp(+176 -0)📄 Description
Claimed in the coordination issue as: RT-LIBLOADER-MODULE-FILENAME
Summary
game_scarlett_master.execall sites show bothapi-ms-win-core-libraryloader-l1-2-0.dll!GetModuleFileNameAandapi-ms-win-core-libraryloader-l1-2-0.dll!GetModuleFileNameWcalled withhModule = NULLandnSize = MAX_PATH(0x104), with the wide caller turning0intoHRESULT_FROM_WIN32(GetLastError()). Without shims, both returngta6rt.exerather than the mapped executable, and calls for bundled DLL handles fail withERROR_MOD_NOT_FOUND.full_path) and EXE flag (is_exe) inrt::Module/rt::Loader(runtime/src/pe_loader.h,runtime/src/pe_loader.cpp), exposed through optional callbacks onrt::shims::BundledModuleOps(runtime/shims/shims.h,runtime/shims/registry.cpp).GetModuleFileNameA,GetModuleFileNameW, andGetModuleHandleA/GetModuleHandleW(nullptr)inruntime/shims/library_loader.cppfor mapped executables, bundled DLLs, and owned shim pseudo-handles while matching Win32 buffer truncation (nSize == len,nSize == 0,ERROR_INSUFFICIENT_BUFFER/ERROR_SUCCESS) and preserving host fallback when no mapped EXE is active.library_loader(runtime/test/library_loader_test.cpp) verifying mapped EXEnullptr/handle resolution acrossSetCurrentDirectory, DLL-only host fallback, bundled dependency handle resolution, pseudo-handle resolution, and truncation/size=0 parity against native::GetModuleFileNameW.Verification
RelWithDebInfo, Windows 11, CPU-only build without Vulkan headers) and ranctest -C RelWithDebInfo -R "^(library_loader|dll_thread_calls|pe_loader|xgameruntime)$" --output-on-failure: 4/4 passed (pe_loader,dll_thread_calls,library_loader,xgameruntime).gta6rt.exe --dry-runagainst a localgame_scarlett_master.execonfirms bothapi-ms-win-core-libraryloader-l1-2-0.dll!GetModuleFileNameAandGetModuleFileNameWnow bind toshim.python -I tests/test_build_runtime_fallback.py: 10 tests OK.python -I tests/test_text_write_line_endings.py: 3 tests OK.git diff --check: clean.AI-assisted; synthetic tests +
--dry-runimport check on Windows 11 (CPU-only build; no game files included).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.