Skip to content

xgameruntime: serve XNetworkingImpl (IXNetworkingImpl2) through QueryApiImpl - #2116

Merged
ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
swam122yam-glitch:feat-xnetworking-impl
Nov 22, 2026
Merged

ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
swam122yam-glitch:feat-xnetworking-impl

Conversation

@swam122yam-glitch

@swam122yam-glitch swam122yam-glitch commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: RT-140

What and why

XCurl.dll calls XNetworkingImpl (IXNetworkingImpl2, slots 3-20) through xgameruntime.lib's QueryApiImpl thunks, but QueryApiImpl previously refused the class. docs/runtime_imports.md noted XCurl.dll calls slots 11-17 and marked it as "Not served yet".

This PR implements the singleton XNetworkingImpl object with offline console semantics:

  • Slot 15 (XNetworkingGetConnectivityHint): Reports networkInitialized = true with level None (1) and cost Unknown (0) so network-dependent subsystems know the stack is initialized but offline. Rejects null pointer with E_POINTER.
  • Slot 14 (XNetworkingVerifyServerCertificate): Returns HRESULT_FROM_WIN32(ERROR_NETWORK_UNREACHABLE).
  • Slots 11-13 (XNetworkingQuerySecurityInformationForUrlUtf16Async*) & Slots 8-10 (ANSI): Fail with ERROR_NETWORK_UNREACHABLE (*Async completes via XAsyncRun). Slots 10 and 13 strictly follow Microsoft's parameter order (async, bufferByteCount, bufferByteCountUsed*, buffer*, information**) leaving sentinel buffers untouched and zeroing outputs in place.
  • Slots 16 & 17 (XNetworkingRegisterConnectivityHintChanged / Unregister): Issues monotonic XTaskQueueRegistrationToken values via std::atomic<uint64_t> that never fire offline; unregister returns true.
  • Slots 18-20 (IXNetworkingImpl2): Returns E_NOTIMPL.
  • Extended runtime/test/xgameruntime_test.cpp (71/71 passing checks) and updated runtime/test/fixtures/tiny_gdk_load.cpp.
  • Updated docs/runtime_imports.md class layout table and documentation of offline behavior.

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

…ApiImpl

- QueryApiImpl hands out XNetworkingImpl (IXNetworkingImpl2, slots 3-20)
  for its class GUID {37e56907-2f10-41e8-b72f-36edb185331a}.
- Serves the slots XCurl.dll calls:
  * Slot 15: XNetworkingGetConnectivityHint reports an initialized network
    with unrestricted internet access offline.
  * Slot 14: XNetworkingVerifyServerCertificate returns S_OK.
  * Slots 16 & 17: XNetworkingRegisterConnectivityHintChanged and
    XNetworkingUnregisterConnectivityHintChanged manage registration tokens.
  * Slots 11-13: Async UTF-16 security information query stubs.
- Updated docs/runtime_imports.md layout table.
- Extended runtime/test/xgameruntime_test.cpp and tiny_gdk_load.cpp
  to verify XNetworkingImpl resolution and slot execution.
@Dom-in

Dom-in commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Hi @swam122yam-glitch, I overlapped with this in #2169 (I didn't see yours first, sorry). I've asked the coordinator on #2078 to pick one. One point for whichever lands: reporting InternetAccess and returning S_OK from XNetworkingVerifyServerCertificate tells XCurl the PC is online with a verified server. XCurl would then attempt real requests, and a certificate check would "pass" without anything being checked. An offline runtime probably wants None plus a network-unreachable error, as #2169 does. Also note @Flyander's catch on #2169: the *AsyncResult parameter order is (async, bufferByteCount, bufferByteCountUsed*, buffer*, information**), in case yours has those slots.

- Handle IXNetworkingImpl2 query for class {37e56907-2f10-41e8-b72f-36edb185331a}.
- Return offline answers matching console behavior without network:
  * Connectivity hint: networkInitialized=true, level=None (1), cost=Unknown (0).
  * Port query and URL security queries fail with ERROR_NETWORK_UNREACHABLE.
  * Async queries complete through XAsync with ERROR_NETWORK_UNREACHABLE.
  * Correct ABI parameter order for AsyncResult:
    (async, bufferByteCount, bufferByteCountUsed*, buffer*, information**).
  * VerifyServerCertificate fails offline with ERROR_NETWORK_UNREACHABLE.
  * Registration tokens are tracked without firing offline.
  * IXNetworkingImpl2 extension methods return E_NOTIMPL.
- Update docs and tests in xgameruntime_test and tiny_gdk_load.
@swam122yam-glitch

Copy link
Copy Markdown
Contributor Author

Thanks @Dom-in and @Flyander for the feedback!

Updated in f0c95d4:

  • Offline Semantics: Connectivity hint now correctly reports networkInitialized = true with level None (1) and cost Unknown (0).
  • Error Behavior: Queries and XNetworkingVerifyServerCertificate now fail with HRESULT_FROM_WIN32(ERROR_NETWORK_UNREACHABLE). The *Async queries complete through XAsyncRun with that error.
  • ABI Correction: Slots 10 and 13 now strictly follow the official parameter order: (async, bufferByteCount, bufferByteCountUsed*, buffer*, information**), ensuring sentinel buffers remain untouched while used and information pointers are zeroed in place.
  • Full 21-slot vtable covering both IXNetworkingImpl and IXNetworkingImpl2 ({bf2346b2-39af-4658-b5ea-44713c7e83b3}).
  • Tested and verified: xgameruntime_test (71/71 passing checks) and tiny_gdk_load.

@ezwinxdlmao

Copy link
Copy Markdown
Contributor

Tested 5f5d6d1 on an NVIDIA GeForce RTX 3050 Laptop GPU, driver 32.0.16.2101, Windows 11, native MSVC (VS 2022 Build Tools, Ninja, RelWithDebInfo), with llvm-mc 21.1.8 for the translated-shader tests: pass.

AI-assisted (Claude Code).

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested 5f5d6d1, merged onto main 4947579 (no conflicts), on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, fresh RelWithDebInfo build:

  • xgameruntime: passes 20 of 20 runs, and passes under LEONIDA_VK_VALIDATION=1.
  • Full ctest: 125/125.

Code read: the served IXNetworkingImpl2 slots answer locally. The security-information calls complete their XAsyncBlock with S_OK, and nothing opens a socket or calls WinHTTP, so it stays within "nothing online". The https://example.com in the test is only a string argument.

AI-assisted (Claude Code).

@swam122yam-glitch

Copy link
Copy Markdown
Contributor Author

Thanks @JRamos1993 for testing and verifying on latest main (RTX 5090)! Good to confirm the clean merge and 125/125 test pass. Note that f0c95d47 is also up, which tightens the offline semantics further (reporting level None and returning ERROR_NETWORK_UNREACHABLE per Dom-in and Flyander's suggestions).

@FaKL-Code

FaKL-Code commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Tested f0c95d4 (merged onto main 4947579) on NVIDIA GeForce RTX 4060 Ti, driver 610.88 (32.0.16.1088), Windows 11 26200, MSVC 14.51.36231 (VS 2026), Vulkan SDK 1.4.363.0: pass

  • Clean configure + build of runtime/ (Visual Studio generator, RelWithDebInfo).
  • ctest -C RelWithDebInfo -j 4: 116/116 passed (7 skipped for missing inputs or optional components: shader_library_corpus, bink_decode, fsr_dispatch, bvh_builder, bink_audio, vk_sync_validation, d3d12_rgb9e5_rtv; gameinput disabled, as on main).
  • xgameruntime passes with the new offline XNetworkingImpl (IXNetworkingImpl2) served through QueryApiImpl.
  • This branch and xgameruntime: XErrorReport returns HRESULT, XErrorSetOptions void (follow-up to #1877) #2327 both touch the xgameruntime shim, and they merge onto main together without conflicts.

AI-assisted (Claude).

@swam122yam-glitch

Copy link
Copy Markdown
Contributor Author

Thanks @FaKL-Code for testing f0c95d47 on the RTX 4060 Ti and confirming the clean merge with #2327 onto latest main, along with the 116/116 test pass! Really appreciate the verification!

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.

6 participants