pe: support width-checked HIGHLOW base relocations #601
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/607"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Joacoorandom on 2026-11-22T15:34:44Z.
Change
The PE mapper rejects IMAGE_REL_BASED_HIGHLOW entries even when Windows accepts them in a source-built AMD64 DLL. Support their four-byte, modulo-2^32 adjustment alongside existing eight-byte DIR64 relocations.
Validate each relocation using its actual width, preserve adjacent bytes, and use memcpy for unaligned fields. Header targets, relocation-directory overlaps, truncated fields and unsupported types remain rejected. Import and delay-import write checks keep their eight-byte default.
This is an independent change to tools/pe_map.cpp; no other PR is required.
Verification
Commit:
8f4e6a3088.Windows 11 build 26300.9974, MSVC 19.44.35230, Python 3.12.8. Built the mapper and existing fixture dependencies in Debug and Release (/O2), then ran:
Both configurations: 4/4 tests passed. The new test covers seven Windows/mapper comparisons and five rejection controls, including carry, unaligned fields, mixed DIR64/HIGHLOW entries and end-of-image boundaries. Values are checked against independently calculated relocation results, with neighboring-byte checks.
Repository checks on Linux:
Passed: 10 Markdown files / 123 links; 558 tracked files checked for bidi controls; Python compilation and staged whitespace checks. The full test suite was not run.
Evidence and follow-up
The new fixture derives from the repository's MIT-licensed, source-built reloc_route.asm DLL. It changes relocation metadata and controlled data fields; Windows loads it with DONT_RESOLVE_DLL_REFERENCES, and the test does not execute the patched guest body. No external binary or implementation was copied.
Semantics reference: Microsoft PE base relocation types.
The experiment documentation records the scope, rejection controls and reproduction commands; README adds the focused test entry. This verifies mapper behavior on public fixtures and does not establish title startup.
Checklist
AI-assisted implementation, documentation and test development.
Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-22T17:12:34Z.
Verification of
8f4e6a3on Windows 11 build 26100.9168 (x64, Intel Skylake), MSVC 19.52.37029,devpreset (Debug). It merges cleanly withmain(git merge-tree).The Windows-side comparisons therefore also hold on 26100, alongside your 26300.9974 run.
I also checked that the fixture detects the four ways this change could go wrong. For each mutation I changed one detail in
tools/pe_map.cpp, rebuiltpe_mapand rancpu_native_highlow. Afterwards I restored the file, verified its hash, and confirmed the test passed again.tools/pe_map.cppcpu_native_highlowwidth(always 8)AI-assisted: run and summarized with Claude Code; outputs copied from the local runs.