Skip to content

gta6rt: an --overlay that is a file or the game folder is refused before mapping - #9351

Closed
Vonsek wants to merge 1 commit into
ProjectLeonida:mainfrom
Vonsek:deepseek/9-overlay-not-folder
Closed

Vonsek wants to merge 1 commit into
ProjectLeonida:mainfrom
Vonsek:deepseek/9-overlay-not-folder

Conversation

@Vonsek

@Vonsek Vonsek commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: EGEN-GTA6RT-OVERLAY-NOT-FOLDER

What and why

gta6rt takes --overlay as the folder a title's writes land in (default <game-dir>\overlay), and the shim layer
promises the package stays exactly as installed (runtime/shims/file_system.cpp, "Console paths and the write
overlay"). Two values made that promise false, and the command line accepted both silently:

  • --overlay naming a file. gta6rt --dry-run <image> --game-dir <package> --overlay afile.txt mapped the image
    and exited 0; the title's first write-open then fails with ERROR_PATH_NOT_FOUND, which in a boot log reads as a
    broken port rather than a mistyped argument.
  • --overlay naming the game folder itself. The run is accepted and writes -> names the package, so a write and
    its copy-up land inside the folder the loader must not modify, and GAME: and the write root are the same tree.

Both are now refused before the image is opened: one line on stderr and exit 2, the same shape as an unusable
--game-dir (#8729). A not-yet-created overlay is still accepted (the default is created on the title's first write),
and the default <game-dir>\overlay is unaffected. This does not build on #8729: the two validate different options and
share no hunk.

Tested

Windows 10/11 x64, MSVC Build Tools 17.14 (RelWithDebInfo, Ninja), no GPU device needed. Base upstream/main
6312c057f.

Negative control (release build of the unpatched tree, same machine):

gta6rt --dry-run F:\CLGame\game_scarlett_master.exe --game-dir F:\CLGame --overlay F:\CLGame
    -> exit 0, "5 module(s) mapped, 20 unimplemented import(s)"
same, --overlay <a text file>      -> exit 0, 5 modules mapped
cmake -DLOADER=<gta6rt.exe> -P runtime/test/check_overlay_folder.cmake
    -> CMake Error: "gta6rt did not refuse an unusable overlay"

After the change (same commands, same machine):

--overlay F:\CLGame
    -> exit 2, "error: --overlay is the game folder, so a title's writes would land in the package: F:\CLGame"
--overlay <a text file>
    -> exit 2, "error: --overlay is not a folder: <path>"
(no --overlay, the default)        -> exit 0, "5 module(s) mapped, 20 unimplemented import(s)" (unchanged)
ctest -R "gta6rt_overlay_folder|run_tiny_game"  -> 4/4 passed
    (run_tiny_game, run_tiny_game_console_paths, run_tiny_game_dir, gta6rt_overlay_folder)

The whole CPU suite (ctest --test-dir build -j 4): 113 tests run, 110 passed, 7 skipped for the retail package and 1
disabled (no SDL3 here); three shim stress/state tests hit their timeouts under the parallel run and each passes alone
(api_ref_state 4.4 s, api_global_refs 0.1 s, context_attach_detach_stress 0.04 s). This CMake configure has no
Vulkan headers, so the D3D12/Vulkan tests are not part of it; the change touches no device code.

The new test builds its own text image and folders, so it needs no game files and no GPU. The local dry run read the
copy in place (read-only) and only the public counts above are reported; no game data, import dump or trace is quoted
here or committed.

Still unverified here: a real gta6rt --run of the title with an unusable overlay. The refusal runs before the image
is opened, so it does not depend on the title; the failure it replaces is the first write-open in
runtime/shims/file_system.cpp.

AI-assisted: yes. Agent deepseek9 of the Leonida agent team; the change, the test and the runs above were made on this
machine.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. — not a translator
    change.

…TA6RT-OVERLAY-NOT-FOLDER)

The overlay is the one folder a title's writes go to, and the loader promises the
package stays exactly as installed. A --overlay naming a file was accepted: the dry
run mapped and exited 0, and the first write-open then failed with
ERROR_PATH_NOT_FOUND, which reads as a broken port. An --overlay naming the game
folder itself was accepted too, so the writes and their copy-ups landed in the
package.

Both are now the usage error (one line on stderr, exit 2) before anything is
mapped, like an unusable --game-dir. The default <game-dir>/overlay is a folder of
its own and is unchanged.

@Grimkaaah Grimkaaah left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent Linux CPU review

Checked: gta6rt refuses --overlay that is a file or the game folder (exit 2 before map); README + cmake check. Windows loader test not run here.

Looks correct from review; no game files.

@abnalstlll-byte abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent Windows Review

What changed:

  • runtime/src/main.cpp:
    • Validates that --overlay is a directory and is not identical to the retail --game-dir.
    • Exits with usage error (exit code 2) before executable mapping if --overlay is invalid.
    • Prevents writing to regular files or accidentally modifying the immutable package directory.

Verification on Windows 11 host:

  • check_overlay_folder.cmake passes.
  • Clean diff: no game files or retail assets.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants