Netoff: block ConnectEx when network is disabled #457
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/462"
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 SandimL on 2026-11-24T00:35:09Z.
Fixes #444.
What is in it
crates/xcl/src/hle/netoff.rs: hookws2_32!WSAIoctl, recognizeWSAID_CONNECTEX, and return a detour that refuses non-loopback destinations while retaining the original function for loopback.WSAIoctl(SIO_GET_EXTENSION_FUNCTION_POINTER)path a title uses.Tested
cargo check -p xcl: passed.cargo test -p xcl --lib hle::netoff::tests -- --nocapture: 2 passed, 0 failed.cargo test -p xcl --lib: 634 passed, 2 failed, 21 ignored. The two failures are the existing GPU texture test on this adapter and its dependent poisoned-mutex test; the VRAM test passes alone and the texture failure reproduces on the base tree.smoke-gametitle for 20 seconds withXCL_NETWORK=0; the required--helloargument was supplied because that test title requires it.Regression run
Not tested
ConnectEx.ConnectExloopback to a real listener; the detour forwards loopback to the captured original function, while the regression covers the refusal path.AI use
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-24T01:09:39Z.
Tested
17172b5merged onto main7ebf1b8(merge 642740b, no conflicts). It closes the gap in #444, and the loopback path the description lists as not tested works.WSAIoctlto a listener on 127.0.0.1, reached as::ffff:127.0.0.1, which the hooks treat as any other host) fails on main7ebf1b8and passes on the merge: ConnectEx is refused with 10051 and nothing arrives at the listener.ConnectExloopback to a real listener" under Not tested.WSAIoctlline left out of the hook table,the_systems_own_network_functions_refusefails. It cannot run on main, whereconnect_ex_detourdoes not exist.On main the ConnectEx row reads
r=1 err=0 REACHEDin both columns; the other rows are the same.Tested
Ryzen 9 9950X, Windows 11 26200, debug. CPU only, loopback only; no GPU test was run.
cargo test -p xcl --lib -- netoff::on the merge 642740b: 2 passed, 0 failed; with theWSAIoctlhook left out 1 passed, 1 failed.cargo test -p xcl --lib -- gap_tests --nocapture(the scratch test, not part of the PR): merge 1 passed, 0 failed; main7ebf1b80 passed, 1 failed.scripts/pr_check.pyfrom main on the description: ok.Not tested
ConnectExpointer for the process.🤖 Claude Fable 5.2
Imported from ivall/xcl. Originally posted by SpaghettiMaster545 on 2026-11-24T02:13:37Z.
Tested
17172b5(this PR's head).cargo test -p xcl --lib hle::netoff::tests -- --nocapture: 2 passed, 0 failed.("ws2_32.dll", "WSAIoctl", …)entry taken out ofinstall_system_hooks(array back to 18),the_systems_own_network_functions_refusefails atassert_eq!(connect_ex, connect_ex_detour as usize), so the test does catch the gap from #444. It fails there beforeConnectExis called, so nothing leaves the machine in that case.main508a0c7+ #451, #300, #468, this PR, #267; release),XCL_NETWORK=0, through its menus into the world load, 150 s until the title's own watchdog stop (#505, not related): the netoff install line is logged as onmain, and noConnectExrefusal was logged, so the title did not callConnectExin that time. The firewall also blockedxcl.exe, so nothing reached the network either way.One remark on the test, checked by reading it: the refused destination is 8.8.8.8. If a later change ever made the detour let a connection through, the test itself would try to reach that host. #444's scratch test used
::ffff:127.0.0.1for that reason: a local listener that the hooks do not count as loopback, so a regression would show up as REACHED without leaving the machine.Not tested
ConnectExitself (the retail title did not in those 150 s).(Claude Code, Claude Opus 5.5: ran the commands above and wrote this report.)
Imported from ivall/xcl. Originally posted by pvfreis on 2026-11-24T03:19:19Z.
Test report for
17172b593a(this PR's head), against its merge base on maina6f5f7a74c. Whole suite on NVIDIA, no regression.Tested
cargo build --workspace --locked --offline, thencargo test --workspace --locked --offline --no-fail-fast -- --test-threads=4, for both commits:a6f5f7a: 675 passed, 1 failed, 41 ignored17172b5: 675 passed, 1 failed, 41 ignoredhle::netoff::tests::the_systems_own_network_functions_refuseandonly_loopback_goes_throughpass on bothgpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64)test_title_runs_and_game_folder_is_untouched(e2e.rs:225,presents0), because these runs are in an isolated non-interactive session whereCreateSwapChainForHwndreturns 0x887A0022. An interactive run of main at7ebf1b8on this machine passed it (677 passed, 0 failed, 41 ignored).Not tested
WSAIoctlhook): already done by SpaghettiMaster545 aboveConnectExon a socket from a non-Microsoft Winsock provider. Reading the diff:O_CONNECT_EXkeeps one original pointer for all sockets, so with two providers that hand out differentConnectExpointers, loopback calls would go to whichever was stored last. Not seen in practice, just a question.Tested and written with Claude Code (Claude Opus 5.5); the runs are real, on the hardware above.
Imported from ivall/xcl. Originally posted by MesshM on 2026-11-24T04:27:52Z.
Test run of
17172b593ae1324591d43ace8192458934cca70eon AMD RDNA4. I merged it onto currentmain64b3f35locally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 701 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 660 passed, 0 failed, 21 ignoredSKIPPED; thenetofftests pass, including theWSAIoctl(SIO_GET_EXTENSION_FUNCTION_POINTER)regression.Review: Handing out a detour for
WSAID_CONNECTEXthat refuses non-loopback destinations closes the path #444 describes. The sameWSAIoctlpath also gives outWSAID_WSASENDMSG(andWSAID_WSARECVMSG), which this hook passes through; #612 hooks theWSASendMsgexport, but a title that gets it throughWSAIoctlwould get the provider's function. Extending the GUID check toWSAID_WSASENDMSGwould cover both. I found nothing to change in what this PR does.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 ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-24T10:40:07Z.
Code/CI review only (not independently runtime-tested by me): clean merge with both checks green (
Build and test+PR description). BlocksWSAIoctlConnectExunderXCL_NETWORK=0, closing an offline-mode gap. Recommend merging, @ivall.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T14:15:37Z.
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!
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:41:53Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:09:42Z.
Triage (#1607) – head
17172b5No open or merged PR blocks
ConnectEx(#444); main'snetoff.rshooks WSASendMsg (#612) but not WSAIoctl.WSAID_CONNECTEXbytes andSIO_GET_EXTENSION_FUNCTION_POINTERare correct, andconnect_ex_detourreturns FALSE with WSAENETUNREACH for non-loopback addresses as ConnectEx callers expect. No problems found in the diff. The PR conflicts with main (the hook array is now 19 entries there, so it becomes 20).Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.