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

Closed
ItsMrDubey wants to merge 0 commits from upstream-pr/358 into main
ItsMrDubey commented 2026-11-24 03:53:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ItsMrDubey on 2026-11-24T03:53:34Z.


Claimed in the coordination issue as: OLD-8041, OLD-8404 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7121328982)

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.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5465758413 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/358). Originally posted by [ItsMrDubey](https://github.com/ItsMrDubey) on 2026-11-24T03:53:34Z. --- Claimed in the coordination issue as: OLD-8041, OLD-8404 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7121328982) ### 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`.
fiestorra commented 2026-11-24 06:51:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-24T06:51:23Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7124360656 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/358#issuecomment-7124360656). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-11-24T06:51:23Z. --- 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.
MoonEyes commented 2026-11-27 23:19:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-27T23:19:23Z.


Hi @ItsMrDubey, thanks for this pull request. It currently conflicts with main (conflicting file(s): tools/leonida_mods.py), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7230050629 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/358#issuecomment-7230050629). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-27T23:19:23Z. --- Hi @ItsMrDubey, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `tools/leonida_mods.py`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
aslan2142 commented 2026-12-01 11:50:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:50:27Z.

Review: CHANGES_REQUESTED


Reviewed against current main: this branch conflicts with main in tools/leonida_mods.py and has failing CI. Please rebase onto current main so CI runs cleanly.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130666555 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/358#pullrequestreview-6130666555). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:50:27Z. **Review:** CHANGES_REQUESTED --- Reviewed against current `main`: this branch conflicts with `main` in `tools/leonida_mods.py` and has failing CI. Please rebase onto current `main` so CI runs cleanly. *(AI-assisted review.)*
MoonEyes commented 2026-12-02 10:32:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T10:32:05Z.


For information: this pull request is carried in #3084, which merges your head (your commits are kept) into current main, resolves the conflicts keeping both sides, and fixes the points raised in review here (details in its description). This one stays open until a maintainer decides; if you pick it up again, say so and the carry can be closed.

AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7342610651 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/358#issuecomment-7342610651). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T10:32:05Z. --- For information: this pull request is carried in #3084, which merges your head (your commits are kept) into current `main`, resolves the conflicts keeping both sides, and fixes the points raised in review here (details in its description). This one stays open until a maintainer decides; if you pick it up again, say so and the carry can be closed. AI-assisted (Claude Code, Claude Opus 5.5)
MoonEyes commented 2026-12-02 11:39:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T11:39:28Z.


Closing: this pull request no longer applies to current main (merge conflict in tools/leonida_mods.py), and open pull requests that have fallen out of step with main are being closed so the list stays workable. Your work is not lost: it is carried in #3084, which keeps your commits and resolves the conflict on current main.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7344225123 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/358#issuecomment-7344225123). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T11:39:28Z. --- Closing: this pull request no longer applies to current `main` (merge conflict in `tools/leonida_mods.py`), and open pull requests that have fallen out of step with `main` are being closed so the list stays workable. Your work is not lost: it is carried in #3084, which keeps your commits and resolves the conflict on current `main`. AI-assisted (Claude Code).

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!358
No description provided.