HLE: implement the RPC runtime's GUID calls #636
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/636"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by Nixitov on 2026-11-24T06:00:30Z.
Fixes #510 (the null GUID). Following @mercuryVM's review, this no longer passes
rpcrt4.dllthrough: it implements the calls titles use and leaves everything else refused.Implemented (
crates/victory-hle/src/modules/rpcrt4.rs, served asrpcrt4.dll):UuidCreate,UuidCreateSequential: 16 bytes fromBCryptGenRandom, 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 answersRPC_S_INVALID_STRING_UUIDand leaves the out GUID alone.UuidToStringA/W: the canonical lower-case form. The allocation keeps its length in a word before the text, soRpcStringFreeAandRpcStringFreeWboth 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,
RpcBindingFromStringBindingwithncacn_ip_tcporncacn_httpopens sockets through rpcrt4's ownws2_32imports, whichmodules::netnever sees.Verified here (Windows 11 26200.9974, RTX 5070, driver 617.14, release build):
loaded as a pseudo module dll="rpcrt4.dll", and noa host DLL outside the host policy: refusedline for it (it was the only one).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 refusesrpcrt4.dll, andthe_rpc_runtime_is_implemented_herechecks that every call above resolves to HLE even withHostPolicy::none().No game files; only log lines and identifiers.
AI-assisted (DeepSeek V4.1 Flash coding agent).
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T07:42:39Z.
Review: CHANGES_REQUESTED
Tested
f35849con Windows 11, RTX 5070, MSVC:cargo test --workspace --no-fail-fastpasses (265 passed, 0 failed).This is the same change as #510, and my concern there applies here too.
ws2_32andwinhttpare only safe to pass through becausemodules::netoverrides the title's imports of them and refuses off-machine traffic.rpcrt4.dllis the RPC client runtime.RpcBindingFromStringBindingwithncacn_ip_tcporncacn_httpopens sockets through rpcrt4's ownws2_32imports, whichmodules::netnever sees.The null-GUID symptom is real and worth fixing. The narrow fix is to implement the calls titles use as HLE in
modules:UuidCreate: 16 bytes fromBCryptGenRandom, version 4 and variant bits set.UuidCreateSequential, if imported: same.UuidFromStringA/W,UuidToStringA/W,RpcStringFreeA/W.Everything else stays refused as today. Happy to re-review that version.
AI-assisted (Claude Code).
[PR #636] HLE: allow rpcrt4.dll in the default host policyto [PR #636] HLE: implement the RPC runtime's GUID callsImported from Marvisak/VIctory. Originally posted by Nixitov on 2026-11-24T08:34:51Z.
Reworked along the lines you suggested, @mercuryVM — thank you, the point about rpcrt4's own
ws2_32imports is right and it is not worth that hole for a GUID.The policy change is gone.
crates/victory-hle/src/modules/rpcrt4.rsnow 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 withHostPolicy::none()), andLoadLibrary("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.UuidCreateandUuidCreateSequential:BCryptGenRandom, version 4, variant bits; sequential deliberately does not report this machine's MAC or clock.UuidFromStringA/WandUuidToStringA/W: the canonical text, braces and upper case accepted on input,RPC_S_INVALID_STRING_UUIDand 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", theoutside the host policy: refusedline for it is gone, and it still reaches the world.cargo test -p victory-hle --lib92 passed,cargo xtask policy152 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).
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T11:09:56Z.
Review: APPROVED
Tested
7216ab7on Windows 11, RTX 5070, MSVC:cargo test -p victory-hle93 passed, includingthe_rpc_runtime_is_implemented_hereand the rpcrt4 module tests. Clippy's 1 warning is the existingfield_reassign_with_defaultat xmem.rs:747.This addresses my earlier review:
rpcrt4.dllstays out ofHostPolicy, and only the eight GUID/string calls are served.RpcServerRegisterIfand the rest still classify asNone, so the RPC transports (and their ownws2_32imports) never load.UuidCreate: the version and variant bits are set on the right bytes (bytes[7]high nibble isdata3's version under little-endian,bytes[8]isdata4[0]).BCryptGenRandomwithBCRYPT_USE_SYSTEM_PREFERRED_RNGis the right source.RpcStringFree*: the length prefix inallocateletsfreerebuild the exactLayout, and nulling the caller's pointer matches the documented contract.parseis more lenient thanUuidFromString. It skips-anywhere and accepts a leading{, so{0123…}and dash-less 32-digit strings succeed, where rpcrt4 returnsRPC_S_INVALID_STRING_UUID. Harmless for well-formed input; mention it in the doc comment if you keep it.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by molodayamama on 2026-11-24T14:07:47Z.
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.