Loader/HLE: run the process-detach notices when a title calls ExitProcess #1445
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1445"
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 fxceless/victory-fork. Originally posted by CwWwWwW on 2026-11-27T08:39:24Z.
Problem
A title's
ExitProcessimport was bound to the host'sExitProcess, which ends the process without the loader's process-detach path. Title images are prepared with no entry point and no TLS callbacks, so the only way a title DLL hearsDLL_PROCESS_DETACH(and its CRTatexit/flush/static destructors, and the exe'sPROCESS_DETACHTLS notice) isvictory_loader::threads::detach_all, registered on the host CRT'satexit. The hostExitProcessdoes not run CRTatexit: a normal exit path silently skipped every detach notice - a data-loss risk for anything flushed or released there.Fix
victory-loader: makedetach_allidempotent (anEXITINGswap guard) and export it asthreads::exit_notices.victory-hle: exportExitProcessfromkernel32,kernelbaseandapi-ms-win-core-processthreads; the override logs, runsexit_notices, then calls the hostExitProcess.TerminateProcessis unchanged (Windows sends no DLL notifications for it).Tests and evidence
tests::exit_process_resolves_to_our_exportclassifiesExitProcessasHlefor the three DLLs; it fails before the change (Host).DllMainmarker and an export calling its importedExitProcess; before:attach, quit-called, after:attach, quit-called, detach.cargo test -p victory-hle --lib --locked: 104 passed;-p victory-loader --lib --locked: 28 passed; clippy clean for both.Implemented independently from the target tree; no external code was copied. Based on main
9a9091d- it supersedes the old branchfix/exitprocess-detach, which was made on 4245f3.The PR's Clippy check fails on main already: at
9a9091dcargo clippy --workspace --all-targetsfails invictory-shader(wave64_after_loop.rs precedence, valu_tests.rs simplifiable/negated partial-ord comparisons); open PR #1440 fixes exactly those lints. This diff touches none of those files, and the touched crate's own tests and clippy are clean locally.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.