Repository navigation
Description
Background
PR #243 added one store-access layer (clean/installer/src/wg_core/util.h LibraryAccess / LibraryRegistryAccess).
In a WRONGGPU_TESTING build with WRONGGPU_TEST_LIBRARIES set, it confines every store-library read to the test run's
own folder. It refuses paths whose final form differs from their long name, reparse points, files with a second name and
a test folder that resolves elsewhere. It logs every access before the read and refuses a read whose line cannot be
written. The test suite never reads a real store library. Three smaller points remain.
1. Check-then-use: the checked handle is not the read handle
util.cpp checks a path with one handle and closes it. The later read then opens the path again:
FinalForm(around lines 535-541) and the reparse / link-count check inRealPathOk(around 563-568) close their
handles;FindFilesNamedthen enumerates the folder by path (around 636-638) and returns file paths (around 647-648);model.cpp(around line 141) passes such a path to the converter, which opens it again (clean/converter/src/api.cpp
around lines 81 and 227).
If a folder or file is replaced with a junction or link between the check and the use, the read can land somewhere else
while the inside path is logged. In the test suite this needs a concurrent swap inside the suite's own synthetic folders,
so it is not reachable there today. It is still not a strict guarantee.
Proposed:
- Open once with
FILE_FLAG_OPEN_REPARSE_POINT(plusFILE_FLAG_BACKUP_SEMANTICSfor folders). Run the final-path,
reparse and link-count checks on that handle, and use the same handle for the read:- enumerate folders with
GetFileInformationByHandleEx(FileIdBothDirectoryInfo); - read files through the handle.
- enumerate folders with
- Let the converter take an open handle (or a file already read into memory) instead of a path, so the launcher's checked
handle is the one that is read.
2. A log line for every actual open, not only discovery
FindFilesNamed logs each folder walked and each matching file found, but some found files are opened more than once
later without their own access line:
- with a non-empty ignore list,
model.cpp(around lines 61-65) andconvert_ignore.cpp(around 309-316) hash a
candidate, opening it throughutil.cpp(around 660-661); model.cpp(around 139-142) then converts the same candidate, and the converter opens it again.
So a failed log append after discovery does not stop these later reads, and the log cannot account for each open.
Proposed: call LibraryAccess (or the handle-based form from point 1) right before each of these opens, the hash and the
convert, so every open has its own line and the fail-closed rule covers it.
3. Release builds: note what still runs
The final-path, environment and access-log code is compiled only in WRONGGPU_TESTING builds, and LibraryAccess /
LibraryRegistryAccess return true in release builds. Release builds still run two things:
- the unconditional atomic access counter (
LibraryAccessCount; increments aroundutil.cpplines 482, 578 and 605); - the new call sites.
The behaviour is unchanged, but the code path is not literally identical, and no release-build parity test covers it.
Proposed: either keep the counter only in testing builds, or keep it and add a short note to util.h and the README's
Tests section that it is the one piece that runs in release. Add a release-build unit test that LibraryAccess returns
true and changes nothing else.
Done when
- The store-access check and the read use the same handle (folder enumeration and file reads in the launcher; the
converter takes a handle or bytes), with a unit test that swaps a checked folder or file for a junction after the check
and shows the read is refused or stays inside. - Hashing and converting a library candidate each write their own access line, and a failed append refuses them (unit
test). - Release-build behaviour is stated and tested as above.
Activity
launcher: one store-access layer; the test suite reads only its own f…
Launcher: settings in the game's state folder, WrongGPU's state files…