The overlay's .gta6rt-deleted, .gta6rt-temp and .gta6rt-copy folders are hidden from GAME:\ listings but an explicit
GAME:\.gta6rt-*\... path still reaches them. These probes open, stat, list, create, mkdir and delete through such
paths in the spellings parse_console() normalises (case, forward slashes, ".", ".." and the G: alias), expect
ERROR_INVALID_NAME and no side effect, and keep T:\ and an ordinary dotted name working. They fail on main.
AI-assisted (Claude Code, Claude Fable 5.1).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GDgoLQVYG7p8mvxkwBroVz
Review on #3955 (@pedro470), both reproduced here:
- A marker folder that cannot be listed (FILE_LIST_DIRECTORY denied, the
markers still reachable by path) read as "no markers", so a deleted
package file came back in the listing. Only ERROR_FILE_NOT_FOUND or
ERROR_PATH_NOT_FOUND now means nothing is deleted; any other failure,
an incomplete FindNextFileW scan or a marker that cannot be checked
sends each entry through deleted().
- A _wcslwr_s key is not _wcsicmp in every locale: under .UTF-8 it folds
U+00C9 and U+00E9, which _wcsicmp keeps apart, so a package entry was
dropped. The names seen are now a std::set ordered by _wcsicmp, so two
names are one entry exactly when same_name says so. Same timing.
Tests: the listing-denied marker folder (through the ACL API, restored
after), and a .UTF-8 merged listing checked against _wcsicmp itself. The
previous head fails both; each single fix removed fails its own check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review on #3955 (@Parakeet-Wheat, @shdann): the fast path only held while
the folder had no marker folder. One DeleteFileW creates it, and every
package entry was probed with deleted() again: 1,073 ms for 16,000 files
after two deletes, against 27 ms now.
collect() lists the marker folder once and keeps the deleted names in a
set, with deleted()'s rule: a marker file, or a marker folder holding
kRemovedDirMarker. The lookup folds ASCII letters only, which is exactly
the file system's case-insensitive compare when both names are ASCII. A
non-ASCII entry, or a marker that is not plain ASCII or is a reparse
point, still goes through deleted(), so the file system's Unicode case
rule decides (deleting éclair.txt hides the package's Éclair.txt, as on
main).
Tests: a delete under another ASCII case in a 300-file folder hides only
that file; the Éclair case above.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
collect() probed the overlay for a deletion marker twice per package entry
(two is_regular_file calls), also when the folder has no marker folder at
all, and de-duplicated names by comparing each one with every name kept so
far. Listing 16,000 package files took 3.7 s against 9 ms on the host.
Every marker for an entry of the listed folder lives inside that folder's
marker folder, so probe it once and skip the per-entry checks when it is
missing. Keep the names seen in an unordered_set, folded with _wcslwr_s,
which follows the same locale rule as the _wcsicmp that same_name uses.
Tests: names that differ only in case are one entry with the overlay's
spelling, and a 300-file folder without a marker folder lists every file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
collect answered ERROR_PATH_NOT_FOUND for any folder that is not one in the title's
view. The host tells a missing folder (3) from a file in the folder's place (267);
view() already knows which. Reported in review by shdann, with the host table.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Three places where the shim disagreed with the host about GAME: paths:
- write_target created the parent folders before checking anything. A failed
OPEN_EXISTING left the missing folders behind, and a create succeeded in a
folder that was never made, below a package file (which then read as a folder)
and inside a folder the title had removed. The parent now has to be a folder in
the title's view, as CreateDirectory, MoveFile and CopyFile already require;
otherwise ERROR_PATH_NOT_FOUND and nothing is created.
- FindFirstFile inside a removed package folder returned "." and "..", and inside
a folder that never existed reported ERROR_FILE_NOT_FOUND. Both are now
ERROR_PATH_NOT_FOUND.
- MoveFile onto the same name, or to the same name in another case, failed with
ERROR_ALREADY_EXISTS. The first now succeeds and changes nothing; the second
renames the overlay entry (a package file gets an overlay copy under the new
spelling; a package folder is refused like any other move of one).
Two existing checks encoded the old answers and are changed: the test that made
GAME:\save\slot1.bin without making GAME:\save first, and the one that expected
ERROR_FILE_NOT_FOUND for a listing inside a missing folder.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- rdna2spirv: declare each packed vertex input register once; a register whose elements disagree on the component
type is refused (SHADER-644).
- runtime: a title's VirtualAlloc drops the console's MEM_GRAPHICS / MEM_TITLE type bits the host rejects (RT-217).
- runtime: XPersistentLocalStorageImpl is served from <overlay>\persistent with the package's 2048 MB quota
(RT-219; layout from the public docs, not measured in a caller).
- runtime: G:\ names the package and T:\ a scratch folder in the overlay; paths under the configured folders and
every path with no folders configured stay host paths (RT-218).
- winhttp_offline: header blocks and timeouts the host WinHTTP rejects are rejected the same way.
- cfg_structure.run: a limit of zero or less runs no blocks.
- shader_meta: an s_movk_i32 with a register operand and a float immediate beyond float32 are left unknown instead
of raising.
Each comes with a test that fails on the old code. Conflicts with main resolved here (internal_dir() hides T:'s
folder; both file_system_test blocks kept).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review on #3655 (kacper-serewis, daemosofchaos, on Windows 11):
- A parameter block shorter than COPYFILE2_EXTENDED_PARAMETERS (dwSize
0, 4, 31) made the fallback copy and return S_OK, where the host's
CopyFile2 returns E_INVALIDARG and writes nothing. Both paths now
check it first, before copy_paths prepares the destination.
- The fallback silently dropped COPY_FILE_SKIP_ALTERNATE_STREAMS and
copied the stream. Its flags are now sorted: passed on (the ones both
calls define), dropped (requests that leave the contents as
CopyFileExW writes them: no offload, compressed traffic, sparse copy,
...), or refused with ERROR_NOT_SUPPORTED before anything is written
(SKIP_ALTERNATE_STREAMS, DIRECTORY, OPEN_AND_COPY_REPARSE_POINT,
IGNORE_SOURCE_ENCRYPTION, unknown bits, a longer V2 block).
- A cancel flag already set is answered by the fallback itself, since
Wine 9's CopyFileExW doesn't read it.
rt::fs::force_copy_file2_fallback lets the test run the fallback on
Windows, where the host has CopyFile2 (Maraco91 noted it couldn't be
reached there). file_system_test runs its CopyFile2 checks both ways:
no block, short blocks, fail-if-exists with a hint flag, a set cancel
flag, and in the fallback the refused flags and block.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GN11jcpJWD4phrXJyDgED6
A two-byte write leaves the rest of the file to compare, so the test also shows the
overlay copy began as the package file's bytes (suggested in review).
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
writes() did not count MAXIMUM_ALLOWED as write access. CreateFileW/A and CreateFile2
then opened the package file itself, and a WriteFile through the handle changed the
package, which docs/runtime_imports.md says is never written. Such an open now gets
the overlay copy like any other write-open.
file_system_test: the three entry points, with the package bytes and the overlay
copy checked after a write; a plain read still makes no overlay copy.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A write-open of a package file copied it straight to its overlay name with
no lock. A process killed mid-copy left a truncated file there that every
later read preferred over the package; two threads write-opening the same
package file both copied, and the second copy_file failed on the taken name,
so that open failed.
write_target now copies into <overlay>\.gta6rt-copy under a private name and
renames it into place, under a mutex that only copy-ups take. Listings hide
the staging folder like .gta6rt-deleted. Without the mutex, copy-then-rename
alone still failed about 2 in 100 runs: a losing rename onto the existing
name briefly holds it, and the winner's open got ERROR_SHARING_VIOLATION.
file_system_test: two threads write-open one 256 KiB package file, 50 rounds;
both opens succeed and the overlay copy matches (fails 3 of 3 runs on the
old code, passes 200 of 200 with this); no staging file is left; a crash
leftover is hidden from a GAME: listing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The calls docs/runtime_imports.md listed as not mapped now follow the RT-97
rules, under kernel32, kernelbase and the api-ms-win-core-file-* sets:
- CreateDirectory/CreateDirectoryEx make the folder in the overlay; a name the
title can already see, package-only folders included, is ERROR_ALREADY_EXISTS.
- RemoveDirectory needs the folder empty in the title's view. An overlay folder
is removed; a package folder is hidden by a .gta6rt-dir marker file inside its
marker folder and stays on disk (deleted() now also checks that file, on top
of the regular-file rule from 3f26a95a).
- MoveFile/MoveFileEx write the destination in the overlay; a moved package file
is copied there and its old name deleted by a marker. MOVEFILE_WRITE_THROUGH
flushes that copy and the marker before returning (review on #1742). Package
folders are not moved (ERROR_ACCESS_DENIED), GAME: <-> host is
ERROR_NOT_SAME_DEVICE and MOVEFILE_DELAY_UNTIL_REBOOT is ERROR_INVALID_PARAMETER.
- CopyFile/CopyFileEx/CopyFile2 read like a read and write a GAME: destination
in the overlay; fail-if-exists counts names only the package has.
- SetFileAttributes sets the overlay copy (copy-up or folder mirror first).
file_system: 123/123 checks. No game files.
AI-assisted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
write_target cleared the delete marker before the host CreateFileW ran, and copied a package file up
without looking at the marker, so a write-open of a deleted name could make it readable again: an
OPEN_EXISTING open succeeded on the copy-up, and one that failed left the marker gone with the package
file visible behind it.
The marker is now never removed, and a tombstoned name is never copied up. Reads and listings prefer an
overlay copy, so a re-created file is visible without clearing anything, while an open that keeps the
contents (OPEN_EXISTING, TRUNCATE_EXISTING) fails with ERROR_FILE_NOT_FOUND and leaves the name deleted.
file_system asserts that sequence: the failed write-open, no overlay copy, and the name still gone.
Review pass over the rest of the shim: Target loses the two fields nothing read, FindFirstFile no longer
parses its pattern twice, collect drops its unreachable non-console branch, and the enumeration states are
unique_ptr entries looked up under the lock instead of raw pointers handed out of it.
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
<game-dir>\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 <noreply@codebuff.com>