Linux/Proton: restart victory.exe directly without PowerShell (Fixes #1954) #2434

Open
steven-seagull27 wants to merge 1 commit from upstream-pr/2434 into main
steven-seagull27 commented 2026-11-29 13:00:08 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by steven-seagull27 on 2026-11-29T13:00:08Z.


Fixes #1954

Summary

  • Root cause: Menu::restart_as in crates/victory-gpu/src/host/menu.rs unconditionally spawned powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "Start-Sleep 3; ... & $env:VICTORY_MENU_PLAY ..." before calling TerminateProcess. Under Linux/Proton (Wine), powershell.exe is either absent or Wine's stub executable (which CreateProcessW starts successfully and which then exits immediately without running anything — matching docs/linux-proton.md and #1954). As a result, both the one-time warmup restart (Menu::warmup) and F1 settings restarts closed the game without relaunching victory.exe.
  • Direct .exe relaunch without PowerShell (crates/victory-gpu/src/host/menu.rs):
    • Added Wine/Proton detection via ntdll.dll's wine_get_version (on_wine()), matching apps/victory/src/main.rs and crates/victory-hle/src/modules/xmem.rs.
    • Added parse_menu_args to parse VICTORY_MENU_ARGS (single-quoted PowerShell tokens, escaped '', and $env:VICTORY_MENU_EXE expansion) into raw OsString arguments while rejecting unclosed quotes or unquoted shell operators.
    • Added MSVCRT / CommandLineToArgvW-compliant Windows command-line quoting (build_windows_command_line) and sorted UTF-16 environment block construction (build_env_block, CREATE_UNICODE_ENVIRONMENT) for CreateProcessW with CREATE_NEW_CONSOLE.
    • Added plan_restart strategy selection:
      • Launches native .exe targets directly without PowerShell under Wine/Proton (never hitting Wine's stub powershell.exe), when restarting victory.exe itself, and for own_command (save import).
      • Preserves PowerShell launch for .ps1 launcher scripts on native Windows (and uses PowerShell with direct-spawn fallback for third-party .exe launchers on native Windows).
      • Refuses cleanly with a warning log and drawable menu note — without terminating the running game — if a non-.exe launcher or unparseable args cannot be restarted under Wine/Proton.
  • Startup delay and error hold for direct restarts (apps/victory/src/main.rs, apps/victory/src/play.rs):
    • Direct restarts pass VICTORY_RESTART_DELAY_SECS=3 and the requested Then override (VICTORY_PRELOAD=1 / VICTORY_CLEAR_SHADERS=1, clearing stale flags) directly in the child environment block.
    • At the very start of main() (before GPU/runtime initialization, address-space reservation, or child process spawns), victory.exe reads and immediately removes VICTORY_RESTART_DELAY_SECS (clamped to 30s), sleeps so the previous process exits and releases GPU/file locks cleanly, and holds the console window on startup error (play::hold_window) when restarted directly.

Verification (synthetic tests only)

  • cargo test --locked -j 3 -p victory-gpu --lib -- menu --nocapture --test-threads=1 — 19 passed, 0 failed:
    • parse_menu_args_handles_quotes_unicode_and_env_expansion (spaces, Unicode, typographic apostrophes #563, escaped ', quotes, backslashes, $env:VICTORY_MENU_EXE, invalid syntax rejection)
    • windows_command_line_round_trips_through_command_line_to_argv_w (Win32 CommandLineToArgvW round-trip)
    • build_env_block_applies_case_insensitive_overrides_and_removals (Then::Play / Preload / ClearShaders, VICTORY_RESTART_DELAY_SECS=3, stale flag clearing)
    • plan_restart_selects_direct_powershell_fallback_and_unavailable (Wine/Proton vs native Windows, .exe vs .ps1, own_command, menu glyph/width checks)
    • direct_restart_spawns_exe_without_powershell_and_passes_env_and_args (end-to-end CreateProcessW direct restart verifying cwd, args with spaces/Unicode/typographic apostrophes/quotes/backslashes, VICTORY_RESTART_DELAY_SECS=3, VICTORY_CLEAR_SHADERS=1, and stale VICTORY_PRELOAD removal)
    • preload_restart_preserves_paths_and_working_directory (existing .ps1 PowerShell path preserved)
  • cargo test --locked -j 3 -p victory --bin victory -- --nocapture — 80 passed, 0 failed (including restart_delay_parses_clamps_and_rejects_invalid_values, take_restart_delay_clears_env_so_children_do_not_inherit_it, and all existing play::tests::*).
  • cargo clippy --locked -j 3 -p victory-gpu -p victory --bins --tests — 0 warnings in touched files.
  • git diff --check — clean.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5550946456 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2434). Originally posted by [steven-seagull27](https://github.com/steven-seagull27) on 2026-11-29T13:00:08Z. --- Fixes #1954 ## Summary - **Root cause:** `Menu::restart_as` in `crates/victory-gpu/src/host/menu.rs` unconditionally spawned `powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "Start-Sleep 3; ... & $env:VICTORY_MENU_PLAY ..."` before calling `TerminateProcess`. Under Linux/Proton (Wine), `powershell.exe` is either absent or Wine's stub executable (which `CreateProcessW` starts successfully and which then exits immediately without running anything — matching `docs/linux-proton.md` and #1954). As a result, both the one-time warmup restart (`Menu::warmup`) and F1 settings restarts closed the game without relaunching `victory.exe`. - **Direct `.exe` relaunch without PowerShell (`crates/victory-gpu/src/host/menu.rs`):** - Added Wine/Proton detection via `ntdll.dll`'s `wine_get_version` (`on_wine()`), matching `apps/victory/src/main.rs` and `crates/victory-hle/src/modules/xmem.rs`. - Added `parse_menu_args` to parse `VICTORY_MENU_ARGS` (single-quoted PowerShell tokens, escaped `''`, and `$env:VICTORY_MENU_EXE` expansion) into raw `OsString` arguments while rejecting unclosed quotes or unquoted shell operators. - Added MSVCRT / `CommandLineToArgvW`-compliant Windows command-line quoting (`build_windows_command_line`) and sorted UTF-16 environment block construction (`build_env_block`, `CREATE_UNICODE_ENVIRONMENT`) for `CreateProcessW` with `CREATE_NEW_CONSOLE`. - Added `plan_restart` strategy selection: - Launches native `.exe` targets directly without PowerShell under Wine/Proton (never hitting Wine's stub `powershell.exe`), when restarting `victory.exe` itself, and for `own_command` (save import). - Preserves PowerShell launch for `.ps1` launcher scripts on native Windows (and uses PowerShell with direct-spawn fallback for third-party `.exe` launchers on native Windows). - Refuses cleanly with a warning log and drawable menu note — without terminating the running game — if a non-`.exe` launcher or unparseable args cannot be restarted under Wine/Proton. - **Startup delay and error hold for direct restarts (`apps/victory/src/main.rs`, `apps/victory/src/play.rs`):** - Direct restarts pass `VICTORY_RESTART_DELAY_SECS=3` and the requested `Then` override (`VICTORY_PRELOAD=1` / `VICTORY_CLEAR_SHADERS=1`, clearing stale flags) directly in the child environment block. - At the very start of `main()` (before GPU/runtime initialization, address-space reservation, or child process spawns), `victory.exe` reads and immediately removes `VICTORY_RESTART_DELAY_SECS` (clamped to 30s), sleeps so the previous process exits and releases GPU/file locks cleanly, and holds the console window on startup error (`play::hold_window`) when restarted directly. ## Verification (synthetic tests only) - `cargo test --locked -j 3 -p victory-gpu --lib -- menu --nocapture --test-threads=1` — **19 passed, 0 failed**: - `parse_menu_args_handles_quotes_unicode_and_env_expansion` (spaces, Unicode, typographic apostrophes `#563`, escaped `'`, quotes, backslashes, `$env:VICTORY_MENU_EXE`, invalid syntax rejection) - `windows_command_line_round_trips_through_command_line_to_argv_w` (Win32 `CommandLineToArgvW` round-trip) - `build_env_block_applies_case_insensitive_overrides_and_removals` (`Then::Play` / `Preload` / `ClearShaders`, `VICTORY_RESTART_DELAY_SECS=3`, stale flag clearing) - `plan_restart_selects_direct_powershell_fallback_and_unavailable` (Wine/Proton vs native Windows, `.exe` vs `.ps1`, `own_command`, menu glyph/width checks) - `direct_restart_spawns_exe_without_powershell_and_passes_env_and_args` (end-to-end `CreateProcessW` direct restart verifying cwd, args with spaces/Unicode/typographic apostrophes/quotes/backslashes, `VICTORY_RESTART_DELAY_SECS=3`, `VICTORY_CLEAR_SHADERS=1`, and stale `VICTORY_PRELOAD` removal) - `preload_restart_preserves_paths_and_working_directory` (existing `.ps1` PowerShell path preserved) - `cargo test --locked -j 3 -p victory --bin victory -- --nocapture` — **80 passed, 0 failed** (including `restart_delay_parses_clamps_and_rejects_invalid_values`, `take_restart_delay_clears_env_so_children_do_not_inherit_it`, and all existing `play::tests::*`). - `cargo clippy --locked -j 3 -p victory-gpu -p victory --bins --tests` — **0 warnings** in touched files. - `git diff --check` — clean.
steven-seagull27 commented 2026-11-30 18:33:36 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by steven-seagull27 on 2026-11-30T18:33:36Z.


Rebased cleanly onto latest main (e1251c31, including #4067 where Steam launches victory.exe play directly and play-nvidia.ps1). Re-verified victory-gpu menu tests, victory binary tests, Clippy, and xtask policy --staged.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7288027713 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2434#issuecomment-7288027713). Originally posted by [steven-seagull27](https://github.com/steven-seagull27) on 2026-11-30T18:33:36Z. --- Rebased cleanly onto latest `main` (`e1251c31`, including `#4067` where Steam launches `victory.exe play` directly and `play-nvidia.ps1`). Re-verified `victory-gpu` menu tests, `victory` binary tests, Clippy, and `xtask policy --staged`.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2434:upstream-pr/2434'
git switch 'upstream-pr/2434'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/2434'
git switch 'upstream-pr/2434'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2434'
git switch 'upstream-pr/2434'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2434'
git switch 'main'
git merge --squash 'upstream-pr/2434'
git switch 'main'
git merge --ff-only 'upstream-pr/2434'
git switch 'main'
git merge 'upstream-pr/2434'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
trustno1-coder/VIctory-NVIDIA!2434
No description provided.