Skip to content

file_system: serve the file shims under the three other API sets a title imports them by - #3683

Open
kotorvr wants to merge 2 commits into
ItsNotRexed:mainfrom
kotorvr:claude/fs-apiset-names
Open

kotorvr wants to merge 2 commits into
ItsNotRexed:mainfrom
kotorvr:claude/fs-apiset-names

Conversation

@kotorvr

@kotorvr kotorvr commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Claim (new RT item, no ID assigned yet)

AI-assisted (Claude Code). I ran everything under "Tested" on Windows.

Problem

The loader binds an import by the exact DLL name in the title's import table. runtime/shims/file_system.cpp registers its 33 file functions under kernel32.dll, kernelbase.dll and three API sets (api-ms-win-core-file-l1-1-0, -l1-2-0, -l2-1-0).

A title linked against the SDK's API-set umbrella libraries imports seven of them from three other sets. Read from the x64 import members of OneCore_apiset.lib and WindowsApp.lib in Windows SDK 10.0.26100 (a script of my own that walks the archive's short import records):

Import DLL the umbrella libraries bind it to
MoveFileA, MoveFileW, MoveFileExA, CopyFileA api-ms-win-core-kernel32-legacy-l1-1-0.dll
CopyFileW api-ms-win-core-file-l2-1-2.dll
CopyFileExA, CreateDirectoryExA api-ms-win-core-file-ansi-l2-1-0.dll

The other 26 bind to the three sets already registered. mincore.lib binds CopyFileW the same way and does not carry the six ANSI/legacy ones; OneCore.lib binds everything to kernel32.dll.

So for such a title those seven were bound to the host: a GAME: path fails there, and a move or copy onto a host path the title built itself skips the overlay. It is the rename of a save or a config file that meets this first.

Change

Three more FILE_API(...) rows, for the three sets in the table, and one clause in docs/runtime_imports.md, whose sentence named only the api-ms-win-core-file-* sets (a second, docs-only commit; #3063 edits the lines next to it). The macro registers all 33 names under each, as it does for the existing sets; a name a set does not really export is never imported from it, so the extra entries are inert.

Not done: other version suffixes of these sets (-l2-1-1, -l1-1-1, ...). The rows are the ones measured in this SDK; gta6rt --dry-run on the executable will show any other.

Test

file_system_test checks that each of the seven (DLL, name) pairs resolves through the registry to the same shim as its kernel32.dll name, and calls one end to end: MoveFileW resolved through the legacy set moves a GAME: file into the overlay and leaves the package file alone.

Tested

Windows 11 (build 26200), MSVC 19.44.35222, Visual Studio's CMake and ctest 3.31.6 with Ninja, RelWithDebInfo, built by scripts/build_runtime.ps1. Base f847748c (main).

  • file_system_test with the new checks on main's file_system.cpp: 8 failures of 142 (the seven pairs do not resolve, and the move cannot be called). With the change: 142 checks, 0 failures.
  • ctest --test-dir runtime/build -C RelWithDebInfo with LEONIDA_GAME_DIR set: 140 run, 134 passed, 6 skipped, 0 failed (gameinput is 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.
  • No game files: every folder in the test is made by the test.

Overlap: #3602, #3651, #3511, #3532 and #3063 also edit file_system.cpp or its test. This adds lines at the end of the shim table, which none of them touches, and one block at the end of the test. My own #3651 adds a block at that same spot, so whichever of the two lands second needs a trivial rebase, which I will do.

🤖 Generated with Claude Code

@Desamodeth Desamodeth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested c91c0ca on Windows 11 x64 with the same synthetic EXE linked against Windows SDK 10.0.26100.0 OneCore_apiset.lib. dumpbin confirmed all seven imports under the three API sets. On main (f847748), creating the GAME: profile directory failed with ERROR_INVALID_NAME. On the PR all seven bound to shims: the guest backed up its original settings, copied a template, and replaced the settings. A fresh gta6rt process read the updated bytes. I verified the overlay files and the original package bytes after both runs. The file_system CTest also passed all 142 checks. No game files or GPU used. AI-assisted.

@Maraco91

Copy link
Copy Markdown

Tested c91c0ca on Windows 11, MSVC 19.42 (VS 2022 Build Tools), Windows SDK 10.0.28000.0, NVIDIA RTX 3080 Ti, driver 616.56: pass

  • scripts\build_runtime.ps1: builds clean (397 steps).
  • ctest -R file_system: passes.
  • Full ctest: 132 of 132 pass (the same 8 skipped and 1 disabled as on main here: no game package, no SDL3, no llvm-mc).
  • Negative control: with runtime/shims/file_system.cpp restored to main and the test kept, file_system fails on exactly the new checks: the seven ...!Name is the shim kernel32.dll!Name is lines and "MoveFileW through the legacy set moves a GAME: file into the overlay and leaves the package alone".

The import table in the description, checked independently with dumpbin /headers on the x64 OneCore_apiset.lib and WindowsApp.lib of a different SDK, 10.0.28000.0: all seven bind to the same DLLs in both libraries (MoveFileA/W, MoveFileExA, CopyFileA → api-ms-win-core-kernel32-legacy-l1-1-0.dll; CopyFileW → api-ms-win-core-file-l2-1-2.dll; CopyFileExA, CreateDirectoryExA → api-ms-win-core-file-ansi-l2-1-0.dll). So the mapping is not specific to 10.0.26100.

One note, not a blocker: FILE_API(...) registers all 33 file functions under each of the three new names, not only the seven that the umbrella libraries bind there. That is harmless (a set that doesn't export a name is never asked for it) and keeps the table uniform; saying so in the comment above the three rows would save the next reader the question.

AI-assisted (Claude Code); synthetic fixtures only, no game files.

@itsonlysimbo

Copy link
Copy Markdown
Contributor

Tested c91c0ca3 on RTX 4070, NVIDIA 621.14, Windows 11 (10.0.26300), MSVC 19.44, Ninja, RelWithDebInfo, Vulkan SDK 1.4.363: pass.

  • file_system passes, with loader, loader_tls and winhttp_offline.
  • ctest: 140/140; run_gpu_tests.py: 153/199 passed, 46 skipped, 0 failed, same as main f847748c.

AI-assisted (Claude Code).

kotorvr and others added 2 commits November 22, 2026 22:08
…tle imports them by

The loader matches an import by the exact DLL name. The file shims were registered
under kernel32, kernelbase and three api-ms-win-core-file sets, but the SDK's
umbrella libraries (OneCore_apiset.lib and WindowsApp.lib, 10.0.26100, x64) bind
seven of them elsewhere: MoveFileA/W, MoveFileExA and CopyFileA to
api-ms-win-core-kernel32-legacy-l1-1-0, CopyFileW to api-ms-win-core-file-l2-1-2,
CopyFileExA and CreateDirectoryExA to api-ms-win-core-file-ansi-l2-1-0. A title
linked that way had those seven bound to the host, where a GAME: path fails and a
write misses the overlay.

file_system_test: each of the seven pairs resolves to the shim its kernel32 name
does, and a MoveFileW through the legacy set lands in the overlay.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…nel32-legacy set

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@kotorvr
kotorvr force-pushed the claude/fs-apiset-names branch from c91c0ca to 03a95be Compare November 22, 2026 22:18
@kotorvr

kotorvr commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main 4c52ce27 (head now 03a95be). The only conflict was in file_system_test.cpp, where this PR and RT-218's G:/T: block both appended at the end; both are kept. The shim change itself (three table rows) did not conflict.

On this head: file_system_test 159 checks, 0 failures. In the full ctest run (Visual Studio's 3.31.6, -j 2, LEONIDA_GAME_DIR set), 144 passed, 7 skipped, and two GPU tests failed: d3d12_fence_timing (segfault) and d3d12_compute. Neither links file_system.cpp, both took 10-11 s in that run against 1-3 s normally, and both passed three times out of three when rerun alone on the same head. I read that as load on a shared machine, not this change, but I am stating it rather than leaving it out. AI-assisted (Claude Code).

@FaKL-Code

Copy link
Copy Markdown
Contributor

Tested 03a95be (merged onto main aa2988c) on NVIDIA GeForce RTX 4060 Ti, driver 610.88 (32.0.16.1088), Windows 11 26200, MSVC 14.51.36231 (VS 2026), Vulkan SDK 1.4.363.0, Windows SDK 10.0.26100.0: pass

  • Merges cleanly; no new compiler warnings against main.

  • ctest: 144 of 144 pass (same 9 skips as main). Loader test passes; validation run: 56 tests clean.

  • file_system -V: "159 check(s), 0 failure(s)". Each of the seven names resolves to the same shim as its kernel32.dll entry, and "MoveFileW through the legacy set moves a GAME: file into the overlay and leaves the package alone".

  • (The earlier head, c91c0ca on main f847748, also passed here: 131 of 131, file_system 142 checks.)

  • I checked the table on my side with dumpbin /headers on the x64 OneCore_apiset.lib from SDK 10.0.26100.0. It binds:

    • MoveFileA, MoveFileW, MoveFileExA and CopyFileA to api-ms-win-core-kernel32-legacy-l1-1-0.dll.
    • CopyFileW to api-ms-win-core-file-l2-1-2.dll.
    • CopyFileExA and CreateDirectoryExA to api-ms-win-core-file-ansi-l2-1-0.dll.

    That matches the body.

  • Heads-up for merge order: file_system: a folder has to exist in the title's view; same-name moves succeed (RT-233) #3651 also adds checks to runtime/test/file_system_test.cpp, and with both rebased, git merge-tree still reports a conflict there (file_system.cpp merges cleanly). file_system: CopyFile2 falls back to CopyFileExW on Wine 9 (RT-237) #3655 merges cleanly with this one.

AI-assisted (Claude).

@kapitche

Copy link
Copy Markdown
Contributor

Tested 03a95be merged with main 3faac55 on Windows (MSVC 14.51, RelWithDebInfo) and with main 98fa503 on Linux (Python 3.12.16): pass. ctest file_system 1/1 (it does not use the GPU; the result is the same with the NVIDIA and the Intel selection). Negative control with main's runtime/shims/file_system.cpp: file_system fails. Linux: the four tests/test_docs_*.py 4/4 ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants