Skip to content

Instantly share code, notes, and snippets.

@qsniyg
Last active June 24, 2021 01:22
Show Gist options
  • Save qsniyg/ec21d68f9407991a1043a71fa6ffd4cf to your computer and use it in GitHub Desktop.
Save qsniyg/ec21d68f9407991a1043a71fa6ffd4cf to your computer and use it in GitHub Desktop.
USVFS wine patch (included in wine 4.21+)
diff --git a/dlls/kernel32/file.c b/dlls/kernel32/file.c
index 2b6a13fc0d..6798ecc8ff 100644
--- a/dlls/kernel32/file.c
+++ b/dlls/kernel32/file.c
@@ -754,7 +754,7 @@ HANDLE WINAPI FindFirstFileExW( LPCWSTR filename, FINDEX_INFO_LEVELS level,
status = NtOpenFile( &info->handle, GENERIC_READ | SYNCHRONIZE, &attr, &io,
FILE_SHARE_READ | FILE_SHARE_WRITE,
- FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT );
+ FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT | FILE_OPEN_FOR_BACKUP_INTENT );
if (status != STATUS_SUCCESS)
{
@@ -801,7 +801,8 @@ HANDLE WINAPI FindFirstFileExW( LPCWSTR filename, FINDEX_INFO_LEVELS level,
}
info->data_len = io.Information;
- if (!has_wildcard || info->data_len < info->data_size - max_entry_size)
+ /* Disable this check because USVFS underflows data_len */
+ if (!has_wildcard /*|| info->data_len < info->data_size - max_entry_size*/)
{
if (has_wildcard) /* release unused buffer space */
HeapReAlloc( GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY,
@Claw256
Copy link

Claw256 commented Nov 13, 2019

So to apply this patch to wine, we save this gist as a file (e.g usvfs.patch), then we cd into the wine source location, then do patch -p1 < path/to/usvfs.patch, then build the wine source?

@qsniyg
Copy link
Author

qsniyg commented Nov 13, 2019

@spudnik1 Correct, although the latest wine (4.17?+) does have the first part of the patch (FILE_OPEN_FOR_BACKUP_INTENT) already applied, only the second is required.

@Claw256
Copy link

Claw256 commented Nov 13, 2019

@spudnik1 Correct, although the latest wine (4.17?+) does have the first part of the patch (FILE_OPEN_FOR_BACKUP_INTENT) already applied, only the second is required.

ok, thanks. If you leave the first part in, it should just be ignored while patching, correct?

@qsniyg
Copy link
Author

qsniyg commented Nov 13, 2019

@spudnik1 I believe it'll return an error unfortunately, so you might just want to patch the second one manually (search for and remove || info->data_len < info->data_size - max_entry_size in dlls/kernel32/file.c)

@jarrard
Copy link

jarrard commented Nov 23, 2019

Tried proton ge 4.19 which I think is based off wine4.19 and this patch is most definitely not in it. Will it ever be merged upstream or must be manually compile our own wine each time (or in this case the entire proton suite) ??

@qsniyg
Copy link
Author

qsniyg commented Nov 23, 2019

@jarrard
Copy link

jarrard commented Nov 23, 2019

Ok, could take a while to show up in releases. We will see.

I'll probably see if I can get this vagrant thing working and compile my own proton sometime.

@jarrard
Copy link

jarrard commented Jun 23, 2021

Is this merged? I've recently got back into Linux and am having these identical issues again.

@qsniyg
Copy link
Author

qsniyg commented Jun 23, 2021

Yes it is, what's the problem you're having?

@jarrard
Copy link

jarrard commented Jun 23, 2021

ModOrganizer2/modorganizer#372
08:38:40.723 [E] failed to hook CopyFile2: No Error (this is just a win10 error, its probably not important and doesn't appear when set to win7)
08:38:40.723 [E] failed to hook NtQueryDirectoryFileEx: No Error

Dotnet48 used, many versions proton-GE testing..
Tested with TKG 6.8, same issue.

Don't know what to think at this point after further testing.. usvfs is just not working for me in any scenario. Perhaps kernel 5.12.6-xanmod1 is to blame...Might wait until some other people do some testing.

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