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

Merged
triggered02 merged 3 commits from upstream-pr/1324 into main 2026-11-24 08:54:21 +00:00
triggered02 commented 2026-11-24 08:04:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T08:04:37Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6577358573 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1324). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T08:04:37Z. --- 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.
upstream-sync closed this pull request 2026-11-24 09:04:30 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 09:04:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T08:08:53Z.

Review: COMMENTED


💡 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".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6035688190 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1324#pullrequestreview-6035688190). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T08:08:53Z. **Review:** COMMENTED --- <!-- 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>
R0Y00 commented 2026-11-24 09:04:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T08:14:33Z.

Review: CHANGES_REQUESTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6035752339 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1324#pullrequestreview-6035752339). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T08:14:33Z. **Review:** CHANGES_REQUESTED --- 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.
tedin7 commented 2026-11-24 09:04:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T08:17:01Z.

Review: COMMENTED


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)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6035784318 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1324#pullrequestreview-6035784318). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T08:17:01Z. **Review:** COMMENTED --- 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`)
R0Y00 commented 2026-11-24 09:04:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T08:30:15Z.

Review: CHANGES_REQUESTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6035937953 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1324#pullrequestreview-6035937953). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T08:30:15Z. **Review:** CHANGES_REQUESTED --- 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 commented 2026-11-24 09:04:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T08:53:19Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6036218777 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1324#pullrequestreview-6036218777). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T08:53:19Z. **Review:** APPROVED --- 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.
chatgpt-codex-connector[bot commented 2026-11-24 09:04:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T08:04:52Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7125702077 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1324#issuecomment-7125702077). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T08:04:52Z. --- <!-- 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>
triggered02 commented 2026-11-24 09:04:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T08:19:30Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7125995816 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1324#issuecomment-7125995816). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T08:19:30Z. --- 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 commented 2026-11-24 09:04:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T08:34:26Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7126299448 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1324#issuecomment-7126299448). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T08:34:26Z. --- 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.
chatgpt-codex-connector[bot commented 2026-11-24 09:04:48 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T08:08:53Z.

Code review location: src/startup_stubs/runtime_proxy.cpp; line 92

@@ -67,11 +67,63 @@ u64 complete_async(u64 async_block);
 void* storage_object();
 constexpr unsigned long save_provider_data1 = 0x704c3f58;  // hypothesis: the game-save API (first seen: slot 4 with the user handle)
 
+// 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 it wrote. Only declared outputs are
+// read: arguments are not probed as pointers, because a handle or size that happens to look like an
+// address would be read as if it were one. A slot with no declared contract reports "out=?" instead.
+bool trace_api() noexcept
+{
+    static const bool on = x2w_local::env_on("X2W_TRACE_API");
+    return on;
+}
+
+// Declared output arguments, as 0-based argument indices. These follow the answers in user_call and
+// area_call below; anything not listed has no known contract here and is not read back.
+struct DeclaredOut {
+    unsigned long provider;
+    int slot;
+    unsigned char first;   // argument index of the first output
+    unsigned char second;  // second output, or 0xff when the slot has one
+};
+
+constexpr unsigned char no_second = 0xff;
+constexpr DeclaredOut declared_outs[] = {
+    {0x01acd177, 8, 1, no_second},   // user add result: &handle
+    {0x01acd177, 12, 1, no_second},  // user id: &id

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 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4677141097 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1324#discussion_r4677141097). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T08:08:53Z. **Code review location:** `src/startup_stubs/runtime_proxy.cpp`; line 92 ~~~~diff @@ -67,11 +67,63 @@ u64 complete_async(u64 async_block); void* storage_object(); constexpr unsigned long save_provider_data1 = 0x704c3f58; // hypothesis: the game-save API (first seen: slot 4 with the user handle) +// 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 it wrote. Only declared outputs are +// read: arguments are not probed as pointers, because a handle or size that happens to look like an +// address would be read as if it were one. A slot with no declared contract reports "out=?" instead. +bool trace_api() noexcept +{ + static const bool on = x2w_local::env_on("X2W_TRACE_API"); + return on; +} + +// Declared output arguments, as 0-based argument indices. These follow the answers in user_call and +// area_call below; anything not listed has no known contract here and is not read back. +struct DeclaredOut { + unsigned long provider; + int slot; + unsigned char first; // argument index of the first output + unsigned char second; // second output, or 0xff when the slot has one +}; + +constexpr unsigned char no_second = 0xff; +constexpr DeclaredOut declared_outs[] = { + {0x01acd177, 8, 1, no_second}, // user add result: &handle + {0x01acd177, 12, 1, no_second}, // user id: &id ~~~~ --- **<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 -->
chatgpt-codex-connector[bot commented 2026-11-24 09:04:49 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T08:08:53Z.

Code review location: src/startup_stubs/runtime_proxy.cpp; line 95

@@ -67,11 +67,63 @@ u64 complete_async(u64 async_block);
 void* storage_object();
 constexpr unsigned long save_provider_data1 = 0x704c3f58;  // hypothesis: the game-save API (first seen: slot 4 with the user handle)
 
+// 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 it wrote. Only declared outputs are
+// read: arguments are not probed as pointers, because a handle or size that happens to look like an
+// address would be read as if it were one. A slot with no declared contract reports "out=?" instead.
+bool trace_api() noexcept
+{
+    static const bool on = x2w_local::env_on("X2W_TRACE_API");
+    return on;
+}
+
+// Declared output arguments, as 0-based argument indices. These follow the answers in user_call and
+// area_call below; anything not listed has no known contract here and is not read back.
+struct DeclaredOut {
+    unsigned long provider;
+    int slot;
+    unsigned char first;   // argument index of the first output
+    unsigned char second;  // second output, or 0xff when the slot has one
+};
+
+constexpr unsigned char no_second = 0xff;
+constexpr DeclaredOut declared_outs[] = {
+    {0x01acd177, 8, 1, no_second},   // user add result: &handle
+    {0x01acd177, 12, 1, no_second},  // user id: &id
+    {0x01acd177, 13, 1, no_second},  // is guest: &flag
+    {0x01acd177, 14, 1, no_second},  // state: &state
+    {0x01acd177, 15, 3, 4},          // gamertag: buffer, &used

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 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4677141109 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1324#discussion_r4677141109). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T08:08:53Z. **Code review location:** `src/startup_stubs/runtime_proxy.cpp`; line 95 ~~~~diff @@ -67,11 +67,63 @@ u64 complete_async(u64 async_block); void* storage_object(); constexpr unsigned long save_provider_data1 = 0x704c3f58; // hypothesis: the game-save API (first seen: slot 4 with the user handle) +// 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 it wrote. Only declared outputs are +// read: arguments are not probed as pointers, because a handle or size that happens to look like an +// address would be read as if it were one. A slot with no declared contract reports "out=?" instead. +bool trace_api() noexcept +{ + static const bool on = x2w_local::env_on("X2W_TRACE_API"); + return on; +} + +// Declared output arguments, as 0-based argument indices. These follow the answers in user_call and +// area_call below; anything not listed has no known contract here and is not read back. +struct DeclaredOut { + unsigned long provider; + int slot; + unsigned char first; // argument index of the first output + unsigned char second; // second output, or 0xff when the slot has one +}; + +constexpr unsigned char no_second = 0xff; +constexpr DeclaredOut declared_outs[] = { + {0x01acd177, 8, 1, no_second}, // user add result: &handle + {0x01acd177, 12, 1, no_second}, // user id: &id + {0x01acd177, 13, 1, no_second}, // is guest: &flag + {0x01acd177, 14, 1, no_second}, // state: &state + {0x01acd177, 15, 3, 4}, // gamertag: buffer, &used ~~~~ --- **<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 -->
chatgpt-codex-connector[bot commented 2026-11-24 09:04:49 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T08:08:53Z.

Code review location: src/startup_stubs/runtime_proxy.cpp; line 120

@@ -67,11 +67,63 @@ u64 complete_async(u64 async_block);
 void* storage_object();
 constexpr unsigned long save_provider_data1 = 0x704c3f58;  // hypothesis: the game-save API (first seen: slot 4 with the user handle)
 
+// 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 it wrote. Only declared outputs are
+// read: arguments are not probed as pointers, because a handle or size that happens to look like an
+// address would be read as if it were one. A slot with no declared contract reports "out=?" instead.
+bool trace_api() noexcept
+{
+    static const bool on = x2w_local::env_on("X2W_TRACE_API");
+    return on;
+}
+
+// Declared output arguments, as 0-based argument indices. These follow the answers in user_call and
+// area_call below; anything not listed has no known contract here and is not read back.
+struct DeclaredOut {
+    unsigned long provider;
+    int slot;
+    unsigned char first;   // argument index of the first output
+    unsigned char second;  // second output, or 0xff when the slot has one
+};
+
+constexpr unsigned char no_second = 0xff;
+constexpr DeclaredOut declared_outs[] = {
+    {0x01acd177, 8, 1, no_second},   // user add result: &handle
+    {0x01acd177, 12, 1, no_second},  // user id: &id
+    {0x01acd177, 13, 1, no_second},  // is guest: &flag
+    {0x01acd177, 14, 1, no_second},  // state: &state
+    {0x01acd177, 15, 3, 4},          // gamertag: buffer, &used
+    {0x01acd177, 19, 1, no_second},  // age group: &group
+    {0x01acd177, 20, 3, 4},          // privilege: &has, &deny reason
+    {0x37e56907, 15, 0, no_second},  // connectivity hint: &words
+};
+
+const DeclaredOut* declared_out(unsigned long provider, int slot)
+{
+    for (const DeclaredOut& entry : declared_outs)
+        if (entry.provider == provider && entry.slot == slot) return &entry;
+    return nullptr;
+}
+
 template <int N>
 __declspec(noinline) u64 forward(Proxy* self, u64 a, u64 b, u64 c, u64 s0, u64 s1, u64 s2, u64 s3, u64 s4, u64 s5, u64 s6, u64 s7)
 {
     const bool log_it = N >= 3 && InterlockedIncrement(&call_counts[self->provider][N]) <= 6;
     u64 args[11] = {a, b, c, s0, s1, s2, s3, s4, s5, s6, s7};
+    // Declared outputs are snapshotted so the write is seen rather than assumed; nothing else is read.
+    u64 before[2] = {};
+    bool readable_argument[2] = {};
+    const DeclaredOut* declared = trace_api() ? declared_out(provider_ids[self->provider].Data1, N) : nullptr;
+    if (declared) {
+        const int index = declared->first;
+        readable_argument[0] = args[index] && x2w_local::readable(reinterpret_cast<const void*>(args[index]), 8);
+        if (readable_argument[0]) std::memcpy(&before[0], reinterpret_cast<const void*>(args[index]), 8);

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 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4677141118 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1324#discussion_r4677141118). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T08:08:53Z. **Code review location:** `src/startup_stubs/runtime_proxy.cpp`; line 120 ~~~~diff @@ -67,11 +67,63 @@ u64 complete_async(u64 async_block); void* storage_object(); constexpr unsigned long save_provider_data1 = 0x704c3f58; // hypothesis: the game-save API (first seen: slot 4 with the user handle) +// 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 it wrote. Only declared outputs are +// read: arguments are not probed as pointers, because a handle or size that happens to look like an +// address would be read as if it were one. A slot with no declared contract reports "out=?" instead. +bool trace_api() noexcept +{ + static const bool on = x2w_local::env_on("X2W_TRACE_API"); + return on; +} + +// Declared output arguments, as 0-based argument indices. These follow the answers in user_call and +// area_call below; anything not listed has no known contract here and is not read back. +struct DeclaredOut { + unsigned long provider; + int slot; + unsigned char first; // argument index of the first output + unsigned char second; // second output, or 0xff when the slot has one +}; + +constexpr unsigned char no_second = 0xff; +constexpr DeclaredOut declared_outs[] = { + {0x01acd177, 8, 1, no_second}, // user add result: &handle + {0x01acd177, 12, 1, no_second}, // user id: &id + {0x01acd177, 13, 1, no_second}, // is guest: &flag + {0x01acd177, 14, 1, no_second}, // state: &state + {0x01acd177, 15, 3, 4}, // gamertag: buffer, &used + {0x01acd177, 19, 1, no_second}, // age group: &group + {0x01acd177, 20, 3, 4}, // privilege: &has, &deny reason + {0x37e56907, 15, 0, no_second}, // connectivity hint: &words +}; + +const DeclaredOut* declared_out(unsigned long provider, int slot) +{ + for (const DeclaredOut& entry : declared_outs) + if (entry.provider == provider && entry.slot == slot) return &entry; + return nullptr; +} + template <int N> __declspec(noinline) u64 forward(Proxy* self, u64 a, u64 b, u64 c, u64 s0, u64 s1, u64 s2, u64 s3, u64 s4, u64 s5, u64 s6, u64 s7) { const bool log_it = N >= 3 && InterlockedIncrement(&call_counts[self->provider][N]) <= 6; u64 args[11] = {a, b, c, s0, s1, s2, s3, s4, s5, s6, s7}; + // Declared outputs are snapshotted so the write is seen rather than assumed; nothing else is read. + u64 before[2] = {}; + bool readable_argument[2] = {}; + const DeclaredOut* declared = trace_api() ? declared_out(provider_ids[self->provider].Data1, N) : nullptr; + if (declared) { + const int index = declared->first; + readable_argument[0] = args[index] && x2w_local::readable(reinterpret_cast<const void*>(args[index]), 8); + if (readable_argument[0]) std::memcpy(&before[0], reinterpret_cast<const void*>(args[index]), 8); ~~~~ --- **<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 -->
chatgpt-codex-connector[bot commented 2026-11-24 09:04:49 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T08:08:53Z.

Code review location: src/startup_stubs/runtime_proxy.cpp; line 172

@@ -107,6 +159,28 @@ __declspec(noinline) u64 forward(Proxy* self, u64 a, u64 b, u64 c, u64 s0, u64 s
     const bool about_tracked = N >= 3 && (tracked(a) || tracked(b) || tracked(c));
     const u64 raw_result = result;
     if (about_tracked && !handled && fake_user() && (result & 0xffffffffu) == borrowed_failure) result = 0;
+    if (trace_api()) {
+        char out[24] = "?";
+        if (declared) {
+            int written = 0;
+            for (int i = 0; i < 2; ++i) {
+                const int index = i == 0 ? declared->first : declared->second;
+                if (index == no_second || !readable_argument[i]) continue;
+                if (!x2w_local::readable(reinterpret_cast<const void*>(args[index]), 8)) continue;
+                u64 now = 0;
+                std::memcpy(&now, reinterpret_cast<const void*>(args[index]), 8);
+                if (now != before[i] && !written) written = index;

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 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4677141123 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1324#discussion_r4677141123). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T08:08:53Z. **Code review location:** `src/startup_stubs/runtime_proxy.cpp`; line 172 ~~~~diff @@ -107,6 +159,28 @@ __declspec(noinline) u64 forward(Proxy* self, u64 a, u64 b, u64 c, u64 s0, u64 s const bool about_tracked = N >= 3 && (tracked(a) || tracked(b) || tracked(c)); const u64 raw_result = result; if (about_tracked && !handled && fake_user() && (result & 0xffffffffu) == borrowed_failure) result = 0; + if (trace_api()) { + char out[24] = "?"; + if (declared) { + int written = 0; + for (int i = 0; i < 2; ++i) { + const int index = i == 0 ? declared->first : declared->second; + if (index == no_second || !readable_argument[i]) continue; + if (!x2w_local::readable(reinterpret_cast<const void*>(args[index]), 8)) continue; + u64 now = 0; + std::memcpy(&now, reinterpret_cast<const void*>(args[index]), 8); + if (now != before[i] && !written) written = index; ~~~~ --- **<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 -->
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1317
No description provided.