startup: check the overlay window choice between two guests #1537

Manually merged
github merged 1 commit from gh-pr/1537/head into gh-pr/1537/base 2026-11-26 23:15:03 +00:00
Owner

@⁠Asimmimx on GitHub · 2026-11-24 13:45 UTC · original
Asimmimx:tests/overlay-window-check → main · +15 −2 · 2 files · 1 commits · merged 2026-11-24 16:11 UTC

Change

Refs #1149. This extends startup_overlay_window, the check for src/startup_stubs/overlay_window.h. overlay_window() picks the guest window that the fallback overlay (draw_overlay() in d3d12_xs_device.cpp) draws into. It enumerates top-level windows in z-order and stops at the first visible, unowned window of this process that is not the presenter.

The existing check creates only one guest window. So a mutant that keeps enumerating instead of stopping at the first match (return FALSE changed to return TRUE), and therefore picks the lowest guest, left it passing.

The new steps create a second guest window and use SetWindowPos(HWND_TOP) to make the z-order explicit. They raise the first guest and expect it to be chosen (exit 6 otherwise), then raise the second and expect that one (exit 7 otherwise). The second guest is destroyed before the existing teardown.

The change touches only tests/startup_overlay_window.cpp and two sentences in the "Output window and fallback diagnostics" section of docs/startup-runtime.md. There is no new CTest, and nothing changes in src/.

Verification

Commit 309cfede (main) plus this change, dev preset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0.

ctest --preset dev --no-tests=error -R '^startup_overlay_window$' -V
#   Passed, 3 of 3 runs with the new steps and again after the mutation sweep

tests/docs_links_check.py, tests/bidi_controls_check.py and git diff --check passed.

Mutation probe

I applied each mutation to the header alone, rebuilt, ran the test, then reverted. None of this is committed.

Mutant Before After
control: never store the candidate killed (exit 3) killed
drop !IsWindowVisible killed killed
drop the GW_OWNER check killed killed
drop the same-process check killed* killed*
presenter comparison == 0 → != 0 killed killed
return FALSE → return TRUE (lowest guest wins) survived killed (exit 6)
class-name buffer 256 → 8 killed killed
GW_OWNER → GW_CHILD killed killed
drop the !GetClassNameW failure check killed killed

* The same-process mutant is killed only because the desktop has visible, unowned windows of other processes. In a session without any, it would survive. Pinning it would need a helper child process that owns a window, which I left out of this change.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

**@⁠Asimmimx** on GitHub · 2026-11-24 13:45 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1537) `Asimmimx:tests/overlay-window-check` → `main` · +15 −2 · 2 files · 1 commits · merged 2026-11-24 16:11 UTC ## Change Refs #1149. This extends `startup_overlay_window`, the check for `src/startup_stubs/overlay_window.h`. `overlay_window()` picks the guest window that the fallback overlay (`draw_overlay()` in `d3d12_xs_device.cpp`) draws into. It enumerates top-level windows in z-order and stops at the first visible, unowned window of this process that is not the presenter. The existing check creates only one guest window. So a mutant that keeps enumerating instead of stopping at the first match (`return FALSE` changed to `return TRUE`), and therefore picks the lowest guest, left it passing. The new steps create a second guest window and use `SetWindowPos(HWND_TOP)` to make the z-order explicit. They raise the first guest and expect it to be chosen (exit 6 otherwise), then raise the second and expect that one (exit 7 otherwise). The second guest is destroyed before the existing teardown. The change touches only `tests/startup_overlay_window.cpp` and two sentences in the "Output window and fallback diagnostics" section of `docs/startup-runtime.md`. There is no new CTest, and nothing changes in `src/`. ## Verification Commit `309cfede` (`main`) plus this change, `dev` preset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0. ```powershell ctest --preset dev --no-tests=error -R '^startup_overlay_window$' -V # Passed, 3 of 3 runs with the new steps and again after the mutation sweep ``` `tests/docs_links_check.py`, `tests/bidi_controls_check.py` and `git diff --check` passed. ## Mutation probe I applied each mutation to the header alone, rebuilt, ran the test, then reverted. None of this is committed. | Mutant | Before | After | |---|---|---| | control: never store the candidate | killed (exit 3) | killed | | drop `!IsWindowVisible` | killed | killed | | drop the `GW_OWNER` check | killed | killed | | drop the same-process check | killed* | killed* | | presenter comparison `== 0` → `!= 0` | killed | killed | | `return FALSE` → `return TRUE` (lowest guest wins) | **survived** | killed (exit 6) | | class-name buffer 256 → 8 | killed | killed | | `GW_OWNER` → `GW_CHILD` | killed | killed | | drop the `!GetClassNameW` failure check | killed | killed | \* The same-process mutant is killed only because the desktop has visible, unowned windows of other processes. In a session without any, it would survive. Pinning it would need a helper child process that owns a window, which I left out of this change. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code).
src/startup_stubs/overlay_window.h picks the GDI fallback target by
enumerating top-level windows and stopping at the first visible, unowned
window of the process that is not the presenter, so the upper guest in
z-order is drawn into. startup_overlay_window created only one guest
window, so a single-point mutant that keeps enumerating (return TRUE
instead of FALSE) and selects the lowest guest left it passing.

The test now creates a second guest, raises the first guest and expects
it, then raises the second and expects that one. The mutant now fails
with exit code 6. Eight further mutants (no selection, dropping the
visibility, owner, process or class-name-failure check, the inverted
presenter comparison, an 8-character class buffer and GW_CHILD in place
of GW_OWNER) were already caught.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:15:02 +00:00
github manually merged commit d4f7a3ff11 into gh-pr/1537/base 2026-11-26 23:15:03 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.