tooling: validate relocated resource roots against their schemas #311

Merged
Vonsek merged 2 commits from upstream-pr/316 into main 2026-11-22 02:36:20 +00:00
Vonsek commented 2026-11-21 21:51:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T21:51:33Z.


Change

The same little-endian PRD0 v0x7a header marker occurs in archived resources from different subsystems. This command identifies the numeric root type and its verified byte size within one explicitly sized zlib member. It checks the root's one-based index, both relocated directory spans, the root span and its independent schema row. The CLI reports only the hash and byte count.

The new experiment describes the observed profile. #186 checks matching sizes in the section-based script tree walker. That walker uses separately serialized instance/schema sections and a five-array 80-byte root. This reader uses relocated virtual addresses and the directory of the supplied member. It shares the existing bounded zlib reader.

Verification

Commit 03d3211930cb5d2d3322c776bb4e9c93d463801e, base b53bfb0b6489398aba7a81f3761e2d56aaa00ccf, Windows x64, Python 3.12.

  • python -B tests/resource_root_check.py RootChecks.test_member_cli: before the reader existed the normal command returned exit 2 and the test failed. On this commit the fixture reports the expected root hash and byte size.
  • In a fresh worktree, python -m venv out/pe-env, out/pe-env/Scripts/python.exe -m pip install -r requirements-dev.txt, . ./tools/dev.ps1 and cmake --preset dev succeeded. ctest --preset dev --no-tests=error -R '^(resource_relocated_root|resource_range_controls|script_state_literals|docs_links)$' --output-on-failure passed all four tests.
  • git diff --check HEAD^ HEAD passed.

Evidence and follow-up

The original MIT-licensed fixture stores two distinct types in opposite schema/block orders. Selecting indices 1 and 2 reports different roots. Controls reject mismatched sizes, an ambiguous root schema, metadata aliasing, out-of-member pointers, incorrect stored length, and an over-budget member before a read.

For local verification, three nonoverlapping 8 MiB windows per archive (start, middle and end) were searched at 16-byte alignment. The survey allowed up to 512 KiB of stored bytes and 2 MiB of decoded bytes per candidate and required checksum-verified EOF. Of 616 marked animation-archive members, 556 contained the full required extents and shared a 352-byte root type. Two controls from the same package yielded 189 of 211 navigation members with a different 304-byte root, and 43 of 63 pack members with a third, 192-byte root. These observations establish directory and schema relationships for the measured profile. Animation class names, clip counts and playback were not established. All local assets stayed out of the repository.

The reader was independently implemented from the measured header fields and the public metadata row layouts and one-based root lookup. CodeWalker documents an older header version. The version-specific reference checks the marker and pointer offsets. Neither source was copied.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

This contribution was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6534850693 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/316). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T21:51:33Z. --- ## Change The same little-endian PRD0 v0x7a header marker occurs in archived resources from different subsystems. This command identifies the numeric root type and its verified byte size within one explicitly sized zlib member. It checks the root's one-based index, both relocated directory spans, the root span and its independent schema row. The CLI reports only the hash and byte count. The [new experiment](https://github.com/Vonsek/Xbox2Windows/blob/03d3211930cb5d2d3322c776bb4e9c93d463801e/docs/experiments.md#relocated-resource-root) describes the observed profile. #186 checks matching sizes in the section-based script tree walker. That walker uses separately serialized instance/schema sections and a five-array 80-byte root. This reader uses relocated virtual addresses and the directory of the supplied member. It shares the existing bounded zlib reader. ## Verification Commit `03d3211930cb5d2d3322c776bb4e9c93d463801e`, base `b53bfb0b6489398aba7a81f3761e2d56aaa00ccf`, Windows x64, Python 3.12. - `python -B tests/resource_root_check.py RootChecks.test_member_cli`: before the reader existed the normal command returned exit 2 and the test failed. On this commit the fixture reports the expected root hash and byte size. - In a fresh worktree, `python -m venv out/pe-env`, `out/pe-env/Scripts/python.exe -m pip install -r requirements-dev.txt`, `. ./tools/dev.ps1` and `cmake --preset dev` succeeded. `ctest --preset dev --no-tests=error -R '^(resource_relocated_root|resource_range_controls|script_state_literals|docs_links)$' --output-on-failure` passed all four tests. - `git diff --check HEAD^ HEAD` passed. ## Evidence and follow-up The original MIT-licensed fixture stores two distinct types in opposite schema/block orders. Selecting indices 1 and 2 reports different roots. Controls reject mismatched sizes, an ambiguous root schema, metadata aliasing, out-of-member pointers, incorrect stored length, and an over-budget member before a read. For local verification, three nonoverlapping 8 MiB windows per archive (start, middle and end) were searched at 16-byte alignment. The survey allowed up to 512 KiB of stored bytes and 2 MiB of decoded bytes per candidate and required checksum-verified EOF. Of 616 marked animation-archive members, 556 contained the full required extents and shared a 352-byte root type. Two controls from the same package yielded 189 of 211 navigation members with a different 304-byte root, and 43 of 63 pack members with a third, 192-byte root. These observations establish directory and schema relationships for the measured profile. Animation class names, clip counts and playback were not established. All local assets stayed out of the repository. The reader was independently implemented from the measured header fields and the public [metadata row layouts and one-based root lookup](https://github.com/dexyfex/CodeWalker/blob/485d56bec00262ed7fa472261cce7bbc6202b96e/CodeWalker.Core/GameFiles/MetaTypes/Meta.cs#L208-L264). CodeWalker documents an older header version. The [version-specific reference](https://github.com/rpatty-dev/PercyStar/blob/1b710c5349ef1911d94092f19173e9813dfb300c/src/anim.rs#L180-L219) checks the marker and pointer offsets. Neither source was copied. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. This contribution was AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:42:23 +00:00
R0Y00 commented 2026-11-24 06:48:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T21:58:58Z.


At 03d3211 the merge conflicts are in README.md. Retain the schema-validation documentation alongside #298's descriptor lookup.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7069855578 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/316#issuecomment-7069855578). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T21:58:58Z. --- At `03d3211` the merge conflicts are in `README.md`. Retain the schema-validation documentation alongside #298's descriptor lookup.
Vonsek commented 2026-11-24 06:48:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T22:04:36Z.


The README at 61ae89e keeps the relocated-root schema experiment and the texture descriptor-key lookup from #298, including its resource_range_controls selector. The four selected CTest cases passed locally, and all three CI jobs passed on this commit.

@codex review

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7069922426 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/316#issuecomment-7069922426). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T22:04:36Z. --- The README at `61ae89e` keeps the relocated-root schema experiment and the texture descriptor-key lookup from #298, including its `resource_range_controls` selector. The four selected CTest cases passed locally, and all three [CI jobs](https://github.com/R0Y00/Xbox2Windows/actions/runs/44954474272) passed on this commit. @codex review
chatgpt-codex-connector[bot commented 2026-11-24 06:48:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T22:07:08Z.


Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 61ae89e953

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7069951889 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/316#issuecomment-7069951889). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T22:07:08Z. --- <!-- codex-review-receipt:v1 --> Codex Review: Didn't find any major issues. More of your lovely PRs please. **Reviewed commit:** `61ae89e953` <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". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
chatgpt-codex-connector[bot commented 2026-11-24 06:48:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T21:51:44Z.


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-21T22:07:09.817692Z 61ae89e Manual request
ℹ️ 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:7069771652 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/316#issuecomment-7069771652). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T21:51:44Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"61ae89e953b965b1758944a4af0c48d14b4b7173","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-21T22:07:09.817692Z">2026-11-21T22:07:09.817692Z</relative-time> | `61ae89e` | Manual request | <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!311
No description provided.