From a98f9925b0c059548ce4359006238a29744cc773 Mon Sep 17 00:00:00 2001 From: HQasper <52220032+HQasper@users.noreply.github.com> Date: Sun, 22 Nov 2026 13:11:57 +0100 Subject: gta6rt: map GAME: console paths, and send writes to an overlay (RT-97) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A mapped title names its files on the console's drives, but nothing mapped them: the file calls went straight to the host and --game-dir was only used to find modules, so the first file a title opens at boot would fail. New shims for CreateFile*, FindFirstFile*/FindNextFile*/FindClose, GetFileAttributes*/ GetFileAttributesEx* and DeleteFile* (kernel32, kernelbase and the api-ms-win-core-file sets) map a GAME: path under --game-dir, and send every open that can write and every delete to --overlay (default \overlay), which reads and listings prefer. A write-open copies the package file into the overlay first, so OPEN_EXISTING keeps its bytes, and a delete of a package file leaves a marker instead of removing it, so the package is never modified. A path that climbs above GAME: with ".." or names another drive is refused with ERROR_INVALID_NAME. A path without the prefix is still a host path. The prefixes and the overlay come from ivall/xcl (GPL-2.0-only), as facts only, no code. file_system ctest: 43 checks over folders in %TEMP%, covering mapping and case, copy-up and read preference, a new file in folders the package lacks, delete and re-create, the merged listing, host-path passthrough, the escape refusal and the narrow variants. 🤖 Generated with Codebuff Co-Authored-By: Codebuff --- runtime/src/main.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'runtime/src/main.cpp') diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp index 9ceccf53a..7d3491653 100644 --- a/runtime/src/main.cpp +++ b/runtime/src/main.cpp @@ -1,18 +1,21 @@ // gta6rt: native runtime for the Xbox Series build. // -// gta6rt --dry-run [--game-dir DIR] +// gta6rt --dry-run [--game-dir DIR] [--overlay DIR] // Maps the image and its bundled modules, applies relocations, binds every import, installs static TLS for // this thread and prints a report. No code from the mapped images // runs. TLS needs the runtime's own gta6rt_tls_host.dll, which reserves the module TLS index; system DLLs are // loaded to resolve host imports, as before. // -// gta6rt --init [--game-dir DIR] +// gta6rt --init [--game-dir DIR] [--overlay DIR] // The same mapping, then each loaded DLL's TLS callbacks and DllMain(DLL_PROCESS_ATTACH) are run. // -// gta6rt --run [--game-dir DIR] [--trace-d3d12] [-- game arguments...] +// gta6rt --run [--game-dir DIR] [--overlay DIR] [--trace-d3d12] [-- game arguments...] // The same, then the EXE's own TLS callbacks and its entry point, on a game thread. The game's argv and // command line are plus the arguments after "--"; exit/ExitProcess from the game end the run // (shims/process.cpp). gta6rt prints the binding report first and returns the game's exit code. +// +// --game-dir is also where a title's GAME: paths read from; anything it writes or deletes goes to the overlay +// (--overlay, default /overlay) so the package is never modified (shims/file_system.cpp). #include #include @@ -22,6 +25,7 @@ #include "pe_loader.h" #include "../shims/d3d12_trace.h" +#include "../shims/file_system.h" #include "../shims/process_shim.h" #include "../shims/shims.h" @@ -38,16 +42,16 @@ const char* binding_name(rt::Binding b) { int usage() { std::fprintf(stderr, - "usage: gta6rt --dry-run [--game-dir DIR]\n" - " gta6rt --init [--game-dir DIR] [--trace-d3d12]\n" - " gta6rt --run [--game-dir DIR] [--trace-d3d12] [-- game arguments...]\n"); + "usage: gta6rt --dry-run [--game-dir DIR] [--overlay DIR]\n" + " gta6rt --init [--game-dir DIR] [--overlay DIR] [--trace-d3d12]\n" + " gta6rt --run [--game-dir DIR] [--overlay DIR] [--trace-d3d12] [-- game arguments...]\n"); return 2; } } // namespace int wmain(int argc, wchar_t** argv) { - std::filesystem::path image, game_dir; + std::filesystem::path image, game_dir, overlay_dir; bool dry_run = false, init = false, run = false, trace_d3d12 = false; std::vector game_args; // wide: path::string() throws on a character the code page lacks (RT-84) for (int i = 1; i < argc; ++i) { @@ -61,6 +65,7 @@ int wmain(int argc, wchar_t** argv) { else if (a == L"--run") run = true; else if (a == L"--trace-d3d12") trace_d3d12 = true; else if (a == L"--game-dir" && i + 1 < argc) game_dir = argv[++i]; + else if (a == L"--overlay" && i + 1 < argc) overlay_dir = argv[++i]; else if (image.empty()) image = a; else return usage(); } @@ -68,6 +73,9 @@ int wmain(int argc, wchar_t** argv) { // Exactly one mode: --dry-run --run would otherwise initialise the modules and call the entry point. if (dry_run + init + run != 1) return usage(); if (game_dir.empty()) game_dir = image.parent_path(); + // GAME: paths read under --game-dir; whatever a title writes lands in the overlay, never in the package. + if (overlay_dir.empty()) overlay_dir = game_dir / "overlay"; + rt::fs::configure(game_dir, overlay_dir); rt::d3d12_trace::set_enabled(trace_d3d12); try { @@ -105,6 +113,7 @@ int wmain(int argc, wchar_t** argv) { return 1; } rt::process::set_command_line(image.filename().wstring(), game_args); + std::printf("console paths: GAME: -> %ls, writes -> %ls\n", game_dir.c_str(), overlay_dir.c_str()); std::printf("running %s\n", main_module.name.c_str()); std::fflush(stdout); const int code = rt::process::run_entry(main_module.base + main_module.entry_rva); -- cgit v1.2.3