Windows: Adding the flag --windows-gui to the relinker causes the relinked application to crash on start #2464
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 FALsGames on 2026-10-09T22:12:08Z.
Summary
An executable relinked with
--windows --windows-guiterminates immediately when started from Explorer or Console.Tested Game
Dreaming Sarah
Reproduction
--windows --windows-gui.Expected behaviour
The Windows GUI executable starts normally without creating or displaying a console window.
Actual behaviour
The process terminates with
0xC0000409.Cause
Explorer starts a GUI executable without standard handles. Setting
GetStdHandlevalues after the process has started is insufficient because the UCRT initializesstdin,stdout, andstderrduring process startup.Scope
The fix belongs in the Windows relinker startup stub. It must set the current directory to the executable directory and, only when a standard handle is missing, restart itself once with inheritable
NULhandles supplied throughSTARTF_USESTDHANDLES. It must preserve the Windows GUI subsystem and must not allocate, hide, or briefly display a console window.Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-09T22:21:37Z.
Data from a title anyone can download: ps5-doom (PPSA99666 v1.1.0, GPL), relinked on
mainb2714175(plus the two-line #2462 fix, needed to build on Windows) as--windows --windows-guiand as plain--windows. Windows 11 (26300), WinLibs GCC 15.2.0 r7, Release.--windows-guibuildShellExecute(PowerShellStart-Process, so no standard handles), working directory = the executable's folderC:\Windows\System32or the user folderexplorer.exe <path>So with this title, missing standard handles alone don't stop a GUI build: it runs from
ShellExecutewithout them. What does stop it is the working directory: started from any other folder, it doesn't find its files and exits, and the console build does the same. The Explorer launch behaves like that too. That supports the first part of the proposed fix (set the current directory to the executable's folder) as a generic problem. I couldn't reproduce the0xC0000409with this title (it exits cleanly with 0), so theNUL-handle restart may only matter for titles that write to the standard streams at start-up.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Get-fix on 2026-10-10T00:58:25Z.
Root cause in the code, a test, and a fix verified with ps5-doom.
Cause. The guest filesystem root is taken from the current directory (
core/libs/prx/libc/src/General.cpp:111,canonical(current_path())), so/app0/...resolves under the launch directory, and save data goes to the relative_sd(core/libs/prx/libSceSaveData.native/Export.cpp:24). That matches the ps5-doom table above;docs/user/USAGE.mddocuments the runtime layout as relative to the executable.Fix. Get-fix/AnyPS5
fix/windows-gui-startup(a2d583f5, onmain0c0dc1e9): the Windows entry stub already finds the executable directory to loadlibs\; it now passes it toSetCurrentDirectoryAbefore loading any library (6 lines inWindowsEntryStubBuilder.cpp, one import), with its own failure message. ChangingGeneral.cppand libSceSaveData instead would also change 11 library tests that use the current directory.Test.
windows_working_directoryconverts a guest whose import spins, starts it from another directory as console and--windows-guibuilds, and reads the child's current directory. It fails onmainand passes with the change. Relinker-only ctest ona2d583f5: 47 of 47; full Windows ctest before the rebase (64fe7439plus the #2462 lines): 544 of 544.ps5-doom (PPSA99666 v1.1.1;
eboot.binandsce_module/libc.prxunwrapped from the fake-signed SELF),--windows --windows-gui, started withStart-Processfrom another directory and fromC:\Windows\System32(3 runs each) and withexplorer.exe <path>: without the change it is gone within 6 s in all 7 starts; with it, it runs in all 7 and the DOOM window renders.Standard handles. Missing standard handles alone do not stop a title: the entry stub skips its writes when
GetStdHandlereturns null or invalid, andsceKernelDebugOutText,sceKernelSendNotificationRequestand the libc standard streams return errors instead of throwing. I could not reproduce0xC0000409. The relaunch in #2466 makeswindows_import_modulesfail (('missing-symbol-gui', '0x0', '0xc0000139')): the parent exits with 0 without waiting, so the child's status never reaches the caller.Linux output has the same current-directory root; this change covers Windows only.
AI-assisted: yes (Claude Code).