Commit Graph

15 Commits

Author SHA1 Message Date
0c1437dfd9 Merge pull request #3651 from kotorvr
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:08:07 -05:00
be8570ace1 Merge remote-tracking branch 'origin/main' into triage-r43
# Conflicts:
#	docs/runtime_imports.md
#	runtime/CMakeLists.txt
#	runtime/shims/xgameruntime.cpp
#	runtime/test/xmem_test.cpp
#	tools/rdna2spirv.py
2026-11-22 22:12:50 -05:00
f46e90310d file_system: a listing directly below a file is ERROR_DIRECTORY, as on the host
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>
2026-11-22 22:05:06 +00:00
95f023f62b file_system: a folder has to exist in the title's view; same-name moves succeed
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>
2026-11-22 22:05:06 +00:00
edbaf7c585 Merge pull request #3602 from kotorvr 2026-11-22 17:02:56 -05:00
4c52ce27a6 Seven fixes from an outside contributor (sent as patches, applied without the author's name)
- 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>
2026-11-22 16:55:46 -05:00
75f1351a07 file_system_test: the MAXIMUM_ALLOWED write is shorter than the file
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>
2026-11-22 21:19:55 +00:00
0977b5dc7e file_system: a MAXIMUM_ALLOWED open is a write-open, so it cannot write the package
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>
2026-11-22 20:48:04 +00:00
fc1e0058e0 file_system: copy-up through a staging name, one at a time
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>
2026-11-22 14:15:36 -05:00
7360583abd Merge pull request #2122 from jaybeebabageyus 2026-11-22 11:41:59 -05:00
403d59060e runtime: shim CreateFile2 and FindFirstFileExA/W for GAME: paths and overlay 2026-11-22 17:01:52 +01:00
c9fbc9d07e gta6rt: GAME: paths for folders, moves, copies and attributes (RT-97 follow-up)
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>
2026-11-22 18:42:08 +03:00
3f26a95a10 fix(file_system): check is_regular_file for deletion markers so nested deletes do not hide parent directories 2026-11-22 10:41:32 -03:00
c5fb25f734 gta6rt: a failed write-open no longer revives a deleted GAME: name (RT-97)
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.
2026-11-22 13:29:20 +01:00
a98f9925b0 gta6rt: map GAME: console paths, and send writes to an overlay (RT-97)
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>
2026-11-22 13:11:57 +01:00