Implement the PIX device-session receive stream #241

Closed
github-bot wants to merge 5 commits from gh-pr/241/head into gh-pr/241/base
Owner

@⁠bambermf on GitHub · 2026-11-23 06:45 UTC · original
bambermf:port/pix-session-stream → main · +453 −9 · 6 files · 5 commits · closed without merging

Library / area — Build 19041 PIX runtime, receive side of XBTP device sessions.

Exports changed — None.

Source of behaviour — Headless IDA MCP on a local 19041 pixrt10.dll. The transport reassembles length-prefixed blocks at RVA 0x2bff8, decodes raw or compressed payloads at 0x2c62c, and assembles messages with a 12-byte header. I ran the reference decoder from 0x329f0 under instruction emulation with synthetic XPRESS inputs produced on Windows.

What was missing

The device engine closes an accepted link before reading a tool request. This draft implements and exercises the stream reader needed between acceptance and request dispatch. The device connection routine now passes accepted in-process links to this reader on build 19041.

Measurements

Seven Windows XPRESS inputs decoded to the exact original bytes in the reference decoder. The input payload sizes before compression were 30, 4095, 4096, 4097, 16384, 65536 and 524288 bytes. A separately constructed overlapping match expanded to 35 repeated bytes in both the reference decoder and the new reader.

The change

Read eight-byte block headers, handle raw payloads or call the Windows XPRESS decoder, and reassemble length-prefixed messages across blocks. Validate lengths before allocating. A clean end of stream and a truncated message produce distinct results.

Build 19041 version query

The session can now reply to opcode 1306. The response carries the request identifiers, the reported magic and version, and the four version-query values returned by the console handler. The writer emits raw PIX blocks that fit the configured block capacity. The reference comparison uses the original reply-building routine at RVA 0x15b24 under instruction emulation. Three synthetic requests varied the sequence, opcode flag bits and echoed fields.

Device request loop and validation

The stream code now builds as part of the pixrt10 library. The 19041 request loop consumes successive messages until the peer closes. Opcodes 1200 through 1202 consume a message without sending a reply. For unknown opcodes the console fallback at RVA 0x14a5c sends a 68-byte E_NOTIMPL reply unless initialization flag bit 0 suppresses it. Recognized requests whose handlers still need porting return a local unsupported error.

A single XBTP exchange sends opcode 1200, an unknown opcode and the version query. The peer checks the complete 68-byte error and 84-byte version messages in order. Both reference replies were produced by executing the original reply builder with synthetic identifiers. All 44 release tests across pixrt and pixrt10 passed with the local reference DLLs available for export comparison.

Device-session handoff

The worker calls the dispatcher after accepting an XBTP link when compat_common::os_host::routes::current_build() == 19041. It checks for the in-process device tag before resolving session I/O and uses the accepted handle for both receive and send. This path opens no OS sockets.

The 19041 test runs the worker’s connection routine, listens on service 0x1080, and exchanges three requests with an in-process peer. The 22000 regression starts the runtime worker, connects a peer and observes EOF with zero response bytes. Its session-I/O resolver would fail the test if invoked. Both PIX release DLLs built, all 44 release tests passed with local reference DLLs, and the PR gate passed.

Remaining integration

The separate 19041 title initializer still returns E_NOTIMPL before starting the worker. This tests the worker connection path directly for that build. Live title startup and capture remain unfinished.

**@⁠bambermf** on GitHub · 2026-11-23 06:45 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/241) `bambermf:port/pix-session-stream` → `main` · +453 −9 · 6 files · 5 commits · closed without merging **Library / area** — Build 19041 PIX runtime, receive side of XBTP device sessions. **Exports changed** — None. **Source of behaviour** — Headless IDA MCP on a local 19041 pixrt10.dll. The transport reassembles length-prefixed blocks at RVA `0x2bff8`, decodes raw or compressed payloads at `0x2c62c`, and assembles messages with a 12-byte header. I ran the reference decoder from `0x329f0` under instruction emulation with synthetic XPRESS inputs produced on Windows. ### What was missing The device engine closes an accepted link before reading a tool request. This draft implements and exercises the stream reader needed between acceptance and request dispatch. The device connection routine now passes accepted in-process links to this reader on build 19041. ### Measurements Seven Windows XPRESS inputs decoded to the exact original bytes in the reference decoder. The input payload sizes before compression were 30, 4095, 4096, 4097, 16384, 65536 and 524288 bytes. A separately constructed overlapping match expanded to 35 repeated bytes in both the reference decoder and the new reader. ### The change Read eight-byte block headers, handle raw payloads or call the Windows XPRESS decoder, and reassemble length-prefixed messages across blocks. Validate lengths before allocating. A clean end of stream and a truncated message produce distinct results. ### Build 19041 version query The session can now reply to opcode 1306. The response carries the request identifiers, the reported magic and version, and the four version-query values returned by the console handler. The writer emits raw PIX blocks that fit the configured block capacity. The reference comparison uses the original reply-building routine at RVA `0x15b24` under instruction emulation. Three synthetic requests varied the sequence, opcode flag bits and echoed fields. ### Device request loop and validation The stream code now builds as part of the pixrt10 library. The 19041 request loop consumes successive messages until the peer closes. Opcodes 1200 through 1202 consume a message without sending a reply. For unknown opcodes the console fallback at RVA `0x14a5c` sends a 68-byte E_NOTIMPL reply unless initialization flag bit 0 suppresses it. Recognized requests whose handlers still need porting return a local unsupported error. A single XBTP exchange sends opcode 1200, an unknown opcode and the version query. The peer checks the complete 68-byte error and 84-byte version messages in order. Both reference replies were produced by executing the original reply builder with synthetic identifiers. All 44 release tests across pixrt and pixrt10 passed with the local reference DLLs available for export comparison. ### Device-session handoff The worker calls the dispatcher after accepting an XBTP link when `compat_common::os_host::routes::current_build() == 19041`. It checks for the in-process device tag before resolving session I/O and uses the accepted handle for both receive and send. This path opens no OS sockets. The 19041 test runs the worker’s connection routine, listens on service 0x1080, and exchanges three requests with an in-process peer. The 22000 regression starts the runtime worker, connects a peer and observes EOF with zero response bytes. Its session-I/O resolver would fail the test if invoked. Both PIX release DLLs built, all 44 release tests passed with local reference DLLs, and the PR gate passed. ### Remaining integration The separate 19041 title initializer still returns E_NOTIMPL before starting the worker. This tests the worker connection path directly for that build. Live title startup and capture remain unfinished.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:15:23 +00:00
github-bot closed this pull request 2026-11-26 06:15:23 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-23 06:57 UTC · original

Thanks, the stream decoding and its tests look careful. One issue before this can go in: transport_stream.rs isn't declared in crates/compat/pixrt/src/lib.rs. Only the pixrt10 test includes it, through #[path], so nothing in the shipped DLL uses it. Could you wire it into the device-session path? When you do:

  • Only answer reply_to_version_query_19041 when compat_common::os_host::routes::current_build() == 19041, the same way #223 gates its 19041 behaviour, and keep other builds on today's path.
  • Keep it on the accepted in-process XBTP link. It must not open or bind any OS socket. If a socket is ever needed, it binds loopback only (127.0.0.1 / ::1), never 0.0.0.0.
  • Add a test showing a non-19041 build takes the old path.
**@⁠omonkeyz** on GitHub · 2026-11-23 06:57 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/241#issuecomment-7093835112) Thanks, the stream decoding and its tests look careful. One issue before this can go in: `transport_stream.rs` isn't declared in `crates/compat/pixrt/src/lib.rs`. Only the pixrt10 test includes it, through `#[path]`, so nothing in the shipped DLL uses it. Could you wire it into the device-session path? When you do: - Only answer `reply_to_version_query_19041` when `compat_common::os_host::routes::current_build() == 19041`, the same way #223 gates its 19041 behaviour, and keep other builds on today's path. - Keep it on the accepted in-process XBTP link. It must not open or bind any OS socket. If a socket is ever needed, it binds loopback only (127.0.0.1 / ::1), never 0.0.0.0. - Add a test showing a non-19041 build takes the old path.
Author
Owner

@⁠bambermf on GitHub · 2026-11-23 07:13 UTC · original

Fixed in 5bf436d. The shipped DLL now includes the stream decoder, and the device worker answers the version query on the accepted in-process XBTP link only when current_build() is 19041. The handler opens no OS sockets. I added a regression test for the existing path on other builds. All 44 release tests across pixrt and pixrt10 passed.

The PR is still a draft while I work on the separate 19041 title initializer. The worker tests exercise an accepted connection directly.

**@⁠bambermf** on GitHub · 2026-11-23 07:13 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/241#issuecomment-7094109924) Fixed in 5bf436d. The shipped DLL now includes the stream decoder, and the device worker answers the version query on the accepted in-process XBTP link only when current_build() is 19041. The handler opens no OS sockets. I added a regression test for the existing path on other builds. All 44 release tests across pixrt and pixrt10 passed. The PR is still a draft while I work on the separate 19041 title initializer. The worker tests exercise an accepted connection directly.
Author
Owner

@⁠bambermf on GitHub · 2026-11-23 07:28 UTC · original

Continued in #250, which includes this PR through commit 5bf436d and adds the 19041 title initializer. Its integration test starts the device worker through the initializer and verifies the version reply over in-process XBTP. I’m closing this draft to keep further work and review in #250.

**@⁠bambermf** on GitHub · 2026-11-23 07:28 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/241#issuecomment-7094365710) Continued in #250, which includes this PR through commit 5bf436d and adds the 19041 title initializer. Its integration test starts the device worker through the initializer and verifies the version reply over in-process XBTP. I’m closing this draft to keep further work and review in #250.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.