tooling: validate relocated resource root block-map pointer #448
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/454"
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 agilesh08 on 2026-11-22T04:32:03Z.
## Change
In
tools/resource_root.py,inspect_root()checked the bounds ofblock_mapviaspan(block_map, 1)but omitted the resulting 1-byte span fromextents = sorted((schemas, blocks, root)). Consequently, a malformed PRD0 v0x7a resource where the block-map pointer aliased the schema table, the block directory, or the root instance passed validation undetected.Because the full payload length of the block map is not explicitly defined in this profile, this change implements the narrower validation of the block-map pointer against the known table and root extents:
block_map_ptr = span(block_map, 1)and includes it inextents = sorted((block_map_ptr, schemas, blocks, root))to validate that the block-map pointer does not fall within the schema directory, block directory, or root instance."Overlapping schema, block directory, block map pointer or root instance".tests/resource_root_check.pyfor block map header violations, out-of-bounds RVAs, buffer overruns, and pointer aliasing against schemas, block directory, and root instance.test_block_map_boundaries()verifying valid boundary placements of the block-map pointer immediately adjacent to each table and at the buffer boundary.docs/experiments.mdto note that the root and both directories must fit in disjoint spans and the block-map pointer must not fall within any of these extents.Verification
Run on Windows x64 with Python 3.14 (
D:\Xbox2Windows\.venv\Scripts\python.exe):Output:
Full platform-independent suite (20 checks including
docs_links_check.pyandbidi_controls_check.py):Result: All 20 checks passed (exit code 0).
Evidence and follow-up
The test uses 100% synthetic in-memory fixtures generated via Python
struct.pack_into()without external files or proprietary assets.This change is AI-assisted.
Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T04:37:04Z.
The implemented check reserves exactly one byte at block_map. A map starting one byte before the root passes even if its data continues into the root, and the new adjacency test accepts that layout. Please describe this as checking the block-map pointer against the known table/root extents, including in docs/experiments.md. If the map length is known for this profile, validate that length and add a crossing-boundary control instead. The current tests support the narrower pointer check.
Imported from R0Y00/Xbox2Windows. Originally posted by agilesh08 on 2026-11-22T04:57:25Z.
@R0Y00 Thanks for the review!
The exact byte length of the PRD0 v0x7a block map payload is not documented or specified for this profile in
docs/experiments.mdortools/resource_root.py. As you noted, the check reserves a 1-byte span (span(block_map, 1)), which validates that the pointer does not fall within the known table/root extents rather than bounding the full extent of the map.I have updated the PR to accurately describe this narrower pointer check:
docs/experiments.mdto state: "The root and both directories must fit in disjoint spans, and the block-map pointer must not fall within any of these extents."tools/resource_root.pyto"Overlapping schema, block directory, block map pointer or root instance"and variable naming toblock_map_ptr.test_block_map_boundaries()intests/resource_root_check.py.