Patch from @bernhardu
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51813
``` 1016195.340:0114:0118:Call KERNEL32.GetFileType(00000014) ret=1022e621 1016195.340:0114:0118:Call ntdll.NtQueryVolumeInformationFile(00000014,0060f598,0060f590,00000008,00000004) ret=7b01f4a5 1016195.340:0114:0118:Ret ntdll.NtQueryVolumeInformationFile() retval=00000000 ret=7b01f4a5 1016195.340:0114:0118:Ret KERNEL32.GetFileType() retval=00000001 ret=1022e621 1016195.340:0114:0118:Call KERNEL32.GetFileInformationByHandle(00000014,0060f608) ret=1022e6ac 1016195.340:0114:0118:Call ntdll.NtQueryInformationFile(00000014,0060f508,0060f528,00000068,00000012) ret=7b01eacc 1016195.340:0114:0118:trace:file:NtQueryInformationFile (0x14,0x60f508,0x60f528,0x00000068,0x00000012) 1016195.340:0114:0118:Ret ntdll.NtQueryInformationFile() retval=c0000024 ret=7b01eacc 1016195.340:0114:0118:Call ntdll.RtlNtStatusToDosError(c0000024) ret=7b01eae3 1016195.340:0114:0118:Ret ntdll.RtlNtStatusToDosError() retval=00000006 ret=7b01eae3 1016195.340:0114:0118:Ret KERNEL32.GetFileInformationByHandle() retval=00000000 ret=1022e6ac ```
Allocation of the fd structure, fd->unix_name is set to NULL: ``` 1697 fd->unix_name = NULL; #0 alloc_fd_object () at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/server/fd.c:1697 #1 0x000056259dd386d8 in create_anonymous_fd (fd_user_ops=fd_user_ops@entry=0x56259dda4900 <file_fd_ops>, unix_fd=unix_fd@entry=28, user=user@entry=0x56259f42db70, options=options@entry=32) at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/server/fd.c:2074 #2 0x000056259dd3b477 in create_file_for_fd (fd=28, access=1074790400, sharing=sharing@entry=3) at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/server/file.c:152 #3 0x000056259dd3b874 in req_alloc_file_handle (req=0x56259f27b768, reply=0x7ffc518872e0) at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/server/file.c:730 #4 0x000056259dd594b3 in call_req_handler (thread=thread@entry=0x56259f27b620) at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/server/request.c:309 ```
Because unix_name is not set no file information get returned: ``` 2780 if (fd->unix_name) #0 req_get_handle_unix_name (req=<optimized out>, reply=0x7ffc518872e0) at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/server/fd.c:2780 #1 0x000056259dd594b3 in call_req_handler (thread=thread@entry=0x56259f432020) at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/server/request.c:309 ... #0 wine_server_call (req_ptr=0x62fac0) at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/dlls/ntdll/unix/server.c:286 #1 0xf7b98514 in server_get_unix_name (handle=handle@entry=0x14, unix_name=unix_name@entry=0x62fb94) at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/dlls/ntdll/unix/file.c:1776 #2 0xf7ba3b1f in NtQueryInformationFile (handle=0x14, io=0x60f568, ptr=0x60f588, len=104, class=FileAllInformation) at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/dlls/ntdll/unix/file.c:4177 #3 0xf7bbd679 in __wine_syscall_dispatcher () at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/dlls/ntdll/unix/signal_i386.c:153 ...
```
https://github.com/python/cpython/blob/99fcf1505218464c489d419d4500f126b6d6d...
https://github.com/python/cpython/blob/99fcf1505218464c489d419d4500f126b6d6d...
-- v2: kernelbase: Workaround for linux-side redirection.
From: Bernhard Ubelacker bernhardu@mailbox.org
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51813 ---- 1016195.340:0114:0118:Call KERNEL32.GetFileType(00000014) ret=1022e621 1016195.340:0114:0118:Call ntdll.NtQueryVolumeInformationFile(00000014,0060f598,0060f590,00000008,00000004) ret=7b01f4a5 1016195.340:0114:0118:Ret ntdll.NtQueryVolumeInformationFile() retval=00000000 ret=7b01f4a5 1016195.340:0114:0118:Ret KERNEL32.GetFileType() retval=00000001 ret=1022e621 1016195.340:0114:0118:Call KERNEL32.GetFileInformationByHandle(00000014,0060f608) ret=1022e6ac 1016195.340:0114:0118:Call ntdll.NtQueryInformationFile(00000014,0060f508,0060f528,00000068,00000012) ret=7b01eacc 1016195.340:0114:0118:trace:file:NtQueryInformationFile (0x14,0x60f508,0x60f528,0x00000068,0x00000012) 1016195.340:0114:0118:Ret ntdll.NtQueryInformationFile() retval=c0000024 ret=7b01eacc 1016195.340:0114:0118:Call ntdll.RtlNtStatusToDosError(c0000024) ret=7b01eae3 1016195.340:0114:0118:Ret ntdll.RtlNtStatusToDosError() retval=00000006 ret=7b01eae3 1016195.340:0114:0118:Ret KERNEL32.GetFileInformationByHandle() retval=00000000 ret=1022e6ac
Allocation of the fd structure, fd->unix_name is set to NULL: 1697 fd->unix_name = NULL;
Because unix_name is not set no file information get returned: 2780 if (fd->unix_name) ... ...
https://github.com/python/cpython/blob/99fcf1505218464c489d419d4500f126b6d6d... https://github.com/python/cpython/blob/99fcf1505218464c489d419d4500f126b6d6d... --- dlls/kernelbase/file.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c index ac04388acde..1126863def9 100644 --- a/dlls/kernelbase/file.c +++ b/dlls/kernelbase/file.c @@ -2929,6 +2929,12 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetFileInformationByHandle( HANDLE file, BY_HANDLE
status = NtQueryInformationFile( file, &io, &all_info, sizeof(all_info), FileAllInformation ); if (status == STATUS_BUFFER_OVERFLOW) status = STATUS_SUCCESS; + if (status == STATUS_OBJECT_TYPE_MISMATCH && GetFileType(file) == FILE_TYPE_DISK) + { + ERR("Workaround for redirection at unix side. Bug#51813\n"); + memset(info, 0, sizeof(*info)); + return TRUE; + } if (!set_ntstatus( status )) return FALSE;
info->dwFileAttributes = all_info.BasicInformation.FileAttributes;
On Thu Dec 1 10:13:15 2022 +0000, Gijs Vermeulen wrote:
@xantares If the patch is by someone else, you'd best set the patch author to that person. (`git commit --amend --author=name <email>`) An aside, could you put your name as your gitlab profile as well? It's listed as a requirement on the [wiki](https://wiki.winehq.org/Submitting_Patches#Check_your_Git_setup).
of course
This raises a couple of questions: - in the first place, python.exe fails, when running in Wine's shell console, as it would expect a FILE_TYPE_CHAR in that case. I wonder if this shouldn't be also fixed. - the change in GetFileInformationByHandle could encompass other HANDLE's type and return success instead of error. It could be tested that the handle is a console handle (eg. GetConsoleMode should succeed when handle is console handle).