HLE: Winsock overrides work when the host lacks newer exports (Wine) #3091

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

@⁠neonbyte1 on GitHub · 2026-11-26 07:29 UTC · original
neonbyte1:pr/winsock → main · +265 −17 · 1 files · 1 commits · open

Split out of #2973, as asked in its review.

victory-hle's Winsock overrides resolve WSAConnectByList and GetAddrInfoExA from the host's ws2_32.dll when the module loads. Wine's ws2_32 doesn't export them, so loading failed and every test that goes through the overrides failed with it. They are now looked up on first use. When the host has no export, the override refuses the call the way an unreachable network does (WSAENETUNREACH for the connect, the existing blocked-lookup result for the name lookup).

The loopback and resolvable checks still run before that fallback, so the offline guards are not loosened: nothing reaches the network that couldn't before.

When the host lacks these exports, the call is refused even for loopback targets (127.0.0.1, localhost): there is nothing to forward it to. On Windows both exports exist, so nothing changes there.

Tested (Linux, GE-Proton11-14 Wine, RTX 5090): victory-hle tests under cargo xtask wine-test (#1218), 152 passed, 1 failed. The one failure is xgamesave::tests::a_kept_blob_past_the_link_limit_is_copied, an NTFS hard-link limit that Wine's filesystem doesn't have; #2973 skips it under Wine. I have no Windows machine; on Windows the exports exist, so the overrides behave as before.

AI-assisted (Claude); measured on my machine, no game data shared.

**@⁠neonbyte1** on GitHub · 2026-11-26 07:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/3091) `neonbyte1:pr/winsock` → `main` · +265 −17 · 1 files · 1 commits · open Split out of #2973, as asked in its review. `victory-hle`'s Winsock overrides resolve `WSAConnectByList` and `GetAddrInfoExA` from the host's `ws2_32.dll` when the module loads. Wine's `ws2_32` doesn't export them, so loading failed and every test that goes through the overrides failed with it. They are now looked up on first use. When the host has no export, the override refuses the call the way an unreachable network does (`WSAENETUNREACH` for the connect, the existing blocked-lookup result for the name lookup). The loopback and `resolvable` checks still run before that fallback, so the offline guards are not loosened: nothing reaches the network that couldn't before. When the host lacks these exports, the call is refused even for loopback targets (`127.0.0.1`, `localhost`): there is nothing to forward it to. On Windows both exports exist, so nothing changes there. **Tested** (Linux, GE-Proton11-14 Wine, RTX 5090): `victory-hle` tests under `cargo xtask wine-test` (#1218), 152 passed, 1 failed. The one failure is `xgamesave::tests::a_kept_blob_past_the_link_limit_is_copied`, an NTFS hard-link limit that Wine's filesystem doesn't have; #2973 skips it under Wine. I have no Windows machine; on Windows the exports exist, so the overrides behave as before. _AI-assisted (Claude); measured on my machine, no game data shared._
Wine's ws2_32 has no WSAConnectByList and only the wide GetAddrInfoExW,
so the overrides that forward to them panicked in the title. They now
find the host function at run time: WSAConnectByList is refused when the
host lacks it (there is no connection to make through it), and
GetAddrInfoExA answers as a console without a network. The test that
every override names a real export skips the ones the host itself
lacks, as it already did for WinHttpGetProxySettingsEx.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 07:37:08 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 07:49 UTC · original · approved these changes

Tested locally merged onto origin/main (63bcca4) on Windows 11 x64:

  • cargo test -p victory-hle net::tests: all tests passed.
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 07:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/3091#pullrequestreview-6070264584) · **approved these changes** Tested locally merged onto `origin/main` (`63bcca4`) on Windows 11 x64: - `cargo test -p victory-hle net::tests`: all tests passed. - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 08:19 UTC · original

Automated triage for the maintainers.

Merge candidate. In crates/victory-hle/src/modules/net.rs, WSAConnectByList and GetAddrInfoExA now look up the host export through an optional LazyLock and refuse the call (WSAENETUNREACH / blocked_lookup) when the host lacks it, instead of the host! macro's panic. I checked that the loopback (reachable) and resolvable checks still run first, so the offline guards are not loosened; on Windows, where both exports exist, behaviour is unchanged. The export test now skips only these named exports when absent.

One small correction to the description: on main the host! macro (modules/files.rs) already resolves on first call, not at module load; what fails under Wine is the panic on that call and the export-check test.

CI: failing, but in victory-gpu (frame::tests::waits_end_on_ticks_and_count_frames), which this PR does not touch; a re-run should settle whether it is a flake.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 08:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/3091#issuecomment-7186451509) <!-- victory-triage v1 head=9b872b7ab384130248144ca72004856aa5f9318e verdict=merge-candidate at=2026-11-26T08:17:31Z --> Automated triage for the maintainers. **Merge candidate.** In `crates/victory-hle/src/modules/net.rs`, `WSAConnectByList` and `GetAddrInfoExA` now look up the host export through an optional `LazyLock` and refuse the call (`WSAENETUNREACH` / `blocked_lookup`) when the host lacks it, instead of the `host!` macro's panic. I checked that the loopback (`reachable`) and `resolvable` checks still run first, so the offline guards are not loosened; on Windows, where both exports exist, behaviour is unchanged. The export test now skips only these named exports when absent. One small correction to the description: on `main` the `host!` macro (`modules/files.rs`) already resolves on first call, not at module load; what fails under Wine is the panic on that call and the export-check test. CI: failing, but in `victory-gpu` (`frame::tests::waits_end_on_ticks_and_count_frames`), which this PR does not touch; a re-run should settle whether it is a flake. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠YaBulochka on GitHub · 2026-11-26 08:39 UTC · original

Tested on Wine: the Winsock fix works, but one test that passes on main fails deterministically on this branch.

Environment: CachyOS kernel 7.3.5, Ryzen 5 9600X, RX 7600 XT, Wine 11.22, x86_64-pc-windows-gnu, --features diagnostics, cargo test -p victory-hle --test-threads=1 through Wine.

main 63bcca4 this branch
whole suite 150 passed, 2 failed 150 passed, 2 failed
modules::net::tests::only_loopback_is_reachable FAILED ok
modules::xgamesave::tests::a_kept_blob_past_the_link_limit_is_copied FAILED (needs NTFS: "the temp folder must be on NTFS, which allows 1024 links to a file") FAILED (same, environmental)
modules::xpackage::tests::completed_installation_unregisters_progress_immediately ok FAILED

Isolated runs, --exact, three times each:

  • xpackage::completed_installation_unregisters_progress_immediately — main: ok, ok, ok; this branch: FAILED, FAILED, FAILED.
  • net::only_loopback_is_reachable — main: FAILED; this branch: ok.

So the lazy lookup does fix the WinSock override on Wine (that test goes from red to green), and the xgamesave failure is ours (no NTFS), not yours. The xpackage one is new and stable: main passes it every time, this branch fails it every time.

Is that expected from the change — the override module now loading where it used to fail the load, so a path that previously short-circuited now runs — or is it a real coupling to look at before merge? I can run any specific test or add logging if it helps.

No game files or dumps, numbers only.

**@⁠YaBulochka** on GitHub · 2026-11-26 08:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/3091#issuecomment-7186865116) Tested on Wine: the Winsock fix works, but one test that passes on `main` fails deterministically on this branch. **Environment:** CachyOS kernel 7.3.5, Ryzen 5 9600X, RX 7600 XT, Wine 11.22, `x86_64-pc-windows-gnu`, `--features diagnostics`, `cargo test -p victory-hle --test-threads=1` through Wine. | | `main` `63bcca4` | this branch | |---|---|---| | whole suite | 150 passed, 2 failed | 150 passed, 2 failed | | `modules::net::tests::only_loopback_is_reachable` | **FAILED** | **ok** | | `modules::xgamesave::tests::a_kept_blob_past_the_link_limit_is_copied` | FAILED (needs NTFS: "the temp folder must be on NTFS, which allows 1024 links to a file") | FAILED (same, environmental) | | `modules::xpackage::tests::completed_installation_unregisters_progress_immediately` | ok | **FAILED** | Isolated runs, `--exact`, three times each: - `xpackage::completed_installation_unregisters_progress_immediately` — `main`: ok, ok, ok; this branch: FAILED, FAILED, FAILED. - `net::only_loopback_is_reachable` — `main`: FAILED; this branch: ok. So the lazy lookup does fix the WinSock override on Wine (that test goes from red to green), and the `xgamesave` failure is ours (no NTFS), not yours. The `xpackage` one is new and stable: `main` passes it every time, this branch fails it every time. Is that expected from the change — the override module now loading where it used to fail the load, so a path that previously short-circuited now runs — or is it a real coupling to look at before merge? I can run any specific test or add logging if it helps. No game files or dumps, numbers only.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 08:41 UTC · original · reviewed

Verified 9b872b7a locally on Windows 11 x64:

  • cargo clippy --all-targets --locked -- -D warnings: clean (1.64s).
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: 1 passed, 0 failed (0.32s).
  • cargo test -p victory-hle --locked: 154 passed, 0 failed (152 lib + 1 fidelityfx + 1 no_dll_planting, 15.51s).
  • rustfmt --edition 2024 --check crates/victory-hle/src/modules/net.rs: clean.

The optional lookup fallbacks look sound: reachable/resolvable policy checks still run before the LazyLock export lookups, and the GetAddrInfoExA missing-export path sets WSAHOST_NOT_FOUND, clears *result via blocked_lookup(result), and returns the same error code.

One coverage gap worth addressing: the existing blocked.invalid test returns before export lookup, and only_loopback_is_reachable does not exercise WSAConnectByList, so neither new missing-export branch is directly covered by tests. Adding direct tests for the missing-export paths (and noting in the PR description that loopback inputs such as 127.0.0.1 / localhost are also refused when the host lacks these two exports) would make the fallback behavior verifiable.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 08:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/3091#pullrequestreview-6070869599) · **reviewed** Verified `9b872b7a` locally on Windows 11 x64: - `cargo clippy --all-targets --locked -- -D warnings`: clean (`1.64s`). - `cargo test -p xtask --locked policy::tests::repository_passes_policy`: 1 passed, 0 failed (`0.32s`). - `cargo test -p victory-hle --locked`: 154 passed, 0 failed (`152` lib + `1` fidelityfx + `1` no_dll_planting, `15.51s`). - `rustfmt --edition 2024 --check crates/victory-hle/src/modules/net.rs`: clean. The optional lookup fallbacks look sound: `reachable`/`resolvable` policy checks still run before the `LazyLock` export lookups, and the `GetAddrInfoExA` missing-export path sets `WSAHOST_NOT_FOUND`, clears `*result` via `blocked_lookup(result)`, and returns the same error code. One coverage gap worth addressing: the existing `blocked.invalid` test returns before export lookup, and `only_loopback_is_reachable` does not exercise `WSAConnectByList`, so neither new missing-export branch is directly covered by tests. Adding direct tests for the missing-export paths (and noting in the PR description that loopback inputs such as `127.0.0.1` / `localhost` are also refused when the host lacks these two exports) would make the fallback behavior verifiable.
github-bot force-pushed github-bot/gh-3091 from 9b872b7ab3 to 9096166b6c 2026-11-26 11:10:17 +00:00 Compare
Author
Owner

@⁠neonbyte1 on GitHub · 2026-11-26 10:01 UTC · original

Thanks both.

@⁠fuzeofficlal: I've added direct tests for the missing-export paths (amended, still one commit, 9096166). The two overrides now take the export lookup as a parameter. Production passes the same lazy lookups as before, so the loopback and resolvable checks still run first. The tests pass None:

  • WSAConnectByList with a loopback list returns WSAENETUNREACH;
  • GetAddrInfoExA for localhost and 127.0.0.1 returns WSAHOST_NOT_FOUND, sets the last error and clears *result;
  • a third test checks that a present export is still forwarded.

With both fallbacks broken on purpose, exactly the two new tests fail. The description now says that loopback targets are refused too when the exports are missing.

@⁠YaBulochka: I couldn't reproduce the xpackage failure. xpackage::tests::completed_installation_unregisters_progress_immediately passed every time, on main and on this branch: with and without diagnostics, run on its own and in the full suite, three runs each (24 runs). That's Wine 11.22 with the x86_64-pc-windows-msvc target on an RTX 5090. I don't have the gnu target installed. The change is confined to net.rs: the new lazy lookups only run inside the two overrides, and that test only touches xpackage's own table, so I don't see a path from this PR to it. Could you post the assertion message and line from your gnu run? That should show whether it's toolchain-specific.

AI-assisted (Claude); measured on my machine, no game data shared.

**@⁠neonbyte1** on GitHub · 2026-11-26 10:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/3091#issuecomment-7188811681) Thanks both. **@⁠fuzeofficlal:** I've added direct tests for the missing-export paths (amended, still one commit, `9096166`). The two overrides now take the export lookup as a parameter. Production passes the same lazy lookups as before, so the loopback and `resolvable` checks still run first. The tests pass `None`: - `WSAConnectByList` with a loopback list returns `WSAENETUNREACH`; - `GetAddrInfoExA` for `localhost` and `127.0.0.1` returns `WSAHOST_NOT_FOUND`, sets the last error and clears `*result`; - a third test checks that a present export is still forwarded. With both fallbacks broken on purpose, exactly the two new tests fail. The description now says that loopback targets are refused too when the exports are missing. **@⁠YaBulochka:** I couldn't reproduce the `xpackage` failure. `xpackage::tests::completed_installation_unregisters_progress_immediately` passed every time, on `main` and on this branch: with and without `diagnostics`, run on its own and in the full suite, three runs each (24 runs). That's Wine 11.22 with the `x86_64-pc-windows-msvc` target on an RTX 5090. I don't have the gnu target installed. The change is confined to `net.rs`: the new lazy lookups only run inside the two overrides, and that test only touches xpackage's own table, so I don't see a path from this PR to it. Could you post the assertion message and line from your gnu run? That should show whether it's toolchain-specific. _AI-assisted (Claude); measured on my machine, no game data shared._
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 11:53 UTC · original · approved these changes

Reviewed 9096166b and verified on Windows 11: reachable/resolvable checks still execute before the optional LazyLock export lookups (crates/victory-hle/src/modules/net.rs:299-379, 630-709), missing WSAConnectByList/GetAddrInfoExA exports fall back to WSAENETUNREACH and WSAHOST_NOT_FOUND (clearing *result via blocked_lookup), present exports forward as before, and the new injected unit tests cover both missing-export and forwarding paths.

rustfmt --edition 2024 --check, xtask policy (191 files ok), cargo clippy -p victory-hle --all-targets -- -D warnings (default and --all-features), modules::net::tests (5/5), and the full victory-hle test suite (155 unit + 2 integration tests) all pass.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 11:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/3091#pullrequestreview-6073677564) · **approved these changes** Reviewed `9096166b` and verified on Windows 11: `reachable`/`resolvable` checks still execute before the optional `LazyLock` export lookups (`crates/victory-hle/src/modules/net.rs:299-379, 630-709`), missing `WSAConnectByList`/`GetAddrInfoExA` exports fall back to `WSAENETUNREACH` and `WSAHOST_NOT_FOUND` (clearing `*result` via `blocked_lookup`), present exports forward as before, and the new injected unit tests cover both missing-export and forwarding paths. `rustfmt --edition 2024 --check`, `xtask policy` (191 files ok), `cargo clippy -p victory-hle --all-targets -- -D warnings` (default and `--all-features`), `modules::net::tests` (5/5), and the full `victory-hle` test suite (155 unit + 2 integration tests) all pass.
This pull request can be merged automatically.
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/3091/head:github-bot/gh-3091'
git switch 'github-bot/gh-3091'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3091'
git switch 'github-bot/gh-3091'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3091'
git switch 'github-bot/gh-3091'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3091'
git switch 'main'
git merge --squash 'github-bot/gh-3091'
git switch 'main'
git merge --ff-only 'github-bot/gh-3091'
git switch 'main'
git merge 'github-bot/gh-3091'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3091
No description provided.