cpu: run a relocated global read/write through the three-way EXE chain #451

Manually merged
github merged 3 commits from gh-pr/451/head into gh-pr/451/base 2026-11-26 21:52:57 +00:00
Owner

@⁠R0Y00 on GitHub · 2026-11-22 04:22 UTC · original
R0Y00:codex/exe-image-data-chain → main · +876 −20 · 10 files · 3 commits · merged 2026-11-22 04:26 UTC

Refs #317. Stacked on #416. The same source-built x64 EXE goes from entry to a fixed-frame caller, then to a bound no-unwind leaf that reads and writes the image's globals, then to a DLL import. A small host binds a live, nonpreferred mapping before calling the generated entry and checks the actual stored 64-bit word before release.

The negative control changes one writable word in the input EXE, keeping the AOT binary fixed. Both selectors change observable branches, DLL arguments, output bytes and exit codes. Native Windows and pe_map use the same source image in each comparison.

Local Windows x64 MSVC, Release:

cmake --build out/rip-release --target cpu_exe_image_lifted cpu_image_data_lifted cpu_bare_calls_lifted cpu_register_probe cpu_calls_lifted cpu_frame_lifted
ctest --test-dir out/rip-release --no-tests=error -R '^(cpu_native_exe_image_chain|cpu_aot_(image_data|stack_frames|direct_calls|bound_callees))$' --output-on-failure

5/5 passed. The four input/state combinations gave 0x60d, 0x57, 0x57, 0x60d across all three runners. Docs include the focused reproduction.

**@⁠R0Y00** on GitHub · 2026-11-22 04:22 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/451) `R0Y00:codex/exe-image-data-chain` → `main` · +876 −20 · 10 files · 3 commits · merged 2026-11-22 04:26 UTC Refs #317. Stacked on #416. The same source-built x64 EXE goes from entry to a fixed-frame caller, then to a bound no-unwind leaf that reads and writes the image's globals, then to a DLL import. A small host binds a live, nonpreferred mapping before calling the generated entry and checks the actual stored 64-bit word before release. The negative control changes one writable word in the input EXE, keeping the AOT binary fixed. Both selectors change observable branches, DLL arguments, output bytes and exit codes. Native Windows and pe_map use the same source image in each comparison. Local Windows x64 MSVC, Release: ```powershell cmake --build out/rip-release --target cpu_exe_image_lifted cpu_image_data_lifted cpu_bare_calls_lifted cpu_register_probe cpu_calls_lifted cpu_frame_lifted ctest --test-dir out/rip-release --no-tests=error -R '^(cpu_native_exe_image_chain|cpu_aot_(image_data|stack_frames|direct_calls|bound_callees))$' --output-on-failure ``` 5/5 passed. The four input/state combinations gave 0x60d, 0x57, 0x57, 0x60d across all three runners. Docs include the focused reproduction.
With --image-data (image_data=True, IMAGE_DATA in cpu_translation), the
jump-table translator turns a RIP-relative memory operand into a load or
store at base + RVA and a RIP-relative LEA into base + RVA, where base is
a live mapping of the input image that the host binds at run time through
lifted_bind_image. Bind checks a hash of the headers and of the read-only
section bytes (DIR64 slots and the IAT excluded) and returns a distinct
status for each refusal. A translated function that addresses image data
raises structured exception 0xE0494D47 at entry while nothing is bound.
Each RVA is checked at translation time against the section's virtual
extent, read access, and write access to a non-executable section. A LEA
that loads a recognised jump-table base stays a guest address. Without the
option the output is unchanged.

cpu_aot_image_data compares the original in one pe_map mapping with the
translation bound to a second mapping after every call: return values
(addresses as RVAs), guarded trace, RBX/RSI and the writable sections.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	CMakeLists.txt
#	docs/experiments.md
#	tools/cpu_switch_aot.py
#	tools/form_coverage.py
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:52:56 +00:00
github manually merged commit ed0a136f67 into gh-pr/451/base 2026-11-26 21:52:57 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.