Skip to content

xnetworking: stop copying struct padding in default_security_info_bytes - #76

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
certified-retart:fix/xnetworking-security-info-padding
Nov 23, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
certified-retart:fix/xnetworking-security-info-padding

Conversation

@certified-retart

Copy link
Copy Markdown
Contributor

Summary

Implements the first change requested in docs/xnetworking-rust-review.md: stop copying uninitialized #[repr(C)] struct padding in default_security_info_bytes.

What changed

  • default_security_info_bytes (crates/xcl/src/hle/xgameruntime/networking.rs):
    • Replaced the unsafe raw struct byte copy (which read uninitialized padding bytes between enabled_http_security_protocol_flags: u32 and thumbprint_count: usize) with a safe zero-initialized Vec<u8> sized to size_of::<XNetworkingSecurityInformation>(), writing DEFAULT_TLS_FLAGS.to_le_bytes() at offset_of!(XNetworkingSecurityInformation, enabled_http_security_protocol_flags).
    • Documented why all-zero bytes represent thumbprint_count == 0, a null thumbprints pointer, and deterministic zero padding on x86_64 Windows.
  • Tests (crates/xcl/src/hle/xgameruntime/networking.rs):
    • Updated security_info_utf8_and_utf16_follow_gdk_arg_order to use storage properly aligned to XNetworkingSecurityInformation (pre-filled with non-zero sentinels 0xAA / 0x55) and assert all three fields (enabled_http_security_protocol_flags, thumbprint_count == 0, thumbprints.is_null()) for both UTF-8 and UTF-16.
    • Added default_security_info_bytes_zeroes_padding_and_fields verifying exact byte length, DEFAULT_TLS_FLAGS at the field offset, and zero bytes everywhere else.
  • Kept async result consumption and TLS verification policy untouched as requested for this first patch.

Verification

  • Target: rustc 1.100.0 (x86_64-pc-windows-msvc), Windows 10 Pro 10.0.19045.
  • cargo test -p xcl --lib hle::xgameruntime::networking: 6 passed, 0 failed.

@ivall
ivall merged commit e132ed4 into xcl-dev:main Nov 23, 2026
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Merged. Tested on Windows 11 with an RX 9070 (RDNA4): cargo test --workspace green with the retail samples (shader pack, console DLLs, texture archive), also with XCL_SPLIT_WAVE64=1 (the 32-lane split path forced on RDNA). Unicorn Overlord and XDefiant run with this round merged. Thanks!

theaustinayers pushed a commit that referenced this pull request Nov 24, 2026
…ites

`pc_resource_desc` takes ALLOW_UNORDERED_ACCESS from a depth buffer the
console also lets shaders write (the PC refuses ALLOW_DEPTH_STENCIL with
ALLOW_UNORDERED_ACCESS). Only CreatePlacedResourceX (#44) moved such a
resource's initial state off UNORDERED_ACCESS as well (to DEPTH_WRITE).
The other paths that create a resource of the converted description
only masked the state with PC_RESOURCE_STATES: the committed fallback of
CreateCommittedResource (#27 / #76 / #127, reached without unified
memory or when its coherent window is full), the PC-way retry and the
committed fallback of CreatePlacedResource (#29), and its memory-of-its-
own path for textures larger on the PC. A console texture with flags
DEPTH_STENCIL | UNORDERED_ACCESS created in UNORDERED_ACCESS was then
asked for in a state D3D12 refuses for a resource without the UAV flag
(E_INVALIDARG; the #29 own-memory path fell back to COMMON).

`device_x::pc_initial_state` does both steps; #44 uses it with no change
in behaviour, and the four other sites use it with the console flags
(or the PC description's, which keep ALLOW_DEPTH_STENCIL).

Tests: a unit test of the helper; a GPU test placing a 256x256 D16
depth+UAV texture in UNORDERED_ACCESS as XCL now does (not run here).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants