textures: report verified zlib segments for descriptor pages #276

Merged
Vonsek merged 1 commit from upstream-pr/280 into main 2026-11-21 20:56:00 +00:00
Vonsek commented 2026-11-21 20:27:50 +00:00 (Migrated from github.com)

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


Change

Add --zlib-segment INDEX to the ETPF descriptor CLI. A codec-8 interval can include trailing alignment bytes. The range reader needs the exact length of the compressed stream. The new mode verifies that length for the interval containing a selected descriptor's first page and reports a segment object accepted directly by Segment(**report["segment"]). The additional offsets identify the segment's logical start and the page's position within that segment.

The descriptor lookup and boundary checks are shared with the raw-page mode. This zlib mode reads and decompresses the selected interval in memory, with a 1 MiB limit on each of its stored and decoded lengths. It returns metadata after the stream reaches checked EOF, produces the declared logical size and has only zero bytes after its Adler-32 trailer. Usage.

Verification

Windows 11 x64, Python 3.12.10, 978186b on upstream 7cb3c9b.

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

The prior CLI exited 2 on --zlib-segment 0; the new CLI test and focused CTest failed. The synthetic file has a 512-byte physical interval containing one 37-byte zlib stream that decodes to 8,192 bytes. Using 512 as the stored length failed the strict reader. The new CLI returned a stored length of 37. Passing the reported segment unchanged to PagedResource reproduced all 4,096 bytes of its second page. All fourteen Python checks and the focused CTest passed.

Evidence and follow-up

The original MIT-licensed fixture compresses two distinct page patterns with Python's standard library and appends zero padding. Negative controls cover altered Adler-32, incomplete stream, short or long decoded size, a second zlib member, a nonzero suffix, and a non-zlib codec. A guarded stream fails on reads outside the metadata or the one selected interval. Separate oversized stored and decoded spans must fail before a payload read. The tool emits offsets, byte counts and codec type, and writes no decoded payload.

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 framing, range and byte-budget errors.
  • I updated the experiment documentation.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6533991072 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/280). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T20:27:50Z. --- ## Change Add `--zlib-segment INDEX` to the [ETPF descriptor CLI](https://github.com/R0Y00/Xbox2Windows/pull/275). A codec-8 interval can include trailing alignment bytes. The range reader needs the exact length of the compressed stream. The new mode verifies that length for the interval containing a selected descriptor's first page and reports a `segment` object accepted directly by `Segment(**report["segment"])`. The additional offsets identify the segment's logical start and the page's position within that segment. The descriptor lookup and boundary checks are shared with the raw-page mode. This zlib mode reads and decompresses the selected interval in memory, with a 1 MiB limit on each of its stored and decoded lengths. It returns metadata after the stream reaches checked EOF, produces the declared logical size and has only zero bytes after its Adler-32 trailer. [Usage](https://github.com/Vonsek/Xbox2Windows/blob/978186b/docs/experiments.md#reading-logical-ranges-and-probing-structured-resources). ## Verification Windows 11 x64, Python 3.12.10, `978186b` on upstream `7cb3c9b`. ```powershell python -m venv out/pe-env .\out\pe-env\Scripts\python.exe -m pip install -r requirements-dev.txt . ./tools/dev.ps1 $segmentPython = (Resolve-Path out/pe-env/Scripts/python.exe).Path cmake --fresh --preset dev "-DINTAKE_PYTHON=$segmentPython" & $segmentPython -B tests/resource_ranges_check.py -v ctest --preset dev --no-tests=error -R '^resource_range_controls$' -V ``` The prior CLI exited 2 on `--zlib-segment 0`; the new CLI test and focused CTest failed. The synthetic file has a 512-byte physical interval containing one 37-byte zlib stream that decodes to 8,192 bytes. Using 512 as the stored length failed the strict reader. The new CLI returned a stored length of 37. Passing the reported segment unchanged to `PagedResource` reproduced all 4,096 bytes of its second page. All fourteen Python checks and the focused CTest passed. ## Evidence and follow-up The original MIT-licensed fixture compresses two distinct page patterns with Python's standard library and appends zero padding. Negative controls cover altered Adler-32, incomplete stream, short or long decoded size, a second zlib member, a nonzero suffix, and a non-zlib codec. A guarded stream fails on reads outside the metadata or the one selected interval. Separate oversized stored and decoded spans must fail before a payload read. The tool emits offsets, byte counts and codec type, and writes no decoded payload. 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 framing, range and byte-budget 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:12 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:47:59 +00:00 (Migrated from github.com)

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


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:30:01.482322Z 978186b 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:7068772031 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/280#issuecomment-7068772031). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T20:27:59Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"978186ba5ba79683598d516d6e8724903a86aec0","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:30:01.482322Z">2026-11-21T20:30:01.482322Z</relative-time> | `978186b` | 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!276
No description provided.