OLD-8041, OLD-8404: leonida_mods checks the executable and DLLs by SHA-256 before starting gta6rt #358

Open
github-bot wants to merge 1 commit from github-bot/gh-358 into main AGit
Owner

@⁠ItsMrDubey on GitHub · 2026-11-24 03:53 UTC · original
ItsMrDubey:verify-exe-sha256 → main · +231 −12 · 6 files · 1 commits · open

Claimed in the coordination issue as: OLD-8041, OLD-8404 (#14)

What and why

Old OLD-8041 / OLD-8404 asked for the executable (and its DLLs) to be checked by SHA-256 before the runtime loads them. On main nothing did: make_game.py checks sizes only (hashes only with --full, via manifest.py) and never launches gta6rt; the only Python path that starts it is tools/leonida_mods.py (run and the window's launch buttons, both through runtime_command), which handed <game>/game_scarlett_master.exe and --game-dir to gta6rt unchecked; runtime/src/pe_loader.cpp maps the DLLs from game_dir with no hash check. Also, game/xbox-1.0.2.1.json listed the 16 package DLLs but not the executable.

Now:

  • tools/manifest_verifier.py: new check_files([(path, size, sha256)], cache_path): size first, then the existing streamed sha256_file; the first mismatch raises one line, <file>: size is N bytes, expected M or <file>: SHA-256 is <actual>, expected <expected>. The cache reuses --cache's stamp/file-id rules and file format; the "only cache a stable, not-just-written file" rule moved into _stable_stamp(), shared with verify_manifest.
  • tools/leonida_mods.py: before starting gta6rt (CLI run and GUI launch; not --print), picks the game/xbox-*.json whose MicrosoftGame.Config matches the copy, checks every manifest DLL present in the game folder and the executable, caching passes in <port>/verified_files.json, and refuses with not starting gta6rt: <file>: ... otherwise.
  • game/xbox-1.0.2.1.json: expected_exe_size / expected_exe_sha256, the values already published in docs/runtime_imports.md ("The retail executable (RT-5)"). Top-level keys, not files, so make_game check still accepts a package without the executable. If maintainers would rather not carry them, dropping the two keys leaves the DLL check working and the exe unchecked.

Mods: mods are mod.json archetype swaps read by the runtime; none modifies the executable or DLLs, so mod workflows are unaffected. The existing --image ("a stand-in executable") is the opt-out: an image named there is not checked (DLLs still are), and a game folder that matches no version manifest needs --image to launch. No new flag or env var.

Tested

Windows 11, Python 3.11.9, no GPU needed.

  • python -I tests/test_leonida_mods.py: 15 OK (5 new LaunchCheckTests: synthetic manifest + fake files; matching start + cache hit without rehashing, changed DLL refused with one-line error, changed exe refused by size, --image stand-in skips the exe but not DLLs, unknown version refused, --print reads nothing). Before the fix: 5 errors.
  • python -m pytest tests/test_manifest_verifier.py -k check_files: new test passes; fails on main (no check_files).
  • python -m pytest over every test file that imports either module or reads the version manifest (test_manifest_verifier, test_leonida_mods, test_docs_repo_paths, test_make_game_dry_run/platform/preflight, test_shell_launchers, test_windows_process_priority): 219 passed, 11 skipped, 22 failed; the same 22 fail on origin/main without this change.
  • python -I scripts/check_no_game_data.py on every changed file: clean.

AI-assisted: yes

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • No new translator rule, so nothing to add to the contract table of docs/design.md.
**@⁠ItsMrDubey** on GitHub · 2026-11-24 03:53 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/358) `ItsMrDubey:verify-exe-sha256` → `main` · +231 −12 · 6 files · 1 commits · open Claimed in the coordination issue as: OLD-8041, OLD-8404 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why Old OLD-8041 / OLD-8404 asked for the executable (and its DLLs) to be checked by SHA-256 before the runtime loads them. On main nothing did: `make_game.py` checks sizes only (hashes only with `--full`, via `manifest.py`) and never launches `gta6rt`; the only Python path that starts it is `tools/leonida_mods.py` (`run` and the window's launch buttons, both through `runtime_command`), which handed `<game>/game_scarlett_master.exe` and `--game-dir` to `gta6rt` unchecked; `runtime/src/pe_loader.cpp` maps the DLLs from `game_dir` with no hash check. Also, `game/xbox-1.0.2.1.json` listed the 16 package DLLs but not the executable. Now: - `tools/manifest_verifier.py`: new `check_files([(path, size, sha256)], cache_path)`: size first, then the existing streamed `sha256_file`; the first mismatch raises one line, `<file>: size is N bytes, expected M` or `<file>: SHA-256 is <actual>, expected <expected>`. The cache reuses `--cache`'s stamp/file-id rules and file format; the "only cache a stable, not-just-written file" rule moved into `_stable_stamp()`, shared with `verify_manifest`. - `tools/leonida_mods.py`: before starting `gta6rt` (CLI `run` and GUI launch; not `--print`), picks the `game/xbox-*.json` whose `MicrosoftGame.Config` matches the copy, checks every manifest DLL present in the game folder and the executable, caching passes in `<port>/verified_files.json`, and refuses with `not starting gta6rt: <file>: ...` otherwise. - `game/xbox-1.0.2.1.json`: `expected_exe_size` / `expected_exe_sha256`, the values already published in `docs/runtime_imports.md` ("The retail executable (RT-5)"). Top-level keys, not `files`, so `make_game check` still accepts a package without the executable. If maintainers would rather not carry them, dropping the two keys leaves the DLL check working and the exe unchecked. Mods: mods are `mod.json` archetype swaps read by the runtime; none modifies the executable or DLLs, so mod workflows are unaffected. The existing `--image` ("a stand-in executable") is the opt-out: an image named there is not checked (DLLs still are), and a game folder that matches no version manifest needs `--image` to launch. No new flag or env var. ### Tested Windows 11, Python 3.11.9, no GPU needed. - `python -I tests/test_leonida_mods.py`: 15 OK (5 new `LaunchCheckTests`: synthetic manifest + fake files; matching start + cache hit without rehashing, changed DLL refused with one-line error, changed exe refused by size, `--image` stand-in skips the exe but not DLLs, unknown version refused, `--print` reads nothing). Before the fix: 5 errors. - `python -m pytest tests/test_manifest_verifier.py -k check_files`: new test passes; fails on main (no `check_files`). - `python -m pytest` over every test file that imports either module or reads the version manifest (test_manifest_verifier, test_leonida_mods, test_docs_repo_paths, test_make_game_dry_run/platform/preflight, test_shell_launchers, test_windows_process_priority): 219 passed, 11 skipped, 22 failed; the same 22 fail on origin/main without this change. - `python -I scripts/check_no_game_data.py` on every changed file: clean. AI-assisted: yes ### Checklist - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] No new translator rule, so nothing to add to the contract table of `docs/design.md`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:55:21 +00:00
Author
Owner

@⁠fiestorra on GitHub · 2026-11-24 06:51 UTC · original

Reviewed on this machine (Windows build 26300, CPython 3.13.14, no GPU used), on f35a1c4e2, which is one commit on top of ece4ba5b3. AI-assisted.

The values in game/xbox-1.0.2.1.json match a real 1.0.2.1 package. I have a local copy of that version and checked it against the two new fields and against everything the manifest already declared:

  • game_scarlett_master.exe: 120,181,760 bytes, SHA-256 e95020b2fa4a721db3df59fdecf75621730ac559d8835252f6c3b658d5a08993 — both agree with expected_exe_size and expected_exe_sha256, and with the value docs/runtime_imports.md and docs/embedded_shaders.md already publish.
  • All 16 .dll entries the manifest lists (Bink2Scarlett.dll, XCurl.dll, XboxBvhBuilder.dll, the two amd_fidelityfx_*_xbox.dll, libHttpClient.GDK.dll, and the 10 CRT runtime DLLs) are present in that package, and the check below reads each one's SHA-256 too: none of the 17 entries mismatched. So the new check runs against a package as it really is, not only against synthetic fixtures.

Their own check over that package passes, and the cache works on real files. Feeding the same 17 entries (16 DLLs + the executable) — the same list check_launch_files builds — to manifest_verifier.check_files:

  • without a cache path: conforms in 0.09 s;
  • with a cache path: conforms in 0.09 s, the cache file is written with 17 entries (the executable's stamp carries size 120181760), and the second call conforms in 0.01 s without re-reading them.

Their test numbers reproduce here, with a wording correction below. python -I tests/test_leonida_mods.py: 15 OK on the branch, 10 OK on ece4ba5b3 (so +5). python -m pytest tests/test_manifest_verifier.py -k check_files: 1 passed. python -I tests/test_manifest_verifier.py as a whole: 58 tests, OK (2 skipped) on the branch. python -I scripts/check_no_game_data.py over all six changed files: exit 0, no output.

The wording, only so the evidence stays exact: on ece4ba5b3 that -k check_files selection reports 57 deselected — there is no test to fail, because the function and its test do not exist there yet. "Fails on main" reads as if a test ran and disagreed.

Two things I would want your decision on, neither of which blocks the change:

  1. check_launch_files builds its list with if … and os.path.isfile(os.path.join(game, rel)), so a .dll that the manifest declares and the package does not have is left out of the check and the preflight reports nothing. On a healthy 1.0.2.1 package the filter never fires — all 16 are there — so its only effect is on the case the whole feature exists for: a damaged or partially copied package. To see it I added a .dll entry to a copy of the manifest with a size and a hash and no file behind it: the filter took 16 of the 17 declared DLLs and check_files conformed. A file the manifest promises and the package lacks looks like the clearest mismatch a preflight can report, so I would ask it to be a ManifestError naming it, unless you know of a package layout where a manifest legitimately names a DLL the package does not carry. (With --image and no matching manifest, the check returns early and nothing is verified at all; that reads deliberate from the message, so I am not asking about that path.)

  2. check_launch_files verifies version.get("expected_exe", EXPECTED_EXE) at tools/leonida_mods.py:564-566, while runtime_command starts os.path.join(game, EXPECTED_EXE) at :577. Today both strings are game_scarlett_master.exe — xbox-1.0.2.1.json is the only manifest in game/ and its expected_exe equals the constant — so nothing is checked that is not started. It only becomes real when a second manifest names a different executable, and then it would be a quiet one: the check would pass on a file the launch does not use. Reading the name from the manifest in both places, or handing the chosen path to the check, would keep them tied together.

**@⁠fiestorra** on GitHub · 2026-11-24 06:51 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/358#issuecomment-7124360656) Reviewed on this machine (Windows build 26300, CPython 3.13.14, no GPU used), on `f35a1c4e2`, which is one commit on top of `ece4ba5b3`. AI-assisted. **The values in `game/xbox-1.0.2.1.json` match a real 1.0.2.1 package.** I have a local copy of that version and checked it against the two new fields and against everything the manifest already declared: * `game_scarlett_master.exe`: 120,181,760 bytes, SHA-256 `e95020b2fa4a721db3df59fdecf75621730ac559d8835252f6c3b658d5a08993` — both agree with `expected_exe_size` and `expected_exe_sha256`, and with the value `docs/runtime_imports.md` and `docs/embedded_shaders.md` already publish. * All 16 `.dll` entries the manifest lists (`Bink2Scarlett.dll`, `XCurl.dll`, `XboxBvhBuilder.dll`, the two `amd_fidelityfx_*_xbox.dll`, `libHttpClient.GDK.dll`, and the 10 CRT runtime DLLs) are present in that package, and the check below reads each one's SHA-256 too: none of the 17 entries mismatched. So the new check runs against a package as it really is, not only against synthetic fixtures. **Their own check over that package passes, and the cache works on real files.** Feeding the same 17 entries (16 DLLs + the executable) — the same list `check_launch_files` builds — to `manifest_verifier.check_files`: * without a cache path: conforms in 0.09 s; * with a cache path: conforms in 0.09 s, the cache file is written with 17 entries (the executable's stamp carries size 120181760), and the second call conforms in 0.01 s without re-reading them. **Their test numbers reproduce here**, with a wording correction below. `python -I tests/test_leonida_mods.py`: 15 OK on the branch, 10 OK on `ece4ba5b3` (so +5). `python -m pytest tests/test_manifest_verifier.py -k check_files`: 1 passed. `python -I tests/test_manifest_verifier.py` as a whole: 58 tests, OK (2 skipped) on the branch. `python -I scripts/check_no_game_data.py` over all six changed files: exit 0, no output. The wording, only so the evidence stays exact: on `ece4ba5b3` that `-k check_files` selection reports `57 deselected` — there is no test to fail, because the function and its test do not exist there yet. "Fails on main" reads as if a test ran and disagreed. Two things I would want your decision on, neither of which blocks the change: 1. `check_launch_files` builds its list with `if … and os.path.isfile(os.path.join(game, rel))`, so a `.dll` that the manifest declares and the package does not have is left out of the check and the preflight reports nothing. On a healthy 1.0.2.1 package the filter never fires — all 16 are there — so its only effect is on the case the whole feature exists for: a damaged or partially copied package. To see it I added a `.dll` entry to a copy of the manifest with a size and a hash and no file behind it: the filter took 16 of the 17 declared DLLs and `check_files` conformed. A file the manifest promises and the package lacks looks like the clearest mismatch a preflight can report, so I would ask it to be a `ManifestError` naming it, unless you know of a package layout where a manifest legitimately names a DLL the package does not carry. (With `--image` and no matching manifest, the check returns early and nothing is verified at all; that reads deliberate from the message, so I am not asking about that path.) 2. `check_launch_files` verifies `version.get("expected_exe", EXPECTED_EXE)` at `tools/leonida_mods.py:564-566`, while `runtime_command` starts `os.path.join(game, EXPECTED_EXE)` at `:577`. Today both strings are `game_scarlett_master.exe` — `xbox-1.0.2.1.json` is the only manifest in `game/` and its `expected_exe` equals the constant — so nothing is checked that is not started. It only becomes real when a second manifest names a different executable, and then it would be a quiet one: the check would pass on a file the launch does not use. Reading the name from the manifest in both places, or handing the chosen path to the check, would keep them tied together.
This pull request has changes conflicting with the target branch.
  • tools/leonida_mods.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/358/head:github-bot/gh-358'
git switch 'github-bot/gh-358'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-358'
git switch 'github-bot/gh-358'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-358'
git switch 'github-bot/gh-358'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-358'
git switch 'main'
git merge --squash 'github-bot/gh-358'
git switch 'main'
git merge --ff-only 'github-bot/gh-358'
git switch 'main'
git merge 'github-bot/gh-358'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.