Files
WoW-Hybrid-gateway/docs/NATIVE_WINE_ACCOUNT.md
2026-11-19 04:16:18 +02:00

10 KiB

Windows-owned native account and protocol boundary

Native engine character selection and world entry remain unfinished. This work removes a verified Windows/Unix ABI dependency; it does not replace the missing Forever account/transport lifecycle with a fabricated connected state.

native/wine_wire_windows.c is an ordinary PE DLL. It loads its owned Unix peer through installed Wine11.19's declared __wine_load_unix_lib interface, then uses __wine_unix_call. The pre-associated builtin-module initialization helper was unsuitable for this ordinary DLL. No guessed Windows-to-SysV function call, Lua callback registration, socket interception or external proxy is used.

The640-byte gw_wire_call POD exchanges borrowed bounded buffers and typed registry IDs. native/wine_wire_registry.cpp owns authenticated accounts and socket-free channels with RAII; it never exports SRP/session keys. Existing SRP/M2 verification, world-proof generation, framing and authenticated roster code are reused. Independent PE/WinSock tests exercise those same algorithms.

native/wine_wire_account.c starts a Windows CreateThread worker only after an explicit command on the verified main-frame callback. A1732-byte owned control holds private input-file references; password contents are read only by the existing authentication implementation. Only public outcome fields and genuine realm metadata are exposed to the inspector. The worker retains legitimate account and prepared-channel ownership for at most120 seconds, closes both on cancellation, clears its private inputs and publishes completion. DLL shutdown refuses active workers/live handles and joins completed worker lifetime before unloading. No world socket is opened by this preparation step.

Realms come from the authentication server. Only a single unambiguous advertised local online realm is automatically selected. Multiple available realms wait for an explicit index; the protocol layer rejects offline/nonlocal selections. No realm name, address or character identity is synthesized.

ops/native_wire_host.py prepare changes only a journaled private DXVK copy to import the two owned modules. Original executable bytes, data and prefix remain untouched. ops/debug_client_owner.py serve-poll-host launches that complete private client with Linux bootstrap/Lua registration disabled. Parent RPCs install-engine-wire-ping, start-engine-wire-account, inspect-wire-account and restore-engine-poll-host operate only on this own-child binding. Account configuration is published at the genuine queue caller0x1401dfad3. Restoration publishes cancellation before restoring the original per-object vtable.

Actual WowB116205 completed the scalar call on Windows main-thread36, status0, echo1 and1ms initialization/call time. Actual WowB120616 then launched Windows worker772, authenticated to local Tortoise with verified M2, discovered its real realm127.0.0.1:8090 and prepared the channel. Gateway/reference services were stopped. The real UI stayed login, engine state2, all transport slots empty. Cancellation released handles with error0; original binding restored, client closed normally and private DXVK restored byte-identically. No character login, position/progression changes or new actual-client crash occurred in these tests.

Normal32/32 and ASan/UBSan32/32 suites passed; optional Windows PE fixtures use the normal bridge and are not claimed sanitizer-instrumented. An additional multiple-realm fixture and focused regressions passed after those full suites. Synthetic bad-M2/security/proof/group rejection cases never use stored accounts. Evidence: evidence/gameplay/native-wine-frame-abi.json and evidence/gameplay/native-Windows-account.json.

Rollback: restore the binding at its safepoint, inspect worker state4/error0, close the exact private client normally, then run python3 ops/native_pe_bridge.py restore. The auxiliary DLL remains inactive. The import publication journal accepts both known intermediate hashes after an interruption. Never restore dependencies underneath a running client.

Next is the actual engine-owned TCP transport/packet-pipe and account provider. The prepared channel is suitable for a verified Windows transport adapter; it must not be paired with a dummy engine socket while traffic uses another socket. The real listener's connected callback consumes four Windows arguments, including R8/R9 metadata; a two-argument wrapper would be incorrect. Actual reference WowB126951 verified its I/O Windows thread388, compared with main-thread36: slot0, connecting4, no accepted transportR8, address metadataR9 present, original callback forwarded/error0. Its actual character-selection screenshot was viewed. The complete13-method listener table was preserved; original restored before normal close. These are labelled gateway-reference observations.

Pipe setup141e446f0 was separately observed at its genuine main-thread callsite. NetClient+0x228 is an indirect holder, as getter141e4de60 confirms. The constructor receives that stored holder, owner and actual connection. Passing the address of the field would corrupt ownership. Account/session bytes are excluded from these observations. Full packet-pipe replacement/destruction and realm/account context remain to validate.

The account now offers gw_wire_account_transport for future verified Windows pipe callbacks. It synchronously borrows the prepared channel under SRWLOCK, permits only bounded protocol/roster operations, rejects auth/close and never exports a session token/key. Exclusive cancellation waits for borrowed calls before closing. Synthetic Windows fixtures exercise a separate reader thread against cancellation plus unavailable/closed-channel rejection. The optional main-frame port-only probe does not open a world socket or adopt engine state.

Source-owned account cancellation

native/ui/source_account_cancel.h defines the typed project-host callback gw_source_account_cancel_fn(expected_generation). The Source owner implements it as the module-local source_account_cancel_generation method. The caller must retain the generation returned for its own attempt; reading the newest generation when an old dialog finally invokes Cancel defeats that protection. The additive ordinary Wire API gw_wire_account_ui_cancel_generation(uint32_t) returns the same signed32 result and has export ordinal81. Every previous name/ordinal binding is retained. It calls the same generation-checked Source method, without accepting inputs, native engine objects or authentication flags.

The method checks generation and ownership while holding channel_lock exclusively, the same lock used to publish and retire generations. It accepts an active authentication attempt (Source state 1) or an unselected realm list (state 5). A stale, missing or invalid generation is refused. Realm proposals, a selected realm, prepared transport or attached lease are past this method's cancellation boundary and are refused without changing that session. A realm proposal submitted after accepted cancellation is also refused.

Return 0 acknowledges only the request. It sets the Source cancellation flag; the existing worker still owns its handles, closes them and publishes the real outcome. Synchronous authentication I/O is not forcefully interrupted. A host keeps submission blocked until a closed (4) or failed (3) status for that exact generation, and ignores both stale and newer unrelated callbacks. Negative results leave the attempt pending: -1 is an invalid generation, -2 is not the current active attempt, and -3 is past the pretransport cancellation boundary. The existing no-argument compatibility entry remains realm-choice-only; it revalidates its captured generation before committing cancellation. Its pre-existing generationless file-input scope is retained separately; generation zero is always invalid for the typed owned-account callback.

Both failure and genuine closed headers survive automatic Source retirement. Closed is latched only after handle retirement completes, the lease is released and no prepared channel remains. Neither latch contains realm rows or inputs; both are cleared when a new real generation is accepted. This prevents a polling host from missing cancellation acknowledgement when retirement runs first.

tests/source_account_cancel_test.py compiles the production cancellation and selection functions with real pthread ownership locks. It covers pending authentication, request-only acknowledgement, stale/current generations, selection/transport/lease refusals, post-cancel selection and a deterministic two-thread generation race. The terminal-header fixture also covers closed publication, retirement, next-generation clearing and premature-close refusal.

The existing numeric project dispatcher accepts GetTurtleRealmSnapshot(11, expected_generation, 0). Query11 is handled before the character-create query range; a zero/out-of-range generation or nonzero reserved argument returns -4005. An unavailable binding or older Wire lacking the new export returns -4001, with no fallback to generationless cancellation. No engine namespace row, registration mechanism or numeric-reader implementation changes. This is an existing project callback calling an ordinary project API.

tests/source_account_cancel_dispatch_test.py exercises the production numeric dispatcher with synthetic arguments/module lookup, including older-Wire refusal, exact generation, reserved arguments and unchanged older query routes. A separate host-ABI probe calls the production export wrapper; a tiny AMD64 PE containing that wrapper and a synthetic provider verifies the new symbol at ordinal81. This is not a full private-component build or a game-loaded module.

The changed modules have not been built or activated in the original client. The account sign-in provider remains unavailable; no authentication entry or credential transport is added. A submission still queued before the Source worker binds a generation is refused by this method, not reported as cancelled or erased. No game, real account, same-window reconnect or immediate network-I/O cancellation acceptance follows from these source-level fixtures.