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

Closed
morodirule wants to merge 1 commit from upstream-pr/901 into main
morodirule commented 2026-11-24 15:06:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by morodirule on 2026-11-24T15:06:13Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5474758766 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/901). Originally posted by [morodirule](https://github.com/morodirule) on 2026-11-24T15:06:13Z. --- 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.
kawaii-shakal commented 2026-11-24 16:13:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-24T16:13:59Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7137330621 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/901#issuecomment-7137330621). Originally posted by [kawaii-shakal](https://github.com/kawaii-shakal) on 2026-11-24T16:13:59Z. --- 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.
ubiquitarianism commented 2026-11-24 16:17:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ubiquitarianism on 2026-11-24T16:17:46Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7137430807 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/901#issuecomment-7137430807). Originally posted by [ubiquitarianism](https://github.com/ubiquitarianism) on 2026-11-24T16:17:46Z. --- 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.
morodirule commented 2026-11-24 16:24:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by morodirule on 2026-11-24T16:24:16Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7137611829 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/901#issuecomment-7137611829). Originally posted by [morodirule](https://github.com/morodirule) on 2026-11-24T16:24:16Z. --- 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

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
ProjectLeonida/mandy!901
No description provided.