textures: report verified zlib segments for descriptor pages #280

Manually merged
github merged 1 commit from gh-pr/280/head into gh-pr/280/base 2026-11-26 21:39:47 +00:00
Owner

@⁠Vonsek on GitHub · 2026-11-21 20:27 UTC · original
Vonsek:codex/texture-zlib-segment → main · +147 −14 · 3 files · 1 commits · merged 2026-11-21 20:56 UTC

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.
**@⁠Vonsek** on GitHub · 2026-11-21 20:27 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/280) `Vonsek:codex/texture-zlib-segment` → `main` · +147 −14 · 3 files · 1 commits · merged 2026-11-21 20:56 UTC ## Change Add `--zlib-segment INDEX` to the [ETPF descriptor CLI](https://git.gtahub.st/github/R0Y00--Xbox2Windows/pulls/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.
The stored interval can include alignment padding that the range reader correctly rejects. Validate the selected zlib stream and return its exact compressed length together with the page position inside the decoded segment.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:39:45 +00:00
github manually merged commit 978186ba5b into gh-pr/280/base 2026-11-26 21:39:47 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-21 20:27 UTC · original · edited 2026-11-21 20:30 UTC

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.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-21 20:27 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/280#issuecomment-7068772031) · edited 2026-11-21 20:30 UTC <!-- 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>
This discussion has been locked. Commenting is limited to contributors.
No description provided.