From 68bfc31be4f2017345c2fa7f561d732250192cc7 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Mon, 13 Jan 2020 12:40:36 +0300 Subject: [PATCH] Updated winebuild-Fake_Dlls patchset Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48410 --- patches/patchinstall.sh | 15 +- ...all-NtOpenFile-through-syscall-thunk.patch | 133 ++++++++++++++++++ 2 files changed, 142 insertions(+), 6 deletions(-) create mode 100644 patches/winebuild-Fake_Dlls/0011-ntdll-Call-NtOpenFile-through-syscall-thunk.patch diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index abb40b57..70cab247 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -3685,12 +3685,13 @@ fi # | Modified files: # | * dlls/dbghelp/cpu_i386.c, dlls/kernel32/tests/loader.c, dlls/krnl386.exe16/kernel.c, # | dlls/krnl386.exe16/kernel16_private.h, dlls/krnl386.exe16/ne_module.c, dlls/krnl386.exe16/ne_segment.c, -# | dlls/krnl386.exe16/task.c, dlls/krnl386.exe16/thunk.c, dlls/krnl386.exe16/wowthunk.c, dlls/ntdll/signal_i386.c, -# | dlls/ntdll/signal_x86_64.c, dlls/ntdll/tests/exception.c, dlls/ntdll/thread.c, dlls/system.drv16/system.c, -# | dlls/toolhelp.dll16/toolhelp.c, dlls/user.exe16/message.c, dlls/user.exe16/user.c, dlls/user.exe16/window.c, -# | include/winternl.h, libs/wine/loader.c, tools/winebuild/build.h, tools/winebuild/import.c, tools/winebuild/parser.c, -# | tools/winebuild/relay.c, tools/winebuild/res32.c, tools/winebuild/spec16.c, tools/winebuild/spec32.c, -# | tools/winebuild/utils.c +# | dlls/krnl386.exe16/task.c, dlls/krnl386.exe16/thunk.c, dlls/krnl386.exe16/wowthunk.c, dlls/ntdll/actctx.c, +# | dlls/ntdll/directory.c, dlls/ntdll/loader.c, dlls/ntdll/locale.c, dlls/ntdll/ntdll_misc.h, dlls/ntdll/path.c, +# | dlls/ntdll/process.c, dlls/ntdll/signal_i386.c, dlls/ntdll/signal_x86_64.c, dlls/ntdll/tests/exception.c, +# | dlls/ntdll/thread.c, dlls/system.drv16/system.c, dlls/toolhelp.dll16/toolhelp.c, dlls/user.exe16/message.c, +# | dlls/user.exe16/user.c, dlls/user.exe16/window.c, include/winternl.h, libs/wine/loader.c, tools/winebuild/build.h, +# | tools/winebuild/import.c, tools/winebuild/parser.c, tools/winebuild/relay.c, tools/winebuild/res32.c, +# | tools/winebuild/spec16.c, tools/winebuild/spec32.c, tools/winebuild/utils.c # | if test "$enable_winebuild_Fake_Dlls" -eq 1; then patch_apply winebuild-Fake_Dlls/0001-kernel32-tests-Add-basic-tests-for-fake-dlls.patch @@ -3703,6 +3704,7 @@ if test "$enable_winebuild_Fake_Dlls" -eq 1; then patch_apply winebuild-Fake_Dlls/0008-winebuild-Try-to-make-sure-RVA-matches-between-fake-.patch patch_apply winebuild-Fake_Dlls/0009-libs-wine-Use-same-file-alignment-for-fake-and-built.patch patch_apply winebuild-Fake_Dlls/0010-tools-winebuild-Add-syscall-thunks-for-64-bit.patch + patch_apply winebuild-Fake_Dlls/0011-ntdll-Call-NtOpenFile-through-syscall-thunk.patch ( printf '%s\n' '+ { "Michael Müller", "kernel32/tests: Add basic tests for fake dlls.", 1 },'; printf '%s\n' '+ { "Sebastian Lackner", "krnl386.exe16: Do not abuse WOW32Reserved field for 16-bit stack address.", 1 },'; @@ -3714,6 +3716,7 @@ if test "$enable_winebuild_Fake_Dlls" -eq 1; then printf '%s\n' '+ { "Michael Müller", "winebuild: Try to make sure RVA matches between fake and builtin DLLs.", 1 },'; printf '%s\n' '+ { "Michael Müller", "libs/wine: Use same file alignment for fake and builtin DLLs.", 1 },'; printf '%s\n' '+ { "Michael Müller", "tools/winebuild: Add syscall thunks for 64 bit.", 1 },'; + printf '%s\n' '+ { "Paul Gofman", "ntdll: Call NtOpenFile through syscall thunk.", 1 },'; ) >> "$patchlist" fi diff --git a/patches/winebuild-Fake_Dlls/0011-ntdll-Call-NtOpenFile-through-syscall-thunk.patch b/patches/winebuild-Fake_Dlls/0011-ntdll-Call-NtOpenFile-through-syscall-thunk.patch new file mode 100644 index 00000000..23f00923 --- /dev/null +++ b/patches/winebuild-Fake_Dlls/0011-ntdll-Call-NtOpenFile-through-syscall-thunk.patch @@ -0,0 +1,133 @@ +From cdfe27833233e77ad87e1552e3c550e99776bc90 Mon Sep 17 00:00:00 2001 +From: Paul Gofman +Date: Fri, 3 Jan 2020 17:39:08 +0300 +Subject: [PATCH] ntdll: Call NtOpenFile through syscall thunk. + +Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48410 +--- + dlls/ntdll/actctx.c | 4 ++-- + dlls/ntdll/directory.c | 2 +- + dlls/ntdll/loader.c | 2 +- + dlls/ntdll/locale.c | 4 ++-- + dlls/ntdll/ntdll_misc.h | 9 +++++++++ + dlls/ntdll/path.c | 2 +- + dlls/ntdll/process.c | 2 +- + 7 files changed, 17 insertions(+), 8 deletions(-) + +diff --git a/dlls/ntdll/actctx.c b/dlls/ntdll/actctx.c +index 9e7782c1ee..59e9671f9a 100644 +--- a/dlls/ntdll/actctx.c ++++ b/dlls/ntdll/actctx.c +@@ -2860,7 +2860,7 @@ static NTSTATUS open_nt_file( HANDLE *handle, UNICODE_STRING *name ) + attr.ObjectName = name; + attr.SecurityDescriptor = NULL; + attr.SecurityQualityOfService = NULL; +- return NtOpenFile( handle, GENERIC_READ | SYNCHRONIZE, &attr, &io, FILE_SHARE_READ, FILE_SYNCHRONOUS_IO_ALERT ); ++ return __syscall_NtOpenFile( handle, GENERIC_READ | SYNCHRONIZE, &attr, &io, FILE_SHARE_READ, FILE_SYNCHRONOUS_IO_ALERT ); + } + + static NTSTATUS get_module_filename( HMODULE module, UNICODE_STRING *str, unsigned int extra_len ) +@@ -3200,7 +3200,7 @@ static NTSTATUS lookup_winsxs(struct actctx_loader* acl, struct assembly_identit + attr.SecurityDescriptor = NULL; + attr.SecurityQualityOfService = NULL; + +- if (!NtOpenFile( &handle, GENERIC_READ | SYNCHRONIZE, &attr, &io, FILE_SHARE_READ | FILE_SHARE_WRITE, ++ if (!__syscall_NtOpenFile( &handle, GENERIC_READ | SYNCHRONIZE, &attr, &io, FILE_SHARE_READ | FILE_SHARE_WRITE, + FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT )) + { + sxs_ai = *ai; +diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c +index 2d96dd0537..9e61892a6b 100644 +--- a/dlls/ntdll/directory.c ++++ b/dlls/ntdll/directory.c +@@ -3026,7 +3026,7 @@ NTSTATUS DIR_get_unix_cwd( char **cwd ) + attr.SecurityDescriptor = NULL; + attr.SecurityQualityOfService = NULL; + +- status = NtOpenFile( &handle, SYNCHRONIZE, &attr, &io, 0, ++ status = __syscall_NtOpenFile( &handle, SYNCHRONIZE, &attr, &io, 0, + FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT ); + RtlFreeUnicodeString( &dirW ); + if (status != STATUS_SUCCESS) goto done; +diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c +index a59f970cd8..037e13e0fb 100644 +--- a/dlls/ntdll/loader.c ++++ b/dlls/ntdll/loader.c +@@ -2375,7 +2375,7 @@ static NTSTATUS open_dll_file( UNICODE_STRING *nt_name, WINE_MODREF **pwm, + attr.ObjectName = nt_name; + attr.SecurityDescriptor = NULL; + attr.SecurityQualityOfService = NULL; +- if ((status = NtOpenFile( &handle, GENERIC_READ | SYNCHRONIZE, &attr, &io, ++ if ((status = __syscall_NtOpenFile( &handle, GENERIC_READ | SYNCHRONIZE, &attr, &io, + FILE_SHARE_READ | FILE_SHARE_DELETE, + FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE ))) + { +diff --git a/dlls/ntdll/locale.c b/dlls/ntdll/locale.c +index b3717b3316..b1b749b475 100644 +--- a/dlls/ntdll/locale.c ++++ b/dlls/ntdll/locale.c +@@ -249,7 +249,7 @@ static NTSTATUS open_nls_data_file( ULONG type, ULONG id, HANDLE *file ) + return STATUS_NO_MEMORY; + valueW.Length = sprintfW( valueW.Buffer, pathfmtW, system_dir, name ) * sizeof(WCHAR); + InitializeObjectAttributes( &attr, &valueW, 0, 0, NULL ); +- status = NtOpenFile( file, GENERIC_READ, &attr, &io, FILE_SHARE_READ, FILE_SYNCHRONOUS_IO_ALERT ); ++ status = __syscall_NtOpenFile( file, GENERIC_READ, &attr, &io, FILE_SHARE_READ, FILE_SYNCHRONOUS_IO_ALERT ); + if (!status) TRACE( "found %s\n", debugstr_w( valueW.Buffer )); + RtlFreeUnicodeString( &valueW ); + if (status != STATUS_OBJECT_NAME_NOT_FOUND) return status; +@@ -274,7 +274,7 @@ static NTSTATUS open_nls_data_file( ULONG type, ULONG id, HANDLE *file ) + strcatW( valueW.Buffer, name ); + valueW.Length = strlenW(valueW.Buffer) * sizeof(WCHAR); + InitializeObjectAttributes( &attr, &valueW, 0, 0, NULL ); +- status = NtOpenFile( file, GENERIC_READ, &attr, &io, FILE_SHARE_READ, FILE_SYNCHRONOUS_IO_ALERT ); ++ status = __syscall_NtOpenFile( file, GENERIC_READ, &attr, &io, FILE_SHARE_READ, FILE_SYNCHRONOUS_IO_ALERT ); + if (!status) TRACE( "found %s\n", debugstr_w( valueW.Buffer )); + } + RtlFreeUnicodeString( &valueW ); +diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h +index a825366992..7a16803df1 100644 +--- a/dlls/ntdll/ntdll_misc.h ++++ b/dlls/ntdll/ntdll_misc.h +@@ -290,4 +290,13 @@ extern BOOL read_process_memory_stats(int unix_pid, VM_COUNTERS *pvmi) DECLSPEC_ + /* string functions */ + int __cdecl NTDLL_tolower( int c ); + int __cdecl _stricmp( LPCSTR str1, LPCSTR str2 ); ++ ++#if defined(__i386__) || defined(__x86_64__) ++NTSTATUS WINAPI __syscall_NtOpenFile( PHANDLE handle, ACCESS_MASK access, ++ POBJECT_ATTRIBUTES attr, PIO_STATUS_BLOCK io, ++ ULONG sharing, ULONG options ); ++#else ++#define __syscall_NtOpenFile NtOpenFile ++#endif ++ + #endif +diff --git a/dlls/ntdll/path.c b/dlls/ntdll/path.c +index 11483fabba..e23bb01978 100644 +--- a/dlls/ntdll/path.c ++++ b/dlls/ntdll/path.c +@@ -1025,7 +1025,7 @@ NTSTATUS WINAPI RtlSetCurrentDirectory_U(const UNICODE_STRING* dir) + attr.SecurityDescriptor = NULL; + attr.SecurityQualityOfService = NULL; + +- nts = NtOpenFile( &handle, FILE_TRAVERSE | SYNCHRONIZE, &attr, &io, FILE_SHARE_READ | FILE_SHARE_WRITE, ++ nts = __syscall_NtOpenFile( &handle, FILE_TRAVERSE | SYNCHRONIZE, &attr, &io, FILE_SHARE_READ | FILE_SHARE_WRITE, + FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT ); + if (nts != STATUS_SUCCESS) goto out; + +diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c +index 2965981c48..d480246452 100644 +--- a/dlls/ntdll/process.c ++++ b/dlls/ntdll/process.c +@@ -1396,7 +1396,7 @@ static NTSTATUS get_pe_file_info( UNICODE_STRING *path, ULONG attributes, + + memset( info, 0, sizeof(*info) ); + InitializeObjectAttributes( &attr, path, attributes, 0, 0 ); +- if ((status = NtOpenFile( handle, GENERIC_READ, &attr, &io, ++ if ((status = __syscall_NtOpenFile( handle, GENERIC_READ, &attr, &io, + FILE_SHARE_READ | FILE_SHARE_DELETE, FILE_SYNCHRONOUS_IO_NONALERT ))) + { + BOOL is_64bit; +-- +2.24.1 +