pe_loader: a compat DLL Windows cannot load is refused without a "Bad Image" box (RT-COMPAT-ERRBOX) #239
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!239
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/239/head"
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?
@natterman12 on GitHub · 2026-11-24 02:51 UTC · original
runtime/compat-load-no-error-dialog→main· +28 −1 · 2 files · 1 commits · merged 2026-11-24 03:36 UTCClaimed 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