fix(sandbox): DLSS starts on Windows PCs where the container is refused ProgramData's path, and NGX's lines are logged when it fails #3086

Merged
HumanBean merged 1 commit from HumanBean/Longshot:fix/ngx-programdata into main 2026-12-03 15:14:15 +00:00
Owner

Summary

Fixes #3085: with the sandbox on, DLSS can't be chosen on some Windows PCs, and the menu wrongly says DLSS needs an RTX GPU.

The cause. In NVIDIA's NGX core (_nvngx.dll), NGXGetPath calls SHGetKnownFolderPath(FOLDERID_ProgramData, 0, NULL, ...) before anything else. If that call fails, NGX logs NGXGetPath failed to obtain path to models (its line 997, 0x3e5) and gives up. That branch is reached from this one call only. I read this from the disassembly of the Windows NGX core that NVIDIA's Linux driver ships for Wine (/usr/lib/nvidia/wine/_nvngx.dll): js straight after the call, the GUID 62AB5D82-… is FOLDERID_ProgramData, and the line number matches the player's log. So on that PC, Windows refuses the AppContainer ProgramData's path. This is why #3085 ruled out the folder's permissions: NGX never got as far as opening anything. Why Windows refuses it on that PC only is still unknown.

The fix.

  • The builder asks Windows for ProgramData outside the container, the same call (SHGetKnownFolderPath), and passes it to the game in LONGSHOT_SANDBOX_PROGRAMDATA: a drive's whole path, normalised by path_norm. The variable is under the sandbox's own LONGSHOT_SANDBOX_ prefix, so a player's file can't set it.
  • The game's file layer (host/hos_file_windows.c) also patches SHGetKnownFolderPath in every module's shell32 imports, including _nvngx.dll's, which is loaded later. Windows' answer is kept whenever the call succeeds. Only when it fails for FOLDERID_ProgramData with no token, the builder's folder is returned instead, and the log says so once with Windows' error: sandbox: Windows refused the container ProgramData's path (SHGetKnownFolderPath: 0x...) ....
  • Only the path is answered. Whatever NGX then opens there is still Windows' decision, as on the PCs where the call already succeeds (the RTX 5080 and 5070 Ti in #3085). No ACL changes and no new file roots.

NGX's lines in the log without a switch. Until now a failed start left one line (NGX did not start (0xbad00002)), and the real reason needed RX_VK_DLSS_LOG=1 and a second round trip with the player. NGX's lines now always go to the game. The last 64 are kept and written out under vk: NVIDIA DLSS: <why>: NGX's last N lines: whenever NGX fails to start (init, capabilities, not available, parameters). RX_VK_DLSS_LOG=1 still logs every line live. NGX's own log files are always off: they went to <game>\ngx, which the sandbox serves read-only.

Read first: my_SHGetKnownFolderPath and patch_known_folder in host/hos_file_windows.c, program_data in sandbox_windows.rs, ngx_log in vk_dlss.cpp.

Testing

Tested:

  • tests/test_sandbox_program_data_wine.py (new, Wine and llvm-mingw): 15 checks pass. Refused β†’ the builder's folder, counted and logged once with 0x80070005. Not refused β†’ Windows' own answer kept. Another known folder, a token, a bad or missing value β†’ never answered. It fails on main, where the layer has no such hook (the test program doesn't build).
  • cargo test -p build-core program_data: the value's form (a drive's whole path; a share, relative path, .. or control character refused).
  • cargo clippy -p build-core --target x86_64-pc-windows-gnullvm -D warnings: clean.
  • llvm-mingw -fsyntax-only -Wall -Wextra -Werror: host/hos_file_windows.c and host/sandbox_windows.c. gpu/vk/vk_dlss.cpp (with the NGX SDK headers): no errors.

Not tested: nothing has run in the game. The change is Windows-only, and the PC this was written on is Linux (RTX 3090). Opened without a game run (--force) at the request of the person I work for.

Still to test:

  • Windows, the RTX 3080 from #3085 (nvmdi.inf, 621.47), sandbox on: expect the sandbox: Windows refused the container ProgramData's path line, then NGX started, and DLSS selectable (by hand, the player)
  • Windows, NVIDIA RTX where DLSS already works (RTX 5080 / 5070 Ti), sandbox on: expect no refused line and no change (by hand or Test Farm)
  • Windows, NVIDIA RTX, DLSS made to fail (e.g. RX_VK_DLSS_DIR pointing at an empty folder with no runtime elsewhere), no RX_VK_DLSS_LOG: expect NGX's last N lines: in the log (by hand or Test Farm)
  • Linux, NVIDIA RTX, DLSS on: expect NGX started and no ngx: lines without the switch (shared queue run)

Measurements

Nothing to measure. One import-table pass more per loaded module (shell32 imports only). NGX's lines are kept in memory instead of written to files: at most 64 strings.

Risks

  • The layer now patches shell32 imports as well as kernel32's. Another program's hook already sitting in an entry is left as it is, as for the file functions.
  • If Windows refuses ProgramData's path for a reason that also blocks what NGX reads next, DLSS still fails, but the log then shows NGX's next error with no switch needed.
  • Revert is enough. Saves, settings and caches don't change.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says. (No: Windows-only change, Linux PC; opened with --force on request)
  • mise run test passes (any failure that also fails on main is named). (Only the new and directly affected tests ran)
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here.
  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Windows: syntax check of the changed files; Linux: the host C changed is Windows-only, vk_dlss.cpp not compiled for Linux)
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

πŸ€– Generated with Claude Code

## Summary Fixes #3085: with the sandbox on, DLSS can't be chosen on some Windows PCs, and the menu wrongly says DLSS needs an RTX GPU. **The cause.** In NVIDIA's NGX core (`_nvngx.dll`), `NGXGetPath` calls `SHGetKnownFolderPath(FOLDERID_ProgramData, 0, NULL, ...)` before anything else. If that call fails, NGX logs `NGXGetPath failed to obtain path to models` (its line 997, `0x3e5`) and gives up. That branch is reached from this one call only. I read this from the disassembly of the Windows NGX core that NVIDIA's Linux driver ships for Wine (`/usr/lib/nvidia/wine/_nvngx.dll`): `js` straight after the call, the GUID `62AB5D82-…` is `FOLDERID_ProgramData`, and the line number matches the player's log. So on that PC, Windows refuses the AppContainer ProgramData's *path*. This is why #3085 ruled out the folder's permissions: NGX never got as far as opening anything. Why Windows refuses it on that PC only is still unknown. **The fix.** - The builder asks Windows for ProgramData outside the container, the same call (`SHGetKnownFolderPath`), and passes it to the game in `LONGSHOT_SANDBOX_PROGRAMDATA`: a drive's whole path, normalised by `path_norm`. The variable is under the sandbox's own `LONGSHOT_SANDBOX_` prefix, so a player's file can't set it. - The game's file layer (`host/hos_file_windows.c`) also patches `SHGetKnownFolderPath` in every module's shell32 imports, including `_nvngx.dll`'s, which is loaded later. Windows' answer is kept whenever the call succeeds. Only when it fails for `FOLDERID_ProgramData` with no token, the builder's folder is returned instead, and the log says so once with Windows' error: `sandbox: Windows refused the container ProgramData's path (SHGetKnownFolderPath: 0x...) ...`. - Only the path is answered. Whatever NGX then opens there is still Windows' decision, as on the PCs where the call already succeeds (the RTX 5080 and 5070 Ti in #3085). No ACL changes and no new file roots. **NGX's lines in the log without a switch.** Until now a failed start left one line (`NGX did not start (0xbad00002)`), and the real reason needed `RX_VK_DLSS_LOG=1` and a second round trip with the player. NGX's lines now always go to the game. The last 64 are kept and written out under `vk: NVIDIA DLSS: <why>: NGX's last N lines:` whenever NGX fails to start (init, capabilities, not available, parameters). `RX_VK_DLSS_LOG=1` still logs every line live. NGX's own log files are always off: they went to `<game>\ngx`, which the sandbox serves read-only. Read first: `my_SHGetKnownFolderPath` and `patch_known_folder` in `host/hos_file_windows.c`, `program_data` in `sandbox_windows.rs`, `ngx_log` in `vk_dlss.cpp`. ## Testing **Tested:** - `tests/test_sandbox_program_data_wine.py` (new, Wine and llvm-mingw): 15 checks pass. Refused β†’ the builder's folder, counted and logged once with `0x80070005`. Not refused β†’ Windows' own answer kept. Another known folder, a token, a bad or missing value β†’ never answered. It **fails on `main`**, where the layer has no such hook (the test program doesn't build). - `cargo test -p build-core program_data`: the value's form (a drive's whole path; a share, relative path, `..` or control character refused). - `cargo clippy -p build-core --target x86_64-pc-windows-gnullvm -D warnings`: clean. - llvm-mingw `-fsyntax-only -Wall -Wextra -Werror`: `host/hos_file_windows.c` and `host/sandbox_windows.c`. `gpu/vk/vk_dlss.cpp` (with the NGX SDK headers): no errors. **Not tested: nothing has run in the game.** The change is Windows-only, and the PC this was written on is Linux (RTX 3090). Opened without a game run (`--force`) at the request of the person I work for. **Still to test:** - Windows, the RTX 3080 from #3085 (`nvmdi.inf`, 621.47), sandbox on: expect the `sandbox: Windows refused the container ProgramData's path` line, then `NGX started`, and DLSS selectable (by hand, the player) - Windows, NVIDIA RTX where DLSS already works (RTX 5080 / 5070 Ti), sandbox on: expect no `refused` line and no change (by hand or Test Farm) - Windows, NVIDIA RTX, DLSS made to fail (e.g. `RX_VK_DLSS_DIR` pointing at an empty folder with no runtime elsewhere), no `RX_VK_DLSS_LOG`: expect `NGX's last N lines:` in the log (by hand or Test Farm) - Linux, NVIDIA RTX, DLSS on: expect `NGX started` and no `ngx:` lines without the switch (shared queue run) ## Measurements Nothing to measure. One import-table pass more per loaded module (shell32 imports only). NGX's lines are kept in memory instead of written to files: at most 64 strings. ## Risks - The layer now patches shell32 imports as well as kernel32's. Another program's hook already sitting in an entry is left as it is, as for the file functions. - If Windows refuses ProgramData's path for a reason that also blocks what NGX reads next, DLSS still fails, but the log then shows NGX's next error with no switch needed. - Revert is enough. Saves, settings and caches don't change. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [ ] Tested on my own PC, in the game for a change the game runs, as Testing says. (No: Windows-only change, Linux PC; opened with `--force` on request) - [ ] `mise run test` passes (any failure that also fails on `main` is named). (Only the new and directly affected tests ran) - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Windows: syntax check of the changed files; Linux: the host C changed is Windows-only, `vk_dlss.cpp` not compiled for Linux) - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. πŸ€– Generated with [Claude Code](https://claude.com/claude-code)
fix(sandbox): DLSS starts on Windows PCs where the container is refused ProgramData's path, and NGX's lines are logged when it fails (#3085)
Some checks failed
CI / What the change needs (pull_request) Successful in 9s
CI / Third-party parts and guide screenshots (pull_request) Successful in 13s
PR description / Title and description (pull_request_target) Failing after 7s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 18s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Failing after 1m17s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 16m35s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 12m31s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 12m39s
CI / Website build and checks (pull_request) Successful in 1m18s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 1h0m5s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 51m9s
c727e429e7
NVIDIA's NGX (_nvngx.dll, NGXGetPath) asks SHGetKnownFolderPath(FOLDERID_ProgramData) before anything else and gives
up when it fails ("NGXGetPath failed to obtain path to models", line 997, reached from that call alone). On some PCs
Windows refuses it to the AppContainer. The builder now asks it outside the container and hands it over
(LONGSHOT_SANDBOX_PROGRAMDATA); the file layer answers SHGetKnownFolderPath(ProgramData) with it only where Windows
refused, logged once with Windows' error.

NGX's own lines always come to the game: kept (the last 64) and written to the log when NGX fails to start, live with
RX_VK_DLSS_LOG=1 as before. Never NGX's own log files, in a folder the sandbox serves read only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
HumanBean changed title from WIP: fix(sandbox): DLSS starts on Windows PCs where the container is refused ProgramData's path, and NGX's lines are logged when it fails to fix(sandbox): DLSS starts on Windows PCs where the container is refused ProgramData's path, and NGX's lines are logged when it fails 2026-12-03 15:14:08 +00:00
HumanBean deleted branch fix/ngx-programdata 2026-12-03 15:14:15 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
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.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!3086
No description provided.