user: validate RegisterClassExA descriptor size #176
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/179"
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 ivall/xcl. Originally posted by BaggyALPHA on 2026-11-23T19:12:41Z.
The
RegisterClassExAbridge replaces the caller'scbSizewith the correct Unicode structure size before calling Windows. As a result, malformed ANSI descriptors that Windows rejects can register successfully through XCL, and the bridge reads their remaining fields before validating the declared size.Check the caller's size before reading or converting the remaining fields. Return zero and set
ERROR_INVALID_PARAMETERfor an invalid size, matching native Windows. Valid descriptors retain the existing Unicode conversion.Related to #106, item 4 (
RegisterClassExAsize validation).Validation
On unchanged main (
956a476bf738a098f39df4f4c8acef682e43030f), a direct native API comparison reproduced the mismatch for all five sizes: 0, 1, 79, 81, andu32::MAX(the x64 structure is 80 bytes). Windows returned zero/error 87 for each; XCL registered the class and left the last-error sentinel unchanged. Each successful registration was unregistered during the test.After the fix:
cargo test --locked -p xcl --lib hle::user::tests -- --nocapture: 3 passed. Covers all five invalid sizes against native Windows, valid registration with preserved class attributes, and a short descriptor followed by an uncommitted page to check that rejection happens before reading the remaining fields.cargo build --locked --workspace: passed.cargo test --locked -p xcl --test e2e -- --nocapture --test-threads=1: 2 passed, as a synthetic-title smoke test.git diff --check: passed.Environment: Windows x64, Rust 1.96.0. No additional dependencies or external fixtures are required. This fixes an API contract mismatch; no affected retail title has been demonstrated. Console/retail fixtures remain unavailable, and the full workspace test suite was not run. Personal filesystem paths have been removed from the logs below.
Reference: Microsoft WNDCLASSEXA documentation.
Native comparison, regression tests, and build output
Synthetic-title smoke test output
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-23T20:50:26Z.
Linux / Wine / GNU run of
a3dedf13(merge-base956a476, the currentmain). Ubuntu 24.04, XCL cross-built forx86_64-pc-windows-gnu(mingw-w64 13, release, so no overflow checks), run under Wine 11.21 Staging (Kron4ek wow64 build). The control is this PR's head with only the production hunks reverse-applied, so the new tests stay in.Under Wine, the test's "native" side is Wine's own
user32.RegisterClassExA, so this also checks that the expected behaviour holds there.hle::user::testsregister_class_rejects_invalid_sizes_like_windowsu32::MAXwith atom 0 / error 87, and XCL does the same0xc036, last error untouched)register_class_checks_size_before_reading_remaining_fieldsUnhandled page fault on read access(the conversion reads into the uncommitted page)register_class_accepts_valid_size_and_preserves_attributesHead: 3 passed, 0 failed. Wine 11.21 matches the Windows behaviour you measured, so the check is right on both. No findings from reading the diff.
Not covered:
RegisterClassExW(untouched); any title.Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T21:09:12Z.
Merged (main
6da33fa). Checked on an RX 9070 (RDNA4) with the 22 PRs merged together on maineaa36b6:cargo build --workspace && cargo test --workspace -- --test-threads=4- 582 unit tests passed, 0 failed (20 ignored), the integration and e2e tests passed too; and the retail game still reaches its first menu (646 frames in 30 s, no device removal).