HLE: UuidFromString reads only what rpcrt4 reads #5038

Open
github-bot wants to merge 1 commit from github-bot/gh-5037 into main AGit
Owner

@⁠breachato on GitHub · 2026-12-01 17:57 UTC · original
breachato:hle-uuid-from-string-strict → main · +72 −15 · 1 files · 1 commits · open

What it changes

UuidFromStringA/W (modules/rpcrt4.rs) took more than the host's rpcrt4 does: {...} with braces, balanced or not, 32 digits with no dashes, and dashes anywhere. And a null string gave RPC_S_INVALID_STRING_UUID, where rpcrt4 writes the nil UUID and returns RPC_S_OK.

parse now takes exactly xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (hex in either case, dashes at 8, 13, 18 and 23), and a null string gives the nil UUID. A title that checks a string with UuidFromString before using it now gets what it would get on Windows. Nothing else in the crate calls parse.

How it was tested

  • No GPU or game needed.

  • Host behaviour measured on Windows 11 26200, calling rpcrt4!UuidFromStringA through P/Invoke:

    Text Host main This PR
    1234abcd-00ef-4a5b-8012-3456789abcde 0 0 0
    the same in upper case 0 0 0
    {1234abcd-00ef-4a5b-8012-3456789abcde} 1705 0 1705
    {... or ...} (one brace only) 1705 0 1705
    1234abcd00ef4a5b80123456789abcde 1705 0 1705
    12-34abcd-00ef-... 1705 0 1705
    "" 1705 1705 1705
    NULL 0, nil UUID 1705 0, nil UUID
  • New test uuid_from_string_reads_only_what_the_runtime_reads checks each row above through both the A and W calls. It fails on main (the braces case is accepted there).

  • cargo test -p victory-hle --lib --locked modules::rpcrt4: 6 passed.

  • cargo clippy -p victory-hle --no-deps --all-targets: nothing in rpcrt4.rs.

  • cargo test passed for the crates it touches: yes

How to try it

cargo test -p victory-hle --lib --locked uuid_from_string_reads_only.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #3650 also touches rpcrt4.rs (it changes the allocator in allocate/free), with no overlap with this change.

Assisted by Claude.

**@⁠breachato** on GitHub · 2026-12-01 17:57 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/5037) `breachato:hle-uuid-from-string-strict` → `main` · +72 −15 · 1 files · 1 commits · open ## What it changes `UuidFromStringA`/`W` (`modules/rpcrt4.rs`) took more than the host's rpcrt4 does: `{...}` with braces, balanced or not, 32 digits with no dashes, and dashes anywhere. And a null string gave `RPC_S_INVALID_STRING_UUID`, where rpcrt4 writes the nil UUID and returns `RPC_S_OK`. `parse` now takes exactly `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` (hex in either case, dashes at 8, 13, 18 and 23), and a null string gives the nil UUID. A title that checks a string with `UuidFromString` before using it now gets what it would get on Windows. Nothing else in the crate calls `parse`. ## How it was tested - No GPU or game needed. - Host behaviour measured on Windows 11 26200, calling `rpcrt4!UuidFromStringA` through P/Invoke: | Text | Host | `main` | This PR | |---|---|---|---| | `1234abcd-00ef-4a5b-8012-3456789abcde` | 0 | 0 | 0 | | the same in upper case | 0 | 0 | 0 | | `{1234abcd-00ef-4a5b-8012-3456789abcde}` | 1705 | 0 | 1705 | | `{...` or `...}` (one brace only) | 1705 | 0 | 1705 | | `1234abcd00ef4a5b80123456789abcde` | 1705 | 0 | 1705 | | `12-34abcd-00ef-...` | 1705 | 0 | 1705 | | `""` | 1705 | 1705 | 1705 | | NULL | 0, nil UUID | 1705 | 0, nil UUID | - New test `uuid_from_string_reads_only_what_the_runtime_reads` checks each row above through both the A and W calls. It fails on `main` (the braces case is accepted there). - `cargo test -p victory-hle --lib --locked modules::rpcrt4`: 6 passed. - `cargo clippy -p victory-hle --no-deps --all-targets`: nothing in `rpcrt4.rs`. - `cargo test` passed for the crates it touches: yes ## How to try it `cargo test -p victory-hle --lib --locked uuid_from_string_reads_only`. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #3650 also touches `rpcrt4.rs` (it changes the allocator in `allocate`/`free`), with no overlap with this change. Assisted by Claude.
The host's UuidFromStringA/W take exactly the 36-character form
(dashes at 8, 13, 18 and 23, hex in either case) and give the nil UUID
with RPC_S_OK for a null string. Ours also took braces (balanced or
not), missing or moved dashes, and refused a null string. A title that
checks a string with UuidFromString before using it as a UUID now gets
the host's answer.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 18:02:36 +00:00
Author
Owner

@⁠cloph-dsp on GitHub · 2026-12-01 18:32 UTC · original

Verification (independent, AI-assisted: Hy4 flash). Windows, Rust 1.100.0 (Scoop rust-msvc), MSVC, commit-scoped shallow worktree.

Base 5fabb46eaf6ed8771321787f8871051abde69b9b, head 3ca06d919e3d6d208a56173bca74e33f412676ca. git diff --numstat → crates/victory-hle/src/modules/rpcrt4.rs 72/15.

The test is new on the base:

git grep -F uuid_from_string_reads_only_what_the_runtime_reads 5fabb46e -- .

→ no match, exit 1.

git diff --check "5fabb46e..3ca06d91" → no output, exit 0.

$env:CARGO_TARGET_DIR='D:\Victory-Contrib\NVIDIA-Contrib\target-5037'
cargo test --locked -p victory-hle --lib -- modules::rpcrt4::tests::uuid_from_string_reads_only_what_the_runtime_reads --exact --test-threads=1 --quiet

Result: running 1 test, test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 482 filtered out.

What it pins, through both UuidFromStringA and the wide UuidFromStringW: the plain 36-character form in either case parses; a leading or trailing brace, braces dropped, dashes removed, a dash moved out of position, one digit missing and the empty string all give INVALID_STRING_UUID; a null string pointer gives OK with the nil GUID, and the wide path is asserted to answer exactly as the narrow one for every case.

Two things worth naming, both about semantics rather than the test:

  • This is a behaviour change, not only a bound: braces were accepted before (n == 0 && c == b'{', plus a closing brace after the last digit) and are refused now. The test pins the new reading, so it cannot also demonstrate the old one was wrong — that rests on the measurement the code comment cites (Windows 11 26200).
  • The nil-string branch is only reachable from the test: UuidFromStringA(null, ptr) now writes NIL. Nothing else in the tree passes a null text pointer, so that arm has no caller coverage beyond this case.

No title data, no device; GPU/driver N/A. No game data.

**@⁠cloph-dsp** on GitHub · 2026-12-01 18:32 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/5037#issuecomment-7321118102) Verification (independent, AI-assisted: Hy4 flash). Windows, Rust 1.100.0 (Scoop rust-msvc), MSVC, commit-scoped shallow worktree. Base `5fabb46eaf6ed8771321787f8871051abde69b9b`, head `3ca06d919e3d6d208a56173bca74e33f412676ca`. `git diff --numstat` → crates/victory-hle/src/modules/rpcrt4.rs 72/15. The test is new on the base: ``` git grep -F uuid_from_string_reads_only_what_the_runtime_reads 5fabb46e -- . ``` → no match, exit 1. `git diff --check "5fabb46e..3ca06d91"` → no output, exit 0. ``` $env:CARGO_TARGET_DIR='D:\Victory-Contrib\NVIDIA-Contrib\target-5037' cargo test --locked -p victory-hle --lib -- modules::rpcrt4::tests::uuid_from_string_reads_only_what_the_runtime_reads --exact --test-threads=1 --quiet ``` Result: `running 1 test`, `test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 482 filtered out`. What it pins, through both `UuidFromStringA` and the wide `UuidFromStringW`: the plain 36-character form in either case parses; a leading or trailing brace, braces dropped, dashes removed, a dash moved out of position, one digit missing and the empty string all give `INVALID_STRING_UUID`; a null string pointer gives `OK` with the nil GUID, and the wide path is asserted to answer exactly as the narrow one for every case. Two things worth naming, both about semantics rather than the test: - This is a behaviour change, not only a bound: braces were accepted before (`n == 0 && c == b'{'`, plus a closing brace after the last digit) and are refused now. The test pins the new reading, so it cannot also demonstrate the old one was wrong — that rests on the measurement the code comment cites (Windows 11 26200). - The nil-string branch is only reachable from the test: `UuidFromStringA(null, ptr)` now writes `NIL`. Nothing else in the tree passes a null text pointer, so that arm has no caller coverage beyond this case. No title data, no device; GPU/driver N/A. No game data.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/5038/head:github-bot/gh-5037'
git switch 'github-bot/gh-5037'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-5037'
git switch 'github-bot/gh-5037'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-5037'
git switch 'github-bot/gh-5037'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-5037'
git switch 'main'
git merge --squash 'github-bot/gh-5037'
git switch 'main'
git merge --ff-only 'github-bot/gh-5037'
git switch 'main'
git merge 'github-bot/gh-5037'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

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