Repository navigation
Conversation
The shim's CopyFile2 called ::CopyFile2 directly. Wine 9's kernel32 and kernelbase don't export it, so Wine binds that import to a stub that aborts the process: under Wine 9 (or a Proton built on it), a title that calls CopyFile2 is killed. The file_system test shows it: it aborts at its CopyFile2 check and runs into ctest's timeout. The host's CopyFile2 is now looked up with GetProcAddress (kernelbase, then kernel32) and used where it exists, so Windows behaves as before. Where it doesn't, the copy goes through CopyFileExW: the flags both calls define and the cancel flag are passed on, the CopyFile2-only hints are dropped, and a COPYFILE2 progress routine is not called. pe_loader.cpp and loader_tls_test.cpp already avoid CopyFile2 for the same reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GN11jcpJWD4phrXJyDgED6
kacper-serewis
left a comment
There was a problem hiding this comment.
At 49ea89f a synthetic parameter block with dwSize=0 returned E_INVALIDARG and left the destination absent on native Windows. The forced fallback returned S_OK and created it. Validate the block before preparing the destination. Both native and forced-fallback builds passed all 134 existing checks; cancellation flag, missing source and fail-if-exists controls passed. Wine 9 dispatch checked from export specifications only. AI-assisted.
|
Tested 49ea89f on Windows 11, MSVC 19.42 (VS 2022 Build Tools), Windows SDK 10.0.28000.0, NVIDIA RTX 3080 Ti, driver 616.56: pass, as the no-regression check on a host that has
What this does not cover: Reading the fallback: the six flags it forwards are the ones both calls define, AI-assisted (Claude Code); synthetic fixtures only, no game files. |
|
Independent Windows 11 build 26300 / MSVC 19.52 check of With a valid The original 134 filesystem checks passed with the forced fallback. I also independently confirmed the reported invalid-size behavior at sizes 0, 4 and 31: native returned I did not run Wine; this is a forced-fallback test on Windows/NTFS, so Wine's alternate-stream behavior is not established. The PR source was restored afterward. No game data or network services were used. — LocalFirst-AI |
Review on ItsNotRexed#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
|
Thanks for the reviews. Pushed c0b821c, which addresses all three:
Also: Wine 9's CopyFileExW ignores a cancel flag that's already set, so the fallback checks it itself and returns HRESULT_FROM_WIN32(ERROR_REQUEST_ABORTED). Tested under Wine 9.0 (Ubuntu 24.04, cross-built with clang-cl 19 + xwin SDK 10.0.26100): ctest -R file_system passes, 153 checks, all of the new ones included. Not yet run on Windows: a re-run there would check that the host path still matches, and the new fallback checks. |
|
Thanks @agulerman. Retested For parameter sizes 0, 4, 31 and 32, both the native shim path and the forced fallback matched native The fallback result is intentionally a refusal, not full support for the flag. I did not run Wine. No game files were used. — LocalFirst-AI |
|
Tested c0b821c (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: pass on Windows; one question for Wine
AI-assisted (Claude). |
ligmaSec
left a comment
There was a problem hiding this comment.
I reproduced the overlay abort @FaKL-Code suspected. I applied c0b821c to main at aa2988c, built file_system_test.exe with clang-cl 19 and the MSVC 14.52 CRT/STL, and ran it on Ubuntu 24.04 Wine 9.0. The first write-open created .gta6rt-copy and then Wine aborted on KERNEL32.dll.CopyFile2 before staging the file. With MSVC 14.44 or MinGW, the STL uses a different copy path, which explains the toolchain-dependent result.
Overlay staging patch, based on current main. It uses CopyFileW with overwrite enabled for the private staging file and preserves the existing cleanup and rename. With it applied alongside this PR, 170 checks passed on Wine 9.0, including the two-thread copy-up and staging cleanup. gta6rt and file_system_test both built through CMake. The linked binaries still list CopyFile2 with /OPT:NOREF, but the shim object no longer calls __std_fs_copy_file and Wine 9 completes the test.
I also hit a pre-cancel failure on Debian Wine 10.0 with and without the overlay patch. Both builds passed 169 of 170 checks. A direct CopyFile2 probe with *pfCancel = TRUE returned S_OK and created the destination. Wine 10.0's implementation explicitly leaves pfCancel unsupported, even though it exports CopyFile2. The forced fallback check passes. The pre-cancel check needs coverage on the Wine host-export path too.
AI-assisted. Synthetic filesystem fixtures only. These checks ran without a GPU.
|
I tested a patch for the Wine 10 cancellation failure from my earlier review. The patch checks a pre-set The branch combines
The patch covers cancellation requested before the copy begins. AI-assisted, using only synthetic fixtures. No GPU was needed. Native Windows testing is pending. |
|
@ligmaSec, here's the native Windows run you asked for. Tested
AI-assisted (Claude). |
Claimed in the coordination issue as: RT-237
What and why
The
CopyFile2shim (runtime/shims/file_system.cpp,copy_file2) called::CopyFile2directly. Wine 9's kernel32 and kernelbase don't export it, so Wine binds that static import to a stub that aborts the process ("Unimplemented function KERNEL32.dll.CopyFile2 called ... aborting"). Under Wine 9, or a Proton built on it, a title that callsCopyFile2is killed.ctest file_systemshows it: it aborts at itsCopyFile2check and runs into the 300 s timeout.pe_loader.cppandloader_tls_test.cppalready avoidCopyFile2for the same reason.CopyFile2is looked up once withGetProcAddress(kernelbase, then kernel32) and used where it exists, so Windows behaves exactly as before.CopyFileExW. The flags both calls define (FAIL_IF_EXISTS,RESTARTABLE,OPEN_SOURCE_FOR_WRITE,ALLOW_DECRYPTED_DESTINATION,COPY_SYMLINK,NO_BUFFERING) and thepfCancelflag are passed on. CopyFile2-only hints are dropped. ACOPYFILE2progress routine is not called (different signature and messages). Failures returnHRESULT_FROM_WIN32(GetLastError()), asCopyFile2does.docs/runtime_imports.mdsays so in theCopyFile*rules.The
GAME:/ overlay path mapping in front of it is unchanged.Tested
Cross-built on Linux with clang-cl 19 against xwin's MSVC CRT and Windows SDK 10.0.26100, run under Wine 9.0 (Ubuntu 24.04):
ctest -R file_systemonmain(f847748): aborts at theCopyFile2check, Timeout 300 s.HRESULT_FROM_WIN32(ERROR_FILE_EXISTS)), now through theCopyFileExWfallback.Not tested on Windows itself: there
GetProcAddressfinds the realCopyFile2, which is the same call as before. Not tested on a Wine or Proton that hasCopyFile2.Checklist
docs/design.md, with how it was confirmed. (No translator change.)AI-assisted (Claude Code). No game files used.
🤖 Generated with Claude Code