Loader: VICTORY_NULL_GUARD gives a start-up callback the null check it leaves out (RTX 4070 Ti) #531

Open
github-bot wants to merge 1 commit from github-bot/gh-531 into a-publier AGit
Owner

@⁠urielbeaupre on GitHub · 2026-11-27 09:55 UTC · original
urielbeaupre:nvidia-null-guard → a-publier · +225 −0 · 6 files · 1 commits · open

What

On an NVIDIA RTX 4070 Ti, every start of game_scarlett_master.exe 1.0.2.1 ended right after pressing A on the start screen with a read of address 0x38 (7 runs of 7: Series X and S, 4K and 1080p, with and without -Safe, at cd8dfc0 and 4eb6cfd).

  • Start-up callback +0x2bb6960 looks an object up by two name hashes (+0x2a23d0). On this card it finds nothing, then tail-jumps to +0x1cfa5a0, which reads +0x38 of the result at once.
  • The title's own function just before it (+0x1cfa590) checks its object for null and returns. VICTORY_NULL_GUARD=1 gives the callback the same check: the 10 int3 padding bytes before +0x1cfa5a0 become test rcx, rcx; jz <ret at +0x1cfa585>; jmp +0x1cfa5a0, and the callback's tail jump goes there instead. Both sites are byte-checked first; the jump is written only after the guard is. Off by default.
  • Also VICTORY_LOCALE / VICTORY_GEO: the locale and region the title gets from GetUserDefaultLocaleName / GetUserDefaultGeoName, in place of the PC's. They are for testing whether the empty lookup depends on the region. The module is served only when one of them is set.
  • README: an RTX 4070 Ti row under "Reports from other GPUs", and rows for the new switches.

Tested

  • RTX 4070 Ti (12 GB), Series X profile, scripts\play.ps1 -More @{VICTORY_NULL_GUARD='1'}: both sites patched, the title went past the start screen into the game, and it closed cleanly with no crash logged.
  • First run on this driver: 1.6 fps (630 ms a frame), with 1,000-3,000 draws a frame waiting for pipelines the driver was still making, and 7.4 GB in use of a 7.6 GB video memory budget. That is in line with the RTX 3090 report (#333).
  • cargo test -p victory-loader null_guard: 2 passed.

Not known / not done

  • Why the lookup finds nothing on this card is not known: the guard only lets the title go on without the object.
  • The VICTORY_LOCALE / VICTORY_GEO overrides have not been tried in a run yet, and cargo test -p victory-hle locale matched no test, so their unit test has not run.
  • One earlier run (before this one, settings unconfirmed) ended in the title's own assert (int3 at +0x1ce6e13, called from +0x293ef38). It did not happen in the tested run.

🤖 Generated with Claude Code

**@⁠urielbeaupre** on GitHub · 2026-11-27 09:55 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/531) `urielbeaupre:nvidia-null-guard` → `a-publier` · +225 −0 · 6 files · 1 commits · open ## What On an NVIDIA RTX 4070 Ti, every start of `game_scarlett_master.exe` 1.0.2.1 ended right after pressing A on the start screen with a read of address 0x38 (7 runs of 7: Series X and S, 4K and 1080p, with and without `-Safe`, at `cd8dfc0` and `4eb6cfd`). - Start-up callback +0x2bb6960 looks an object up by two name hashes (+0x2a23d0). On this card it finds nothing, then tail-jumps to +0x1cfa5a0, which reads +0x38 of the result at once. - The title's own function just before it (+0x1cfa590) checks its object for null and returns. `VICTORY_NULL_GUARD=1` gives the callback the same check: the 10 int3 padding bytes before +0x1cfa5a0 become `test rcx, rcx; jz <ret at +0x1cfa585>; jmp +0x1cfa5a0`, and the callback's tail jump goes there instead. Both sites are byte-checked first; the jump is written only after the guard is. **Off by default.** - Also `VICTORY_LOCALE` / `VICTORY_GEO`: the locale and region the title gets from `GetUserDefaultLocaleName` / `GetUserDefaultGeoName`, in place of the PC's. They are for testing whether the empty lookup depends on the region. The module is served only when one of them is set. - README: an RTX 4070 Ti row under "Reports from other GPUs", and rows for the new switches. ## Tested - RTX 4070 Ti (12 GB), Series X profile, `scripts\play.ps1 -More @{VICTORY_NULL_GUARD='1'}`: both sites patched, the title went past the start screen into the game, and it closed cleanly with no crash logged. - First run on this driver: 1.6 fps (630 ms a frame), with 1,000-3,000 draws a frame waiting for pipelines the driver was still making, and 7.4 GB in use of a 7.6 GB video memory budget. That is in line with the RTX 3090 report (#333). - `cargo test -p victory-loader null_guard`: 2 passed. ## Not known / not done - Why the lookup finds nothing on this card is not known: the guard only lets the title go on without the object. - The `VICTORY_LOCALE` / `VICTORY_GEO` overrides have not been tried in a run yet, and `cargo test -p victory-hle locale` matched no test, so their unit test has not run. - One earlier run (before this one, settings unconfirmed) ended in the title's own assert (`int3` at +0x1ce6e13, called from +0x293ef38). It did not happen in the tested run. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
On an RTX 4070 Ti, every start of game_scarlett_master.exe 1.0.2.1 ended
after the start screen's A with a read of 0x38: start-up callback
+0x2bb6960 looks an object up by two name hashes, finds nothing, and
tail-jumps to +0x1cfa5a0, which reads +0x38 of it. The guard writes
`test rcx, rcx; jz <ret>; jmp +0x1cfa5a0` into the int3 padding before
the function (byte-checked) and points the tail jump at it. Off by default.

With it the title goes on into the game (first run 1.6 fps, 630 ms a
frame, while the driver still makes pipelines and the 7.6 GB video memory
budget is full). Why the lookup finds nothing is not known yet.

Also VICTORY_LOCALE / VICTORY_GEO: the locale and region the title is
told through GetUserDefaultLocaleName / GetUserDefaultGeoName, to see
whether the lookup depends on them (module served only when set).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 10:41:07 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-27 11:40 UTC · original

Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At a8b7c9e: victory-hle 163 passed, 0 failed, 2 ignored; victory-loader 58 passed; victory bins 25 passed.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-27 11:40 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/531#issuecomment-7217339925) Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At `a8b7c9e`: `victory-hle` 163 passed, 0 failed, 2 ignored; `victory-loader` 58 passed; `victory` bins 25 passed. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠gut0to on GitHub · 2026-11-27 13:23 UTC · original · reviewed

AI-assisted review: I checked the override behavior against the Win32 contracts for both functions. One compatibility detail is missing on their failure path:

**@⁠gut0to** on GitHub · 2026-11-27 13:23 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/531#pullrequestreview-6088819438) · **reviewed** AI-assisted review: I checked the override behavior against the Win32 contracts for both functions. One compatibility detail is missing on their failure path:
@ -0,0 +37,4 @@
if out.is_null() || count < need {
return 0;
}
// SAFETY: the caller's buffer holds `count` units, at least `need`.
Author
Owner

@⁠gut0to on GitHub · 2026-11-27 13:23 UTC · original

When out is null or count is too small, these overrides return 0 without setting ERROR_INSUFFICIENT_BUFFER. Both Win32 APIs document that error for this failure, so callers that inspect GetLastError() will see a stale value only when the override is enabled. Please set the same last error as the host API and cover both cases in the helper/API tests. See Microsoft docs: https://learn.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-getuserdefaultlocalename and https://learn.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-getuserdefaultgeoname

**@⁠gut0to** on GitHub · 2026-11-27 13:23 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/531#discussion_r4719917764) When `out` is null or `count` is too small, these overrides return 0 without setting `ERROR_INSUFFICIENT_BUFFER`. Both Win32 APIs document that error for this failure, so callers that inspect `GetLastError()` will see a stale value only when the override is enabled. Please set the same last error as the host API and cover both cases in the helper/API tests. See Microsoft docs: https://learn.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-getuserdefaultlocalename and https://learn.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-getuserdefaultgeoname
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/531/head:github-bot/gh-531'
git switch 'github-bot/gh-531'

Merge

Merge the changes and update on Forgejo.
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-531'
git switch 'github-bot/gh-531'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-531'
git switch 'github-bot/gh-531'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-531'
git switch 'a-publier'
git merge --squash 'github-bot/gh-531'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-531'
git switch 'a-publier'
git merge 'github-bot/gh-531'
git push origin 'a-publier'
This discussion has been locked. Commenting is limited to contributors.
No description provided.