Windows: a GUI title started without standard handles loses the stdio of msvcrt- and ucrt-linked modules to a preloaded CRT (injected DLLs: Windhawk, antivirus) #10152
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?
Imported from boykopovar/AnyPS5. Originally posted by Usama171 on 2026-10-23T10:56:07Z.
What happens
windows_import_modules fails its gui-dll-msvcrt-both-missing case: anyps5.log holds only "Transferring control to ELF entry point" and the module's "Windows DLL stdout probe"/"Windows DLL stderr probe" never arrive, because an injected DLL (Windhawk here) loads msvcrt.dll before the entry stub's SetStdHandle and msvcrt pins its streams to _file = -2 (no console) for the life of the process.
Title, test or build step
ctest windows_import_modules (relinker-only build), the gui-dll-msvcrt-both-missing case; the ucrt case passes only because nothing preloads ucrtbase.dll here.
AnyPS5 commit
main
348157914(2026-10-23), no local changes.System
Windows 11 Home 26200, WinLibs GCC 15.3.0 (x86_64-ucrt-posix-seh, r1), CMake 4.2.0. Windhawk 1.6 installed with its global injection active; no AppInit_DLLs. No GPU involved.
Steps to reproduce
cmake --build build-relinker --parallel
ctest --test-dir build-relinker -R windows_import_modules --output-on-failure
Fails after about 18 s, every run, on any machine where a globally injected DLL links msvcrt. Without an injector, loading msvcrt.dll or ucrtbase.dll into the suspended converted executable with CreateRemoteThread before its first instruction reproduces the same loss for either runtime.
Log
What was checked
A fix follows as a pull request: after the entry stub redirects the standard handles to anyps5.log, for each of msvcrt.dll and ucrtbase.dll that GetModuleHandleW reports already loaded, rebind the streams whose standard handle is the stub's log handle through that runtime's own exports (__iob_func or __acrt_iob_func, plus _wfreopen in append mode; the stub's log handle already shares read and write). Verified by the probes above, with a regression test that preloads the runtime into the suspended guest with CreateRemoteThread.