mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:50:53 +01:00
[PR #239] [MERGED] pe_loader: a compat DLL Windows cannot load is refused without a "Bad Image" box (RT-COMPAT-ERRBOX) #292
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#292
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/239
Author: @natterman12
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @ubiquitarianism
Base:
main← Head:runtime/compat-load-no-error-dialog📝 Commits (1)
682fd05pe_loader: a compat DLL Windows cannot load is refused without a "Bad Image" box📊 Changes
2 files changed (+28 additions, -1 deletions)
View changed files
📝
runtime/src/pe_loader.cpp(+8 -1)📝
runtime/test/loader_test.cpp(+20 -0)📄 Description
Claimed in the coordination issue as: RT-COMPAT-ERRBOX (#14)
What and why
Loader::resolve_compat()loads a drop-in DLL fromLEONIDA_COMPAT_DIRwithLoadLibraryExW. When Windows cannot map the file (truncated, wrong machine, not a PE image), the system raises a modal "Bad Image" hard-error box (status 0xc000012f) andLoadLibraryExWdoes not return until someone clicks OK.The loader already reports that failure itself on the next line ("LEONIDA_COMPAT_DIR: ... exists but Windows could not load it (error N)"), so the box adds nothing and costs two things:
gta6rtwith a broken file in the compat folder hangs on a machine with nobody at it;loader_testwrites exactly such a file on purpose (compat_bad/testcompat.dll, 64 bytes of 0x5A), so every unattendedctestrun on Windows stops at theloadertest until the box is dismissed. Seven other runtime tests setSEM_FAILCRITICALERRORSfor themselves; here the fix belongs in the loader, since the runtime has the same problem.The load now runs with
SEM_FAILCRITICALERRORSadded to the calling thread's error mode (SetThreadErrorMode, so other threads are unaffected), and the previous mode is restored afterwards.GetLastError()is read before the mode is put back, so the reported code is the load's own.loader_testgains three checks on the existing bad-file case: the thread's error mode is unchanged afterwards (the case starts from a mode withoutSEM_FAILCRITICALERRORS, so a loader that suppresses nothing would show the box), the message still carries a non-zero Windows error code, and the refusal returns within 5 s rather than waiting on a box.Tested
Windows 11 (10.0.26300), Visual Studio Build Tools 2022 (MSVC 19.44.35230), NVIDIA RTX 3080 Ti, driver 621.24. No game files.
mainda60a3615: the "loader_test.exe - Bad Image" box appeared duringctestand theloadertest took 28.69 s, the wait for the click.loader_test.exerun directly finishes in 9 s with no box,95 checks, 0 failed, including the three new ones.loader_test(which links the loader) on this branch; the full runtime suite was run onmain, not on this branch. Not tested under Wine, where the box does not appear in the first place.AI-assisted: yes (Claude Code)
Checklist
docs/design.md, with how it was confirmed. (not applicable: no translator change)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.