startup: trace declared provider outputs behind an opt-in switch #1324

Manually merged
github merged 3 commits from gh-pr/1324/head into gh-pr/1324/base 2026-11-26 22:58:12 +00:00
Owner

@⁠triggered02 on GitHub · 2026-11-24 08:04 UTC · original
triggered02:tooling/api-trace → main · +339 −0 · 4 files · 3 commits · merged 2026-11-24 08:54 UTC

The optional logging PR you welcomed is up: #1301, X2W_TRACE_API=1, one line per provider call with the return code, whether the answer came from the stand-in or the real runtime, and which declared output argument was written. It reads only the outputs in a small contract table (user add result, id, guest flag, state, gamertag buffer and used count, age group, privilege result and deny reason, connectivity hint); a slot with no declared contract reports out=? and nothing is read. The real provider result is left intact — nothing overrides or rewrites it.

While writing it I also found that my previous "5,555 successes with no sampled argument changed" figure was too strong and should be withdrawn: with declared outputs, the connectivity hint reports unchanged 3,400 times simply because its four words are constant, so a repeat call leaves identical bytes. "Unchanged" therefore is not evidence that an output was skipped, and the earlier number cannot be read as "an S_OK with an untouched out-pointer". The new line says which case it is per call instead of leaving it to be inferred.

Interface identification, since you asked for the contract: the poll pair is provider 37e56907-2f10-41e8-b72f-36edb185331a, interface bf2346b2-39af-4658-b5ea-44713c7e83b3. That provider is the connectivity family in our stand-in (slot 15 is answered locally as a connectivity hint with level none, cost unknown, initialized set — the "stack initialized, no connectivity" answer already in the code), and slot 2 is not covered by the stand-in at all, so it passes through to the real runtime and returns S_FALSE (0x00000001) there, 5,587 times in the last run, immediately before the assertion.

So the typed poll you asked for is the next step and I have what it needs: a fixture that asks that interface for connectivity and distinguishes ready-with-item / empty-not-ready / failure, and records which of the three the real runtime gives for slot 2 versus what our hint says for slot 15. The contract I still cannot state from the code is what slot 2 is supposed to mean — if you can name the interface method, I will pin the documented return and output values into the fixture instead of inferring them.

Keeping the factory diagnosis open, as instructed: the trace ties the last call before the assertion to a S_FALSE poll, but has not tied that call to the consuming condition inside the factory.

**@⁠triggered02** on GitHub · 2026-11-24 08:04 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1324) `triggered02:tooling/api-trace` → `main` · +339 −0 · 4 files · 3 commits · merged 2026-11-24 08:54 UTC The optional logging PR you welcomed is up: #1301, `X2W_TRACE_API=1`, one line per provider call with the return code, whether the answer came from the stand-in or the real runtime, and which **declared** output argument was written. It reads only the outputs in a small contract table (user add result, id, guest flag, state, gamertag buffer and used count, age group, privilege result and deny reason, connectivity hint); a slot with no declared contract reports `out=?` and nothing is read. The real provider result is left intact — nothing overrides or rewrites it. While writing it I also found that my previous "5,555 successes with no sampled argument changed" figure was too strong and should be withdrawn: with declared outputs, the connectivity hint reports `unchanged` 3,400 times simply because its four words are constant, so a repeat call leaves identical bytes. "Unchanged" therefore is not evidence that an output was skipped, and the earlier number cannot be read as "an S_OK with an untouched out-pointer". The new line says which case it is per call instead of leaving it to be inferred. Interface identification, since you asked for the contract: the poll pair is provider `37e56907-2f10-41e8-b72f-36edb185331a`, interface `bf2346b2-39af-4658-b5ea-44713c7e83b3`. That provider is the connectivity family in our stand-in (slot 15 is answered locally as a connectivity hint with level `none`, cost unknown, `initialized` set — the "stack initialized, no connectivity" answer already in the code), and **slot 2 is not covered by the stand-in at all, so it passes through to the real runtime and returns `S_FALSE` (`0x00000001`) there**, 5,587 times in the last run, immediately before the assertion. So the typed poll you asked for is the next step and I have what it needs: a fixture that asks that interface for connectivity and distinguishes ready-with-item / empty-not-ready / failure, and records which of the three the real runtime gives for slot 2 versus what our hint says for slot 15. The contract I still cannot state from the code is what slot 2 is supposed to mean — if you can name the interface method, I will pin the documented return and output values into the fixture instead of inferring them. Keeping the factory diagnosis open, as instructed: the trace ties the last call before the assertion to a `S_FALSE` poll, but has not tied that call to the consuming condition inside the factory.
Adds X2W_TRACE_API=1, one line per provider call with the return code, whether the answer came from
the stand-in or the real runtime, and which declared output argument was written.

Only declared outputs are read. The previous revision of this trace probed every argument that looked
like a readable pointer, which cannot distinguish an out-argument from a handle or size that happens
to look like an address, and reports "none" for calls whose outputs sit outside the probed slots. The
contracts are now a small table (user add result, id, guest flag, state, gamertag buffer and used
count, age group, privilege result and deny reason, connectivity hint); a slot with no declared
contract reports out=? and nothing is read.

Nothing changes unless the switch is set.

Measured with the switch on over a 70 s offline run (7,250 provider calls):

  x2w-api 37e56907::slot15 -> 0x00000000 local out=unchanged
  x2w-api 37e56907::slot2  -> 0x00000001 real  out=?

Outcomes: 3,833 undeclared (out=?), 3,400 unchanged, 15 arg3, 2 arg1. The 3,400 "unchanged" are the
connectivity hint, whose four words are constant, so a repeat call leaves the same bytes — which is
why "unchanged" is not by itself evidence that an output was skipped, and the log now says so per
call instead of leaving it to be inferred.
Addresses the review of #1324.

The trace took eight bytes from every output. A readable page does not establish the object's extent,
so a one-byte flag or a DWORD could be read past its end or be classified unreadable when it straddles
a page. The contract now carries each output's width: 1 for the guest flag, 4 for the state, age group
and deny reason, 8 for handles, ids and used counts, 16 for the connectivity hint, and a caller-sized
buffer for the gamertag, where the capacity comes from the size argument and the snapshot is bounded by
it (and by a small cap).

Also from the review:

- Argument index 0 is a real output (the connectivity hint), so index 0 can no longer double as "no
  output changed". The trace uses a separate changed flag; before this, a changed hint was logged as
  `out=unchanged`.
- XUserGetId is slot 11, not 12; slot 12 is XUserFindUserById. Both are declared, along with the
  duplicate-handle, local-id and find-for-device slots.
- The dedicated gamertag interface (provider 0xcef4fac0, slot 3) has its own declaration, so its buffer
  and used count are no longer logged as unknown.

Measured with X2W_TRACE_API=1 over a 60 s offline run (5,638 calls): 2,893 undeclared, 2,601 arg0
(the connectivity hint now correctly reported), 84 arg3 (gamertag buffer), 56 arg1, 4 unchanged.
Because the widths are now correct, "unchanged" drops from thousands to four - the constant hint is
compared over its real 16 bytes and reported as written.

Nothing changes unless the switch is set; `startup_stubs` passes.
Addresses the second review of #1324.

The trace no longer stops at the first changed output: it reports every declared output that differs
("changed:0", "changed:3,4"), and it distinguishes three outcomes that were previously collapsed into
one word:

- "same" - every declared output was compared and held the same value;
- "same,partial" - at least one output was compared and held the same value while another declared
  output could not be compared;
- "unreadable" - no declared output could be compared at all.

The wording is now about what was observed, not about what the provider did: a provider may legitimately
write the value that was already there, so "same" never means "did not write".

The decision is moved into src/startup_stubs/api_trace.h with the contract table, so it can be checked
without a running title, and tests/api_trace_check.cpp covers the four cases the review asked for plus
the surrounding ones:

- argument index 0 changed is reported as "changed:0" (index 0 cannot double as "nothing changed");
- two changed outputs are both listed ("changed:3,4");
- a one-byte output is compared over one byte, and a byte past the declared width is not its change;
- a caller buffer shorter than the declared width is compared over the caller's capacity only;
- identical bytes report "same";
- one comparable output beside an uncomparable one reports "same,partial";
- no comparable output reports "unreadable", and an undeclared slot reports "?" and reads nothing;
- the table answers for XUserGetId (11), XUserFindUserById (12), the secondary gamertag interface
  (0xcef4fac0 slot 3) and the connectivity hint (0x37e56907 slot 15).

api_trace passes (13 cases) and startup_stubs passes; nothing changes unless X2W_TRACE_API is set.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:58:10 +00:00
github manually merged commit 9731fae2d3 into gh-pr/1324/base 2026-11-26 22:58:12 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 08:04 UTC · original · edited 2026-11-24 08:08 UTC

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T08:08:56.055748Z dce4ce6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 08:04 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1324#issuecomment-7125702077) · edited 2026-11-24 08:08 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"dce4ce6da0208bf65816bf1fbbbebb7f739d51b0","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T08:08:56.055748Z">2026-11-24T08:08:56.055748Z</relative-time> | `dce4ce6` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 08:08 UTC · original

P2 Badge Track XUserGetId at its actual vtable slot

With X2W_TRACE_API=1, a user-provider call to XUserGetId reaches slot 11 in user_call, but this table only declares slot 12, so forward leaves declared null and logs out=? for the ID output; slot 12 is XUserFindUserById. Add the slot-11 declaration and keep slot 12 under its actual contract if it is also meant to be traced.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 08:08 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1324#discussion_r4677141097) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Track XUserGetId at its actual vtable slot** With `X2W_TRACE_API=1`, a user-provider call to `XUserGetId` reaches slot 11 in `user_call`, but this table only declares slot 12, so `forward` leaves `declared` null and logs `out=?` for the ID output; slot 12 is `XUserFindUserById`. Add the slot-11 declaration and keep slot 12 under its actual contract if it is also meant to be traced. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 08:08 UTC · original

P2 Badge Declare the secondary gamertag interface's outputs

When QueryApiImpl returns the dedicated gamertag interface, proxy_query normalizes its provider key to gamertag_iid_data1 (0xcef4fac0) and forward handles slot 3. This row only matches the base user provider at slot 15, so the secondary interface's known buffer and used writes are logged as out=?; add a declaration for that provider and slot.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 08:08 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1324#discussion_r4677141109) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Declare the secondary gamertag interface's outputs** When `QueryApiImpl` returns the dedicated gamertag interface, `proxy_query` normalizes its provider key to `gamertag_iid_data1` (`0xcef4fac0`) and `forward` handles slot 3. This row only matches the base user provider at slot 15, so the secondary interface's known buffer and `used` writes are logged as `out=?`; add a declaration for that provider and slot. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 08:08 UTC · original

P2 Badge Snapshot only each output's declared width

For scalar outputs such as XUserGetIsGuest (1 byte) and XUserGetState (4 bytes), this probes and copies 8 bytes. readable checks page accessibility, not the output object's extent, so tracing can read past a valid short output or classify it as unreadable when it straddles a page; carry each output's actual width, including the gamertag buffer's supplied size.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 08:08 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1324#discussion_r4677141118) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Snapshot only each output's declared width** For scalar outputs such as `XUserGetIsGuest` (1 byte) and `XUserGetState` (4 bytes), this probes and copies 8 bytes. `readable` checks page accessibility, not the output object's extent, so tracing can read past a valid short output or classify it as unreadable when it straddles a page; carry each output's actual width, including the gamertag buffer's supplied size. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 08:08 UTC · original

P2 Badge Distinguish argument zero from no output change

When tracing 0x37e56907::slot15, the declared output is args[0] and area_call writes the words there. If that readable output changes, this stores the argument index 0 in written, but the later truth test treats zero as no write and logs out=unchanged; use a separate changed flag or a nonzero sentinel.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 08:08 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1324#discussion_r4677141123) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Distinguish argument zero from no output change** When tracing `0x37e56907::slot15`, the declared output is `args[0]` and `area_call` writes the words there. If that readable output changes, this stores the argument index `0` in `written`, but the later truth test treats zero as no write and logs `out=unchanged`; use a separate changed flag or a nonzero sentinel. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠triggered02 on GitHub · 2026-11-24 08:19 UTC · original

All four findings and R0Y00's request are addressed in 8d6c5477.

Widths (R0Y00 + the third finding). The contract now carries each output's real width instead of taking eight bytes everywhere: 1 for the guest flag, 4 for the state, age group and deny reason, 8 for handles/ids/used counts, 16 for the connectivity hint, and for the gamertag a caller-sized buffer whose capacity comes from the size argument, bounded by it and by a small cap. readable was checking page accessibility, not the object's extent, which is exactly the hole you both identified.

written sentinel (R0Y00 + the fourth finding). Index 0 is a real output — the connectivity hint — so int written = 0 double-counted it as "nothing changed". It is now -1 with a separate notion of "any output was readable", so a changed hint reports arg0 instead of unchanged.

Slot contracts (first finding). XUserGetId is slot 11; slot 12 is XUserFindUserById. Both are declared, plus the duplicate-handle (3), local-id (9), find-for-device (40) slots that were missing for the same reason.

Secondary gamertag interface (second finding). Provider 0xcef4fac0 slot 3 now has its own row, so its buffer and used count are traced rather than reported as unknown.

Measured with X2W_TRACE_API=1 over a 60 s offline run (5,638 calls):

out=?        2893   (no declared contract)
out=arg0     2601   (connectivity hint, previously misreported as unchanged)
out=arg3       84   (gamertag buffer)
out=arg1       56
out=unchanged   4

The unchanged count collapsing from thousands to four is the width fix working: the constant hint is now compared over its real 16 bytes and correctly reported as written. startup_stubs passes; nothing changes unless the switch is set.

**@⁠triggered02** on GitHub · 2026-11-24 08:19 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1324#issuecomment-7125995816) All four findings and R0Y00's request are addressed in `8d6c5477`. **Widths (R0Y00 + the third finding).** The contract now carries each output's real width instead of taking eight bytes everywhere: 1 for the guest flag, 4 for the state, age group and deny reason, 8 for handles/ids/used counts, 16 for the connectivity hint, and for the gamertag a caller-sized buffer whose capacity comes from the size argument, bounded by it and by a small cap. `readable` was checking page accessibility, not the object's extent, which is exactly the hole you both identified. **`written` sentinel (R0Y00 + the fourth finding).** Index 0 is a real output — the connectivity hint — so `int written = 0` double-counted it as "nothing changed". It is now `-1` with a separate notion of "any output was readable", so a changed hint reports `arg0` instead of `unchanged`. **Slot contracts (first finding).** `XUserGetId` is slot **11**; slot 12 is `XUserFindUserById`. Both are declared, plus the duplicate-handle (3), local-id (9), find-for-device (40) slots that were missing for the same reason. **Secondary gamertag interface (second finding).** Provider `0xcef4fac0` slot 3 now has its own row, so its buffer and used count are traced rather than reported as unknown. Measured with `X2W_TRACE_API=1` over a 60 s offline run (5,638 calls): ``` out=? 2893 (no declared contract) out=arg0 2601 (connectivity hint, previously misreported as unchanged) out=arg3 84 (gamertag buffer) out=arg1 56 out=unchanged 4 ``` The `unchanged` count collapsing from thousands to four is the width fix working: the constant hint is now compared over its real 16 bytes and correctly reported as written. `startup_stubs` passes; nothing changes unless the switch is set.
Author
Owner

@⁠triggered02 on GitHub · 2026-11-24 08:34 UTC · original

Second review addressed in 9731fae2, including the source-built controls.

Every changed output is reported. The loop no longer stops at the first: it prints changed:0 or changed:3,4.

The three outcomes are now distinguished, which is what the single word was conflating:

text meaning
same every declared output was compared and held the same value
same,partial one was compared and equal while another declared output could not be compared
unreadable no declared output could be compared

Wording about providers. All text about observed bytes now says "same value", never "not written": a provider can write the value that was already there, so identical bytes are not evidence of a skipped write.

Source-built controls. The decision now lives in src/startup_stubs/api_trace.h with the contract table, so it is testable without a title. tests/api_trace_check.cpp (ctest api_trace) covers the four cases you asked for:

index 0 change is reported: ok                       -> changed:0, not "nothing changed"
both changed outputs are listed: ok                  -> changed:3,4
a byte past the width is not this output's change: ok -> one-byte output compared over one byte
a short caller buffer is compared over its capacity: ok
identical bytes are reported as same: ok
one comparable output is partial: ok                 -> same,partial
no comparable output is unreadable: ok
undeclared slot reports unknown: ok                  -> "?" and nothing read

It also asserts the table answers for XUserGetId (11), XUserFindUserById (12), the secondary gamertag interface (0xcef4fac0 slot 3) and the connectivity hint (0x37e56907 slot 15) - the four contracts the previous round added or corrected.

api_trace passes (13 cases) and startup_stubs passes; nothing changes unless X2W_TRACE_API is set.

**@⁠triggered02** on GitHub · 2026-11-24 08:34 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1324#issuecomment-7126299448) Second review addressed in `9731fae2`, including the source-built controls. **Every changed output is reported.** The loop no longer stops at the first: it prints `changed:0` or `changed:3,4`. **The three outcomes are now distinguished**, which is what the single word was conflating: | text | meaning | |---|---| | `same` | every declared output was compared and held the same value | | `same,partial` | one was compared and equal while another declared output could not be compared | | `unreadable` | no declared output could be compared | **Wording about providers.** All text about observed bytes now says "same value", never "not written": a provider can write the value that was already there, so identical bytes are not evidence of a skipped write. **Source-built controls.** The decision now lives in `src/startup_stubs/api_trace.h` with the contract table, so it is testable without a title. `tests/api_trace_check.cpp` (ctest `api_trace`) covers the four cases you asked for: ``` index 0 change is reported: ok -> changed:0, not "nothing changed" both changed outputs are listed: ok -> changed:3,4 a byte past the width is not this output's change: ok -> one-byte output compared over one byte a short caller buffer is compared over its capacity: ok identical bytes are reported as same: ok one comparable output is partial: ok -> same,partial no comparable output is unreadable: ok undeclared slot reports unknown: ok -> "?" and nothing read ``` It also asserts the table answers for `XUserGetId` (11), `XUserFindUserById` (12), the secondary gamertag interface (`0xcef4fac0` slot 3) and the connectivity hint (`0x37e56907` slot 15) - the four contracts the previous round added or corrected. `api_trace` passes (13 cases) and `startup_stubs` passes; nothing changes unless `X2W_TRACE_API` is set.
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 08:08 UTC · original · reviewed

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dce4ce6da0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 08:08 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1324#pullrequestreview-6035688190) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `dce4ce6da0` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback". </details>
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-24 08:14 UTC · original · requested changes

The opt-in trace still takes eight bytes from every output, even when the declared output is a flag, DWORD or a shorter caller buffer. A readable page does not establish the object's size. Please store the actual size/type in the contract, bound the snapshot by the declared buffer capacity, and report every changed output. The current written sentinel also treats index 0 (connectivity) as unchanged. A source-built control should cover index 0, two changed outputs, exact-width and short buffers, and a same-value write (which should remain reported as no observed change). Unknown slots should remain opaque. Please link #1160 in the PR body.

**@⁠R0Y00** on GitHub · 2026-11-24 08:14 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1324#pullrequestreview-6035752339) · **requested changes** The opt-in trace still takes eight bytes from every output, even when the declared output is a flag, DWORD or a shorter caller buffer. A readable page does not establish the object's size. Please store the actual size/type in the contract, bound the snapshot by the declared buffer capacity, and report every changed output. The current `written` sentinel also treats index 0 (connectivity) as unchanged. A source-built control should cover index 0, two changed outputs, exact-width and short buffers, and a same-value write (which should remain reported as no observed change). Unknown slots should remain opaque. Please link #1160 in the PR body.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 08:17 UTC · original · reviewed

Reviewed at commit dce4ce6da0208bf65816bf1fbbbebb7f739d51b0.

Code Review & Findings

  • Bug (written sentinel for arg0): in forward(), int written = 0; is used both as the "no output changed" sentinel and as the index of the changed argument (if (now != before[i] && !written) written = index; and if (written)). For {0x37e56907, 15, 0, no_second}, declared->first is 0 (arg0), so when args[0] changes, written stays 0 and out=unchanged is logged instead of out=arg0. Initializing int written = -1; and checking written < 0 / written >= 0 resolves this.
  • Minor:
    • x2w_local::readable(..., 8) safely avoids probing arbitrary non-pointer arguments, though a 4-byte output sitting in the final 4 bytes of a page will report out=unreadable (safe, just worth noting).
    • For two-output slots (15 and 20), only the first modified output is reported (out=arg3 even if arg4 also changed).
    • No unit test in tests/startup_stub_consumer.cpp exercises X2W_TRACE_API=1 yet.

Verification

Linux:

  • git diff --check origin/main...HEAD: clean
  • python -B tests/docs_links_check.py: passed (16 Markdown files, 286 links)
  • python -B tests/bidi_controls_check.py: passed (1076 files)

Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):

  • Debug (--preset dev): cmake --build --preset dev --target startup_stub_gameinput startup_stub_consumer -- -j 6 (4.95s) + ctest --preset dev -R '^startup_stubs$' --parallel 4 --no-tests=error --output-on-failure: 1/1 passed (0.67s)
  • Release /O2 (--preset release): cmake --build --preset release --target startup_stub_gameinput startup_stub_consumer -- -j 6 (2.94s) + ctest --preset release -R '^startup_stubs$' --parallel 4 --no-tests=error --output-on-failure: 1/1 passed (0.44s)
**@⁠tedin7** on GitHub · 2026-11-24 08:17 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1324#pullrequestreview-6035784318) · **reviewed** Reviewed at commit `dce4ce6da0208bf65816bf1fbbbebb7f739d51b0`. ### Code Review & Findings - **Bug (`written` sentinel for `arg0`)**: in `forward()`, `int written = 0;` is used both as the "no output changed" sentinel and as the index of the changed argument (`if (now != before[i] && !written) written = index;` and `if (written)`). For `{0x37e56907, 15, 0, no_second}`, `declared->first` is `0` (`arg0`), so when `args[0]` changes, `written` stays `0` and `out=unchanged` is logged instead of `out=arg0`. Initializing `int written = -1;` and checking `written < 0` / `written >= 0` resolves this. - **Minor**: - `x2w_local::readable(..., 8)` safely avoids probing arbitrary non-pointer arguments, though a 4-byte output sitting in the final 4 bytes of a page will report `out=unreadable` (safe, just worth noting). - For two-output slots (`15` and `20`), only the first modified output is reported (`out=arg3` even if `arg4` also changed). - No unit test in `tests/startup_stub_consumer.cpp` exercises `X2W_TRACE_API=1` yet. ### Verification **Linux:** - `git diff --check origin/main...HEAD`: clean - `python -B tests/docs_links_check.py`: passed (16 Markdown files, 286 links) - `python -B tests/bidi_controls_check.py`: passed (1076 files) **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):** - **Debug (`--preset dev`)**: `cmake --build --preset dev --target startup_stub_gameinput startup_stub_consumer -- -j 6` (`4.95s`) + `ctest --preset dev -R '^startup_stubs$' --parallel 4 --no-tests=error --output-on-failure`: **1/1 passed** (`0.67s`) - **Release `/O2` (`--preset release`)**: `cmake --build --preset release --target startup_stub_gameinput startup_stub_consumer -- -j 6` (`2.94s`) + `ctest --preset release -R '^startup_stubs$' --parallel 4 --no-tests=error --output-on-failure`: **1/1 passed** (`0.44s`)
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-24 08:30 UTC · original · requested changes

The declared widths and arg0 handling are improved. The revised loop stops after the first changed output and still has no source-built trace control. Please log both changed output indices where applicable, and distinguish “at least one compared and unchanged” from a partial comparison when another declared output was unreadable. Keep the text about observed byte changes precise: a provider can write the same value. Please add the index 0, two-output, exact/short-buffer and same-value controls from the previous review before requesting another pass.

**@⁠R0Y00** on GitHub · 2026-11-24 08:30 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1324#pullrequestreview-6035937953) · **requested changes** The declared widths and arg0 handling are improved. The revised loop stops after the first changed output and still has no source-built trace control. Please log both changed output indices where applicable, and distinguish “at least one compared and unchanged” from a partial comparison when another declared output was unreadable. Keep the text about observed byte changes precise: a provider can write the same value. Please add the index 0, two-output, exact/short-buffer and same-value controls from the previous review before requesting another pass.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-24 08:53 UTC · original · approved these changes

Retested the new trace and startup stand-ins on Windows Release (2/2). The declared width/capacity, arg0, two changes, same-value and partial cases now match the requested scope. The provider result stays unchanged.

**@⁠R0Y00** on GitHub · 2026-11-24 08:53 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1324#pullrequestreview-6036218777) · **approved these changes** Retested the new trace and startup stand-ins on Windows Release (2/2). The declared width/capacity, arg0, two changes, same-value and partial cases now match the requested scope. The provider result stays unchanged.
This discussion has been locked. Commenting is limited to contributors.
No description provided.