Repository navigation
Conversation
|
Tested bac7060 on Windows 11 (NVIDIA GeForce RTX 4080 machine, driver 617.42; the test is CPU-side), cross-built with clang-cl 23.1.5 + xwin: pass. file_system_test: exit 0, 170 check(s), 0 failure(s), including the new host-path block:
Not run on main here. AI-assisted. |
|
Independent Windows check at Environment: Windows 11 x64, MSVC 19.51.36260 (VS18 14.51.36231), Ninja, RelWithDebInfo,
Two spellings of a path inside
Both probes fail 2 checks each at this head (4 failures total); they also fail on the parent, so this is not a regression. The normal absolute case is fixed. If the scope is intentional, qualifying the docs would close the mismatch; otherwise stripping AI-assisted. |
|
APPROVE, with two doc/test nits. Verified at head
Minor: AI-assisted review, no game files, no GPU. |
|
Tested
AI-assisted (Claude Code). Synthetic stand-in package only, no game files. |
|
Independent check of Environment: Windows 11, MSVC 19.44.35230.0 (RelWithDebInfo, Ninja), CPU only, synthetic temp dirs, no game files.
Same note as on #4965: that PR also edits This is a real "get the game working" fix: without it a host path under the game dir could write into the package tree. AI-assisted (Devin). |
|
pushed 8ae6fd7 (thanks @tupacfan04, @gertify):
AI-assisted (Claude Code). |
|
@Sc4ros found a remaining bypass for an ordinary absolute Win32 path at current head With a synthetic I prepared the small patch below: use Native Windows 11 x64, MSVC 19.44,
The new checks also cover a sibling sharing the prefix, Patch against Proposed patch (implementation + 11 regression checks)--- a/runtime/shims/file_system.cpp
+++ b/runtime/shims/file_system.cpp
@@ -33,6 +33,7 @@
#include <memory>
#include <mutex>
#include <string>
+#include <utility>
#include <vector>
#include "file_system.h"
@@ -122,20 +123,37 @@
// as `.gta6rt-temp`.
enum class Drive { None, Game, Scratch };
+// Match the normalisation the ordinary Win32 file APIs apply, including a single trailing dot in an intermediate
+// directory component ("package.\\file" names "package\\file"). Lexical normalisation alone misses that alias.
+// Relative and device/extended paths keep their existing host-path handling.
+bool normal_host_path(const std::wstring& path, std::wstring& normal) {
+ const bool absolute = (path.size() >= 3 && path[1] == L':' && is_separator(path[2])) ||
+ (path.size() >= 2 && is_separator(path[0]) && is_separator(path[1]));
+ if (!absolute || (path.size() >= 4 && is_separator(path[0]) && is_separator(path[1]) &&
+ (path[2] == L'?' || path[2] == L'.') && is_separator(path[3]))) return false;
+ const DWORD capacity = ::GetFullPathNameW(path.c_str(), 0, nullptr, nullptr);
+ if (capacity == 0) return false;
+ std::wstring buffer(capacity, L'\0');
+ const DWORD length = ::GetFullPathNameW(path.c_str(), capacity, buffer.data(), nullptr);
+ if (length == 0 || length >= capacity) return false;
+ buffer.resize(length);
+ normal = std::move(buffer);
+ return true;
+}
+
// A host path whose normalised form lies inside --game-dir (and not inside the overlay) names a package file by its
// host name: a title builds one from GetModuleFileName or from the folder it was started in. It gets the same rules
// as its GAME: spelling, so a read sees the overlay copy and a write, delete, move or attribute change goes to the
// overlay instead of the package. Returns the part below the game folder ("\data\x", or "" for the folder itself);
// false for any other path. ".." is resolved first, so a path that climbs out of the game folder is a host path.
bool game_dir_rest(const std::wstring& path, std::wstring& rest) {
- const bool absolute = (path.size() >= 3 && path[1] == L':' && is_separator(path[2])) ||
- (path.size() >= 2 && is_separator(path[0]) && is_separator(path[1]));
- if (!absolute) return false;
+ std::wstring normal;
+ if (!normal_host_path(path, normal)) return false;
const Roots r = roots();
if (r.game.empty()) return false;
- const std::wstring normal = std::filesystem::path(path).lexically_normal().native();
- if (!lies_under(normal, r.game) || (!r.overlay.empty() && lies_under(normal, r.overlay))) return false;
- std::wstring base = r.game.lexically_normal().native();
+ std::wstring base, overlay;
+ if (!normal_host_path(r.game.native(), base) || !lies_under(normal, base) ||
+ (normal_host_path(r.overlay.native(), overlay) && lies_under(normal, overlay))) return false;
while (!base.empty() && is_separator(base.back())) base.pop_back();
rest = normal.substr(std::min(base.size(), normal.size()));
return true;
--- a/runtime/test/file_system_test.cpp
+++ b/runtime/test/file_system_test.cpp
@@ -806,6 +806,72 @@
"a move from GAME: to a host path outside the game folder is ERROR_NOT_SAME_DEVICE");
}
+ // Ordinary Win32 paths also discard a single trailing dot from an intermediate directory. Classify the same
+ // name the host API will open, before deciding whether a write belongs in the overlay.
+ {
+ const auto write_shim = [&](const std::filesystem::path& path, bool ansi = false) {
+ const HANDLE h = ansi ? create_a(path.string().c_str(), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, 0, nullptr)
+ : create_w(path.c_str(), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, 0, nullptr);
+ if (h == INVALID_HANDLE_VALUE) return false;
+ DWORD written = 0;
+ const bool ok = ::WriteFile(h, "changed", 7, &written, nullptr) != FALSE && written == 7;
+ ::CloseHandle(h);
+ return ok;
+ };
+ const std::filesystem::path dotted_package = package.native() + L".";
+ write_path(package / "dot-wide.txt", "package");
+ check(read_path(dotted_package / "dot-wide.txt") == "package", "native Win32 confirms package. aliases package");
+ check(write_shim(dotted_package / "dot-wide.txt"), "a write through package. succeeds");
+ check(read_path(package / "dot-wide.txt") == "package" && read_path(overlay / "dot-wide.txt") == "changed",
+ "package. writes to the overlay and preserves the package");
+ HANDLE h = create_w((dotted_package / "dot-wide.txt").c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr,
+ OPEN_EXISTING, 0, nullptr);
+ check(h != INVALID_HANDLE_VALUE && read_handle(h) == "changed", "package. reads prefer the overlay copy");
+ if (h != INVALID_HANDLE_VALUE) ::CloseHandle(h);
+
+ write_path(package / "host" / "dot-ansi.txt", "package");
+ check(write_shim(dotted_package / "host." / "dot-ansi.txt", true) &&
+ read_path(package / "host" / "dot-ansi.txt") == "package" &&
+ read_path(overlay / "host" / "dot-ansi.txt") == "changed",
+ "CreateFileA normalises dots on the package and a child directory");
+ write_path(package / "dot-delete.txt", "package");
+ const auto dotted_delete = dotted_package / "dot-delete.txt";
+ check(delete_w(dotted_delete.c_str()) && read_path(package / "dot-delete.txt") == "package" &&
+ attributes_w(dotted_delete.c_str()) == INVALID_FILE_ATTRIBUTES,
+ "DeleteFileW through package. hides the name without deleting the package file");
+
+ write_path(package / "root-dot.txt", "package");
+ rt::fs::configure(dotted_package, overlay);
+ check(write_shim(package / "root-dot.txt") && read_path(package / "root-dot.txt") == "package" &&
+ read_path(overlay / "root-dot.txt") == "changed",
+ "a configured package. root is normalised before comparison");
+ write_path(package / "root-parent.txt", "package");
+ rt::fs::configure(package / ".." / "package", overlay);
+ check(write_shim(package / "root-parent.txt") && read_path(package / "root-parent.txt") == "package" &&
+ read_path(overlay / "root-parent.txt") == "changed",
+ "a configured root containing .. uses the same normalisation as the input");
+ rt::fs::configure(package, overlay);
+
+ const auto neighbour = root / "package-other" / "direct.txt";
+ write_path(neighbour, "host");
+ check(write_shim(neighbour) && read_path(neighbour) == "changed" &&
+ !std::filesystem::exists(overlay / "-other" / "direct.txt"),
+ "a sibling sharing the package prefix stays a host path");
+ check(write_shim(dotted_package / ".." / "dot-outside.txt") && read_path(root / "dot-outside.txt") == "changed" &&
+ !std::filesystem::exists(overlay / "dot-outside.txt"),
+ ".. out of package. stays a host path after Win32 normalisation");
+
+ // The default overlay is inside the package. Its aliases must remain direct host paths, not overlay/overlay.
+ const auto nested_overlay = package / "overlay";
+ rt::fs::configure(package, nested_overlay.native() + L".");
+ write_path(nested_overlay / "direct.txt", "host");
+ check(write_shim(dotted_package / "overlay." / "direct.txt") &&
+ read_path(nested_overlay / "direct.txt") == "changed" &&
+ !std::filesystem::exists(nested_overlay / "overlay" / "direct.txt"),
+ "normalised overlay aliases remain direct host paths even inside the package");
+ rt::fs::configure(package, overlay);
+ }
+
std::filesystem::remove_all(root);
std::printf("%d check(s), %d failure(s)\n", g_checks, g_failures);
return g_failures == 0 ? 0 : 1; |
|
Tested
AI-assisted (Gemini 4 Neon). |
|
Tested 8ae6fd7 merged with main 3faac55 on Windows 11 native, MSVC 14.51 (VS 18), Ninja, RelWithDebInfo (the test is CPU-side), plus Linux (WSL2) Python 3.12.16 for the docs tests: pass.
|
|
Tested
Not run: other GPUs/vendors, Linux, the Vulkan validation layer (not installed). No game files. AI-assisted (Claude Code). |
|
Tested together with #4965, since both change Merge of You map host paths in
Results: AI-assisted (Claude Code). No game files used. |
|
Tested
AI-assisted (Claude Code). |
…o it cannot write the package A title builds absolute paths into its own folder (GetModuleFileName, its start folder). Those were passed to the host unchanged, so a write-open, CREATE_NEW, DeleteFile, a move or an attribute change through that spelling changed the installed package. parse_console now reads an absolute host path whose normalised form lies inside --game-dir (and not inside the overlay) as its GAME: spelling. ".." is resolved first, so a path that climbs out of the game folder stays a host path. file_system_test gets a block for it (4 failures on main, 0 with the change). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ICE only outside --game-dir The comment on the G:-drive package case said those host paths stay host paths; they now name the package's own files, and the check says what it looks at. docs/runtime_imports.md: a move between GAME: and a host path is ERROR_NOT_SAME_DEVICE only when the host path is outside --game-dir. Two checks for that: a move from GAME: to a host path inside the game folder stays in the overlay, one to a host path outside fails with the error. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
8ae6fd7 to
e1f7c1d
Compare
|
pushed e1f7c1d: rebased on main Windows 11 / RX 9060 XT, MSVC Release: AI-assisted (Claude Code). |
Claim and finding: #4933 (comment)
AI-assisted (Claude Code). Tested by running the code below on Windows; see "Tested". No game files: the test uses a stand-in package folder under
%TEMP%.Problem
runtime/shims/file_system.cppgives theGAME:rules only toGAME:,G:andT:paths. Every other path goes to the host unchanged, including an absolute path into the game folder. The comment aboveconsole_drivenames one such path itself ("a path GetModuleFileName handed back"). A title builds those fromGetModuleFileNameor from the folder it was started in, and through that spelling:CREATE_ALWAYS,OPEN_ALWAYS,OPEN_EXISTINGwith write access) changes the package file;CREATE_NEWcreates the file in the package;DeleteFile,MoveFile*andSetFileAttributes*change or remove package files.That goes against
docs/runtime_imports.md("The package is never written"). Onmain3faac55, the new test block below fails 4 checks: the package file's bytes are replaced, the new file is made in the package, andDeleteFileWremoves the package file.Change
parse_console()(the one place every shim classifies a path) first asksgame_dir_rest(). An absolute host path (drive or UNC) whoselexically_normal()form lies inside--game-dir, and not inside the overlay, is re-read asGAME:plus the rest. From there on it follows exactly theGAME:rules: reads see the overlay copy first, writes are copied up into the overlay, deletes leave a marker, and so on...is resolved before the check, so<game>\..\xis a host path again, as on Windows. A path inside the overlay stays a host path, also when the overlay sits inside the game folder (the current default, RT-240).G:keeps working: its host paths now map to the same files throughGAME:. The existing check "a path under a configured G: game folder is a host path" still passes.docs/runtime_imports.md: the bullet on host paths says so.Not changed
GAME:\overlay(RT-240, waiting for the maintainer's decision).\\?\paths and relative paths stay host paths.Tested
Windows 11 (build 26300), MSVC 19.44 (VS 2022 Build Tools, Visual Studio generator, Release), AMD Radeon RX 9060 XT (driver 32.0.32029.2010) for the Vulkan tests in the full run.
file_system_test, new block (host path into the game folder: read, write, create, delete, path into the overlay,..out of and inside the game folder). Onmain3faac55 without the change:170 check(s), 4 failure(s). With it:170 check(s), 0 failure(s). Every existing check passes, including theG:host-drive cases.ctest -C Release: 169 run, 168 passed, 1 failed. The failure isd3d12_sparse_queue_family_contract, which crashes inside the Vulkan SDK's API dump layer on this AMD driver (TEST-843, the same onmain).🤖 Generated with Claude Code