Commit Graph

5 Commits

Author SHA1 Message Date
69c18554a0 Merge pull request #616 from hamdog0203/fix/exe-sha-validate
exe_sha: validate 64-hex SHA-256, reject bool size, and fail on unreadable --manifest (EXE-SHA-VALIDATE)
2026-11-28 14:03:39 +01:00
Fin
1d983bcb24 exe_sha: report --expect as the explicit hash source 2026-11-24 16:45:19 -05:00
ce9bf43c5b tools: replace stdout encoding errors in the two remaining tools
Rebased onto main 21625bca8c.
2026-11-24 10:25:00 +00:00
c09daf1f66 exe_sha: validate 64-hex SHA-256, reject bool size, and fail on unreadable --manifest (EXE-SHA-VALIDATE) 2026-11-24 10:59:05 +01:00
49c81019c7 exe_sha: one command that says whether your copy is the file the notes were written against
Contributors run the tools in `tools/` against their own copy of the game, and nothing checks that the copies are the
same file. A truncated or patched image still reports as "Executable found", and every RVA a note quotes is quietly
measured on something else (#8041).

`tools/exe_sha.py` prints the size and SHA-256 of the image it is given and compares them with the numbers the package
manifest records (`expected_exe_size`, `expected_exe_sha256`, both optional, read from the `game/*.json` whose
`expected_exe` names the file), or with `--expect SHA256` when a hash is quoted directly. It exits 1 on a mismatch and
0 when the numbers match or nothing is recorded, checks the size before hashing so a truncated 120 MB copy is reported
without reading it all, and `--print-keys` emits the two manifest lines for the file in hand. `--json` gives a script
the same numbers. `docs/design.md`'s "Day one" list now starts with it.

Measured on the retail Xbox 1.0.2.1 package: 120,181,760 bytes and sha256 e95020b2fa4a721db3df59fdecf75621730ac559d8835252f6c3b658d5a08993, the same pair #7123 records for the build preflight; that PR and this one are
the two halves of #8041.

Tests: `python -I tests/test_exe_sha.py` 11 OK (match, wrong hash, wrong size, manifest without the keys, `--expect`
both ways, a non-hash `--expect`, `--json`, `--print-keys`, a missing file, and the repository's own manifest).
`tests/test_docs_cli_flags.py` and `tests/test_docs_links.py` each have one failure that is already on `main`
(`docs/embedded_shaders.md`'s pass flags, `docs/dev-tools.md`'s `../runtime/README` link); the lists are identical
before and after this change. No game files or game-derived bytes in the diff.

AI-assisted.
2026-11-23 23:17:22 -06:00