Skip to content

fix(windows): resolve iphlpapi connectivity-hint exports dynamically (#2043) - #2051

Merged
Hona merged 1 commit into
devfrom
fix/win-server-2019-iphlpapi-dynamic-load
Dec 1, 2026
Merged

Hona merged 1 commit into
devfrom
fix/win-server-2019-iphlpapi-dynamic-load

Conversation

@Hona

@Hona Hona commented Dec 1, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #2043.

Resolves GetNetworkConnectivityHint and NotifyNetworkConnectivityHintChange from iphlpapi.dll at runtime instead of importing them at link time, preventing the 0xC06D007F (ERROR_PROC_NOT_FOUND) delay-load abort on Windows Server 2019 and Windows 10 1809–1909 (build 17763).

Root cause

apps/desktop/src/workspace/lifecycle/launch/network.rs imported GetNetworkConnectivityHint and NotifyNetworkConnectivityHintChange directly from windows-sys. Because both exports were added in Windows 10 2004 (build 19041) and iphlpapi.dll is delay-loaded, the MSVC delay-load helper raised 0xC06D007F shortly after the first frame when on_ready called network::subscribe, before the existing NotifyIpInterfaceChange fallback could run.

Changes

  • Load iphlpapi.dll with LoadLibraryExW(..., LOAD_LIBRARY_SEARCH_SYSTEM32) and look up GetNetworkConnectivityHint and NotifyNetworkConnectivityHintChange via GetProcAddress in apps/desktop/src/workspace/lifecycle/launch/network.rs.
  • Keep the exact Windows 10 2004+ / Windows 11 behavior when both exports exist (seeding LEVEL, registering reach_changed, and keeping iphlpapi.dll loaded for the process lifetime).
  • When either export is missing or registration fails, release the module handle with FreeLibrary and fall through cleanly to NotifyIpInterfaceChange (available since Windows Vista).
  • Verified crates/browser-pane/src/background.rs (NetworkInformation::GetInternetConnectionProfile) already handles Err without panicking, and no other Windows 10 2004+ link-time imports exist in the desktop binary.

Verification

  • pwsh scripts/guardrails.ps1: 11/11 passed.
  • cargo check -p opencode-desktop --lib --bins, cargo check -p opencode-desktop-library, and cargo clippy -p opencode-desktop --no-deps --lib --bins: passed with zero warnings in network.rs.
  • Built opencode-desktop-library (opencode_desktop_app.dll) on Windows 11 and parsed its PE32+ import and delay-import tables: iphlpapi.dll is delay-imported with only NotifyIpInterfaceChange, and neither GetNetworkConnectivityHint nor NotifyNetworkConnectivityHintChange appears in either table.
  • Not verified on hardware: live execution on Windows Server 2019 / Windows 10 build 17763 (verified on Windows 11 build/compile + PE import-table inspection only).

Copilot AI balanced review requested due to automatic review settings December 1, 2026 18:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@Hona
Hona merged commit 69493d2 into dev Dec 1, 2026
3 checks passed
@Hona
Hona deleted the fix/win-server-2019-iphlpapi-dynamic-load branch December 1, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows Server 2019 (build 17763): dev-513 exits ~1s after launch — 0xC06D007F, delay-load of iphlpapi!GetNetworkConnectivityHint

2 participants