startup: let X2W_PROBE_PRECHECK=0 turn the probe pre-check off under a debugger #3315

Manually merged
github merged 1 commit from github-bot/gh-3313 into main 2026-11-28 08:50:30 +00:00 AGit
Owner

@⁠lukaslw-lab on GitHub · 2026-11-28 08:09 UTC · original
lukaslw-lab:runtime/probe-precheck-env → main · +30 −10 · 4 files · 1 commits · merged 2026-11-28 08:35 UTC

Change

precheck_enabled() (src/startup_stubs/local_log.h) now reads X2W_PROBE_PRECHECK first: 0 turns the probe
pre-check from #2846 off, any other value turns it on, and only an unset variable falls back to IsDebuggerPresent().
Before, the variable could only turn it on, so title runs, which always start under debug_launch.py, paid a
VirtualQuery before every probe_readable and guarded copy with no way out. Unset behaviour is unchanged. The
docs/startup-runtime.md row says the same. Fixes #3314. Refs #2846.

Verification

Commit cdce92da on main 1f07b2c1, Windows 10 22H2 (build 19045), Visual Studio 2026 18.12 (MSVC 19.52), Windows
SDK 10.0.26100, CMake 4.3.1, Python 3.13.7.

ctest --preset dev --no-tests=error -j 1 -R '^(startup_local_log.*|startup_acphal_xma.*)$'
100% tests passed, 0 tests failed out of 8
ctest --preset release --no-tests=error -j 1 -R '^(startup_local_log.*|startup_acphal_xma.*)$'
100% tests passed, 0 tests failed out of 8

Startup run of the main executable (local, same host, RTX 3080 Ti, NVIDIA 32.0.16.1047): main fd7ce57a with this
change and X2W_PROBE_PRECHECK=0 gave 11.2 fps between 140 and 190 s, against 1.2 at #2846 and 14.5 at its parent
(numbers and bisect in #3314).

Evidence and follow-up

  • New startup_local_log_precheck_off_debugger (source-built, MIT): sets the PEB's BeingDebugged byte, which is what
    IsDebuggerPresent reads, then with X2W_PROBE_PRECHECK=0 requires a free range to be refused by the touch, with
    one first-chance fault and nothing counted in faults_avoided. No real debugger is attached, so the fault reaches
    the test's vectored handler.
  • Negative control: with the old condition the new test fails (no refusal is counted as an avoided fault,
    the free range is found by the touch, one first-chance fault each; 2 of 5), while the existing
    startup_local_log_precheck_off still passes.
  • Not changed: the default under a debugger. Turning it off there by default would also make sense for title runs.

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: prepared with Claude Code; the commands and results above were run on the author's PC.

🤖 Generated with Claude Code

**@⁠lukaslw-lab** on GitHub · 2026-11-28 08:09 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3313) `lukaslw-lab:runtime/probe-precheck-env` → `main` · +30 −10 · 4 files · 1 commits · merged 2026-11-28 08:35 UTC ## Change `precheck_enabled()` (`src/startup_stubs/local_log.h`) now reads `X2W_PROBE_PRECHECK` first: `0` turns the probe pre-check from #2846 off, any other value turns it on, and only an unset variable falls back to `IsDebuggerPresent()`. Before, the variable could only turn it on, so title runs, which always start under `debug_launch.py`, paid a `VirtualQuery` before every `probe_readable` and guarded copy with no way out. Unset behaviour is unchanged. The `docs/startup-runtime.md` row says the same. Fixes #3314. Refs #2846. ## Verification Commit `cdce92da` on `main` `1f07b2c1`, Windows 10 22H2 (build 19045), Visual Studio 2026 18.12 (MSVC 19.52), Windows SDK 10.0.26100, CMake 4.3.1, Python 3.13.7. ctest --preset dev --no-tests=error -j 1 -R '^(startup_local_log.*|startup_acphal_xma.*)$' 100% tests passed, 0 tests failed out of 8 ctest --preset release --no-tests=error -j 1 -R '^(startup_local_log.*|startup_acphal_xma.*)$' 100% tests passed, 0 tests failed out of 8 Startup run of the main executable (local, same host, RTX 3080 Ti, NVIDIA 32.0.16.1047): `main` `fd7ce57a` with this change and `X2W_PROBE_PRECHECK=0` gave 11.2 fps between 140 and 190 s, against 1.2 at #2846 and 14.5 at its parent (numbers and bisect in #3314). ## Evidence and follow-up - New `startup_local_log_precheck_off_debugger` (source-built, MIT): sets the PEB's `BeingDebugged` byte, which is what `IsDebuggerPresent` reads, then with `X2W_PROBE_PRECHECK=0` requires a free range to be refused by the touch, with one first-chance fault and nothing counted in `faults_avoided`. No real debugger is attached, so the fault reaches the test's vectored handler. - Negative control: with the old condition the new test fails (`no refusal is counted as an avoided fault`, `the free range is found by the touch, one first-chance fault each`; 2 of 5), while the existing `startup_local_log_precheck_off` still passes. - Not changed: the default under a debugger. Turning it off there by default would also make sense for title runs. ## 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: prepared with Claude Code; the commands and results above were run on the author's PC._ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
precheck_enabled() returned IsDebuggerPresent() || <X2W_PROBE_PRECHECK set and
not 0>, so the variable could only turn the pre-check on. Title runs always
start under debug_launch.py, where the VirtualQuery before each probe and
guarded copy now runs on every call. An explicit setting now decides (0 off,
anything else on); unset keeps the debugger check.

startup_local_log_precheck_off_debugger sets the PEB's BeingDebugged byte and
checks with X2W_PROBE_PRECHECK=0 that a free range is refused by the touch,
with one first-chance fault and nothing counted as avoided. With the old
condition it fails on both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 08:21:11 +00:00
github manually merged commit 3f78071657 into main 2026-11-28 08:50:30 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.