make_game: read XvcDataLength as 64-bit (XVD-DATALEN-64) #901

Closed
github-bot wants to merge 1 commit from gh-pr/901/head into gh-pr/901/base
Owner

@⁠morodirule on GitHub · 2026-11-24 15:06 UTC · original
fix/xvd-datalen-64 → main · +8 −2 · 2 files · 1 commits · closed without merging

Claimed in the coordination issue as: XVD-DATALEN-64

Carries abnalstlll-byte's finding: xvd_header() read XvcDataLength (file offset 0x290) with <I, but the field is a 64-bit <Q. Reproduced: a synthetic header with length 0x1_0000_0000 reported kind XVD on main; with <Q it reports XVC.

Change: make_game.py reads <Q; the synthetic xvd_bytes() helper in tests/test_make_game_container.py writes <Q; new test_a_length_above_4gib_stays_an_xvc covers 0x1_0000_0001 and low-32-zero 0x1_0000_0000.

Tests: python -I tests/test_make_game_container.py 16/16 OK; test_make_game_preflight.py OK (1 skipped, pre-existing); check_no_game_data.py PASS. Stdlib only, synthetic bytes. No game files, no GPU, nothing online.

AI-assisted.

**@⁠morodirule** on GitHub · 2026-11-24 15:06 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/901) `fix/xvd-datalen-64` → `main` · +8 −2 · 2 files · 1 commits · closed without merging Claimed in the coordination issue as: XVD-DATALEN-64 Carries abnalstlll-byte's finding: xvd_header() read XvcDataLength (file offset 0x290) with <I, but the field is a 64-bit <Q. Reproduced: a synthetic header with length 0x1_0000_0000 reported kind XVD on main; with <Q it reports XVC. Change: make_game.py reads <Q; the synthetic xvd_bytes() helper in tests/test_make_game_container.py writes <Q; new test_a_length_above_4gib_stays_an_xvc covers 0x1_0000_0001 and low-32-zero 0x1_0000_0000. Tests: python -I tests/test_make_game_container.py 16/16 OK; test_make_game_preflight.py OK (1 skipped, pre-existing); check_no_game_data.py PASS. Stdlib only, synthetic bytes. No game files, no GPU, nothing online. AI-assisted.
xvd_header read the length at file offset 0x290 as 32-bit <I; the field is 8 bytes (<Q), so lengths above 4 GiB truncated and a low-32-zero length misreported XVC as XVD. Synthetic helper now writes <Q plus a >4 GiB regression.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:27:10 +00:00
github-bot closed this pull request 2026-11-26 09:27:10 +00:00
Author
Owner

@⁠kawaii-shakal on GitHub · 2026-11-24 16:13 UTC · original

Independent review of #901 (XVD-DATALEN-64)

Head tested: 7d944bf4f8 (merge base f3e26be7). Environment: Windows 11, native Python 3.13.13, no GPU. Synthetic bytes only.

Commands and results:

  • python -I -B tests/test_make_game_container.py: Ran 16 tests, OK.
  • Same test file with make_game.py from the merge base: the new test_a_length_above_4gib_stays_an_xvc FAILS ('XVD' != 'XVC'), so the test does exercise the change.
  • git merge-tree --write-tree origin/main <head> (origin/main 0af7753c): clean. The branch is based on an older main (f3e26be7).
  • python -I scripts/check_no_game_data.py on the changed files: exit 0. git diff --check: clean.

Findings:

  • make_game.py:430: the premise looks wrong. docs/design.md:15-18 says these offsets are xvdtool's XvdHeader plus 0x200. In xvdtool (LibXboxOne/XVD/XVDStructs.cs), the fields are:

    • XvcDataLength at struct offset 0x90 (file 0x290), declared uint, i.e. 32-bit;
    • uint DynamicHeaderLength at 0x94 (file 0x294);
    • uint BlockSize at 0x98.

    Reading <Q at 0x290 therefore puts DynamicHeaderLength into the high 32 bits of the value.

  • This is a regression. I built a synthetic plain XVD with XvcDataLength = 0 at 0x290 and DynamicHeaderLength = 0x1000 at 0x294. This head reports it as XVC; the merge base reports XVD. The probe:

    b = bytearray(make_game.XVD_HEADER_SIZE); b[0x200:0x208] = make_game.XVD_MAGIC
    struct.pack_into("<I", b, 0x208, 0x41); struct.pack_into("<I", b, 0x284, 1)
    struct.pack_into("<I", b, 0x290, 0); struct.pack_into("<I", b, 0x294, 0x1000)
    make_game.xvd_header(path)["kind"]   # head: 'XVC', base: 'XVD'
    
  • Also checked on a real file: the gameos.xvd of my own 1.0.2.1 package is a plain XVD (msft-xvd at 0x200). Its u32 at 0x290 is 0 and its u32 at 0x294 is non-zero. Read as one u64, it would be classified XVC by this head. Only those two header words were read; nothing from the file is quoted or kept.

  • tests/test_make_game_container.py:31 switches the fixture writer to <Q, so the tests now encode the same assumption as the code. The new test passes because it writes into the bytes of DynamicHeaderLength, not because XvcDataLength is 64-bit.

  • The PR cites no source for the 64-bit claim beyond the carried finding. AGENTS.md asks for the file and offset that a format claim comes from. The body also does not link the claim in issue #14.

Requested changes:

  1. Keep <I at 0x290, or cite a primary source (a newer header layout) showing that XvcDataLength is a u64. In that case, also explain what happens to DynamicHeaderLength at 0x294.
  2. If the read does change, update docs/design.md:18 with the field width and the source.
  3. Add a test that a plain XVD with a non-zero u32 at 0x294 stays XVD. That is the case this change breaks today.
  4. Link the claim comment in issue #14.

Verdict: needs changes.

AI-assisted.

**@⁠kawaii-shakal** on GitHub · 2026-11-24 16:13 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/901#issuecomment-7137330621) Independent review of #901 (XVD-DATALEN-64) Head tested: 7d944bf4f80ea24dc2c6f25580e9f0f6514c63e0 (merge base f3e26be7). Environment: Windows 11, native Python 3.13.13, no GPU. Synthetic bytes only. Commands and results: - `python -I -B tests/test_make_game_container.py`: Ran 16 tests, OK. - Same test file with `make_game.py` from the merge base: the new `test_a_length_above_4gib_stays_an_xvc` FAILS (`'XVD' != 'XVC'`), so the test does exercise the change. - `git merge-tree --write-tree origin/main <head>` (origin/main 0af7753c): clean. The branch is based on an older main (f3e26be7). - `python -I scripts/check_no_game_data.py` on the changed files: exit 0. `git diff --check`: clean. Findings: - make_game.py:430: the premise looks wrong. docs/design.md:15-18 says these offsets are xvdtool's `XvdHeader` plus 0x200. In xvdtool (LibXboxOne/XVD/XVDStructs.cs), the fields are: - `XvcDataLength` at struct offset 0x90 (file 0x290), declared `uint`, i.e. 32-bit; - `uint DynamicHeaderLength` at 0x94 (file 0x294); - `uint BlockSize` at 0x98. Reading `<Q` at 0x290 therefore puts DynamicHeaderLength into the high 32 bits of the value. - This is a regression. I built a synthetic plain XVD with XvcDataLength = 0 at 0x290 and DynamicHeaderLength = 0x1000 at 0x294. This head reports it as `XVC`; the merge base reports `XVD`. The probe: ```python b = bytearray(make_game.XVD_HEADER_SIZE); b[0x200:0x208] = make_game.XVD_MAGIC struct.pack_into("<I", b, 0x208, 0x41); struct.pack_into("<I", b, 0x284, 1) struct.pack_into("<I", b, 0x290, 0); struct.pack_into("<I", b, 0x294, 0x1000) make_game.xvd_header(path)["kind"] # head: 'XVC', base: 'XVD' ``` - Also checked on a real file: the `gameos.xvd` of my own 1.0.2.1 package is a plain XVD (`msft-xvd` at 0x200). Its u32 at 0x290 is 0 and its u32 at 0x294 is non-zero. Read as one u64, it would be classified `XVC` by this head. Only those two header words were read; nothing from the file is quoted or kept. - tests/test_make_game_container.py:31 switches the fixture writer to `<Q`, so the tests now encode the same assumption as the code. The new test passes because it writes into the bytes of DynamicHeaderLength, not because XvcDataLength is 64-bit. - The PR cites no source for the 64-bit claim beyond the carried finding. AGENTS.md asks for the file and offset that a format claim comes from. The body also does not link the claim in issue #14. Requested changes: 1. Keep `<I` at 0x290, or cite a primary source (a newer header layout) showing that XvcDataLength is a u64. In that case, also explain what happens to DynamicHeaderLength at 0x294. 2. If the read does change, update docs/design.md:18 with the field width and the source. 3. Add a test that a plain XVD with a non-zero u32 at 0x294 stays `XVD`. That is the case this change breaks today. 4. Link the claim comment in issue #14. Verdict: needs changes. AI-assisted.
Author
Owner

@⁠ubiquitarianism on GitHub · 2026-11-24 16:17 UTC · original

Closing: docs/design.md:15-18 takes the header layout from xvdtool's XvdHeader, which declares XvcDataLength as a 32-bit field at 0x90 followed by DynamicHeaderLength at 0x94, so reading it as <Q merges the two and a plain XVD with a non-zero DynamicHeaderLength is classified as XVC. This was also rebutted in the coordination issue before the claim.

**@⁠ubiquitarianism** on GitHub · 2026-11-24 16:17 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/901#issuecomment-7137430807) Closing: docs/design.md:15-18 takes the header layout from xvdtool's XvdHeader, which declares XvcDataLength as a 32-bit field at 0x90 followed by DynamicHeaderLength at 0x94, so reading it as <Q merges the two and a plain XVD with a non-zero DynamicHeaderLength is classified as XVC. This was also rebutted in the coordination issue before the claim.
Author
Owner

@⁠morodirule on GitHub · 2026-11-24 16:24 UTC · original

Acknowledged — closing is correct, and I will not reopen this. My claim missed the two rebuttals posted before it (KernelSmoker 14:35Z with the XVD format map + xvdtool XVDStructs.cs offsets, Sangonapou 14:50Z confirming uint XvcDataLength at 0x90 with uint DynamicHeaderLength at 0x94): reading <Q at file offset 0x290 folds DynamicHeaderLength into the high half and can misreport a plain XVD as XVC, the opposite of what my PR description claimed to fix. The passing 16/16 was self-consistent only because I changed the synthetic helper to <Q as well. Main keeps the correct <I read; no further action from me on this ID.

**@⁠morodirule** on GitHub · 2026-11-24 16:24 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/901#issuecomment-7137611829) Acknowledged — closing is correct, and I will not reopen this. My claim missed the two rebuttals posted before it (KernelSmoker 14:35Z with the XVD format map + xvdtool XVDStructs.cs offsets, Sangonapou 14:50Z confirming uint XvcDataLength at 0x90 with uint DynamicHeaderLength at 0x94): reading <Q at file offset 0x290 folds DynamicHeaderLength into the high half and can misreport a plain XVD as XVC, the opposite of what my PR description claimed to fix. The passing 16/16 was self-consistent only because I changed the synthetic helper to <Q as well. Main keeps the correct <I read; no further action from me on this ID.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.