textures: inventory bounded ETPF descriptor tables #262

Merged
Vonsek merged 1 commit from upstream-pr/266 into main 2026-11-21 19:58:37 +00:00
Vonsek commented 2026-11-21 19:47:24 +00:00 (Migrated from github.com)

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


Change

Add a read-only inventory of texture dimensions, DXGI format numbers and mip-marker bytes from the first raw ETPF table in an RDS5 archive. This gives an independent source for the explicit base dimensions used by the late BC7 tail check. The marker is recorded as its original byte. Establishing which mip is resident at runtime requires separate evidence.

The existing range reader reads the initial and terminal boundaries, checks the descriptor table against both the stored and logical extent of its chunk, and verifies each descriptor's 4 KiB page address against the declared virtual size. The CLI groups matching descriptors and prints JSON. This inventory profile accepts at most 1 MiB of descriptor records per archive (65,536 entries). Command and field layout.

Verification

Windows 11 x64, Python 3.12.10, commit dad7776 on upstream 7233cec.

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

Before implementation the CLI test exited 2 because the tool was absent, and the bounds test could not import the reader. An intermediate exact-EOF check rejected valid declared ranges when the test appended 256 unrelated trailing bytes. With the patch, all eight Python tests passed and CTest passed in 0.22 seconds. The synthetic CLI run reported 258 descriptors grouped as 257 with a 44×12 extent, DXGI 99 and marker 2, and one with a 12×44 extent, DXGI 71 and marker 0.

Evidence and follow-up

The fixtures are original MIT-licensed Python constructions. They include distinct reserved and codec bits, a table spanning a 4 KiB read boundary, an individually invalid last descriptor, a truncated file, inconsistent physical and virtual extents, and a declared table over the 1 MiB limit. The guarded input rejects reads outside the outer header, counted boundary, and descriptor table, or any read longer than 4 KiB.

The independently written reader uses the descriptor fields documented by PercyStar. It adds no external code or dependency. It validates the ranges needed by the inventory and leaves later chunk contents unread.

AI-assisted contribution.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the commands and results for the public fixture checks.
  • I included negative controls for range, budget and descriptor validation.
  • I updated the experiment documentation.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6533587515 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/266). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T19:47:24Z. --- ## Change Add a read-only inventory of texture dimensions, DXGI format numbers and mip-marker bytes from the first raw ETPF table in an RDS5 archive. This gives an independent source for the explicit base dimensions used by the [late BC7 tail check](https://github.com/R0Y00/Xbox2Windows/pull/248). The marker is recorded as its original byte. Establishing which mip is resident at runtime requires separate evidence. The existing range reader reads the initial and terminal boundaries, checks the descriptor table against both the stored and logical extent of its chunk, and verifies each descriptor's 4 KiB page address against the declared virtual size. The CLI groups matching descriptors and prints JSON. This inventory profile accepts at most 1 MiB of descriptor records per archive (65,536 entries). [Command and field layout](https://github.com/Vonsek/Xbox2Windows/blob/dad7776/docs/experiments.md#reading-logical-ranges-and-probing-structured-resources). ## Verification Windows 11 x64, Python 3.12.10, commit `dad7776` on upstream `7233cec`. ```powershell python -m venv out/pe-env .\out\pe-env\Scripts\python.exe -m pip install -r requirements-dev.txt . ./tools/dev.ps1 $descriptorPython = (Resolve-Path out/pe-env/Scripts/python.exe).Path cmake --preset dev "-DINTAKE_PYTHON=$descriptorPython" & $descriptorPython -B tests/resource_ranges_check.py -v ctest --preset dev --no-tests=error -R '^resource_range_controls$' -V ``` Before implementation the CLI test exited 2 because the tool was absent, and the bounds test could not import the reader. An intermediate exact-EOF check rejected valid declared ranges when the test appended 256 unrelated trailing bytes. With the patch, all eight Python tests passed and CTest passed in 0.22 seconds. The synthetic CLI run reported 258 descriptors grouped as 257 with a 44×12 extent, DXGI 99 and marker 2, and one with a 12×44 extent, DXGI 71 and marker 0. ## Evidence and follow-up The fixtures are original MIT-licensed Python constructions. They include distinct reserved and codec bits, a table spanning a 4 KiB read boundary, an individually invalid last descriptor, a truncated file, inconsistent physical and virtual extents, and a declared table over the 1 MiB limit. The guarded input rejects reads outside the outer header, counted boundary, and descriptor table, or any read longer than 4 KiB. The independently written reader uses the [descriptor fields documented by PercyStar](https://github.com/rpatty-dev/PercyStar/blob/1b710c5349ef1911d94092f19173e9813dfb300c/src/tex.rs#L748-L785). It adds no external code or dependency. It validates the ranges needed by the inventory and leaves later chunk contents unread. AI-assisted contribution. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the commands and results for the public fixture checks. - [x] I included negative controls for range, budget and descriptor validation. - [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:07 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:47:56 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T19:47:36Z.


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-21T19:50:29.249506Z dad7776 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:7068281649 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/266#issuecomment-7068281649). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T19:47:36Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"dad7776ee3a508e98fcf75b86f65155c0aa988ad","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-21T19:50:29.249506Z">2026-11-21T19:50:29.249506Z</relative-time> | `dad7776` | 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!262
No description provided.