Problem
The Rockstar Games Launcher installer (a one-time install for Red Dead Redemption 2 and GTA IV, see willfaust/Madeira#151) writes its own x64 ucrtbase.dll and the api-ms-win-crt-* forwarders into C:\Program Files\Rockstar Games\Launcher. The application directory is searched first, so ARM64EC modules that import ucrtbase.dll by name bind that x64 copy instead of the ARM64EC one, and have no exit thunk for it:
- the x64 emulator (
xtajit64.dll) died inside it withSTATUS_ILLEGAL_INSTRUCTION(ucrtbase.dll+0x8980); - with the emulator's import worked around locally,
RockstarService.exedied the same way atuser32.dll+0x0: user32's CRT import (memcpy) was bound to the x64 copy.
Fix
Windows 10 and later always use the Universal CRT in the system directory, even if the application includes its own copy (Universal CRT deployment, "Local deployment").
find_dll_file now does the same under __arm64ec__: after the known-DLL lookup, a bare ucrtbase.dll becomes C:\windows\system32\ucrtbase.dll, and the existing mixed-arch fallback to sysx64 still applies. Api-set names already resolve to system32, and names with a path or an activation-context redirect are unchanged. Each redirect is logged as [ucrt-system].
Testing
- iPhone 17 Pro, iOS 27.0, Madeira 0.1.3 with only
arm64ec-windows/ntdll.dllreplaced by a build of this branch (llvm-mingw 20260421). The missing DLLs from willfaust/Madeira#151 (Msftedit.dll and others) were added with willfaust/Madeira#163's script. - Red Dead Redemption 2 (Steam 1174180), one-time install of
Rockstar-Games-Launcher.exe1.0.109.3031:[ucrt-system]fires and there is noc000001d. The installer writes its files, andvc_redist.x86.exeandvc_redist.x64.exeboth exit 0. - The installer then stops at a separate problem this PR does not address:
RockstarService.exe installexits withc0000005, an execute fault at exe+0x14c9bd (in.rsrc) after a long run of write faults into its own.text. The exe is packed and rewrites its own code at run time. - Merges cleanly together with #19, which changes the same function in a different place.
AI assistance: prepared with Claude under the owner's direction (Co-Authored-By trailer). Signed off (DCO) by Lincoln Holcomb. LGPL-2.1+ as the file.
🤖 Generated with Claude Code