textures: honor declared zero padding in raw page maps #286

Merged
Vonsek merged 1 commit from upstream-pr/290 into main 2026-11-21 21:25:51 +00:00
Vonsek commented 2026-11-21 20:57:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T20:57:47Z.


Change

Extend the raw descriptor page map to account for a declared alignment suffix in a raw interval. The 12 high bits of the interval's starting boundary give the trailing-byte count. For unequal lengths the count must equal the excess of stored length over logical length, and every byte in that suffix must be zero. Equal-size ranges retain their original metadata-only mapping. The reader then maps the logical prefix at the stored interval start. The reported offsets and 4 KiB page size are unchanged. Usage and field reference.

Verification

Windows 11 x64, Python 3.12.10, commit a809eb23ae46235c1a64f18124de7f9da19cff5f on upstream d311159b7ba56f4c75c10c1dd8c4303988c80d99.

python -m venv out/pe-env
.\out\pe-env\Scripts\python.exe -m pip install -r requirements-dev.txt
. ./tools/dev.ps1
$paddingPython = (Resolve-Path out/pe-env/Scripts/python.exe).Path
cmake --fresh --preset dev "-DINTAKE_PYTHON=$paddingPython"
& $paddingPython -B tests/resource_ranges_check.py -v
ctest --preset dev --no-tests=error -R '^resource_range_controls$' -V

Before the change both the Python regression and its CTest failed with Raw mapping requires equal stored and logical range sizes. The new control puts a 1,280-byte zero suffix after a two-page raw payload, gives its next boundary a different count, and verifies that the second logical page still maps to file offset 8,704. All fifteen Python tests and the focused CTest passed.

Evidence and follow-up

The input is an original MIT-licensed Python fixture. Its guarded stream permits only metadata and the padding range to be read. It rejects a wrong neighboring count, a truncated count, a nonzero first or last suffix byte, and premature EOF during the suffix read. A short-read guard reproduces the original equal-size mapping even with nonzero high bits and permits no suffix read in that case. The suffix check reads at most 4,095 bytes and does not interpret texture pixels or subresource layout. This change shares the indexed interval lookup integrated by #280.

AI-assisted contribution.

Checklist

  • This pull request covers one reviewable behavior.
  • I included commands and results for the public fixture checks.
  • I included negative controls for size, field ownership and storage errors.
  • I updated the experiment documentation.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6534305490 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/290). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T20:57:47Z. --- ## Change Extend the [raw descriptor page map](https://github.com/R0Y00/Xbox2Windows/pull/275) to account for a declared alignment suffix in a raw interval. The 12 high bits of the interval's starting boundary give the trailing-byte count. For unequal lengths the count must equal the excess of stored length over logical length, and every byte in that suffix must be zero. Equal-size ranges retain their original metadata-only mapping. The reader then maps the logical prefix at the stored interval start. The reported offsets and 4 KiB page size are unchanged. [Usage and field reference](https://github.com/Vonsek/Xbox2Windows/blob/a809eb23ae46235c1a64f18124de7f9da19cff5f/docs/experiments.md#reading-logical-ranges-and-probing-structured-resources). ## Verification Windows 11 x64, Python 3.12.10, commit `a809eb23ae46235c1a64f18124de7f9da19cff5f` on upstream `d311159b7ba56f4c75c10c1dd8c4303988c80d99`. ```powershell python -m venv out/pe-env .\out\pe-env\Scripts\python.exe -m pip install -r requirements-dev.txt . ./tools/dev.ps1 $paddingPython = (Resolve-Path out/pe-env/Scripts/python.exe).Path cmake --fresh --preset dev "-DINTAKE_PYTHON=$paddingPython" & $paddingPython -B tests/resource_ranges_check.py -v ctest --preset dev --no-tests=error -R '^resource_range_controls$' -V ``` Before the change both the Python regression and its CTest failed with `Raw mapping requires equal stored and logical range sizes`. The new control puts a 1,280-byte zero suffix after a two-page raw payload, gives its next boundary a different count, and verifies that the second logical page still maps to file offset 8,704. All fifteen Python tests and the focused CTest passed. ## Evidence and follow-up The input is an original MIT-licensed Python fixture. Its guarded stream permits only metadata and the padding range to be read. It rejects a wrong neighboring count, a truncated count, a nonzero first or last suffix byte, and premature EOF during the suffix read. A short-read guard reproduces the original equal-size mapping even with nonzero high bits and permits no suffix read in that case. The suffix check reads at most 4,095 bytes and does not interpret texture pixels or subresource layout. This change shares the indexed interval lookup integrated by [#280](https://github.com/R0Y00/Xbox2Windows/pull/280). AI-assisted contribution. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included commands and results for the public fixture checks. - [x] I included negative controls for size, field ownership and storage errors. - [x] I updated the experiment documentation. - [x] I did not include game files, dumps, distribution links or secrets.
upstream-sync closed this pull request 2026-11-24 06:42:15 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:48:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T20:57:58Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T20:59:13.566058Z a809eb2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7069136295 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/290#issuecomment-7069136295). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T20:57:58Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"a809eb23ae46235c1a64f18124de7f9da19cff5f","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-21T20:59:13.566058Z">2026-11-21T20:59:13.566058Z</relative-time> | `a809eb2` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!286
No description provided.