XCL_NETWORK=0: the system's WSASendMsg refuses too #612

Open
github-bot wants to merge 1 commit from github-bot/gh-612 into main AGit
Owner

@⁠Kalmarv on GitHub · 2026-11-24 02:31 UTC · original
Kalmarv:fix/netoff-wsasendmsg → main · +55 −1 · 1 files · 1 commits · open

With XCL_NETWORK=0 the system's sendto and WSASendTo are hooked (db1ddb2, #305), but WSASendMsg is not, and it carries its destination in the message. On main 508a0c7 a datagram sent with it to an address the hooked sendto refuses still arrives. This hooks it with sendto's rule: no address or loopback goes to the original, anything else is refused with WSAENETUNREACH.

Follow-up to #305 (closed), found with the scratch test from #444.

What is in it

  • crates/xcl/src/hle/netoff.rs: ws2_32!WSASendMsg in the table of install_system_hooks, its detour wsa_send_msg and the call to the original.
  • hle::netoff::tests::the_systems_wsasendmsg_refuses: the export, found through GetProcAddress, is called with no socket. For 8.8.8.8 the hook answers 10051 before it looks at the socket. For 127.0.0.1 the call reaches the system, which answers something else. No socket is opened and nothing is sent.

Tested

  • RTX 5070 Ti, NVIDIA 610.74, Ryzen 9 9950X, Windows 11 Pro 26200; Rust 1.99.0, MSVC stable, debug.
  • cargo test --workspace -- --test-threads=4 on bbf3174 (this PR, on main 508a0c7): 681 passed, 0 failed, 41 ignored (the xcl library: 641 passed, 21 ignored). SKIPPED GPU tests: 2, both no wave64 (gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware).
  • The new test:
    • main 508a0c7 with only the test added: fails (left: 10093, right: 10051, the system's own answer);
    • this change: passes.
  • A scratch test, not in the PR, loopback only: a UDP socket listens on 127.0.0.1 and is sent to as ::ffff:127.0.0.1, which the hooks treat as any other host.
    • main 508a0c7 with the hooks: sendto and WSASendTo are refused (10051); WSASendMsg returns 0 and the datagram arrives.
    • this change with the hooks: all three are refused (10051); WSASendMsg to 127.0.0.1 itself still arrives.
  • @⁠MesshM's run on AMD (comment): Radeon RX 9060 XT 16 GB, driver 32.0.32029.2010, Ryzen 7 5700X, Windows 11 Pro 26200, Rust 1.100.0, debug. bbf3174 merged onto main dd2ae9a: 691 passed, 0 failed, 41 ignored (the xcl library: 651 passed, 21 ignored), no SKIPPED tests.

Regression run

Our own runs, one after the other on the machine under Tested (RTX 5070 Ti), release builds, no uncommitted changes.

main:

xcl-smoke v1
commit: 508a0c74d7c0625d6d2de8d24494e69dc2e1926f
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1512 (PresentX 1513)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14267 MB

PR:

xcl-smoke v1
commit: bbf31746947d2cbd98dd243f68eb42f96f48fdc6
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1509 (PresentX 1509)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14267 MB

Not tested

  • The WSASendMsg that WSAIoctl(SIO_GET_EXTENSION_FUNCTION_POINTER, WSAID_WSASENDMSG) hands out. It is another function than the export (the scratch test prints two addresses), and a datagram sent through it still arrives with this change. Refusing it needs a hook on WSAIoctl, which #462 (open) adds for ConnectEx; it is not in this PR.
  • A title that sends datagrams, and any datagram to another machine.
  • An overlapped WSASendMsg through the hook: the calls above are synchronous.
  • Intel GPUs. Wine.
  • macOS / Linux: not built.
  • #462 (open) also adds a line to the hook table and changes its length, so whichever merges second needs a rebase.

AI use

  • Claude Code, Claude Fable 5.2: wrote the change, the test and this description; the runs above are its own.

🤖 Generated with Claude Code

**@⁠Kalmarv** on GitHub · 2026-11-24 02:31 UTC · [original](https://github.com/xcl-dev/xcl/pull/612) `Kalmarv:fix/netoff-wsasendmsg` → `main` · +55 −1 · 1 files · 1 commits · open With `XCL_NETWORK=0` the system's `sendto` and `WSASendTo` are hooked (db1ddb2, #305), but `WSASendMsg` is not, and it carries its destination in the message. On main 508a0c7 a datagram sent with it to an address the hooked `sendto` refuses still arrives. This hooks it with `sendto`'s rule: no address or loopback goes to the original, anything else is refused with `WSAENETUNREACH`. Follow-up to #305 (closed), found with the scratch test from #444. **What is in it** - `crates/xcl/src/hle/netoff.rs`: `ws2_32!WSASendMsg` in the table of `install_system_hooks`, its detour `wsa_send_msg` and the call to the original. - `hle::netoff::tests::the_systems_wsasendmsg_refuses`: the export, found through `GetProcAddress`, is called with no socket. For 8.8.8.8 the hook answers 10051 before it looks at the socket. For 127.0.0.1 the call reaches the system, which answers something else. No socket is opened and nothing is sent. **Tested** - RTX 5070 Ti, NVIDIA 610.74, Ryzen 9 9950X, Windows 11 Pro 26200; Rust 1.99.0, MSVC stable, debug. - `cargo test --workspace -- --test-threads=4` on `bbf3174` (this PR, on main `508a0c7`): 681 passed, 0 failed, 41 ignored (the `xcl` library: 641 passed, 21 ignored). SKIPPED GPU tests: 2, both `no wave64` (`gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`). - The new test: - main `508a0c7` with only the test added: fails (`left: 10093, right: 10051`, the system's own answer); - this change: passes. - A scratch test, not in the PR, loopback only: a UDP socket listens on 127.0.0.1 and is sent to as `::ffff:127.0.0.1`, which the hooks treat as any other host. - main `508a0c7` with the hooks: `sendto` and `WSASendTo` are refused (10051); `WSASendMsg` returns 0 and the datagram arrives. - this change with the hooks: all three are refused (10051); `WSASendMsg` to 127.0.0.1 itself still arrives. - @⁠MesshM's run on AMD ([comment](https://github.com/ivall/xcl/pull/612#issuecomment-7120865570)): Radeon RX 9060 XT 16 GB, driver 32.0.32029.2010, Ryzen 7 5700X, Windows 11 Pro 26200, Rust 1.100.0, debug. `bbf3174` merged onto main `dd2ae9a`: 691 passed, 0 failed, 41 ignored (the `xcl` library: 651 passed, 21 ignored), no SKIPPED tests. **Regression run** Our own runs, one after the other on the machine under **Tested** (RTX 5070 Ti), release builds, no uncommitted changes. main: ``` xcl-smoke v1 commit: 508a0c74d7c0625d6d2de8d24494e69dc2e1926f gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1512 (PresentX 1513) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14267 MB ``` PR: ``` xcl-smoke v1 commit: bbf31746947d2cbd98dd243f68eb42f96f48fdc6 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1509 (PresentX 1509) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14267 MB ``` **Not tested** - The `WSASendMsg` that `WSAIoctl(SIO_GET_EXTENSION_FUNCTION_POINTER, WSAID_WSASENDMSG)` hands out. It is another function than the export (the scratch test prints two addresses), and a datagram sent through it still arrives with this change. Refusing it needs a hook on `WSAIoctl`, which #462 (open) adds for `ConnectEx`; it is not in this PR. - A title that sends datagrams, and any datagram to another machine. - An overlapped `WSASendMsg` through the hook: the calls above are synchronous. - Intel GPUs. Wine. - macOS / Linux: not built. - #462 (open) also adds a line to the hook table and changes its length, so whichever merges second needs a rebase. **AI use** - Claude Code, Claude Fable 5.2: wrote the change, the test and this description; the runs above are its own. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
WSASendMsg carries the destination in its message, so a datagram sent with
it needs neither sendto nor connect, which are hooked. With XCL_NETWORK=0
on main a datagram sent with it to an address the hooked sendto refuses
still arrived. It is hooked like sendto now: no address or loopback goes
to the original, anything else is refused (WSAENETUNREACH).

Not covered: the WSASendMsg that WSAIoctl hands out for WSAID_WSASENDMSG
is another function (the provider's), not this export.

Test: the export found through GetProcAddress refuses 8.8.8.8 with no
socket; it fails on main, where the system answers 'not a socket'.

Co-Authored-By: Claude <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:27:11 +00:00
Author
Owner

@⁠MesshM on GitHub · 2026-11-24 03:12 UTC · original

Test run of bbf31746947d2cbd98dd243f68eb42f96f48fdc6 on AMD RDNA4. I merged it onto current main dd2ae9a locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 691 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 651 passed, 0 failed, 21 ignored
  • 0 SKIPPED; the_systems_wsasendmsg_refuses and the_systems_own_network_functions_refuse pass.

Review: On x64 WSAMSG starts with name (8-byte pointer) and namelen (INT at +8), which is what wsa_send_msg reads; a null name (a connected socket) and loopback go to the original. A question rather than a finding: older code gets WSASendMsg through WSAIoctl(SIO_GET_EXTENSION_FUNCTION_POINTER) with WSAID_WSASENDMSG rather than the export. That pointer comes from the provider, so it would not go through this hook unless the WSAIoctl path hands out the hooked function (as ConnectEx needs too, see #444/#462). I did not check whether netoff already does that.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

**@⁠MesshM** on GitHub · 2026-11-24 03:12 UTC · [original](https://github.com/xcl-dev/xcl/pull/612#issuecomment-7120865570) Test run of `bbf31746947d2cbd98dd243f68eb42f96f48fdc6` on AMD RDNA4. I merged it onto current `main` `dd2ae9a` locally (clean merge) and tested that tree. **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 `stable-x86_64-pc-windows-msvc`, debug - `cargo build --workspace` + `cargo test --workspace -- --test-threads=4` on the merge: **691 passed, 0 failed, 41 ignored**, exit code 0; `xcl` lib tests 651 passed, 0 failed, 21 ignored - **0 `SKIPPED`**; `the_systems_wsasendmsg_refuses` and `the_systems_own_network_functions_refuse` pass. **Review:** On x64 `WSAMSG` starts with `name` (8-byte pointer) and `namelen` (INT at +8), which is what `wsa_send_msg` reads; a null name (a connected socket) and loopback go to the original. A question rather than a finding: older code gets `WSASendMsg` through `WSAIoctl(SIO_GET_EXTENSION_FUNCTION_POINTER)` with `WSAID_WSASENDMSG` rather than the export. That pointer comes from the provider, so it would not go through this hook unless the `WSAIoctl` path hands out the hooked function (as `ConnectEx` needs too, see #444/#462). I did not check whether netoff already does that. **Not tested:** no retail title or regression run (I have no unpacked game), no `XCL_SAMPLE_*` tests, release build; the PR's head on its old base was not run, only its merge onto `main`. Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
Author
Owner

@⁠Kalmarv on GitHub · 2026-11-24 03:13 UTC · original

@⁠MesshM, thanks for the RDNA4 run.

On the question: yes, that is a second path, and this PR does not cover it. I checked it on main 508a0c7 and on this branch with a loopback-only scratch test:

  • The pointer that WSAIoctl(SIO_GET_EXTENSION_FUNCTION_POINTER, WSAID_WSASENDMSG) hands out is a different address from the ws2_32 export.
  • A datagram sent through it to an address the hooked sendto refuses still arrives, with and without this change.

Netoff has no hook on WSAIoctl on main. #462 adds one for ConnectEx; the WSASendMsg pointer can be answered in the same place once that is merged, and I will follow up then. It is under Not tested in the description.

🤖 Claude Fable 5.2

**@⁠Kalmarv** on GitHub · 2026-11-24 03:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/612#issuecomment-7120888073) @⁠MesshM, thanks for the RDNA4 run. On the question: yes, that is a second path, and this PR does not cover it. I checked it on main 508a0c7 and on this branch with a loopback-only scratch test: - The pointer that `WSAIoctl(SIO_GET_EXTENSION_FUNCTION_POINTER, WSAID_WSASENDMSG)` hands out is a different address from the `ws2_32` export. - A datagram sent through it to an address the hooked `sendto` refuses still arrives, with and without this change. Netoff has no hook on `WSAIoctl` on main. #462 adds one for `ConnectEx`; the `WSASendMsg` pointer can be answered in the same place once that is merged, and I will follow up then. It is under **Not tested** in the description. 🤖 Claude Fable 5.2
Author
Owner

@⁠tiagonleal on GitHub · 2026-11-24 12:49 UTC · original

Windows / NVIDIA test of #612 (bbf3174694) and #619 (2970626721) merged together onto main 47efa2e (both clean), with #570 rebased on top.

Tested

  • NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1742), Ryzen 7 9800X3D, Windows 11 Pro 26300, rustc 1.100.0 MSVC, debug.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4 on 47efa2e + #612 + #619 + #570: 743 passed, 0 failed, 41 ignored. SKIPPED: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware (no wave64).
  • cargo test -p xcl --lib netoff: 4 passed (only_loopback_goes_through, the_systems_own_network_functions_refuse, the_systems_wsasendmsg_refuses, a_bind_to_every_interface_stays_on_loopback).
  • #570 on top conflicts as upipibi described on #570 (note_bind next to the rewritten loopback doc, O_BIND / O_WSA_SEND_MSG, the hooks array); resolved with both entries and the array at 20. I'll push that rebase to #570 once these two are in.

Not tested: a retail run of this combined tree; AMD / Intel.

Run and written with Claude Code (Claude Opus 5.5).

**@⁠tiagonleal** on GitHub · 2026-11-24 12:49 UTC · [original](https://github.com/xcl-dev/xcl/pull/612#issuecomment-7131966096) Windows / NVIDIA test of #612 (`bbf3174694`) and #619 (`2970626721`) merged together onto `main` `47efa2e` (both clean), with #570 rebased on top. **Tested** - NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1742), Ryzen 7 9800X3D, Windows 11 Pro 26300, rustc 1.100.0 MSVC, debug. - `cargo build --workspace && cargo test --workspace -- --test-threads=4` on `47efa2e` + #612 + #619 + #570: 743 passed, 0 failed, 41 ignored. SKIPPED: `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware` (no wave64). - `cargo test -p xcl --lib netoff`: 4 passed (`only_loopback_goes_through`, `the_systems_own_network_functions_refuse`, `the_systems_wsasendmsg_refuses`, `a_bind_to_every_interface_stays_on_loopback`). - #570 on top conflicts as upipibi described on #570 (`note_bind` next to the rewritten `loopback` doc, `O_BIND` / `O_WSA_SEND_MSG`, the hooks array); resolved with both entries and the array at 20. I'll push that rebase to #570 once these two are in. **Not tested:** a retail run of this combined tree; AMD / Intel. Run and written with Claude Code (Claude Opus 5.5).
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 06:37 UTC · original

Empirical test report (bbf31746)

Hardware / environment

  • Commit bbf31746947d2cbd98dd243f68eb42f96f48fdc6 (PR #612), clean detached checkout.
  • Windows 10.0.26200.9974. CPU identified by Windows as AMD64 Family 23 Model 113 Stepping 0, AuthenticAMD, with 12 logical processors available to the process.
  • Rust 1.100.0 (0ef1bc386 2026-11-09), host x86_64-pc-windows-msvc. DXC 1.9.2609.5 (01b62ad47).
  • The build and CPU-only run ran directly under Cargo, outside Invoke-ArcTest.ps1, with zero Arc GPU mutex hold.

Commands and results

  • cargo test --workspace --no-run exited 0 and built 15 test executables. It emitted a fetch_update deprecation warning. This command only compiled tests.
  • With XCL_ADAPTER=NONE_CPU_ONLY and RUST_TEST_NOCAPTURE=1, cargo test -p xcl --lib hle::netoff::tests:: exited 0 with 3 passed, 0 failed, 0 ignored, and 0 skipped. The skip count is the number of case-sensitive log lines beginning with SKIPPED . The harness reported 659 tests filtered out.

Observed behavior

  • The new regression test resolved the system WSASendMsg export and verified that the hook refused the non-loopback destination with WSAENETUNREACH (10051). For 127.0.0.1, the same invalid socket produced a different error. The test checks the error returned by the hook using an invalid socket.
  • Both existing module tests passed. They cover IPv4 and IPv6 loopback classification and the behavior of hooked WinHTTP, WinINet, and Winsock lookup exports. The PR adds no integration tests.

Not tested

The full GPU workspace suite and game smoke runs were omitted.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr612-focused.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 06:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/612#issuecomment-7154978960) ### Empirical test report (bbf31746) **Hardware / environment** - Commit `bbf31746947d2cbd98dd243f68eb42f96f48fdc6` (PR #612), clean detached checkout. - Windows `10.0.26200.9974`. CPU identified by Windows as `AMD64 Family 23 Model 113 Stepping 0, AuthenticAMD`, with 12 logical processors available to the process. - Rust `1.100.0 (0ef1bc386 2026-11-09)`, host `x86_64-pc-windows-msvc`. DXC `1.9.2609.5 (01b62ad47)`. - The build and CPU-only run ran directly under Cargo, outside `Invoke-ArcTest.ps1`, with zero Arc GPU mutex hold. **Commands and results** - `cargo test --workspace --no-run` exited 0 and built 15 test executables. It emitted a `fetch_update` deprecation warning. This command only compiled tests. - With `XCL_ADAPTER=NONE_CPU_ONLY` and `RUST_TEST_NOCAPTURE=1`, `cargo test -p xcl --lib hle::netoff::tests::` exited 0 with 3 passed, 0 failed, 0 ignored, and 0 skipped. The skip count is the number of case-sensitive log lines beginning with `SKIPPED `. The harness reported 659 tests filtered out. **Observed behavior** - The new regression test resolved the system `WSASendMsg` export and verified that the hook refused the non-loopback destination with `WSAENETUNREACH` (10051). For `127.0.0.1`, the same invalid socket produced a different error. The test checks the error returned by the hook using an invalid socket. - Both existing module tests passed. They cover IPv4 and IPv6 loopback classification and the behavior of hooked WinHTTP, WinINet, and Winsock lookup exports. The PR adds no integration tests. **Not tested** The full GPU workspace suite and game smoke runs were omitted. **AI use** Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr612-focused.log and published.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 12:55 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 12:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/612#issuecomment-7163049492) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/612/head:github-bot/gh-612'
git switch 'github-bot/gh-612'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-612'
git switch 'github-bot/gh-612'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-612'
git switch 'github-bot/gh-612'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-612'
git switch 'main'
git merge --squash 'github-bot/gh-612'
git switch 'main'
git merge --ff-only 'github-bot/gh-612'
git switch 'main'
git merge 'github-bot/gh-612'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.