HLE: UuidFromString reads only what rpcrt4 reads #5037

Open
breachato wants to merge 1 commit from upstream-pr/5037 into main
breachato commented 2026-12-01 17:57:55 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by breachato on 2026-12-01T17:57:55Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5591413179 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/5037). Originally posted by [breachato](https://github.com/breachato) on 2026-12-01T17:57:55Z. --- ## 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.
cloph-dsp commented 2026-12-01 18:32:49 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by cloph-dsp on 2026-12-01T18:32:49Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7321118102 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/5037#issuecomment-7321118102). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-12-01T18:32:49Z. --- 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 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/5037:upstream-pr/5037'
git switch 'upstream-pr/5037'

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/5037'
git switch 'upstream-pr/5037'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/5037'
git switch 'upstream-pr/5037'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/5037'
git switch 'main'
git merge --squash 'upstream-pr/5037'
git switch 'main'
git merge --ff-only 'upstream-pr/5037'
git switch 'main'
git merge 'upstream-pr/5037'
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!5037
No description provided.