From d452acf61b3fd3bf6e3b4d1b9704961f58f5bd3a Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Mon, 24 Aug 2020 21:21:59 -0500 Subject: [PATCH] Rebase against aaea13a128b76fa0076b8852187c7d10e5eb5d68. --- .../advapi32-Token_Integrity_Level/definition | 4 + ...t-for-hiding-wine-version-informatio.patch | 20 +- patches/ntdll-Hide_Wine_Exports/definition | 1 - ...upport-for-relative-symlink-creation.patch | 58 +++-- patches/ntdll-NtQueryVirtualMemory/definition | 4 +- ...mporary-signal-handler-during-proces.patch | 36 +-- .../0006-ntdll-Support-WRITECOPY-on-x64.patch | 14 +- patches/patchinstall.sh | 134 +--------- ...ate-syscall-thunks-for-Nt-functions-.patch | 244 ------------------ ...ub-implementation-of-Wow64Transition.patch | 31 +-- patches/wow64cpu-Wow64Transition/definition | 1 - staging/upstream-commit | 2 +- 12 files changed, 85 insertions(+), 464 deletions(-) delete mode 100644 patches/winebuild-pe_syscall_thunks/0003-ntdll-Also-generate-syscall-thunks-for-Nt-functions-.patch diff --git a/patches/advapi32-Token_Integrity_Level/definition b/patches/advapi32-Token_Integrity_Level/definition index 76031efe..99f8d51b 100644 --- a/patches/advapi32-Token_Integrity_Level/definition +++ b/patches/advapi32-Token_Integrity_Level/definition @@ -2,3 +2,7 @@ Fixes: [40613] Basic implementation for token integrity levels and UAC handling Fixes: [39262] Run explorer.exe as unevaluated process Depends: advapi32-CreateRestrictedToken Depends: Staging +# Broken due to ntdll.so <- ntdll.dll imports. This isn't particularly difficult +# to fix, but it was already broken for some more obscure reason, and the whole +# patch set needs to be rewritten anyway. +Disabled: true diff --git a/patches/ntdll-Hide_Wine_Exports/0001-ntdll-Add-support-for-hiding-wine-version-informatio.patch b/patches/ntdll-Hide_Wine_Exports/0001-ntdll-Add-support-for-hiding-wine-version-informatio.patch index bf653ca4..a56324d5 100644 --- a/patches/ntdll-Hide_Wine_Exports/0001-ntdll-Add-support-for-hiding-wine-version-informatio.patch +++ b/patches/ntdll-Hide_Wine_Exports/0001-ntdll-Add-support-for-hiding-wine-version-informatio.patch @@ -1,4 +1,4 @@ -From a569b1652595651e6b3a55c83b061f774cbb785f Mon Sep 17 00:00:00 2001 +From 2fafcf0fbf764a830604ae4d69d5edf724701b8f Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sat, 30 May 2015 02:23:15 +0200 Subject: [PATCH] ntdll: Add support for hiding wine version information from @@ -10,7 +10,7 @@ Subject: [PATCH] ntdll: Add support for hiding wine version information from 2 files changed, 103 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c -index 9a8f13901b2..3b72c5420ad 100644 +index 54d56f4e148..3157bc21fdb 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -76,6 +76,9 @@ static const WCHAR system_path[] = @@ -138,20 +138,20 @@ index 9a8f13901b2..3b72c5420ad 100644 { *address = proc; ret = STATUS_SUCCESS; -@@ -4048,6 +4143,8 @@ void __wine_process_init(void) +@@ -4009,6 +4104,8 @@ void __wine_process_init(void) + NtTerminateProcess( GetCurrentProcess(), status ); } - #endif + hidden_exports_init( wm->ldr.FullDllName.Buffer ); + - /* elevate process if necessary */ - status = RtlQueryInformationActivationContext( 0, NULL, 0, RunlevelInformationInActivationContext, - &runlevel, sizeof(runlevel), NULL ); + #ifndef _WIN64 + if (NtCurrentTeb64()) + { diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h -index 0603ee9c495..0d088ddd07f 100644 +index 63ceac42e94..18300cc4d9e 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h -@@ -128,6 +128,11 @@ void WINAPI LdrInitializeThunk(CONTEXT*,void**,ULONG_PTR,ULONG_PTR); +@@ -126,6 +126,11 @@ void WINAPI LdrInitializeThunk(CONTEXT*,void**,ULONG_PTR,ULONG_PTR); #define InterlockedCompareExchange64(dest,xchg,cmp) RtlInterlockedCompareExchange64(dest,xchg,cmp) #endif @@ -164,5 +164,5 @@ index 0603ee9c495..0d088ddd07f 100644 static inline void ascii_to_unicode( WCHAR *dst, const char *src, size_t len ) { -- -2.27.0 +2.28.0 diff --git a/patches/ntdll-Hide_Wine_Exports/definition b/patches/ntdll-Hide_Wine_Exports/definition index 3bd69ea0..e799d1a4 100644 --- a/patches/ntdll-Hide_Wine_Exports/definition +++ b/patches/ntdll-Hide_Wine_Exports/definition @@ -1,2 +1 @@ Fixes: [38656] Add support for hiding wine version information from applications -Depends: advapi32-Token_Integrity_Level diff --git a/patches/ntdll-Junction_Points/0010-ntdll-Add-support-for-relative-symlink-creation.patch b/patches/ntdll-Junction_Points/0010-ntdll-Add-support-for-relative-symlink-creation.patch index 17e91a36..fd2e3cfc 100644 --- a/patches/ntdll-Junction_Points/0010-ntdll-Add-support-for-relative-symlink-creation.patch +++ b/patches/ntdll-Junction_Points/0010-ntdll-Add-support-for-relative-symlink-creation.patch @@ -1,4 +1,4 @@ -From c3cc1222c92372b8f260618835e547910ba6a07d Mon Sep 17 00:00:00 2001 +From bcd9d5db2f28b626854ef463cc9615ccfc853b44 Mon Sep 17 00:00:00 2001 From: "Erich E. Hoover" Date: Thu, 11 Apr 2019 12:16:49 -0600 Subject: [PATCH] ntdll: Add support for relative symlink creation. @@ -6,15 +6,15 @@ Subject: [PATCH] ntdll: Add support for relative symlink creation. Signed-off-by: Erich E. Hoover --- dlls/ntdll/tests/file.c | 30 +++++++++++--- - dlls/ntdll/unix/file.c | 90 +++++++++++++++++++++++++++++++++++++---- + dlls/ntdll/unix/file.c | 92 +++++++++++++++++++++++++++++++++++++---- include/ntifs.h | 2 + - 3 files changed, 109 insertions(+), 13 deletions(-) + 3 files changed, 111 insertions(+), 13 deletions(-) diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c -index 6e4e90b4bbf..9e05270a25e 100644 +index 5352ff034b7..7e9b214eb63 100644 --- a/dlls/ntdll/tests/file.c +++ b/dlls/ntdll/tests/file.c -@@ -5205,7 +5205,8 @@ static void test_mailslot_name(void) +@@ -5142,7 +5142,8 @@ static void test_mailslot_name(void) CloseHandle( device ); } @@ -24,7 +24,7 @@ index 6e4e90b4bbf..9e05270a25e 100644 { static INT header_size = offsetof(REPARSE_DATA_BUFFER, GenericReparseBuffer); INT buffer_size, struct_size, data_size, string_len, prefix_len; -@@ -5223,7 +5224,7 @@ static INT build_reparse_buffer(const WCHAR *filename, ULONG tag, REPARSE_DATA_B +@@ -5160,7 +5161,7 @@ static INT build_reparse_buffer(const WCHAR *filename, ULONG tag, REPARSE_DATA_B default: return 0; } @@ -33,7 +33,7 @@ index 6e4e90b4bbf..9e05270a25e 100644 string_len = lstrlenW(&filename[prefix_len]); data_size = (prefix_len + 2 * string_len + 2) * sizeof(WCHAR); buffer_size = struct_size + data_size; -@@ -5243,6 +5244,7 @@ static INT build_reparse_buffer(const WCHAR *filename, ULONG tag, REPARSE_DATA_B +@@ -5180,6 +5181,7 @@ static INT build_reparse_buffer(const WCHAR *filename, ULONG tag, REPARSE_DATA_B buffer->SymbolicLinkReparseBuffer.SubstituteNameLength = (prefix_len + string_len) * sizeof(WCHAR); buffer->SymbolicLinkReparseBuffer.PrintNameOffset = (prefix_len + string_len + 1) * sizeof(WCHAR); buffer->SymbolicLinkReparseBuffer.PrintNameLength = string_len * sizeof(WCHAR); @@ -41,7 +41,7 @@ index 6e4e90b4bbf..9e05270a25e 100644 subst_dest = &buffer->SymbolicLinkReparseBuffer.PathBuffer[0]; print_dest = &buffer->SymbolicLinkReparseBuffer.PathBuffer[prefix_len + string_len + 1]; break; -@@ -5320,7 +5322,7 @@ static void test_reparse_points(void) +@@ -5257,7 +5259,7 @@ static void test_reparse_points(void) } dwret = NtQueryInformationFile(handle, &iosb, &old_attrib, sizeof(old_attrib), FileBasicInformation); ok(dwret == STATUS_SUCCESS, "Failed to get junction point folder's attributes (0x%x).\n", dwret); @@ -50,7 +50,7 @@ index 6e4e90b4bbf..9e05270a25e 100644 bret = DeviceIoControl(handle, FSCTL_SET_REPARSE_POINT, (LPVOID)buffer, buffer_len, NULL, 0, &dwret, 0); ok(bret, "Failed to create junction point! (0x%x)\n", GetLastError()); -@@ -5361,7 +5363,7 @@ static void test_reparse_points(void) +@@ -5298,7 +5300,7 @@ static void test_reparse_points(void) HeapFree(GetProcessHeap(), 0, buffer); handle = CreateFileW(reparse_path, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, 0); @@ -59,7 +59,7 @@ index 6e4e90b4bbf..9e05270a25e 100644 bret = DeviceIoControl(handle, FSCTL_SET_REPARSE_POINT, (LPVOID)buffer, buffer_len, NULL, 0, &dwret, 0); ok(bret, "Failed to create junction point! (0x%x)\n", GetLastError()); CloseHandle(handle); -@@ -5376,7 +5378,7 @@ static void test_reparse_points(void) +@@ -5313,7 +5315,7 @@ static void test_reparse_points(void) ok(bret, "Failed to create junction point target directory.\n"); handle = CreateFileW(reparse_path, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, 0); @@ -68,7 +68,7 @@ index 6e4e90b4bbf..9e05270a25e 100644 bret = DeviceIoControl(handle, FSCTL_SET_REPARSE_POINT, (LPVOID)buffer, buffer_len, NULL, 0, &dwret, 0); ok(bret, "Failed to create junction point! (0x%x)\n", GetLastError()); CloseHandle(handle); -@@ -5438,7 +5440,7 @@ static void test_reparse_points(void) +@@ -5375,7 +5377,7 @@ static void test_reparse_points(void) } dwret = NtQueryInformationFile(handle, &iosb, &old_attrib, sizeof(old_attrib), FileBasicInformation); ok(dwret == STATUS_SUCCESS, "Failed to get symlink folder's attributes (0x%x).\n", dwret); @@ -77,7 +77,7 @@ index 6e4e90b4bbf..9e05270a25e 100644 bret = DeviceIoControl(handle, FSCTL_SET_REPARSE_POINT, (LPVOID)buffer, buffer_len, NULL, 0, &dwret, 0); ok(bret, "Failed to create symlink! (0x%x)\n", GetLastError()); -@@ -5475,6 +5477,22 @@ static void test_reparse_points(void) +@@ -5412,6 +5414,22 @@ static void test_reparse_points(void) "Symlink folder's access time does not match.\n"); CloseHandle(handle); @@ -101,10 +101,10 @@ index 6e4e90b4bbf..9e05270a25e 100644 /* Cleanup */ pRtlFreeUnicodeString(&nameW); diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c -index 0c6426242e8..fcad9fd68bb 100644 +index 097adfb5572..9dd65de2de6 100644 --- a/dlls/ntdll/unix/file.c +++ b/dlls/ntdll/unix/file.c -@@ -5663,17 +5663,20 @@ static void ignore_server_ioctl_struct_holes( ULONG code, const void *in_buffer, +@@ -5651,17 +5651,20 @@ static void ignore_server_ioctl_struct_holes( ULONG code, const void *in_buffer, */ NTSTATUS FILE_CreateSymlink(HANDLE handle, REPARSE_DATA_BUFFER *buffer) { @@ -127,7 +127,7 @@ index 0c6426242e8..fcad9fd68bb 100644 int i; switch(buffer->ReparseTag) -@@ -5682,11 +5685,13 @@ NTSTATUS FILE_CreateSymlink(HANDLE handle, REPARSE_DATA_BUFFER *buffer) +@@ -5670,11 +5673,13 @@ NTSTATUS FILE_CreateSymlink(HANDLE handle, REPARSE_DATA_BUFFER *buffer) dest_len = buffer->MountPointReparseBuffer.SubstituteNameLength; offset = buffer->MountPointReparseBuffer.SubstituteNameOffset; dest = &buffer->MountPointReparseBuffer.PathBuffer[offset]; @@ -141,7 +141,7 @@ index 0c6426242e8..fcad9fd68bb 100644 break; default: return STATUS_NOT_IMPLEMENTED; -@@ -5698,8 +5703,64 @@ NTSTATUS FILE_CreateSymlink(HANDLE handle, REPARSE_DATA_BUFFER *buffer) +@@ -5686,8 +5691,66 @@ NTSTATUS FILE_CreateSymlink(HANDLE handle, REPARSE_DATA_BUFFER *buffer) if ((status = server_get_unix_name( handle, &unix_src ))) goto cleanup; src_allocated = TRUE; @@ -185,22 +185,24 @@ index 0c6426242e8..fcad9fd68bb 100644 + goto cleanup; + } + nt_path_tmp.Buffer = nt_path; -+ nt_path_tmp.Length = lstrlenW(nt_path) * sizeof(WCHAR); ++ nt_path_tmp.Length = wcslen(nt_path) * sizeof(WCHAR); + status = wine_nt_to_unix_file_name( &nt_path_tmp, unix_path, &unix_path_len, FALSE ); + if (status != STATUS_BUFFER_TOO_SMALL) break; + free( unix_path ); + } + /* append the destination */ -+ nt_dest.MaximumLength = dest_len + (lstrlenW( nt_path ) + 1) * sizeof(WCHAR); -+ nt_dest.Buffer = RtlAllocateHeap( GetProcessHeap(), 0, nt_dest.MaximumLength ); -+ lstrcpyW( nt_dest.Buffer, nt_path ); ++ nt_dest.MaximumLength = dest_len + (wcslen( nt_path ) + 1) * sizeof(WCHAR); ++ nt_dest.Buffer = malloc( nt_dest.MaximumLength ); ++ wcscpy( nt_dest.Buffer, nt_path ); + free( nt_path ); -+ memcpy( &nt_dest.Buffer[lstrlenW(nt_dest.Buffer)], dest, dest_len + sizeof(WCHAR)); -+ nt_dest.Length = lstrlenW( nt_dest.Buffer ) * sizeof(WCHAR); ++ memcpy( &nt_dest.Buffer[wcslen(nt_dest.Buffer)], dest, dest_len + sizeof(WCHAR)); ++ nt_dest.Length = wcslen( nt_dest.Buffer ) * sizeof(WCHAR); + } + else + { -+ RtlCreateUnicodeString( &nt_dest, dest ); ++ nt_dest.MaximumLength = (wcslen( dest ) + 1) * sizeof(WCHAR); ++ nt_dest.Buffer = malloc( nt_dest.MaximumLength ); ++ wcscpy( nt_dest.Buffer, dest ); + nt_dest.Length = dest_len; + } + nt_dest_allocated = TRUE; @@ -208,7 +210,7 @@ index 0c6426242e8..fcad9fd68bb 100644 for (;;) { unix_dest = malloc( unix_dest_len ); -@@ -5715,11 +5776,24 @@ NTSTATUS FILE_CreateSymlink(HANDLE handle, REPARSE_DATA_BUFFER *buffer) +@@ -5703,11 +5766,24 @@ NTSTATUS FILE_CreateSymlink(HANDLE handle, REPARSE_DATA_BUFFER *buffer) if (status != STATUS_SUCCESS && status != STATUS_NO_SUCH_FILE) goto cleanup; dest_allocated = TRUE; @@ -235,7 +237,7 @@ index 0c6426242e8..fcad9fd68bb 100644 for (i = 0; i < sizeof(ULONG)*8; i++) { if ((buffer->ReparseTag >> i) & 1) -@@ -5738,7 +5812,7 @@ NTSTATUS FILE_CreateSymlink(HANDLE handle, REPARSE_DATA_BUFFER *buffer) +@@ -5726,7 +5802,7 @@ NTSTATUS FILE_CreateSymlink(HANDLE handle, REPARSE_DATA_BUFFER *buffer) strcat( magic_dest, "." ); strcat( magic_dest, "/" ); } @@ -244,13 +246,13 @@ index 0c6426242e8..fcad9fd68bb 100644 /* Produce the link in a temporary location in the same folder */ strcpy( tmpdir, unix_src ); -@@ -5788,7 +5862,9 @@ NTSTATUS FILE_CreateSymlink(HANDLE handle, REPARSE_DATA_BUFFER *buffer) +@@ -5776,7 +5852,9 @@ NTSTATUS FILE_CreateSymlink(HANDLE handle, REPARSE_DATA_BUFFER *buffer) cleanup: if (tempdir_created) rmdir( tmpdir ); + if (path_allocated) free( unix_path ); if (dest_allocated) free( unix_dest ); -+ if (nt_dest_allocated) RtlFreeUnicodeString( &nt_dest ); ++ if (nt_dest_allocated) free( nt_dest.Buffer ); if (src_allocated) free( unix_src ); if (needs_close) close( dest_fd ); return status; @@ -266,5 +268,5 @@ index ab3273d3f81..0d02225bc4f 100644 + #endif /* __WINE_NTIFS_H */ -- -2.27.0 +2.28.0 diff --git a/patches/ntdll-NtQueryVirtualMemory/definition b/patches/ntdll-NtQueryVirtualMemory/definition index 45dd735c..2368120a 100644 --- a/patches/ntdll-NtQueryVirtualMemory/definition +++ b/patches/ntdll-NtQueryVirtualMemory/definition @@ -4,5 +4,5 @@ Depends: ntdll-NtDevicePath Depends: ntdll-ForceBottomUpAlloc Depends: ntdll-Junction_Points # This uses RtlDosPathNameToNtPathName_U (and RtlInitUnicodeString) from -# ntdll.so, and needs to stop. Defer this until after we have a conversation -# about volumes. \ No newline at end of file +# ntdll.so, and needs to stop. +Disabled: true diff --git a/patches/ntdll-WRITECOPY/0003-ntdll-Setup-a-temporary-signal-handler-during-proces.patch b/patches/ntdll-WRITECOPY/0003-ntdll-Setup-a-temporary-signal-handler-during-proces.patch index e82cfcc5..f3e0a1eb 100644 --- a/patches/ntdll-WRITECOPY/0003-ntdll-Setup-a-temporary-signal-handler-during-proces.patch +++ b/patches/ntdll-WRITECOPY/0003-ntdll-Setup-a-temporary-signal-handler-during-proces.patch @@ -1,4 +1,4 @@ -From d30ca787e91e5c6140689219ce372d6f0edb6da9 Mon Sep 17 00:00:00 2001 +From 56a7847900cca65126f586cb58f65ba46af203b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Sat, 4 Oct 2014 02:53:22 +0200 Subject: [PATCH] ntdll: Setup a temporary signal handler during process @@ -15,22 +15,22 @@ Subject: [PATCH] ntdll: Setup a temporary signal handler during process 7 files changed, 74 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c -index e7cc050ba9d..4e9fdfc7040 100644 +index 69ea69ad530..c5834cd58fa 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c -@@ -1706,6 +1706,7 @@ void __wine_main( int argc, char *argv[], char *envp[] ) +@@ -1649,6 +1649,7 @@ void __wine_main( int argc, char *argv[], char *envp[] ) #endif virtual_init(); + signal_init_early(); + load_ntdll(); - ntdll_module = load_ntdll(); - fixup_ntdll_imports( &__wine_spec_nt_header ); + init_environment( argc, argv, envp ); diff --git a/dlls/ntdll/unix/signal_arm.c b/dlls/ntdll/unix/signal_arm.c -index 175e86168a4..551d07c0598 100644 +index be8e5e4b735..1f01305f629 100644 --- a/dlls/ntdll/unix/signal_arm.c +++ b/dlls/ntdll/unix/signal_arm.c -@@ -921,6 +921,12 @@ void signal_init_process(void) +@@ -980,6 +980,12 @@ void signal_init_process(void) exit(1); } @@ -44,10 +44,10 @@ index 175e86168a4..551d07c0598 100644 /*********************************************************************** * init_thread_context diff --git a/dlls/ntdll/unix/signal_arm64.c b/dlls/ntdll/unix/signal_arm64.c -index 52f00323a02..0803d8e5a28 100644 +index 169f50985e9..ccdd438b62a 100644 --- a/dlls/ntdll/unix/signal_arm64.c +++ b/dlls/ntdll/unix/signal_arm64.c -@@ -1003,6 +1003,13 @@ void signal_init_process(void) +@@ -1080,6 +1080,13 @@ void signal_init_process(void) exit(1); } @@ -62,10 +62,10 @@ index 52f00323a02..0803d8e5a28 100644 * init_thread_context */ diff --git a/dlls/ntdll/unix/signal_i386.c b/dlls/ntdll/unix/signal_i386.c -index bc30dd34df8..06213fb2ebc 100644 +index bb11b50f8f7..6b5a5c6c82f 100644 --- a/dlls/ntdll/unix/signal_i386.c +++ b/dlls/ntdll/unix/signal_i386.c -@@ -1657,6 +1657,30 @@ static BOOL handle_interrupt( unsigned int interrupt, ucontext_t *sigcontext, vo +@@ -1815,6 +1815,30 @@ static BOOL handle_syscall_fault( ucontext_t *sigcontext, void *stack_ptr, } @@ -96,7 +96,7 @@ index bc30dd34df8..06213fb2ebc 100644 /********************************************************************** * segv_handler * -@@ -2215,6 +2239,34 @@ void signal_init_process(void) +@@ -2374,6 +2398,34 @@ void signal_init_process(void) exit(1); } @@ -132,10 +132,10 @@ index bc30dd34df8..06213fb2ebc 100644 /*********************************************************************** * init_thread_context diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c -index ef3fe864986..21c819aed3b 100644 +index 6b57d0cdb1b..db608b358ea 100644 --- a/dlls/ntdll/unix/signal_x86_64.c +++ b/dlls/ntdll/unix/signal_x86_64.c -@@ -2469,6 +2469,12 @@ void signal_init_process(void) +@@ -2636,6 +2636,12 @@ void signal_init_process(void) exit(1); } @@ -149,10 +149,10 @@ index ef3fe864986..21c819aed3b 100644 /*********************************************************************** * init_thread_context diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h -index b020256e36d..c5b2030f4b2 100644 +index b55eb571283..806abc21fb2 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h -@@ -230,6 +230,7 @@ extern NTSTATUS signal_alloc_thread( TEB *teb ) DECLSPEC_HIDDEN; +@@ -227,6 +227,7 @@ extern NTSTATUS signal_alloc_thread( TEB *teb ) DECLSPEC_HIDDEN; extern void signal_free_thread( TEB *teb ) DECLSPEC_HIDDEN; extern void signal_init_thread( TEB *teb ) DECLSPEC_HIDDEN; extern void signal_init_process(void) DECLSPEC_HIDDEN; @@ -161,10 +161,10 @@ index b020256e36d..c5b2030f4b2 100644 BOOL suspend, void *relay, void *thunk, TEB *teb ) DECLSPEC_HIDDEN; extern void DECLSPEC_NORETURN signal_exit_thread( int status, void (*func)(int) ) DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c -index fa46ec09668..65e54821195 100644 +index e3f2820de56..0d2dd6f019d 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c -@@ -2884,7 +2884,7 @@ NTSTATUS virtual_handle_fault( void *addr, DWORD err, void *stack ) +@@ -2886,7 +2886,7 @@ NTSTATUS virtual_handle_fault( void *addr, DWORD err, void *stack ) pthread_mutex_lock( &virtual_mutex ); /* no need for signal masking inside signal handler */ vprot = get_page_vprot( page ); diff --git a/patches/ntdll-WRITECOPY/0006-ntdll-Support-WRITECOPY-on-x64.patch b/patches/ntdll-WRITECOPY/0006-ntdll-Support-WRITECOPY-on-x64.patch index 86b8760d..a1f4ec8d 100644 --- a/patches/ntdll-WRITECOPY/0006-ntdll-Support-WRITECOPY-on-x64.patch +++ b/patches/ntdll-WRITECOPY/0006-ntdll-Support-WRITECOPY-on-x64.patch @@ -1,4 +1,4 @@ -From 9749f5941c2bc14e4b94dc0ca2cabf25c781d675 Mon Sep 17 00:00:00 2001 +From 153825fbb1dfc7e8624808681fd44f244b5c7c0e Mon Sep 17 00:00:00 2001 From: Andrew Wesie Date: Fri, 24 Apr 2020 14:55:15 -0500 Subject: [PATCH] ntdll: Support WRITECOPY on x64. @@ -10,13 +10,13 @@ Signed-off-by: Andrew Wesie 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c -index 870c0c7e258..e30f7c67ce5 100644 +index db608b358ea..741d0ebed5f 100644 --- a/dlls/ntdll/unix/signal_x86_64.c +++ b/dlls/ntdll/unix/signal_x86_64.c -@@ -2204,6 +2204,30 @@ static inline BOOL handle_interrupt( ucontext_t *sigcontext, EXCEPTION_RECORD *r - return TRUE; +@@ -2266,6 +2266,30 @@ static BOOL handle_syscall_fault( ucontext_t *sigcontext, EXCEPTION_RECORD *rec, } + +/********************************************************************** + * segv_handler_early + * @@ -44,7 +44,7 @@ index 870c0c7e258..e30f7c67ce5 100644 /********************************************************************** * segv_handler * -@@ -2578,6 +2602,23 @@ void signal_init_process(void) +@@ -2641,6 +2665,23 @@ void signal_init_process(void) */ void signal_init_early(void) { @@ -69,10 +69,10 @@ index 870c0c7e258..e30f7c67ce5 100644 /*********************************************************************** diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c -index 5ab87f1aa81..e708f3c44b0 100644 +index 21760152115..534f99a7064 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c -@@ -818,7 +818,7 @@ static int get_unix_prot( BYTE vprot ) +@@ -820,7 +820,7 @@ static int get_unix_prot( BYTE vprot ) if (vprot & VPROT_READ) prot |= PROT_READ; if (vprot & VPROT_WRITE) prot |= PROT_WRITE | PROT_READ; if (vprot & VPROT_EXEC) prot |= PROT_EXEC | PROT_READ; diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index cb6a8a1a..8c2cbc7e 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -52,7 +52,7 @@ usage() # Get the upstream commit sha upstream_commit() { - echo "13ea90d80f7275e1ad4f3fc3c1c75b68bdbefbb4" + echo "aaea13a128b76fa0076b8852187c7d10e5eb5d68" } # Show version information @@ -88,7 +88,6 @@ patch_enable_all () enable_Staging="$1" enable_advapi32_CreateRestrictedToken="$1" enable_advapi32_LsaLookupPrivilegeName="$1" - enable_advapi32_Token_Integrity_Level="$1" enable_api_ms_win_Stub_DLLs="$1" enable_atl_AtlAxDialogBox="$1" enable_bcrypt_ECDHSecretAgreement="$1" @@ -181,7 +180,6 @@ patch_enable_all () enable_ntdll_NtDevicePath="$1" enable_ntdll_NtQueryEaFile="$1" enable_ntdll_NtQuerySection="$1" - enable_ntdll_NtQueryVirtualMemory="$1" enable_ntdll_NtSetLdtEntries="$1" enable_ntdll_Pipe_SpecialCharacters="$1" enable_ntdll_ProcessQuotaLimits="$1" @@ -354,9 +352,6 @@ patch_enable () advapi32-LsaLookupPrivilegeName) enable_advapi32_LsaLookupPrivilegeName="$2" ;; - advapi32-Token_Integrity_Level) - enable_advapi32_Token_Integrity_Level="$2" - ;; api-ms-win-Stub_DLLs) enable_api_ms_win_Stub_DLLs="$2" ;; @@ -633,9 +628,6 @@ patch_enable () ntdll-NtQuerySection) enable_ntdll_NtQuerySection="$2" ;; - ntdll-NtQueryVirtualMemory) - enable_ntdll_NtQueryVirtualMemory="$2" - ;; ntdll-NtSetLdtEntries) enable_ntdll_NtSetLdtEntries="$2" ;; @@ -1451,13 +1443,6 @@ if test "$enable_ws2_32_TransmitFile" -eq 1; then enable_server_Desktop_Refcount=1 fi -if test "$enable_wow64cpu_Wow64Transition" -eq 1; then - if test "$enable_advapi32_Token_Integrity_Level" -gt 1; then - abort "Patchset advapi32-Token_Integrity_Level disabled, but wow64cpu-Wow64Transition depends on that." - fi - enable_advapi32_Token_Integrity_Level=1 -fi - if test "$enable_winex11_WM_WINDOWPOSCHANGING" -eq 1; then if test "$enable_winex11__NET_ACTIVE_WINDOW" -gt 1; then abort "Patchset winex11-_NET_ACTIVE_WINDOW disabled, but winex11-WM_WINDOWPOSCHANGING depends on that." @@ -1624,21 +1609,6 @@ if test "$enable_ntdll_Syscall_Emulation" -eq 1; then enable_winebuild_pe_syscall_thunks=1 fi -if test "$enable_ntdll_NtQueryVirtualMemory" -eq 1; then - if test "$enable_ntdll_ForceBottomUpAlloc" -gt 1; then - abort "Patchset ntdll-ForceBottomUpAlloc disabled, but ntdll-NtQueryVirtualMemory depends on that." - fi - if test "$enable_ntdll_Junction_Points" -gt 1; then - abort "Patchset ntdll-Junction_Points disabled, but ntdll-NtQueryVirtualMemory depends on that." - fi - if test "$enable_ntdll_NtDevicePath" -gt 1; then - abort "Patchset ntdll-NtDevicePath disabled, but ntdll-NtQueryVirtualMemory depends on that." - fi - enable_ntdll_ForceBottomUpAlloc=1 - enable_ntdll_Junction_Points=1 - enable_ntdll_NtDevicePath=1 -fi - if test "$enable_ntdll_NtDevicePath" -eq 1; then if test "$enable_ntdll_Pipe_SpecialCharacters" -gt 1; then abort "Patchset ntdll-Pipe_SpecialCharacters disabled, but ntdll-NtDevicePath depends on that." @@ -1657,13 +1627,6 @@ if test "$enable_ntdll_Junction_Points" -eq 1; then enable_ntdll_NtQueryEaFile=1 fi -if test "$enable_ntdll_Hide_Wine_Exports" -eq 1; then - if test "$enable_advapi32_Token_Integrity_Level" -gt 1; then - abort "Patchset advapi32-Token_Integrity_Level disabled, but ntdll-Hide_Wine_Exports depends on that." - fi - enable_advapi32_Token_Integrity_Level=1 -fi - if test "$enable_ntdll_Builtin_Prot" -eq 1; then if test "$enable_ntdll_WRITECOPY" -gt 1; then abort "Patchset ntdll-WRITECOPY disabled, but ntdll-Builtin_Prot depends on that." @@ -1741,17 +1704,6 @@ if test "$enable_nvapi_Stub_DLL" -eq 1; then enable_nvcuda_CUDA_Support=1 fi -if test "$enable_advapi32_Token_Integrity_Level" -eq 1; then - if test "$enable_Staging" -gt 1; then - abort "Patchset Staging disabled, but advapi32-Token_Integrity_Level depends on that." - fi - if test "$enable_advapi32_CreateRestrictedToken" -gt 1; then - abort "Patchset advapi32-CreateRestrictedToken disabled, but advapi32-Token_Integrity_Level depends on that." - fi - enable_Staging=1 - enable_advapi32_CreateRestrictedToken=1 -fi - # If autoupdate is enabled then create a tempfile to keep track of all patches if test "$enable_patchlist" -eq 1; then @@ -1874,48 +1826,6 @@ if test "$enable_advapi32_LsaLookupPrivilegeName" -eq 1; then ) >> "$patchlist" fi -# Patchset advapi32-Token_Integrity_Level -# | -# | This patchset has the following (direct or indirect) dependencies: -# | * Staging, advapi32-CreateRestrictedToken -# | -# | This patchset fixes the following Wine bugs: -# | * [#40613] Basic implementation for token integrity levels and UAC handling -# | * [#39262] Run explorer.exe as unevaluated process -# | -# | Modified files: -# | * configure.ac, dlls/advapi32/tests/Makefile.in, dlls/advapi32/tests/security.c, dlls/ntdll/loader.c, -# | dlls/ntdll/ntdll.spec, dlls/ntdll/ntdll_misc.h, dlls/ntdll/process.c, dlls/ntdll/unix/security.c, -# | dlls/shell32/shlexec.c, dlls/user32/win.c, programs/runas/Makefile.in, programs/runas/runas.c, programs/runas/runas.h, -# | programs/runas/runas.rc, server/process.c, server/process.h, server/protocol.def, server/security.h, server/token.c -# | -if test "$enable_advapi32_Token_Integrity_Level" -eq 1; then - patch_apply advapi32-Token_Integrity_Level/0001-advapi32-tests-Extend-security-label-token-integrity.patch - patch_apply advapi32-Token_Integrity_Level/0002-server-Implement-token-elevation-information.patch - patch_apply advapi32-Token_Integrity_Level/0003-server-Correctly-treat-zero-access-mask-in-duplicate.patch - patch_apply advapi32-Token_Integrity_Level/0004-server-Implement-token-integrity-level.patch - patch_apply advapi32-Token_Integrity_Level/0005-server-Use-all-group-attributes-in-create_token.patch - patch_apply advapi32-Token_Integrity_Level/0006-ntdll-Add-function-to-create-new-tokens-for-elevatio.patch - patch_apply advapi32-Token_Integrity_Level/0007-shell32-Implement-process-elevation-using-runas-verb.patch - patch_apply advapi32-Token_Integrity_Level/0008-ntdll-Implement-process-token-elevation-through-mani.patch - patch_apply advapi32-Token_Integrity_Level/0012-user32-Start-explorer.exe-using-limited-rights.patch - patch_apply advapi32-Token_Integrity_Level/0014-programs-runas-Basic-implementation-for-starting-pro.patch - patch_apply advapi32-Token_Integrity_Level/0015-ntdll-Add-semi-stub-for-TokenLinkedToken-info-class.patch - ( - printf '%s\n' '+ { "Michael Müller", "advapi32/tests: Extend security label / token integrity tests.", 1 },'; - printf '%s\n' '+ { "Michael Müller", "server: Implement token elevation information.", 1 },'; - printf '%s\n' '+ { "Michael Müller", "server: Correctly treat zero access mask in duplicate_token wineserver call.", 1 },'; - printf '%s\n' '+ { "Michael Müller", "server: Implement token integrity level.", 1 },'; - printf '%s\n' '+ { "Sebastian Lackner", "server: Use all group attributes in create_token.", 1 },'; - printf '%s\n' '+ { "Michael Müller", "ntdll: Add function to create new tokens for elevation purposes.", 1 },'; - printf '%s\n' '+ { "Michael Müller", "shell32: Implement process elevation using runas verb.", 1 },'; - printf '%s\n' '+ { "Michael Müller", "ntdll: Implement process token elevation through manifests.", 1 },'; - printf '%s\n' '+ { "Michael Müller", "user32: Start explorer.exe using limited rights.", 1 },'; - printf '%s\n' '+ { "Michael Müller", "programs/runas: Basic implementation for starting processes with a different trustlevel.", 1 },'; - printf '%s\n' '+ { "Sebastian Lackner", "ntdll: Add semi-stub for TokenLinkedToken info class.", 1 },'; - ) >> "$patchlist" -fi - # Patchset api-ms-win-Stub_DLLs # | # | Modified files: @@ -3659,9 +3569,6 @@ fi # Patchset ntdll-Hide_Wine_Exports # | -# | This patchset has the following (direct or indirect) dependencies: -# | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level -# | # | This patchset fixes the following Wine bugs: # | * [#38656] Add support for hiding wine version information from applications # | @@ -3842,37 +3749,6 @@ if test "$enable_ntdll_NtQuerySection" -eq 1; then ) >> "$patchlist" fi -# Patchset ntdll-NtQueryVirtualMemory -# | -# | This patchset has the following (direct or indirect) dependencies: -# | * ntdll-ForceBottomUpAlloc, ntdll-DOS_Attributes, ntdll-NtQueryEaFile, ntdll-Junction_Points, ntdll- -# | Pipe_SpecialCharacters, ntdll-NtDevicePath -# | -# | This patchset fixes the following Wine bugs: -# | * [#23999] Implement MemorySectionName class in NtQueryVirtualMemory -# | * [#27248] Implement K32GetMappedFileName -# | -# | Modified files: -# | * dlls/kernelbase/debug.c, dlls/ntdll/tests/info.c, dlls/ntdll/unix/file.c, dlls/ntdll/unix/unix_private.h, -# | dlls/ntdll/unix/virtual.c, dlls/psapi/tests/psapi_main.c, server/mapping.c, server/protocol.def -# | -if test "$enable_ntdll_NtQueryVirtualMemory" -eq 1; then - patch_apply ntdll-NtQueryVirtualMemory/0003-ntdll-Implement-NtQueryVirtualMemory-MemorySectionNa.patch - patch_apply ntdll-NtQueryVirtualMemory/0004-ntdll-tests-Add-tests-for-NtQueryVirtualMemory-Memor.patch - patch_apply ntdll-NtQueryVirtualMemory/0005-ntdll-tests-Add-test-to-ensure-section-name-is-full-.patch - patch_apply ntdll-NtQueryVirtualMemory/0006-ntdll-Allow-to-query-section-names-from-other-proces.patch - patch_apply ntdll-NtQueryVirtualMemory/0007-kernel32-Implement-K32GetMappedFileName.-v2.patch - patch_apply ntdll-NtQueryVirtualMemory/0008-ntdll-Resolve-drive-symlinks-before-returning-sectio.patch - ( - printf '%s\n' '+ { "Dmitry Timoshkov", "ntdll: Implement NtQueryVirtualMemory(MemorySectionName).", 3 },'; - printf '%s\n' '+ { "Dmitry Timoshkov", "ntdll/tests: Add tests for NtQueryVirtualMemory(MemorySectionName).", 1 },'; - printf '%s\n' '+ { "Sebastian Lackner", "ntdll/tests: Add test to ensure section name is full path.", 1 },'; - printf '%s\n' '+ { "Sebastian Lackner", "ntdll: Allow to query section names from other processes.", 2 },'; - printf '%s\n' '+ { "Dmitry Timoshkov", "kernel32: Implement K32GetMappedFileName.", 2 },'; - printf '%s\n' '+ { "Sebastian Lackner", "ntdll: Resolve drive symlinks before returning section name.", 1 },'; - ) >> "$patchlist" -fi - # Patchset ntdll-NtSetLdtEntries # | # | Modified files: @@ -3969,15 +3845,12 @@ fi # | * [#45650] chromium 32-bit sandbox expects different syscall thunks depending on Windows version # | # | Modified files: -# | * dlls/ntdll/ntdll.spec, dlls/ntdll/unix/loader.c, dlls/ntdll/unix/virtual.c, tools/winebuild/import.c, -# | tools/winebuild/spec32.c +# | * dlls/ntdll/unix/virtual.c, tools/winebuild/import.c # | if test "$enable_winebuild_pe_syscall_thunks" -eq 1; then patch_apply winebuild-pe_syscall_thunks/0002-winebuild-Call-__wine_syscall_dispatcher-through-the.patch - patch_apply winebuild-pe_syscall_thunks/0003-ntdll-Also-generate-syscall-thunks-for-Nt-functions-.patch ( printf '%s\n' '+ { "Paul Gofman", "winebuild: Call __wine_syscall_dispatcher through the fixed address.", 1 },'; - printf '%s\n' '+ { "Paul Gofman", "ntdll: Also generate syscall thunks for Nt functions not yet in the Unix part.", 1 },'; ) >> "$patchlist" fi @@ -6259,9 +6132,6 @@ fi # Patchset wow64cpu-Wow64Transition # | -# | This patchset has the following (direct or indirect) dependencies: -# | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level -# | # | This patchset fixes the following Wine bugs: # | * [#45567] League of Legends 8.12+ fails to start a game (anticheat engine, validation of WoW64 syscall dispatcher) # | diff --git a/patches/winebuild-pe_syscall_thunks/0003-ntdll-Also-generate-syscall-thunks-for-Nt-functions-.patch b/patches/winebuild-pe_syscall_thunks/0003-ntdll-Also-generate-syscall-thunks-for-Nt-functions-.patch deleted file mode 100644 index 59c4fc11..00000000 --- a/patches/winebuild-pe_syscall_thunks/0003-ntdll-Also-generate-syscall-thunks-for-Nt-functions-.patch +++ /dev/null @@ -1,244 +0,0 @@ -From 6ddc75bcb9bff473ff52717021c5287d426fce13 Mon Sep 17 00:00:00 2001 -From: Paul Gofman -Date: Tue, 14 Jul 2020 02:05:59 +0300 -Subject: [PATCH] ntdll: Also generate syscall thunks for Nt functions not yet - in the Unix part. - ---- - dlls/ntdll/ntdll.spec | 1 + - dlls/ntdll/unix/loader.c | 37 ++++++++++++++++++++++++ - tools/winebuild/import.c | 62 +++++++++++++++++++++++++++++----------- - tools/winebuild/spec32.c | 16 ++++++++++- - 4 files changed, 98 insertions(+), 18 deletions(-) - -diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec -index 79ec71ed91e0..b001a2fb2f91 100644 ---- a/dlls/ntdll/ntdll.spec -+++ b/dlls/ntdll/ntdll.spec -@@ -1586,6 +1586,7 @@ - @ cdecl __wine_set_unix_funcs(long ptr) - @ extern __wine_syscall_dispatcher - @ extern -arch=i386 __wine_ldt_copy -+@ extern pe_syscall_table - - # Debugging - @ cdecl -norelay __wine_dbg_get_channel_flags(ptr) -diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c -index d7aa088e1d4e..b95e1fb4de93 100644 ---- a/dlls/ntdll/unix/loader.c -+++ b/dlls/ntdll/unix/loader.c -@@ -788,6 +788,41 @@ static ULONG_PTR find_pe_export( HMODULE module, const IMAGE_EXPORT_DIRECTORY *e - return find_named_export( module, exports, (char *)name->Name ); - } - -+static void fixup_syscall_table(const IMAGE_EXPORT_DIRECTORY *ntdll_exports) -+{ -+ extern unsigned int syscall_count; -+ extern void *syscall_table[]; -+ unsigned int fixup_count; -+ void **pe_syscall_table; -+ unsigned int i; -+ -+ pe_syscall_table = (void **)find_named_export( ntdll_module, ntdll_exports, "pe_syscall_table" ); -+ -+ if (!pe_syscall_table) -+ { -+ ERR( "pe_syscall_table not found\n" ); -+ return; -+ } -+ -+ fixup_count = 0; -+ for (i = 0; i < syscall_count; ++i) -+ { -+ assert ( (syscall_table[i] == (void *)0xdeadbeef -+ && pe_syscall_table[i] && pe_syscall_table[i] != (void *)0xdeadcafe) -+ || (pe_syscall_table[i] == (void *)0xdeadcafe && syscall_table[i] -+ && syscall_table[i] != (void *)0xdeadbeef) ); -+ -+ if (syscall_table[i] == (void *)0xdeadbeef) -+ { -+ syscall_table[i] = pe_syscall_table[i]; -+ ++fixup_count; -+ } -+ } -+ -+ if (!fixup_count) -+ FIXME("No functions to fixup.\n"); -+} -+ - static void fixup_ntdll_imports( const IMAGE_NT_HEADERS *nt ) - { - const IMAGE_EXPORT_DIRECTORY *ntdll_exports = get_export_dir( ntdll_module ); -@@ -828,6 +863,8 @@ static void fixup_ntdll_imports( const IMAGE_NT_HEADERS *nt ) - thunk_list++; - } - -+ fixup_syscall_table(ntdll_exports); -+ - #define GET_FUNC(name) \ - if (!(p##name = (void *)find_named_export( ntdll_module, ntdll_exports, #name ))) \ - ERR( "%s not found\n", #name ) -diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c -index 094b9da0ccf5..229729386390 100644 ---- a/tools/winebuild/import.c -+++ b/tools/winebuild/import.c -@@ -563,7 +563,8 @@ static void check_undefined_exports( DLLSPEC *spec ) - spec->src_name, odp->lineno, odp->link_name ); - break; - default: -- if (!strcmp( odp->link_name, "__wine_syscall_dispatcher" )) break; -+ if (!strcmp( odp->link_name, "__wine_syscall_dispatcher" ) -+ || !strcmp( odp->link_name, "pe_syscall_table" )) break; - error( "%s:%d: external symbol '%s' is not a function\n", - spec->src_name, odp->lineno, odp->link_name ); - break; -@@ -1418,11 +1419,13 @@ void output_syscalls( DLLSPEC *spec ) - const unsigned int invalid_param = 0xc000000d; /* STATUS_INVALID_PARAMETER */ - int i, count; - ORDDEF **syscalls = NULL; -+ int is_ntdll = spec->dll_name && !strcmp(spec->dll_name, "ntdll"); - - for (i = count = 0; i < spec->nb_entry_points; i++) - { - ORDDEF *odp = &spec->entry_points[i]; -- if (!(odp->flags & FLAG_SYSCALL)) continue; -+ if (!(odp->flags & FLAG_SYSCALL) && (!is_ntdll -+ || (strncmp(odp->link_name, "Nt", 2) && strncmp(odp->link_name, "Zw", 2)))) continue; - if (!syscalls) syscalls = xmalloc( (spec->nb_entry_points - i) * sizeof(*syscalls) ); - syscalls[count++] = odp; - } -@@ -1560,25 +1563,56 @@ void output_syscalls( DLLSPEC *spec ) - } - output_cfi( ".cfi_endproc" ); - output_function_size( "__wine_syscall_dispatcher" ); -- - output( "\t.data\n" ); -+ -+ output( "\t.align %d\n", get_alignment( get_ptr_size() ) ); -+ output( "%s\n", asm_globl("syscall_count") ); -+ output( "\t.long %u\n", count ); -+ - output( "\t.align %d\n", get_alignment( get_ptr_size() ) ); -+ output( "%s\n", asm_globl("syscall_table") ); - output( ".Lsyscall_table:\n" ); - for (i = 0; i < count; i++) -- output( "\t%s %s\n", get_asm_ptr_keyword(), asm_name( get_link_name( syscalls[i] ))); -+ { -+ if (syscalls[i]->flags & FLAG_SYSCALL) -+ output( "\t%s %s\n", get_asm_ptr_keyword(), asm_name( get_link_name( syscalls[i] ))); -+ else -+ output( "\t%s 0xdeadbeef\n", get_asm_ptr_keyword()); -+ } - output( ".Lsyscall_args:\n" ); - for (i = 0; i < count; i++) - output( "\t.byte %u\n", get_args_size( syscalls[i] )); - return; - } - -+ output( "\t.data\n" ); -+ output( "\t.align %d\n", get_alignment( get_ptr_size() ) ); -+ output( "%s\n", asm_globl("pe_syscall_table") ); -+ output( ".Lpe_syscall_table:\n" ); -+ -+ for (i = 0; i < count; i++) -+ { -+ if (!(syscalls[i]->flags & FLAG_SYSCALL)) -+ output( "\t%s %s\n", get_asm_ptr_keyword(), asm_name( get_link_name( syscalls[i] ))); -+ else -+ output( "\t%s 0xdeadcafe\n", get_asm_ptr_keyword()); -+ } -+ output( "\t.text\n" ); -+ - for (i = 0; i < count; i++) - { - ORDDEF *odp = syscalls[i]; - const char *name = get_link_name(odp); -+ char exp_name[256]; -+ -+ if (odp->flags & FLAG_SYSCALL) -+ strcpy(exp_name, name); -+ else -+ sprintf(exp_name, "_syscall_%s", name); -+ - output( "\t.align %d\n", get_alignment(16) ); -- output( "\t%s\n", func_declaration(name) ); -- output( "%s\n", asm_globl(name) ); -+ output( "\t%s\n", func_declaration(exp_name) ); -+ output( "%s\n", asm_globl(exp_name) ); - output_cfi( ".cfi_startproc" ); - switch (target_cpu) - { -@@ -1613,16 +1647,10 @@ void output_syscalls( DLLSPEC *spec ) - output( "\t.byte 0xc3\n" ); /* ret */ - output( "\tjmp 1f\n" ); - output( "\t.byte 0xc3\n" ); /* ret */ -- if (target_platform == PLATFORM_WINDOWS || target_platform == PLATFORM_APPLE) -- { -- output( "1:\t.byte 0xff,0x14,0x25\n" ); /* call *(user_shared_data + 0x1000) */ -- output( "\t.long 0x7ffe1000\n" ); -- } -- else -- { -- output( "\tnop\n" ); -- output( "1:\tcallq *%s(%%rip)\n", asm_name("__wine_syscall_dispatcher") ); -- } -+ -+ output( "1:\t.byte 0xff,0x14,0x25\n" ); /* call *(user_shared_data + 0x1000) */ -+ output( "\t.long 0x7ffe1000\n" ); -+ - output( "\tret\n" ); - break; - case CPU_ARM: -@@ -1645,7 +1673,7 @@ void output_syscalls( DLLSPEC *spec ) - assert(0); - } - output_cfi( ".cfi_endproc" ); -- output_function_size( name ); -+ output_function_size( exp_name ); - } - - if (target_cpu == CPU_x86 && !UsePIC) -diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c -index c85249b2a961..7cfbe5389bdf 100644 ---- a/tools/winebuild/spec32.c -+++ b/tools/winebuild/spec32.c -@@ -394,6 +394,7 @@ void output_exports( DLLSPEC *spec ) - int nr_exports = get_exports_count( spec ); - const char *func_ptr = (target_platform == PLATFORM_WINDOWS) ? ".rva" : get_asm_ptr_keyword(); - const char *name; -+ int is_ntdll = spec->dll_name && !strcmp(spec->dll_name, "ntdll"); - - if (!nr_exports) return; - -@@ -445,6 +446,7 @@ void output_exports( DLLSPEC *spec ) - else if ((odp->flags & FLAG_IMPORT) && (target_cpu == CPU_x86 || target_cpu == CPU_x86_64)) - { - name = odp->name ? odp->name : odp->export_name; -+ - if (name) output( "\t%s %s_%s\n", func_ptr, asm_name("__wine_spec_imp"), name ); - else output( "\t%s %s_%u\n", func_ptr, asm_name("__wine_spec_imp"), i ); - needs_imports = 1; -@@ -455,7 +457,19 @@ void output_exports( DLLSPEC *spec ) - } - else - { -- output( "\t%s %s\n", func_ptr, asm_name( get_link_name( odp ))); -+ const char *name = get_link_name( odp ); -+ -+ if (!(odp->flags & FLAG_SYSCALL) && is_ntdll -+ && (!strncmp(name, "Nt", 2) || !strncmp(name, "Zw", 2))) -+ { -+ char sc_name[256]; -+ sprintf(sc_name, "_syscall_%s", name); -+ output( "\t%s %s\n", func_ptr, asm_name( sc_name )); -+ } -+ else -+ { -+ output( "\t%s %s\n", func_ptr, asm_name( name )); -+ } - } - break; - case TYPE_STUB: --- -2.26.2 - diff --git a/patches/wow64cpu-Wow64Transition/0002-ntdll-Add-a-stub-implementation-of-Wow64Transition.patch b/patches/wow64cpu-Wow64Transition/0002-ntdll-Add-a-stub-implementation-of-Wow64Transition.patch index ccf909cb..fac30063 100644 --- a/patches/wow64cpu-Wow64Transition/0002-ntdll-Add-a-stub-implementation-of-Wow64Transition.patch +++ b/patches/wow64cpu-Wow64Transition/0002-ntdll-Add-a-stub-implementation-of-Wow64Transition.patch @@ -1,18 +1,18 @@ -From 0413b624582ad1db0af0dbeddb41ef698a2d2504 Mon Sep 17 00:00:00 2001 +From 7b7d57b72af6bdc18e8aa18be772512501c378bb Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Wed, 8 Aug 2018 20:00:15 -0500 Subject: [PATCH] ntdll: Add a stub implementation of Wow64Transition. --- - dlls/ntdll/loader.c | 13 ++++++++++++- + dlls/ntdll/loader.c | 10 +++++++++- dlls/ntdll/ntdll.spec | 1 + - 2 files changed, 13 insertions(+), 1 deletion(-) + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c -index 1a76be3f0a6..b6c55071a15 100644 +index 54d56f4e148..d45d4ea6751 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c -@@ -3912,6 +3912,7 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) +@@ -3887,6 +3887,7 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) return TRUE; } @@ -20,30 +20,21 @@ index 1a76be3f0a6..b6c55071a15 100644 /*********************************************************************** * __wine_process_init -@@ -3921,13 +3922,16 @@ void __wine_process_init(void) - static const WCHAR ntdllW[] = {'\\','?','?','\\','C',':','\\','w','i','n','d','o','w','s','\\', - 's','y','s','t','e','m','3','2','\\', - 'n','t','d','l','l','.','d','l','l',0}; -+ static const WCHAR wow64cpuW[] = {'\\','?','?','\\','C',':','\\','w','i','n','d','o','w','s','\\', -+ 's','y','s','t','e','m','3','2','\\', -+ 'w','o','w','6','4','c','p','u','.','d','l','l',0}; - static const WCHAR kernel32W[] = {'\\','?','?','\\','C',':','\\','w','i','n','d','o','w','s','\\', - 's','y','s','t','e','m','3','2','\\', +@@ -3901,7 +3902,7 @@ void __wine_process_init(void) 'k','e','r','n','e','l','3','2','.','d','l','l',0}; void (WINAPI *kernel32_start_process)(LPTHREAD_START_ROUTINE,void*) = NULL; RTL_USER_PROCESS_PARAMETERS *params; - ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION runlevel; - WINE_MODREF *wm; + WINE_MODREF *wm, *wow64cpu_wm; NTSTATUS status; ANSI_STRING func_name; UNICODE_STRING nt_name; -@@ -3986,6 +3990,13 @@ void __wine_process_init(void) +@@ -3960,6 +3961,13 @@ void __wine_process_init(void) MESSAGE( "wine: could not load kernel32.dll, status %x\n", status ); NtTerminateProcess( GetCurrentProcess(), status ); } + -+ RtlInitUnicodeString( &nt_name, wow64cpuW ); ++ RtlInitUnicodeString( &nt_name, L"\\??\\C:\\windows\\system32\\wow64cpu.dll" ); + if ((status = load_builtin_dll( NULL, &nt_name, 0, 0, &wow64cpu_wm )) == STATUS_SUCCESS) + Wow64Transition = wow64cpu_wm->ldr.DllBase; + else @@ -53,10 +44,10 @@ index 1a76be3f0a6..b6c55071a15 100644 if ((status = LdrGetProcedureAddress( wm->ldr.DllBase, &func_name, 0, (void **)&kernel32_start_process )) != STATUS_SUCCESS) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec -index 850a40412d0..2734099f11f 100644 +index 9981c57bd7d..0a6959aee90 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec -@@ -1112,6 +1112,7 @@ +@@ -1113,6 +1113,7 @@ @ stdcall WinSqmIsOptedIn() @ stdcall WinSqmSetDWORD(ptr long long) @ stdcall WinSqmStartSession(ptr long long) @@ -65,5 +56,5 @@ index 850a40412d0..2734099f11f 100644 @ stdcall -private -syscall ZwAccessCheck(ptr long long ptr ptr ptr ptr ptr) NtAccessCheck @ stdcall -private -syscall ZwAccessCheckAndAuditAlarm(ptr long ptr ptr ptr long ptr long ptr ptr ptr) NtAccessCheckAndAuditAlarm -- -2.27.0 +2.28.0 diff --git a/patches/wow64cpu-Wow64Transition/definition b/patches/wow64cpu-Wow64Transition/definition index 2b682bf8..52022c4d 100644 --- a/patches/wow64cpu-Wow64Transition/definition +++ b/patches/wow64cpu-Wow64Transition/definition @@ -1,2 +1 @@ Fixes: [45567] League of Legends 8.12+ fails to start a game (anticheat engine, validation of WoW64 syscall dispatcher) -Depends: advapi32-Token_Integrity_Level diff --git a/staging/upstream-commit b/staging/upstream-commit index 14aaf312..d32d53fb 100644 --- a/staging/upstream-commit +++ b/staging/upstream-commit @@ -1 +1 @@ -ab94abb14f74fe863ae40dafc7a8301db22792fc +aaea13a128b76fa0076b8852187c7d10e5eb5d68