HLE: implement the RPC runtime's GUID calls #636

Manually merged
github merged 1 commit from gh-pr/636/head into gh-pr/636/base 2026-11-26 04:10:55 +00:00
Owner

@⁠Nixitov on GitHub · 2026-11-24 06:00 UTC · original
Nixitov:hle/allow-rpcrt4 → main · +442 −0 · 4 files · 1 commits · merged 2026-11-25 00:09 UTC

Fixes #510 (the null GUID). Following @⁠mercuryVM's review, this no longer passes rpcrt4.dll through: it implements the calls titles use and leaves everything else refused.

Implemented (crates/victory-hle/src/modules/rpcrt4.rs, served as rpcrt4.dll):

  • UuidCreate, UuidCreateSequential: 16 bytes from BCryptGenRandom, version 4 and variant bits set. Sequential does not report a MAC address or a clock of this machine; it is the same generator in the same shape.
  • UuidFromStringA/W: braces and upper case taken, 32 hex digits required, dashes optional, and nothing after the last digit but a closing brace. Anything else answers RPC_S_INVALID_STRING_UUID and leaves the out GUID alone.
  • UuidToStringA/W: the canonical lower-case form. The allocation keeps its length in a word before the text, so RpcStringFreeA and RpcStringFreeW both give the whole thing back, and both take null.
  • RpcStringFreeA/W.

LoadLibrary("rpcrt4.dll") returns our pseudo module: the kernel module already does that for a DLL a module serves that the host policy refuses, so the title resolves these imports without the host DLL.

Why not pass-through: as the review says, RpcBindingFromStringBinding with ncacn_ip_tcp or ncacn_http opens sockets through rpcrt4's own ws2_32 imports, which modules::net never sees.

Verified here (Windows 11 26200.9974, RTX 5070, driver 617.14, release build):

  • loaded as a pseudo module dll="rpcrt4.dll", and no a host DLL outside the host policy: refused line for it (it was the only one).
  • The title runs through its first screens and into the world, same as before.
  • cargo test -p victory-hle --lib: 92 passed. The new tests cover the format/parse round trip in both string widths, version and variant bits over 64 creates, invalid text refused, and both frees including null.
  • cargo xtask policy: 152 files ok. Clippy clean on the new module; fmt clean on the touched files.

The host policy is unchanged: HostPolicy::default() still refuses rpcrt4.dll, and the_rpc_runtime_is_implemented_here checks that every call above resolves to HLE even with HostPolicy::none().

No game files; only log lines and identifiers.

AI-assisted (DeepSeek V4.1 Flash coding agent).

**@⁠Nixitov** on GitHub · 2026-11-24 06:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/636) `Nixitov:hle/allow-rpcrt4` → `main` · +442 −0 · 4 files · 1 commits · merged 2026-11-25 00:09 UTC Fixes #510 (the null GUID). Following @⁠mercuryVM's review, this no longer passes `rpcrt4.dll` through: it implements the calls titles use and leaves everything else refused. **Implemented (`crates/victory-hle/src/modules/rpcrt4.rs`, served as `rpcrt4.dll`):** - `UuidCreate`, `UuidCreateSequential`: 16 bytes from `BCryptGenRandom`, version 4 and variant bits set. Sequential does not report a MAC address or a clock of this machine; it is the same generator in the same shape. - `UuidFromStringA/W`: braces and upper case taken, 32 hex digits required, dashes optional, and nothing after the last digit but a closing brace. Anything else answers `RPC_S_INVALID_STRING_UUID` and leaves the out GUID alone. - `UuidToStringA/W`: the canonical lower-case form. The allocation keeps its length in a word before the text, so `RpcStringFreeA` and `RpcStringFreeW` both give the whole thing back, and both take null. - `RpcStringFreeA/W`. `LoadLibrary("rpcrt4.dll")` returns our pseudo module: the kernel module already does that for a DLL a module serves that the host policy refuses, so the title resolves these imports without the host DLL. **Why not pass-through:** as the review says, `RpcBindingFromStringBinding` with `ncacn_ip_tcp` or `ncacn_http` opens sockets through rpcrt4's own `ws2_32` imports, which `modules::net` never sees. **Verified here** (Windows 11 26200.9974, RTX 5070, driver 617.14, release build): - `loaded as a pseudo module dll="rpcrt4.dll"`, and no `a host DLL outside the host policy: refused` line for it (it was the only one). - The title runs through its first screens and into the world, same as before. - `cargo test -p victory-hle --lib`: 92 passed. The new tests cover the format/parse round trip in both string widths, version and variant bits over 64 creates, invalid text refused, and both frees including null. - `cargo xtask policy`: 152 files ok. Clippy clean on the new module; fmt clean on the touched files. The host policy is unchanged: `HostPolicy::default()` still refuses `rpcrt4.dll`, and `the_rpc_runtime_is_implemented_here` checks that every call above resolves to HLE even with `HostPolicy::none()`. No game files; only log lines and identifiers. AI-assisted (DeepSeek V4.1 Flash coding agent).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:10:54 +00:00
github manually merged commit 7216ab7113 into gh-pr/636/base 2026-11-26 04:10:55 +00:00
Author
Owner

@⁠Nixitov on GitHub · 2026-11-24 08:34 UTC · original

Reworked along the lines you suggested, @⁠mercuryVM — thank you, the point about rpcrt4's own ws2_32 imports is right and it is not worth that hole for a GUID.

The policy change is gone. crates/victory-hle/src/modules/rpcrt4.rs now implements exactly the calls you listed and serves the DLL name from the modules registry, so the resolution order makes them HLE with any policy (a test asserts that with HostPolicy::none()), and LoadLibrary("rpcrt4.dll") takes the pseudo-module path the kernel module already uses for console DLLs the host policy refuses. Every other rpcrt4 import stays Missing.

  • UuidCreate and UuidCreateSequential: BCryptGenRandom, version 4, variant bits; sequential deliberately does not report this machine's MAC or clock.
  • UuidFromStringA/W and UuidToStringA/W: the canonical text, braces and upper case accepted on input, RPC_S_INVALID_STRING_UUID and the out GUID untouched otherwise.
  • RpcStringFreeA/W: the allocation carries its length, so both frees take it (and null).

On this machine (Windows 11, RTX 5070, release build) the title logs loaded as a pseudo module dll="rpcrt4.dll", the outside the host policy: refused line for it is gone, and it still reaches the world. cargo test -p victory-hle --lib 92 passed, cargo xtask policy 152 files ok, clippy clean on the new module.

One thing I could not check: whether the title's identifiers now differ from the null GUID in its own logs beyond the creation call — the UUID calls no longer answer zero, but I have no other observable of the value it uses. If you have a check for that in mind, I will add it.

AI-assisted (DeepSeek V4.1 Flash coding agent).

**@⁠Nixitov** on GitHub · 2026-11-24 08:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/636#issuecomment-7126307641) Reworked along the lines you suggested, @⁠mercuryVM — thank you, the point about rpcrt4's own `ws2_32` imports is right and it is not worth that hole for a GUID. The policy change is gone. `crates/victory-hle/src/modules/rpcrt4.rs` now implements exactly the calls you listed and serves the DLL name from the modules registry, so the resolution order makes them HLE with any policy (a test asserts that with `HostPolicy::none()`), and `LoadLibrary("rpcrt4.dll")` takes the pseudo-module path the kernel module already uses for console DLLs the host policy refuses. Every other rpcrt4 import stays Missing. - `UuidCreate` and `UuidCreateSequential`: `BCryptGenRandom`, version 4, variant bits; sequential deliberately does not report this machine's MAC or clock. - `UuidFromStringA/W` and `UuidToStringA/W`: the canonical text, braces and upper case accepted on input, `RPC_S_INVALID_STRING_UUID` and the out GUID untouched otherwise. - `RpcStringFreeA/W`: the allocation carries its length, so both frees take it (and null). On this machine (Windows 11, RTX 5070, release build) the title logs `loaded as a pseudo module dll="rpcrt4.dll"`, the `outside the host policy: refused` line for it is gone, and it still reaches the world. `cargo test -p victory-hle --lib` 92 passed, `cargo xtask policy` 152 files ok, clippy clean on the new module. One thing I could not check: whether the title's identifiers now differ from the null GUID in its own logs beyond the creation call — the UUID calls no longer answer zero, but I have no other observable of the value it uses. If you have a check for that in mind, I will add it. AI-assisted (DeepSeek V4.1 Flash coding agent).
Author
Owner

@⁠molodayamama on GitHub · 2026-11-24 14:07 UTC · original

Independent Windows check of 7216ab7113115ea1accfabc6e3a00ee700c7c846 (Windows 10 22H2 19045, Rust 1.98.1, MSVC x64).

  • cargo test -p victory-hle --locked --lib rpcrt4 -- --test-threads=1 --nocapture: 5 passed.

The focused RPC UUID fixtures ran on Windows. They cover format/parse round trips, malformed text, version-4 creation, and releasing strings using the two entry points. No RPC connection was opened.

Only source-built synthetic fixtures were used. AI-assisted verification.

**@⁠molodayamama** on GitHub · 2026-11-24 14:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/636#issuecomment-7133885514) Independent Windows check of `7216ab7113115ea1accfabc6e3a00ee700c7c846` (Windows 10 22H2 19045, Rust 1.98.1, MSVC x64). - `cargo test -p victory-hle --locked --lib rpcrt4 -- --test-threads=1 --nocapture`: 5 passed. The focused RPC UUID fixtures ran on Windows. They cover format/parse round trips, malformed text, version-4 creation, and releasing strings using the two entry points. No RPC connection was opened. Only source-built synthetic fixtures were used. AI-assisted verification.
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/Marvisak--VIctory!636
No description provided.