Repository navigation
file_system: a MAXIMUM_ALLOWED open is a write-open, so it cannot write the package (RT-229) - #3602
Conversation
…te 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>
kacper-serewis
left a comment
There was a problem hiding this comment.
At 0977b5d all 142 native Windows checks passed. Synthetic writes through CreateFileA/W/2 preserved the package and used the overlay. A scratch partial-overwrite fixture additionally verified preservation of the untouched suffix through all three APIs. Consider retaining that assertion. AI-assisted CPU validation.
|
Tested
Private build dir; |
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>
|
Thanks both. Taken up in 75f1351 (test only): the write through each |
kacper-serewis
left a comment
There was a problem hiding this comment.
At 75f1351 all 142 native Windows LLVM-MinGW checks passed. Across W/A/CreateFile2 the two-byte overwrite preserved the copied suffix and the package source. A scratch mutation creating an empty overlay instead made all three content assertions fail despite successful writes. AI-assisted CPU-only synthetic validation.
|
Tested 75f1351 on Windows 11, MSVC (VS 2022 Build Tools) RelWithDebInfo, with RTX 5080 (driver 616.92) and AMD Radeon iGPU gfx1036 (driver 26.10.1) each selected in turn ( No negative control run. AI-assisted. |
|
Tested 0977b5d (on its base
AI-assisted (Claude Code). |
RT-229 (claim)
AI-assisted (Claude Code). I ran everything under "Tested" on Windows.
Problem
docs/runtime_imports.mdpromises "The package is never written": an open that can write goes to the overlay.writes()inruntime/shims/file_system.cppdecides that from the access mask, and its mask had noMAXIMUM_ALLOWED. That bit names no right and grants every one the file allows, write included. SoCreateFileW("GAME:\data\x", MAXIMUM_ALLOWED, ..., OPEN_EXISTING)was treated as a read, the shim handed out a handle to the package file itself, and aWriteFilethrough it changed the user's install.CreateFileAandCreateFile2share the function.Change
MAXIMUM_ALLOWEDis in the write mask, so such an open gets the overlay copy like any other write-open (copy-up forOPEN_EXISTING). One constant and a comment; nothing else in the open path changes. The cost is a copy-up for a title that asks forMAXIMUM_ALLOWEDand then only reads.Test
file_system_test(synthetic folders in%TEMP%, no game files) opens a package file withMAXIMUM_ALLOWEDthroughCreateFileW,CreateFileA(withGENERIC_READadded) andCreateFile2, writes through the handle, and checks that the package file still holds its bytes and the overlay copy holds the write. It also checks that aGENERIC_READopen still makes no overlay copy.Tested
Windows 11 (build 26200), MSVC 19.44.35222, Visual Studio's CMake and
ctest3.31.6 with Ninja, RelWithDebInfo, built byscripts/build_runtime.ps1. Basef847748c(main).file_system_testwith the new checks onmain'sfile_system.cpp: 4 failures of 142 (the package file was written and no overlay copy existed, for each of the three entry points). With the change: 142 checks, 0 failures.ctest --test-dir runtime/build -C RelWithDebInfowithLEONIDA_GAME_DIRset: 140 run, 134 passed, 6 skipped, 0 failed (gameinputis disabled, no SDL3 here). NVIDIA GeForce RTX 4090, driver 32.0.16.2114, for the Vulkan tests in that run; this change needs no GPU.#3063 and #2957 also edit
file_system.cppor its test; this touches neither's hunks (writes()and a new block after theCreateFile2checks).🤖 Generated with Claude Code