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

Open
neonbyte1 wants to merge 1 commit from upstream-pr/3091 into main
neonbyte1 commented 2026-11-26 07:29:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-26T07:29:59Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5505853329 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3091). Originally posted by [neonbyte1](https://github.com/neonbyte1) on 2026-11-26T07:29:59Z. --- 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._
Dukestar69 commented 2026-11-26 07:49:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T07:49:58Z.

Review: APPROVED


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).

<!-- greyfinch-sync:Marvisak/VIctory:review:6070264584 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3091#pullrequestreview-6070264584). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T07:49:58Z. **Review:** APPROVED --- 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).
fuzeofficlal commented 2026-11-26 08:41:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T08:41:59Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6070869599 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3091#pullrequestreview-6070869599). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T08:41:59Z. **Review:** COMMENTED --- 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.
Marvisak commented 2026-11-26 09:06:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T08:19:13Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7186451509 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3091#issuecomment-7186451509). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T08:19:13Z. --- <!-- 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)_
YaBulochka commented 2026-11-26 09:06:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by YaBulochka on 2026-11-26T08:39:40Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7186865116 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3091#issuecomment-7186865116). Originally posted by [YaBulochka](https://github.com/YaBulochka) on 2026-11-26T08:39:40Z. --- 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.
neonbyte1 commented 2026-11-26 10:05:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-26T10:01:47Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7188811681 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3091#issuecomment-7188811681). Originally posted by [neonbyte1](https://github.com/neonbyte1) on 2026-11-26T10:01:47Z. --- 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._
fuzeofficlal commented 2026-11-26 11:53:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T11:53:14Z.

Review: APPROVED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6073677564 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3091#pullrequestreview-6073677564). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T11:53:14Z. **Review:** APPROVED --- 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.
neonbyte1 commented 2026-11-28 01:22:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-28T01:22:06Z.


Overlap note: while merging all triage: merge candidate PRs together on one branch, this PR conflicted with #2249 (@desplmfao), which fixes the same Wine case: WSAConnectByList and GetAddrInfoExA missing from Wine's ws2_32. The two differ only in what the override returns when the export is missing: #2249 returns WSAEOPNOTSUPP, this PR WSAENETUNREACH through connect()/resolve() helpers. #2249 is older and already a merge candidate, so I'd rather not have two fixes for one problem: unless a reviewer prefers this one, I'll close it in favour of #2249. If the loopback/resolvable-before-fallback ordering this PR tests isn't covered there, I can offer those tests on #2249 instead.

AI-assisted (Claude); found during an integration merge, no game data shared.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7231615257 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3091#issuecomment-7231615257). Originally posted by [neonbyte1](https://github.com/neonbyte1) on 2026-11-28T01:22:06Z. --- Overlap note: while merging all `triage: merge candidate` PRs together on one branch, this PR conflicted with #2249 (@desplmfao), which fixes the same Wine case: `WSAConnectByList` and `GetAddrInfoExA` missing from Wine's `ws2_32`. The two differ only in what the override returns when the export is missing: #2249 returns `WSAEOPNOTSUPP`, this PR `WSAENETUNREACH` through `connect()`/`resolve()` helpers. #2249 is older and already a merge candidate, so I'd rather not have two fixes for one problem: unless a reviewer prefers this one, I'll close it in favour of #2249. If the loopback/`resolvable`-before-fallback ordering this PR tests isn't covered there, I can offer those tests on #2249 instead. _AI-assisted (Claude); found during an integration merge, no game data shared._
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3091:upstream-pr/3091'
git switch 'upstream-pr/3091'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/3091'
git switch 'upstream-pr/3091'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3091'
git switch 'upstream-pr/3091'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3091'
git switch 'main'
git merge --squash 'upstream-pr/3091'
git switch 'main'
git merge --ff-only 'upstream-pr/3091'
git switch 'main'
git merge 'upstream-pr/3091'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!3089
No description provided.