From 4e6a477acd32651dd571205786132666505aeb5b Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Thu, 30 Apr 2020 18:14:40 -0500 Subject: [PATCH] ntdll-User_Shared_Data: Replace with new wineserver-based implementation. --- ...eventfd-based-objects-for-semaphores.patch | 26 +- ...0001-ntdll-Fix-holes-in-ELF-mappings.patch | 32 +- patches/ntdll-Builtin_Prot/definition | 2 +- ...to-update-user-shared-data-into-a-se.patch | 79 ---- ...t-user_shared_data-timestamp-updates.patch | 132 +++++++ ...USER_SHARED_DATA-before-accessing-me.patch | 76 ---- ...d-USD-support-with-timestamp-updates.patch | 349 ++++++++++++++++++ ...ead-to-update-user_shared_data-time-.patch | 223 ----------- ...-updating-TickCount-in-user_shared_d.patch | 77 ---- patches/ntdll-User_Shared_Data/definition | 1 - ...andle-PAGE_WRITECOPY-protection.-try.patch | 20 +- patches/ntdll-WRITECOPY/definition | 1 - patches/patchinstall.sh | 280 +++++++------- ...e-wineserver-shared-memory-communica.patch | 14 +- patches/server-Shared_Memory/definition | 1 + ...ebuild-Add-syscall-thunks-for-64-bit.patch | 18 +- 16 files changed, 663 insertions(+), 668 deletions(-) delete mode 100644 patches/ntdll-User_Shared_Data/0001-ntdll-Move-code-to-update-user-shared-data-into-a-se.patch create mode 100644 patches/ntdll-User_Shared_Data/0001-ntdll-tests-Test-user_shared_data-timestamp-updates.patch delete mode 100644 patches/ntdll-User_Shared_Data/0002-ntoskrnl-Update-USER_SHARED_DATA-before-accessing-me.patch create mode 100644 patches/ntdll-User_Shared_Data/0002-server-Add-USD-support-with-timestamp-updates.patch delete mode 100644 patches/ntdll-User_Shared_Data/0003-ntdll-Create-thread-to-update-user_shared_data-time-.patch delete mode 100644 patches/ntdll-User_Shared_Data/0004-ntdll-tests-Test-updating-TickCount-in-user_shared_d.patch diff --git a/patches/eventfd_synchronization/0003-ntdll-Create-eventfd-based-objects-for-semaphores.patch b/patches/eventfd_synchronization/0003-ntdll-Create-eventfd-based-objects-for-semaphores.patch index 3b96fb01..eeef2e5c 100644 --- a/patches/eventfd_synchronization/0003-ntdll-Create-eventfd-based-objects-for-semaphores.patch +++ b/patches/eventfd_synchronization/0003-ntdll-Create-eventfd-based-objects-for-semaphores.patch @@ -1,4 +1,4 @@ -From 43baedbee4f25d88f8af30c216b888f5161e62df Mon Sep 17 00:00:00 2001 +From f75d03835dd04b2838a2cdcde64346efc26e9972 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Thu, 7 Jun 2018 20:29:21 -0500 Subject: [PATCH] ntdll: Create eventfd-based objects for semaphores. @@ -16,10 +16,10 @@ This patch break things, of course. That is fine. Its purpose is to prevent a Ma create mode 100644 dlls/ntdll/esync.h diff --git a/dlls/ntdll/Makefile.in b/dlls/ntdll/Makefile.in -index ed4bb94e4dc..b75e8308ac7 100644 +index 7971ef98cf0..2f26f0dc958 100644 --- a/dlls/ntdll/Makefile.in +++ b/dlls/ntdll/Makefile.in -@@ -15,6 +15,7 @@ C_SRCS = \ +@@ -17,6 +17,7 @@ C_SRCS = \ directory.c \ env.c \ error.c \ @@ -213,10 +213,10 @@ index 00000000000..1a88170cfc4 + * "server_fd_section" or something similar. */ +extern RTL_CRITICAL_SECTION fd_cache_section; diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h -index 11463146da0..a370256245c 100644 +index 177d4fd9e44..51c067bb8a0 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h -@@ -106,6 +106,7 @@ extern unsigned int server_queue_process_apc( HANDLE process, const apc_call_t * +@@ -136,6 +136,7 @@ extern unsigned int server_queue_process_apc( HANDLE process, const apc_call_t * extern int server_remove_fd_from_cache( HANDLE handle ) DECLSPEC_HIDDEN; extern int server_get_unix_fd( HANDLE handle, unsigned int access, int *unix_fd, int *needs_close, enum server_fd_type *type, unsigned int *options ) DECLSPEC_HIDDEN; @@ -225,18 +225,18 @@ index 11463146da0..a370256245c 100644 extern NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct object_attributes **ret, data_size_t *ret_len ) DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c -index 43dfe9303bb..46f1cae3f1f 100644 +index 973804967d1..c240bd1d9f8 100644 --- a/dlls/ntdll/server.c +++ b/dlls/ntdll/server.c -@@ -81,6 +81,7 @@ - #include "wine/server.h" +@@ -98,6 +98,7 @@ #include "wine/debug.h" #include "ntdll_misc.h" + #include "ddk/wdm.h" +#include "esync.h" WINE_DEFAULT_DEBUG_CHANNEL(server); WINE_DECLARE_DEBUG_CHANNEL(winediag); -@@ -120,14 +121,14 @@ sigset_t server_block_set; /* signals to block during server calls */ +@@ -170,14 +171,14 @@ sigset_t server_block_set; /* signals to block during server calls */ static int fd_socket = -1; /* socket to exchange file descriptors with the server */ static pid_t server_pid; @@ -253,7 +253,7 @@ index 43dfe9303bb..46f1cae3f1f 100644 /* atomically exchange a 64-bit value */ static inline LONG64 interlocked_xchg64( LONG64 *dest, LONG64 val ) -@@ -764,7 +765,7 @@ void CDECL wine_server_send_fd( int fd ) +@@ -919,7 +920,7 @@ void CDECL wine_server_send_fd( int fd ) * * Receive a file descriptor passed from the server. */ @@ -263,7 +263,7 @@ index 43dfe9303bb..46f1cae3f1f 100644 struct iovec vec; struct msghdr msghdr; diff --git a/dlls/ntdll/sync.c b/dlls/ntdll/sync.c -index 8974c7ed907..3939ce1ba78 100644 +index fbfb8f893ec..74dbde017e8 100644 --- a/dlls/ntdll/sync.c +++ b/dlls/ntdll/sync.c @@ -59,7 +59,9 @@ @@ -276,7 +276,7 @@ index 8974c7ed907..3939ce1ba78 100644 WINE_DEFAULT_DEBUG_CHANNEL(sync); -@@ -249,6 +251,9 @@ NTSTATUS WINAPI NtCreateSemaphore( OUT PHANDLE SemaphoreHandle, +@@ -259,6 +261,9 @@ NTSTATUS WINAPI NtCreateSemaphore( OUT PHANDLE SemaphoreHandle, if (MaximumCount <= 0 || InitialCount < 0 || InitialCount > MaximumCount) return STATUS_INVALID_PARAMETER; @@ -287,5 +287,5 @@ index 8974c7ed907..3939ce1ba78 100644 SERVER_START_REQ( create_semaphore ) -- -2.20.1 +2.26.2 diff --git a/patches/ntdll-Builtin_Prot/0001-ntdll-Fix-holes-in-ELF-mappings.patch b/patches/ntdll-Builtin_Prot/0001-ntdll-Fix-holes-in-ELF-mappings.patch index acd1c65b..cef9bed6 100644 --- a/patches/ntdll-Builtin_Prot/0001-ntdll-Fix-holes-in-ELF-mappings.patch +++ b/patches/ntdll-Builtin_Prot/0001-ntdll-Fix-holes-in-ELF-mappings.patch @@ -1,7 +1,7 @@ -From 7c2a302a95f6be16dbb5f6b3379e57d411a5310a Mon Sep 17 00:00:00 2001 +From ce12fa75ca18eeea3f0ec53788353d07ec683e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Thu, 1 Jun 2017 06:04:53 +0200 -Subject: ntdll: Fix holes in ELF mappings. (v2) +Subject: [PATCH] ntdll: Fix holes in ELF mappings. (v2) Based on a patch by Andrew Wesie. --- @@ -10,13 +10,14 @@ Based on a patch by Andrew Wesie. 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index 53db698..f1869be 100644 +index 6cb47f2cae8..2ba116c4e92 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c -@@ -429,6 +429,16 @@ static inline BOOL is_write_watch_range( const void *addr, size_t size ) +@@ -485,6 +485,16 @@ static inline BOOL is_write_watch_range( const void *addr, size_t size ) + } - /*********************************************************************** ++/*********************************************************************** + * is_system_range + */ +static inline BOOL is_system_range( const void *addr, size_t size ) @@ -26,13 +27,12 @@ index 53db698..f1869be 100644 +} + + -+/*********************************************************************** + /*********************************************************************** * find_view_range * - * Find the first view overlapping at least part of the specified range. -@@ -2047,6 +2057,19 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) - if (VIRTUAL_GetUnixProt( get_page_vprot( page )) & PROT_READ) ret = STATUS_SUCCESS; - else update_shared_data = FALSE; +@@ -2386,6 +2396,19 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) + /* ignore fault if page is writable now */ + if (VIRTUAL_GetUnixProt( get_page_vprot( page )) & PROT_WRITE) ret = STATUS_SUCCESS; } + else if (!err && (VIRTUAL_GetUnixProt( vprot ) & PROT_READ) && is_system_range( page, page_size )) + { @@ -48,13 +48,13 @@ index 53db698..f1869be 100644 + set_page_vprot_bits( page, page_size, 0, VPROT_READ | VPROT_EXEC ); + } server_leave_uninterrupted_section( &csVirtual, &sigset ); - - if (update_shared_data) + return ret; + } diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c -index e61cf02..6e98754 100644 +index eb52fc690cf..178f5605a23 100644 --- a/dlls/psapi/tests/psapi_main.c +++ b/dlls/psapi/tests/psapi_main.c -@@ -196,6 +196,7 @@ todo_wine +@@ -195,6 +195,7 @@ todo_wine static void test_GetModuleInformation(void) { HMODULE hMod = GetModuleHandleA(NULL); @@ -62,7 +62,7 @@ index e61cf02..6e98754 100644 MODULEINFO info; DWORD ret; -@@ -215,10 +216,21 @@ static void test_GetModuleInformation(void) +@@ -214,10 +215,21 @@ static void test_GetModuleInformation(void) GetModuleInformation(hpQV, hMod, &info, sizeof(info)-1); ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected error=ERROR_INSUFFICIENT_BUFFER but got %d\n", GetLastError()); @@ -86,5 +86,5 @@ index e61cf02..6e98754 100644 static BOOL check_with_margin(SIZE_T perf, SIZE_T sysperf, int margin) -- -2.7.4 +2.26.2 diff --git a/patches/ntdll-Builtin_Prot/definition b/patches/ntdll-Builtin_Prot/definition index ce2fa566..226c297c 100644 --- a/patches/ntdll-Builtin_Prot/definition +++ b/patches/ntdll-Builtin_Prot/definition @@ -1,2 +1,2 @@ Fixes: [44650] Fix holes in ELF mappings -Depends: ntdll-User_Shared_Data +Depends: ntdll-WRITECOPY diff --git a/patches/ntdll-User_Shared_Data/0001-ntdll-Move-code-to-update-user-shared-data-into-a-se.patch b/patches/ntdll-User_Shared_Data/0001-ntdll-Move-code-to-update-user-shared-data-into-a-se.patch deleted file mode 100644 index db424a61..00000000 --- a/patches/ntdll-User_Shared_Data/0001-ntdll-Move-code-to-update-user-shared-data-into-a-se.patch +++ /dev/null @@ -1,79 +0,0 @@ -From cfc04e8d11f8ed0cc7a7a0097c0ae888f1222f92 Mon Sep 17 00:00:00 2001 -From: Sebastian Lackner -Date: Wed, 26 Nov 2014 10:46:09 +0100 -Subject: [PATCH] ntdll: Move code to update user shared data into a separate - function. - ---- - dlls/ntdll/ntdll.spec | 3 +++ - dlls/ntdll/thread.c | 28 +++++++++++++++++++++------- - 2 files changed, 24 insertions(+), 7 deletions(-) - -diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec -index c50e83b5aa7..97cb16d4c3a 100644 ---- a/dlls/ntdll/ntdll.spec -+++ b/dlls/ntdll/ntdll.spec -@@ -1591,3 +1591,6 @@ - # Filesystem - @ cdecl wine_nt_to_unix_file_name(ptr ptr long long) - @ cdecl wine_unix_to_nt_file_name(ptr ptr) -+ -+# User shared data -+@ cdecl __wine_user_shared_data() -diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c -index 78c18bc2d84..cd9cd1b9754 100644 ---- a/dlls/ntdll/thread.c -+++ b/dlls/ntdll/thread.c -@@ -275,7 +275,6 @@ TEB *thread_init(void) - TEB *teb; - void *addr; - SIZE_T size; -- LARGE_INTEGER now; - NTSTATUS status; - struct ntdll_thread_data *thread_data; - -@@ -351,7 +350,26 @@ TEB *thread_init(void) - init_paths(); - set_process_name( __wine_main_argc, __wine_main_argv ); - -- /* initialize time values in user_shared_data */ -+ /* initialize user_shared_data */ -+ __wine_user_shared_data(); -+ fill_cpu_info(); -+ -+ virtual_get_system_info( &sbi ); -+ user_shared_data->NumberOfPhysicalPages = sbi.MmNumberOfPhysicalPages; -+ -+ return teb; -+} -+ -+ -+ -+/************************************************************************** -+ * __wine_user_shared_data (NTDLL.@) -+ * -+ * Update user shared data and return the address of the structure. -+ */ -+BYTE* CDECL __wine_user_shared_data(void) -+{ -+ LARGE_INTEGER now; - NtQuerySystemTime( &now ); - user_shared_data->SystemTime.LowPart = now.u.LowPart; - user_shared_data->SystemTime.High1Time = user_shared_data->SystemTime.High2Time = now.u.HighPart; -@@ -359,12 +377,8 @@ TEB *thread_init(void) - user_shared_data->u.TickCount.High2Time = user_shared_data->u.TickCount.High1Time; - user_shared_data->TickCountLowDeprecated = user_shared_data->u.TickCount.LowPart; - user_shared_data->TickCountMultiplier = 1 << 24; -- fill_cpu_info(); - -- virtual_get_system_info( &sbi ); -- user_shared_data->NumberOfPhysicalPages = sbi.MmNumberOfPhysicalPages; -- -- return teb; -+ return (BYTE *)user_shared_data; - } - - BOOL read_process_memory_stats(int unix_pid, VM_COUNTERS *pvmi) --- -2.26.2 - diff --git a/patches/ntdll-User_Shared_Data/0001-ntdll-tests-Test-user_shared_data-timestamp-updates.patch b/patches/ntdll-User_Shared_Data/0001-ntdll-tests-Test-user_shared_data-timestamp-updates.patch new file mode 100644 index 00000000..ec6ffcf8 --- /dev/null +++ b/patches/ntdll-User_Shared_Data/0001-ntdll-tests-Test-user_shared_data-timestamp-updates.patch @@ -0,0 +1,132 @@ +From 69d23a66b69e6953035cfe02c4268f4bcfc0fb81 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?R=C3=A9mi=20Bernon?= +Date: Thu, 30 Apr 2020 18:58:58 +0200 +Subject: [PATCH] ntdll/tests: Test user_shared_data timestamp updates. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Rémi Bernon +--- + dlls/ntdll/tests/time.c | 78 +++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 78 insertions(+) + +diff --git a/dlls/ntdll/tests/time.c b/dlls/ntdll/tests/time.c +index 5382a952d8d..fe71d4458c0 100644 +--- a/dlls/ntdll/tests/time.c ++++ b/dlls/ntdll/tests/time.c +@@ -18,7 +18,9 @@ + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + ++#define NONAMELESSUNION + #include "ntdll_test.h" ++#include "ddk/wdm.h" + + #define TICKSPERSEC 10000000 + #define TICKSPERMSEC 10000 +@@ -29,6 +31,7 @@ static VOID (WINAPI *pRtlTimeFieldsToTime)( PTIME_FIELDS TimeFields, PLARGE_IN + static NTSTATUS (WINAPI *pNtQueryPerformanceCounter)( LARGE_INTEGER *counter, LARGE_INTEGER *frequency ); + static NTSTATUS (WINAPI *pRtlQueryTimeZoneInformation)( RTL_TIME_ZONE_INFORMATION *); + static NTSTATUS (WINAPI *pRtlQueryDynamicTimeZoneInformation)( RTL_DYNAMIC_TIME_ZONE_INFORMATION *); ++static BOOL (WINAPI *pRtlQueryUnbiasedInterruptTime)( ULONGLONG *time ); + + static const int MonthLengths[2][12] = + { +@@ -153,6 +156,79 @@ static void test_RtlQueryTimeZoneInformation(void) + wine_dbgstr_w(tzinfo.DaylightName)); + } + ++static ULONGLONG read_ksystem_time(volatile KSYSTEM_TIME *time) ++{ ++ ULONGLONG high, low; ++ do ++ { ++ high = time->High1Time; ++ low = time->LowPart; ++ } ++ while (high != time->High2Time); ++ return high << 32 | low; ++} ++ ++static void test_user_shared_data_time(void) ++{ ++ KSHARED_USER_DATA *user_shared_data = (void *)0x7ffe0000; ++ ULONGLONG t1, t2, t3; ++ int i = 0; ++ ++ i = 0; ++ do ++ { ++ t1 = GetTickCount(); ++ if (user_shared_data->NtMajorVersion <= 5 && user_shared_data->NtMinorVersion <= 1) ++ t2 = ((ULONG64)user_shared_data->TickCountLowDeprecated * user_shared_data->TickCountMultiplier) >> 24; ++ else ++ t2 = (read_ksystem_time(&user_shared_data->u.TickCount) * user_shared_data->TickCountMultiplier) >> 24; ++ t3 = GetTickCount(); ++ } while(t3 < t1 && i++ < 1); /* allow for wrap, but only once */ ++ ++ ok(t1 <= t2, "USD TickCount / GetTickCount are out of order: %s %s\n", ++ wine_dbgstr_longlong(t1), wine_dbgstr_longlong(t2)); ++ todo_wine ++ ok(t2 <= t3, "USD TickCount / GetTickCount are out of order: %s %s\n", ++ wine_dbgstr_longlong(t2), wine_dbgstr_longlong(t3)); ++ ++ i = 0; ++ do ++ { ++ LARGE_INTEGER system_time; ++ NtQuerySystemTime(&system_time); ++ t1 = system_time.QuadPart; ++ t2 = read_ksystem_time(&user_shared_data->SystemTime); ++ NtQuerySystemTime(&system_time); ++ t3 = system_time.QuadPart; ++ } while(t3 < t1 && i++ < 1); /* allow for wrap, but only once */ ++ ++ todo_wine ++ ok(t1 <= t2, "USD SystemTime / NtQuerySystemTime are out of order %s %s\n", ++ wine_dbgstr_longlong(t1), wine_dbgstr_longlong(t2)); ++ ok(t2 <= t3, "USD SystemTime / NtQuerySystemTime are out of order %s %s\n", ++ wine_dbgstr_longlong(t2), wine_dbgstr_longlong(t3)); ++ ++ if (!pRtlQueryUnbiasedInterruptTime) ++ win_skip("skipping RtlQueryUnbiasedInterruptTime tests\n"); ++ else ++ { ++ i = 0; ++ do ++ { ++ pRtlQueryUnbiasedInterruptTime(&t1); ++ t2 = read_ksystem_time(&user_shared_data->InterruptTime); ++ pRtlQueryUnbiasedInterruptTime(&t3); ++ } while(t3 < t1 && i++ < 1); /* allow for wrap, but only once */ ++ ++ todo_wine ++ ok(t1 <= t2, "USD InterruptTime / RtlQueryUnbiasedInterruptTime are out of order %s %s\n", ++ wine_dbgstr_longlong(t1), wine_dbgstr_longlong(t2)); ++ ok(t2 <= t3 || broken(t2 == t3 + 82410089070) /* w864 has some weird offset on testbot */, ++ "USD InterruptTime / RtlQueryUnbiasedInterruptTime are out of order %s %s\n", ++ wine_dbgstr_longlong(t2), wine_dbgstr_longlong(t3)); ++ } ++} ++ + START_TEST(time) + { + HMODULE mod = GetModuleHandleA("ntdll.dll"); +@@ -163,6 +239,7 @@ START_TEST(time) + (void *)GetProcAddress(mod, "RtlQueryTimeZoneInformation"); + pRtlQueryDynamicTimeZoneInformation = + (void *)GetProcAddress(mod, "RtlQueryDynamicTimeZoneInformation"); ++ pRtlQueryUnbiasedInterruptTime = (void *)GetProcAddress(mod, "RtlQueryUnbiasedInterruptTime"); + + if (pRtlTimeToTimeFields && pRtlTimeFieldsToTime) + test_pRtlTimeToTimeFields(); +@@ -170,4 +247,5 @@ START_TEST(time) + win_skip("Required time conversion functions are not available\n"); + test_NtQueryPerformanceCounter(); + test_RtlQueryTimeZoneInformation(); ++ test_user_shared_data_time(); + } +-- +2.26.2 + diff --git a/patches/ntdll-User_Shared_Data/0002-ntoskrnl-Update-USER_SHARED_DATA-before-accessing-me.patch b/patches/ntdll-User_Shared_Data/0002-ntoskrnl-Update-USER_SHARED_DATA-before-accessing-me.patch deleted file mode 100644 index b4683cae..00000000 --- a/patches/ntdll-User_Shared_Data/0002-ntoskrnl-Update-USER_SHARED_DATA-before-accessing-me.patch +++ /dev/null @@ -1,76 +0,0 @@ -From 9e1ef78fd1ba5fbdd660d2d9ee735f811c65cf9a Mon Sep 17 00:00:00 2001 -From: Sebastian Lackner -Date: Fri, 19 Jun 2015 15:57:14 +0200 -Subject: [PATCH] ntoskrnl: Update USER_SHARED_DATA before accessing memory. - ---- - dlls/ntoskrnl.exe/instr.c | 23 +++++------------------ - 1 file changed, 5 insertions(+), 18 deletions(-) - -diff --git a/dlls/ntoskrnl.exe/instr.c b/dlls/ntoskrnl.exe/instr.c -index d5d197de35..68112506db 100644 ---- a/dlls/ntoskrnl.exe/instr.c -+++ b/dlls/ntoskrnl.exe/instr.c -@@ -484,8 +484,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(int); - #define SIB_INDEX( sib, rex ) (((sib) >> 3) & 7) | (((rex) & REX_X) ? 8 : 0) - #define SIB_BASE( sib, rex ) (((sib) & 7) | (((rex) & REX_B) ? 8 : 0)) - --/* keep in sync with dlls/ntdll/thread.c:thread_init */ --static const BYTE *wine_user_shared_data = (BYTE *)0x7ffe0000; -+extern BYTE* CDECL __wine_user_shared_data(void); - static const BYTE *user_shared_data = (BYTE *)0xfffff78000000000; - - static inline DWORD64 *get_int_reg( CONTEXT *context, int index ) -@@ -595,15 +594,6 @@ static void fake_syscall_function(void) - } - - --static void update_shared_data(void) --{ -- struct _KUSER_SHARED_DATA *shared_data = (struct _KUSER_SHARED_DATA *)wine_user_shared_data; -- -- shared_data->u.TickCountQuad = GetTickCount64(); -- shared_data->u.TickCount.High2Time = shared_data->u.TickCount.High1Time; --} -- -- - /*********************************************************************** - * emulate_instruction - * -@@ -804,8 +794,7 @@ static DWORD emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT *context ) - if (offset <= sizeof(KSHARED_USER_DATA) - data_size) - { - ULONGLONG temp = 0; -- update_shared_data(); -- memcpy( &temp, wine_user_shared_data + offset, data_size ); -+ memcpy( &temp, __wine_user_shared_data() + offset, data_size ); - store_reg_word( context, instr[2], (BYTE *)&temp, long_op, rex ); - context->Rip += prefixlen + len + 2; - return ExceptionContinueExecution; -@@ -825,11 +814,10 @@ static DWORD emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT *context ) - - if (offset <= sizeof(KSHARED_USER_DATA) - data_size) - { -- update_shared_data(); - switch (*instr) - { -- case 0x8a: store_reg_byte( context, instr[1], wine_user_shared_data + offset, rex ); break; -- case 0x8b: store_reg_word( context, instr[1], wine_user_shared_data + offset, long_op, rex ); break; -+ case 0x8a: store_reg_byte( context, instr[1], __wine_user_shared_data() + offset, rex ); break; -+ case 0x8b: store_reg_word( context, instr[1], __wine_user_shared_data() + offset, long_op, rex ); break; - } - context->Rip += prefixlen + len + 1; - return ExceptionContinueExecution; -@@ -847,8 +835,7 @@ static DWORD emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT *context ) - - if (offset <= sizeof(KSHARED_USER_DATA) - data_size) - { -- update_shared_data(); -- memcpy( &context->Rax, wine_user_shared_data + offset, data_size ); -+ memcpy( &context->Rax, __wine_user_shared_data() + offset, data_size ); - context->Rip += prefixlen + len + 1; - return ExceptionContinueExecution; - } --- -2.20.1 - diff --git a/patches/ntdll-User_Shared_Data/0002-server-Add-USD-support-with-timestamp-updates.patch b/patches/ntdll-User_Shared_Data/0002-server-Add-USD-support-with-timestamp-updates.patch new file mode 100644 index 00000000..a9bb8d4f --- /dev/null +++ b/patches/ntdll-User_Shared_Data/0002-server-Add-USD-support-with-timestamp-updates.patch @@ -0,0 +1,349 @@ +From f87e42d852d66331469af5bc18f153f91f4c23b7 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?R=C3=A9mi=20Bernon?= +Date: Thu, 30 Apr 2020 18:58:59 +0200 +Subject: [PATCH] server: Add USD support with timestamp updates. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The USD page is created when the first process (wineboot.exe) completes +its creation, using its provided user_shared_data for initialization. + +The server maps the page write-only and the clients map it read-only, +then the server updates the timestamps every 16 ms. + +The tests todo_wine cannot be completely removed as the read may have +missed a server timestamp update whereas the time functions are still +directly calling native clocks to get their values. + +It may then be possible to implement time using USD but that would +reduce the clocks accuracy down to the server update frequency. + +Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=29168 +Signed-off-by: Rémi Bernon +--- + dlls/ntdll/ntdll_misc.h | 1 + + dlls/ntdll/server.c | 25 ++++++++++++-- + dlls/ntdll/tests/time.c | 9 +++-- + dlls/ntdll/thread.c | 2 ++ + dlls/ntoskrnl.exe/instr.c | 12 ------- + server/file.h | 2 ++ + server/mapping.c | 69 +++++++++++++++++++++++++++++++++++++++ + server/process.c | 8 +++++ + server/protocol.def | 1 + + 9 files changed, 112 insertions(+), 17 deletions(-) + +diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h +index 76e8ec284e8..0d2ef09c87b 100644 +--- a/dlls/ntdll/ntdll_misc.h ++++ b/dlls/ntdll/ntdll_misc.h +@@ -221,6 +221,7 @@ extern void virtual_set_large_address_space(void) DECLSPEC_HIDDEN; + extern void virtual_fill_image_information( const pe_image_info_t *pe_info, + SECTION_IMAGE_INFORMATION *info ) DECLSPEC_HIDDEN; + extern struct _KUSER_SHARED_DATA *user_shared_data DECLSPEC_HIDDEN; ++extern size_t user_shared_data_size DECLSPEC_HIDDEN; + + /* completion */ + extern NTSTATUS NTDLL_AddCompletion( HANDLE hFile, ULONG_PTR CompletionValue, +diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c +index 3832a80f1e2..1a9780e95ba 100644 +--- a/dlls/ntdll/server.c ++++ b/dlls/ntdll/server.c +@@ -91,6 +91,7 @@ + #include "wine/server.h" + #include "wine/debug.h" + #include "ntdll_misc.h" ++#include "ddk/wdm.h" + + WINE_DEFAULT_DEBUG_CHANNEL(server); + +@@ -1862,8 +1863,15 @@ void server_init_process_done(void) + PEB *peb = NtCurrentTeb()->Peb; + IMAGE_NT_HEADERS *nt = RtlImageNtHeader( peb->ImageBaseAddress ); + void *entry = (char *)peb->ImageBaseAddress + nt->OptionalHeader.AddressOfEntryPoint; ++ obj_handle_t usd_handle; + NTSTATUS status; +- int suspend; ++ int suspend, usd_fd = -1; ++ sigset_t old_set; ++ SIZE_T size = user_shared_data_size; ++ void *addr = user_shared_data; ++ ULONG old_prot; ++ ++ NtProtectVirtualMemory( NtCurrentProcess(), &addr, &size, PAGE_READONLY, &old_prot ); + + #ifdef __APPLE__ + send_server_task_port(); +@@ -1878,6 +1886,7 @@ void server_init_process_done(void) + signal_init_process(); + + /* Signal the parent process to continue */ ++ pthread_sigmask( SIG_BLOCK, &server_block_set, &old_set ); + SERVER_START_REQ( init_process_done ) + { + req->module = wine_server_client_ptr( peb->ImageBaseAddress ); +@@ -1886,10 +1895,22 @@ void server_init_process_done(void) + #endif + req->entry = wine_server_client_ptr( entry ); + req->gui = (nt->OptionalHeader.Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CUI); +- status = wine_server_call( req ); ++ wine_server_add_data( req, user_shared_data, sizeof(*user_shared_data) ); ++ status = server_call_unlocked( req ); + suspend = reply->suspend; + } + SERVER_END_REQ; ++ if (!status) usd_fd = receive_fd( &usd_handle ); ++ pthread_sigmask( SIG_SETMASK, &old_set, NULL ); ++ ++ if (usd_fd != -1) ++ { ++ munmap( user_shared_data, user_shared_data_size ); ++ if (user_shared_data != mmap( user_shared_data, user_shared_data_size, ++ PROT_READ, MAP_SHARED | MAP_FIXED, usd_fd, 0 )) ++ fatal_error( "failed to remap the process user shared data\n" ); ++ close( usd_fd ); ++ } + + assert( !status ); + signal_start_process( entry, suspend ); +diff --git a/dlls/ntdll/tests/time.c b/dlls/ntdll/tests/time.c +index fe71d4458c0..7f81c20f21e 100644 +--- a/dlls/ntdll/tests/time.c ++++ b/dlls/ntdll/tests/time.c +@@ -185,9 +185,10 @@ static void test_user_shared_data_time(void) + t3 = GetTickCount(); + } while(t3 < t1 && i++ < 1); /* allow for wrap, but only once */ + ++ /* FIXME: not always in order, but should be close */ ++ todo_wine_if(t1 > t2 && t1 - t2 < 50) + ok(t1 <= t2, "USD TickCount / GetTickCount are out of order: %s %s\n", + wine_dbgstr_longlong(t1), wine_dbgstr_longlong(t2)); +- todo_wine + ok(t2 <= t3, "USD TickCount / GetTickCount are out of order: %s %s\n", + wine_dbgstr_longlong(t2), wine_dbgstr_longlong(t3)); + +@@ -202,7 +203,8 @@ static void test_user_shared_data_time(void) + t3 = system_time.QuadPart; + } while(t3 < t1 && i++ < 1); /* allow for wrap, but only once */ + +- todo_wine ++ /* FIXME: not always in order, but should be close */ ++ todo_wine_if(t1 > t2 && t1 - t2 < 50 * TICKSPERMSEC) + ok(t1 <= t2, "USD SystemTime / NtQuerySystemTime are out of order %s %s\n", + wine_dbgstr_longlong(t1), wine_dbgstr_longlong(t2)); + ok(t2 <= t3, "USD SystemTime / NtQuerySystemTime are out of order %s %s\n", +@@ -220,7 +222,8 @@ static void test_user_shared_data_time(void) + pRtlQueryUnbiasedInterruptTime(&t3); + } while(t3 < t1 && i++ < 1); /* allow for wrap, but only once */ + +- todo_wine ++ /* FIXME: not always in order, but should be close */ ++ todo_wine_if(t1 > t2 && t1 - t2 < 50 * TICKSPERMSEC) + ok(t1 <= t2, "USD InterruptTime / RtlQueryUnbiasedInterruptTime are out of order %s %s\n", + wine_dbgstr_longlong(t1), wine_dbgstr_longlong(t2)); + ok(t2 <= t3 || broken(t2 == t3 + 82410089070) /* w864 has some weird offset on testbot */, +diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c +index d116c7bd571..f4da99db760 100644 +--- a/dlls/ntdll/thread.c ++++ b/dlls/ntdll/thread.c +@@ -56,6 +56,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(thread); + #endif + + struct _KUSER_SHARED_DATA *user_shared_data = NULL; ++size_t user_shared_data_size = 0; + static const WCHAR default_windirW[] = {'C',':','\\','w','i','n','d','o','w','s',0}; + + void (WINAPI *kernel32_start_process)(LPTHREAD_START_ROUTINE,void*) = NULL; +@@ -244,6 +245,7 @@ TEB *thread_init(void) + exit(1); + } + user_shared_data = addr; ++ user_shared_data_size = size; + memcpy( user_shared_data->NtSystemRoot, default_windirW, sizeof(default_windirW) ); + + /* allocate and initialize the PEB and initial TEB */ +diff --git a/dlls/ntoskrnl.exe/instr.c b/dlls/ntoskrnl.exe/instr.c +index 77803f07d72..0973b3a80a0 100644 +--- a/dlls/ntoskrnl.exe/instr.c ++++ b/dlls/ntoskrnl.exe/instr.c +@@ -593,15 +593,6 @@ static void fake_syscall_function(void) + } + + +-static void update_shared_data(void) +-{ +- struct _KUSER_SHARED_DATA *shared_data = (struct _KUSER_SHARED_DATA *)wine_user_shared_data; +- +- shared_data->u.TickCountQuad = GetTickCount64(); +- shared_data->u.TickCount.High2Time = shared_data->u.TickCount.High1Time; +-} +- +- + /*********************************************************************** + * emulate_instruction + * +@@ -802,7 +793,6 @@ static DWORD emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT *context ) + if (offset <= sizeof(KSHARED_USER_DATA) - data_size) + { + ULONGLONG temp = 0; +- update_shared_data(); + memcpy( &temp, wine_user_shared_data + offset, data_size ); + store_reg_word( context, instr[2], (BYTE *)&temp, long_op, rex ); + context->Rip += prefixlen + len + 2; +@@ -823,7 +813,6 @@ static DWORD emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT *context ) + + if (offset <= sizeof(KSHARED_USER_DATA) - data_size) + { +- update_shared_data(); + switch (*instr) + { + case 0x8a: store_reg_byte( context, instr[1], wine_user_shared_data + offset, rex ); break; +@@ -845,7 +834,6 @@ static DWORD emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT *context ) + + if (offset <= sizeof(KSHARED_USER_DATA) - data_size) + { +- update_shared_data(); + memcpy( &context->Rax, wine_user_shared_data + offset, data_size ); + context->Rip += prefixlen + len + 1; + return ExceptionContinueExecution; +diff --git a/server/file.h b/server/file.h +index 7395814dadd..d577aaed3cf 100644 +--- a/server/file.h ++++ b/server/file.h +@@ -173,6 +173,8 @@ extern struct file *get_mapping_file( struct process *process, client_ptr_t base + extern void free_mapped_views( struct process *process ); + extern int get_page_size(void); + ++int get_user_shared_data_fd( const void *usd_init, data_size_t usd_size ); ++ + /* device functions */ + + extern struct object *create_named_pipe_device( struct object *root, const struct unicode_str *name ); +diff --git a/server/mapping.c b/server/mapping.c +index 6990a1913d7..d73d8de9c28 100644 +--- a/server/mapping.c ++++ b/server/mapping.c +@@ -35,6 +35,7 @@ + #define WIN32_NO_STATUS + #include "windef.h" + #include "winternl.h" ++#include "ddk/wdm.h" + + #include "file.h" + #include "handle.h" +@@ -943,6 +944,74 @@ int get_page_size(void) + return page_mask + 1; + } + ++static int kusd_fd; ++static KSHARED_USER_DATA *kusd; ++static const timeout_t kusd_timeout = 16 * -TICKS_PER_SEC / 1000; ++ ++static void kusd_set_current_time( void *private ) ++{ ++ ULONG system_time_high = current_time >> 32; ++ ULONG system_time_low = current_time & 0xffffffff; ++ ULONG interrupt_time_high = monotonic_time >> 32; ++ ULONG interrupt_time_low = monotonic_time & 0xffffffff; ++ ULONG tick_count_high = (monotonic_time * 1000 / TICKS_PER_SEC) >> 32; ++ ULONG tick_count_low = (monotonic_time * 1000 / TICKS_PER_SEC) & 0xffffffff; ++ KSHARED_USER_DATA *ptr = kusd; ++ ++ add_timeout_user( kusd_timeout, kusd_set_current_time, NULL ); ++ ++#if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))) ++ __atomic_store_n(&ptr->SystemTime.High2Time, system_time_high, __ATOMIC_SEQ_CST); ++ __atomic_store_n(&ptr->SystemTime.LowPart, system_time_low, __ATOMIC_SEQ_CST); ++ __atomic_store_n(&ptr->SystemTime.High1Time, system_time_high, __ATOMIC_SEQ_CST); ++ ++ __atomic_store_n(&ptr->InterruptTime.High2Time, interrupt_time_high, __ATOMIC_SEQ_CST); ++ __atomic_store_n(&ptr->InterruptTime.LowPart, interrupt_time_low, __ATOMIC_SEQ_CST); ++ __atomic_store_n(&ptr->InterruptTime.High1Time, interrupt_time_high, __ATOMIC_SEQ_CST); ++ ++ __atomic_store_n(&ptr->TickCount.High2Time, tick_count_high, __ATOMIC_SEQ_CST); ++ __atomic_store_n(&ptr->TickCount.LowPart, tick_count_low, __ATOMIC_SEQ_CST); ++ __atomic_store_n(&ptr->TickCount.High1Time, tick_count_high, __ATOMIC_SEQ_CST); ++ __atomic_store_n(&ptr->TickCountLowDeprecated, tick_count_low, __ATOMIC_SEQ_CST); ++#else ++ ptr->SystemTime.High2Time = system_time_high; ++ ptr->SystemTime.LowPart = system_time_low; ++ ptr->SystemTime.High1Time = system_time_high; ++ ++ ptr->InterruptTime.High2Time = interrupt_time_high; ++ ptr->InterruptTime.LowPart = interrupt_time_low; ++ ptr->InterruptTime.High1Time = interrupt_time_high; ++ ++ ptr->TickCount.High2Time = tick_count_high; ++ ptr->TickCount.LowPart = tick_count_low; ++ ptr->TickCount.High1Time = tick_count_high; ++ ptr->TickCountLowDeprecated = tick_count_low; ++#endif ++} ++ ++int get_user_shared_data_fd( const void *usd_init, data_size_t usd_size ) ++{ ++ /* keep it the same as user_shared_data_size in ntdll */ ++ size_t size = 0x10000; ++ ++ if (sizeof(*kusd) != usd_size) return -1; ++ if (kusd) return kusd_fd; ++ ++ if ((kusd_fd = create_temp_file( size )) == -1) ++ return -1; ++ ++ if ((kusd = mmap( NULL, size, PROT_WRITE, MAP_SHARED, kusd_fd, 0 )) == MAP_FAILED) ++ { ++ close( kusd_fd ); ++ return -1; ++ } ++ ++ memcpy( kusd, usd_init, usd_size ); ++ ++ kusd_set_current_time( NULL ); ++ return kusd_fd; ++} ++ + /* create a file mapping */ + DECL_HANDLER(create_mapping) + { +diff --git a/server/process.c b/server/process.c +index 211207ed03b..123dd9b28de 100644 +--- a/server/process.c ++++ b/server/process.c +@@ -1361,6 +1361,7 @@ DECL_HANDLER(init_process_done) + { + struct process_dll *dll; + struct process *process = current->process; ++ int usd_fd; + + if (is_process_init_done(process)) + { +@@ -1372,6 +1373,13 @@ DECL_HANDLER(init_process_done) + set_error( STATUS_DLL_NOT_FOUND ); + return; + } ++ if ((usd_fd = get_user_shared_data_fd( get_req_data(), get_req_data_size() )) == -1) ++ { ++ set_error( STATUS_NO_MEMORY ); ++ return; ++ } ++ ++ send_client_fd( process, usd_fd, -1 ); + + /* main exe is the first in the dll list */ + list_remove( &dll->entry ); +diff --git a/server/protocol.def b/server/protocol.def +index 06a29b153ea..b1fe198ad04 100644 +--- a/server/protocol.def ++++ b/server/protocol.def +@@ -854,6 +854,7 @@ struct rawinput_device + mod_handle_t module; /* main module base address */ + client_ptr_t ldt_copy; /* address of LDT copy (in thread address space) */ + client_ptr_t entry; /* process entry point */ ++ VARARG(usd,bytes); /* USD initialization data */ + @REPLY + int suspend; /* is process suspended? */ + @END +-- +2.26.2 + diff --git a/patches/ntdll-User_Shared_Data/0003-ntdll-Create-thread-to-update-user_shared_data-time-.patch b/patches/ntdll-User_Shared_Data/0003-ntdll-Create-thread-to-update-user_shared_data-time-.patch deleted file mode 100644 index 3a7964a1..00000000 --- a/patches/ntdll-User_Shared_Data/0003-ntdll-Create-thread-to-update-user_shared_data-time-.patch +++ /dev/null @@ -1,223 +0,0 @@ -From c6b63b60eabacaff48103e6bde62866190c559f1 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Michael=20M=C3=BCller?= -Date: Fri, 5 May 2017 05:40:50 +0200 -Subject: [PATCH] ntdll: Create thread to update user_shared_data time values - when necessary. - ---- - dlls/ntdll/loader.c | 31 ++++++++++++++++++ - dlls/ntdll/ntdll_misc.h | 3 ++ - dlls/ntdll/thread.c | 70 ++++++++++++++++++++++++++++++++++++----- - dlls/ntdll/virtual.c | 17 ++++++++++ - 4 files changed, 113 insertions(+), 8 deletions(-) - -diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c -index 1cf82f421a5..ff99791cefe 100644 ---- a/dlls/ntdll/loader.c -+++ b/dlls/ntdll/loader.c -@@ -4047,6 +4047,36 @@ PIMAGE_NT_HEADERS WINAPI RtlImageNtHeader(HMODULE hModule) - } - - -+/*********************************************************************** -+ * user_shared_data_init -+ * -+ * Initializes a user shared -+ */ -+static void user_shared_data_init(void) -+{ -+ void *addr = user_shared_data_external; -+ SIZE_T data_size = page_size; -+ ULONG old_prot; -+ -+ /* initialize time fields */ -+ __wine_user_shared_data(); -+ -+ /* invalidate high times to prevent race conditions */ -+ user_shared_data->SystemTime.High2Time = 0; -+ user_shared_data->SystemTime.High1Time = -1; -+ -+ user_shared_data->InterruptTime.High2Time = 0; -+ user_shared_data->InterruptTime.High1Time = -1; -+ -+ user_shared_data->u.TickCount.High2Time = 0; -+ user_shared_data->u.TickCount.High1Time = -1; -+ -+ /* copy to correct address and make it non accessible */ -+ memcpy(user_shared_data_external, user_shared_data, sizeof(*user_shared_data)); -+ NtProtectVirtualMemory( NtCurrentProcess(), &addr, &data_size, PAGE_NOACCESS, &old_prot ); -+} -+ -+ - /****************************************************************** - * LdrInitializeThunk (NTDLL.@) - * -@@ -4694,6 +4724,7 @@ void __wine_process_init(void) - NtTerminateProcess( GetCurrentProcess(), status ); - } - -+ user_shared_data_init(); - hidden_exports_init( wm->ldr.FullDllName.Buffer ); - - virtual_set_large_address_space(); -diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h -index 7aa678c79d6..1c1d6c67f28 100644 ---- a/dlls/ntdll/ntdll_misc.h -+++ b/dlls/ntdll/ntdll_misc.h -@@ -224,6 +224,9 @@ extern void virtual_set_large_address_space(void) DECLSPEC_HIDDEN; - extern void virtual_fill_image_information( const pe_image_info_t *pe_info, - SECTION_IMAGE_INFORMATION *info ) DECLSPEC_HIDDEN; - extern struct _KUSER_SHARED_DATA *user_shared_data DECLSPEC_HIDDEN; -+extern struct _KUSER_SHARED_DATA *user_shared_data_external DECLSPEC_HIDDEN; -+extern void create_user_shared_data_thread(void) DECLSPEC_HIDDEN; -+extern BYTE* CDECL __wine_user_shared_data(void); - - /* completion */ - extern NTSTATUS NTDLL_AddCompletion( HANDLE hFile, ULONG_PTR CompletionValue, -diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c -index 85a03013240..89174717374 100644 ---- a/dlls/ntdll/thread.c -+++ b/dlls/ntdll/thread.c -@@ -47,6 +47,7 @@ - #include "wine/library.h" - #include "wine/server.h" - #include "wine/debug.h" -+#include "winbase.h" - #include "ntdll_misc.h" - #include "ddk/wdm.h" - #include "wine/exception.h" -@@ -57,7 +58,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(thread); - #define PTHREAD_STACK_MIN 16384 - #endif - --struct _KUSER_SHARED_DATA *user_shared_data = NULL; -+static struct _KUSER_SHARED_DATA user_shared_data_internal; -+struct _KUSER_SHARED_DATA *user_shared_data_external; -+struct _KUSER_SHARED_DATA *user_shared_data = &user_shared_data_internal; - static const WCHAR default_windirW[] = {'C',':','\\','w','i','n','d','o','w','s',0}; - - void (WINAPI *kernel32_start_process)(LPTHREAD_START_ROUTINE,void*) = NULL; -@@ -291,7 +294,7 @@ TEB *thread_init(void) - MESSAGE( "wine: failed to map the shared user data: %08x\n", status ); - exit(1); - } -- user_shared_data = addr; -+ user_shared_data_external = addr; - memcpy( user_shared_data->NtSystemRoot, default_windirW, sizeof(default_windirW) ); - - /* allocate and initialize the PEB and initial TEB */ -@@ -356,18 +359,69 @@ TEB *thread_init(void) - */ - BYTE* CDECL __wine_user_shared_data(void) - { -- LARGE_INTEGER now; -+ static int spinlock; -+ ULARGE_INTEGER interrupt; -+ LARGE_INTEGER now; -+ -+ while (interlocked_cmpxchg( &spinlock, 1, 0 ) != 0); -+ - NtQuerySystemTime( &now ); -- user_shared_data->SystemTime.LowPart = now.u.LowPart; -- user_shared_data->SystemTime.High1Time = user_shared_data->SystemTime.High2Time = now.u.HighPart; -- user_shared_data->u.TickCountQuad = (now.QuadPart - server_start_time) / 10000; -- user_shared_data->u.TickCount.High2Time = user_shared_data->u.TickCount.High1Time; -- user_shared_data->TickCountLowDeprecated = user_shared_data->u.TickCount.LowPart; -+ user_shared_data->SystemTime.High2Time = now.u.HighPart; -+ user_shared_data->SystemTime.LowPart = now.u.LowPart; -+ user_shared_data->SystemTime.High1Time = now.u.HighPart; -+ -+ RtlQueryUnbiasedInterruptTime( &interrupt.QuadPart ); -+ user_shared_data->InterruptTime.High2Time = interrupt.HighPart; -+ user_shared_data->InterruptTime.LowPart = interrupt.LowPart; -+ user_shared_data->InterruptTime.High1Time = interrupt.HighPart; -+ -+ interrupt.QuadPart /= 10000; -+ user_shared_data->u.TickCount.High2Time = interrupt.HighPart; -+ user_shared_data->u.TickCount.LowPart = interrupt.LowPart; -+ user_shared_data->u.TickCount.High1Time = interrupt.HighPart; -+ user_shared_data->TickCountLowDeprecated = interrupt.LowPart; - user_shared_data->TickCountMultiplier = 1 << 24; - -+ spinlock = 0; - return (BYTE *)user_shared_data; - } - -+static void *user_shared_data_thread(void *arg) -+{ -+ struct timeval tv; -+ -+ while (TRUE) -+ { -+ __wine_user_shared_data(); -+ -+ tv.tv_sec = 0; -+ tv.tv_usec = 15600; -+ select(0, NULL, NULL, NULL, &tv); -+ } -+ return NULL; -+} -+ -+ -+void create_user_shared_data_thread(void) -+{ -+ static int thread_created; -+ pthread_attr_t attr; -+ pthread_t thread; -+ -+ if (interlocked_cmpxchg(&thread_created, 1, 0) != 0) -+ return; -+ -+ TRACE("Creating user shared data update thread.\n"); -+ -+ user_shared_data = user_shared_data_external; -+ __wine_user_shared_data(); -+ -+ pthread_attr_init(&attr); -+ pthread_attr_setstacksize(&attr, 0x10000); -+ pthread_create(&thread, &attr, user_shared_data_thread, NULL); -+ pthread_attr_destroy(&attr); -+} -+ - BOOL read_process_memory_stats(int unix_pid, VM_COUNTERS *pvmi) - { - BOOL ret = FALSE; -diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index 7700385eb7b..865344d91d2 100644 ---- a/dlls/ntdll/virtual.c -+++ b/dlls/ntdll/virtual.c -@@ -2318,6 +2318,7 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) - { - NTSTATUS ret = STATUS_ACCESS_VIOLATION; - void *page = ROUND_ADDR( addr, page_mask ); -+ BOOL update_shared_data = FALSE; - sigset_t sigset; - BYTE vprot; - -@@ -2343,7 +2344,23 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) - ret = STATUS_SUCCESS; - } - } -+ else if (!err && page == user_shared_data_external) -+ { -+ if (!(vprot & VPROT_READ)) -+ { -+ set_page_vprot_bits( page, page_size, VPROT_READ | VPROT_WRITE, 0 ); -+ mprotect_range( page, page_size, 0, 0 ); -+ update_shared_data = TRUE; -+ } -+ /* ignore fault if page is readable now */ -+ if (VIRTUAL_GetUnixProt( get_page_vprot( page )) & PROT_READ) ret = STATUS_SUCCESS; -+ else update_shared_data = FALSE; -+ } - server_leave_uninterrupted_section( &csVirtual, &sigset ); -+ -+ if (update_shared_data) -+ create_user_shared_data_thread(); -+ - return ret; - } - --- -2.26.2 - diff --git a/patches/ntdll-User_Shared_Data/0004-ntdll-tests-Test-updating-TickCount-in-user_shared_d.patch b/patches/ntdll-User_Shared_Data/0004-ntdll-tests-Test-updating-TickCount-in-user_shared_d.patch deleted file mode 100644 index 334d1f05..00000000 --- a/patches/ntdll-User_Shared_Data/0004-ntdll-tests-Test-updating-TickCount-in-user_shared_d.patch +++ /dev/null @@ -1,77 +0,0 @@ -From 6a1a8685b7ee9fa485a796963d9b2a3430067b14 Mon Sep 17 00:00:00 2001 -From: Andrew Wesie -Date: Tue, 2 May 2017 21:19:03 -0500 -Subject: ntdll/tests: Test updating TickCount in user_shared_data. - ---- - dlls/ntdll/tests/time.c | 28 ++++++++++++++++++++++++++++ - 1 file changed, 28 insertions(+) - -diff --git a/dlls/ntdll/tests/time.c b/dlls/ntdll/tests/time.c -index b684bc1980d..f90ac6ff91c 100644 ---- a/dlls/ntdll/tests/time.c -+++ b/dlls/ntdll/tests/time.c -@@ -18,7 +18,9 @@ - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -+#define NONAMELESSUNION - #include "ntdll_test.h" -+#include "ddk/wdm.h" - - #define TICKSPERSEC 10000000 - #define TICKSPERMSEC 10000 -@@ -29,6 +29,7 @@ static VOID (WINAPI *pRtlTimeFieldsToTime)( PTIME_FIELDS TimeFields, PLARGE_IN - static NTSTATUS (WINAPI *pNtQueryPerformanceCounter)( LARGE_INTEGER *counter, LARGE_INTEGER *frequency ); - static NTSTATUS (WINAPI *pRtlQueryTimeZoneInformation)( RTL_TIME_ZONE_INFORMATION *); - static NTSTATUS (WINAPI *pRtlQueryDynamicTimeZoneInformation)( RTL_DYNAMIC_TIME_ZONE_INFORMATION *); -+static ULONG (WINAPI *pNtGetTickCount)(void); - - static const int MonthLengths[2][12] = - { -@@ -153,12 +155,36 @@ static void test_RtlQueryTimeZoneInforma - wine_dbgstr_w(tzinfo.DaylightName)); - } - -+static void test_NtGetTickCount(void) -+{ -+#ifndef _WIN64 -+ KSHARED_USER_DATA *user_shared_data = (void *)0x7ffe0000; -+ LONG diff; -+ int i; -+ -+ if (!pNtGetTickCount) -+ { -+ win_skip("NtGetTickCount is not available\n"); -+ return; -+ } -+ -+ for (i = 0; i < 5; ++i) -+ { -+ diff = (user_shared_data->u.TickCountQuad * user_shared_data->TickCountMultiplier) >> 24; -+ diff = pNtGetTickCount() - diff; -+ ok(diff < 32, "NtGetTickCount - TickCountQuad too high, expected < 32 got %d\n", diff); -+ Sleep(50); -+ } -+#endif -+} -+ - START_TEST(time) - { - HMODULE mod = GetModuleHandleA("ntdll.dll"); - pRtlTimeToTimeFields = (void *)GetProcAddress(mod,"RtlTimeToTimeFields"); - pRtlTimeFieldsToTime = (void *)GetProcAddress(mod,"RtlTimeFieldsToTime"); - pNtQueryPerformanceCounter = (void *)GetProcAddress(mod, "NtQueryPerformanceCounter"); -+ pNtGetTickCount = (void *)GetProcAddress(mod,"NtGetTickCount"); - pRtlQueryTimeZoneInformation = - (void *)GetProcAddress(mod, "RtlQueryTimeZoneInformation"); - pRtlQueryDynamicTimeZoneInformation = -@@ -169,5 +195,6 @@ START_TEST(time) - else - win_skip("Required time conversion functions are not available\n"); - test_NtQueryPerformanceCounter(); -+ test_NtGetTickCount(); - test_RtlQueryTimeZoneInformation(); - } --- -2.12.2 diff --git a/patches/ntdll-User_Shared_Data/definition b/patches/ntdll-User_Shared_Data/definition index 1f1491fc..242595c5 100644 --- a/patches/ntdll-User_Shared_Data/definition +++ b/patches/ntdll-User_Shared_Data/definition @@ -1,2 +1 @@ Fixes: [29168] Update user shared data at realtime -Depends: ntdll-Hide_Wine_Exports diff --git a/patches/ntdll-WRITECOPY/0004-ntdll-Properly-handle-PAGE_WRITECOPY-protection.-try.patch b/patches/ntdll-WRITECOPY/0004-ntdll-Properly-handle-PAGE_WRITECOPY-protection.-try.patch index 076cda95..851f9296 100644 --- a/patches/ntdll-WRITECOPY/0004-ntdll-Properly-handle-PAGE_WRITECOPY-protection.-try.patch +++ b/patches/ntdll-WRITECOPY/0004-ntdll-Properly-handle-PAGE_WRITECOPY-protection.-try.patch @@ -1,4 +1,4 @@ -From 53d03a31463a98450b44f1d99c86195b78044691 Mon Sep 17 00:00:00 2001 +From b304bfba257073741c03dbcb719f55d2788c18a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Sat, 4 Oct 2014 03:22:09 +0200 Subject: [PATCH] ntdll: Properly handle PAGE_WRITECOPY protection. (try 5) @@ -9,10 +9,10 @@ For now, only enable it when a special environment variable is set. 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index aa1107f136f..fa39a67b9ca 100644 +index 7700385eb7b..aec6c18da87 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c -@@ -323,6 +323,21 @@ static const char *VIRTUAL_GetProtStr( BYTE prot ) +@@ -321,6 +321,21 @@ static const char *VIRTUAL_GetProtStr( BYTE prot ) return buffer; } @@ -34,7 +34,7 @@ index aa1107f136f..fa39a67b9ca 100644 /*********************************************************************** * VIRTUAL_GetUnixProt -@@ -336,8 +351,19 @@ static int VIRTUAL_GetUnixProt( BYTE vprot ) +@@ -334,8 +349,19 @@ static int VIRTUAL_GetUnixProt( BYTE vprot ) { if (vprot & VPROT_READ) prot |= PROT_READ; if (vprot & VPROT_WRITE) prot |= PROT_WRITE | PROT_READ; @@ -55,7 +55,7 @@ index aa1107f136f..fa39a67b9ca 100644 if (vprot & VPROT_WRITEWATCH) prot &= ~PROT_WRITE; } if (!prot) prot = PROT_NONE; -@@ -1073,7 +1099,7 @@ static void update_write_watches( void *base, size_t size, size_t accessed_size +@@ -1080,7 +1106,7 @@ static void update_write_watches( void *base, size_t size, size_t accessed_size { TRACE( "updating watch %p-%p-%p\n", base, (char *)base + accessed_size, (char *)base + size ); /* clear write watch flag on accessed pages */ @@ -64,7 +64,7 @@ index aa1107f136f..fa39a67b9ca 100644 /* restore page protections on the entire range */ mprotect_range( base, size, 0, 0 ); } -@@ -2291,12 +2317,13 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) +@@ -2336,12 +2362,13 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) set_page_vprot_bits( page, page_size, 0, VPROT_WRITEWATCH ); mprotect_range( page, page_size, 0, 0 ); } @@ -80,9 +80,9 @@ index aa1107f136f..fa39a67b9ca 100644 + /* ignore fault if page is writable now */ + if (VIRTUAL_GetUnixProt( get_page_vprot( page )) & PROT_WRITE) ret = STATUS_SUCCESS; } - else if (!err && page == user_shared_data_external) - { -@@ -2347,11 +2374,16 @@ static NTSTATUS check_write_access( void *base, size_t size, BOOL *has_write_wat + server_leave_uninterrupted_section( &csVirtual, &sigset ); + return ret; +@@ -2363,11 +2390,16 @@ static NTSTATUS check_write_access( void *base, size_t size, BOOL *has_write_wat { BYTE vprot = get_page_vprot( addr + i ); if (vprot & VPROT_WRITEWATCH) *has_write_watch = TRUE; @@ -101,5 +101,5 @@ index aa1107f136f..fa39a67b9ca 100644 } -- -2.25.4 +2.26.2 diff --git a/patches/ntdll-WRITECOPY/definition b/patches/ntdll-WRITECOPY/definition index 9e95bb36..d5806b79 100644 --- a/patches/ntdll-WRITECOPY/definition +++ b/patches/ntdll-WRITECOPY/definition @@ -1,5 +1,4 @@ Fixes: [29384] Multiple applications expect correct handling of WRITECOPY memory protection (Voobly fails to launch Age of Empires II, MSYS2) -Depends: ntdll-User_Shared_Data # Causes regressions? # https://bugs.wine-staging.com/show_bug.cgi?id=207 diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index d81c2b08..125c3918 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -1679,13 +1679,6 @@ if test "$enable_nvcuvid_CUDA_Video_Support" -eq 1; then enable_nvapi_Stub_DLL=1 fi -if test "$enable_ntdll_WRITECOPY" -eq 1; then - if test "$enable_ntdll_User_Shared_Data" -gt 1; then - abort "Patchset ntdll-User_Shared_Data disabled, but ntdll-WRITECOPY depends on that." - fi - enable_ntdll_User_Shared_Data=1 -fi - if test "$enable_ntdll_Syscall_Emulation" -eq 1; then if test "$enable_winebuild_Fake_Dlls" -gt 1; then abort "Patchset winebuild-Fake_Dlls disabled, but ntdll-Syscall_Emulation depends on that." @@ -1721,6 +1714,17 @@ if test "$enable_ntdll_NtContinue" -eq 1; then enable_winebuild_Fake_Dlls=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 + if test "$enable_ntdll_ThreadTime" -gt 1; then + abort "Patchset ntdll-ThreadTime disabled, but ntdll-Hide_Wine_Exports depends on that." + fi + enable_advapi32_Token_Integrity_Level=1 + enable_ntdll_ThreadTime=1 +fi + if test "$enable_ntdll_DOS_Attributes" -eq 1; then if test "$enable_ntdll_Junction_Points" -gt 1; then abort "Patchset ntdll-Junction_Points disabled, but ntdll-DOS_Attributes depends on that." @@ -1729,10 +1733,10 @@ if test "$enable_ntdll_DOS_Attributes" -eq 1; then fi if test "$enable_ntdll_Builtin_Prot" -eq 1; then - if test "$enable_ntdll_User_Shared_Data" -gt 1; then - abort "Patchset ntdll-User_Shared_Data disabled, but ntdll-Builtin_Prot depends on that." + if test "$enable_ntdll_WRITECOPY" -gt 1; then + abort "Patchset ntdll-WRITECOPY disabled, but ntdll-Builtin_Prot depends on that." fi - enable_ntdll_User_Shared_Data=1 + enable_ntdll_WRITECOPY=1 fi if test "$enable_ntdll_ApiSetMap" -eq 1; then @@ -1817,6 +1821,9 @@ if test "$enable_server_Shared_Memory" -eq 1; then if test "$enable_ntdll_Threading" -gt 1; then abort "Patchset ntdll-Threading disabled, but server-Shared_Memory depends on that." fi + if test "$enable_ntdll_User_Shared_Data" -gt 1; then + abort "Patchset ntdll-User_Shared_Data disabled, but server-Shared_Memory depends on that." + fi if test "$enable_ntdll_ext4_case_folder" -gt 1; then abort "Patchset ntdll-ext4-case-folder disabled, but server-Shared_Memory depends on that." fi @@ -1833,6 +1840,7 @@ if test "$enable_server_Shared_Memory" -eq 1; then abort "Patchset user32-rawinput-nolegacy disabled, but server-Shared_Memory depends on that." fi enable_ntdll_Threading=1 + enable_ntdll_User_Shared_Data=1 enable_ntdll_ext4_case_folder=1 enable_server_Key_State=1 enable_server_PeekMessage=1 @@ -1883,24 +1891,6 @@ if test "$enable_winebuild_Fake_Dlls" -eq 1; then enable_ntdll_User_Shared_Data=1 fi -if test "$enable_ntdll_User_Shared_Data" -eq 1; then - if test "$enable_ntdll_Hide_Wine_Exports" -gt 1; then - abort "Patchset ntdll-Hide_Wine_Exports disabled, but ntdll-User_Shared_Data depends on that." - fi - enable_ntdll_Hide_Wine_Exports=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 - if test "$enable_ntdll_ThreadTime" -gt 1; then - abort "Patchset ntdll-ThreadTime disabled, but ntdll-Hide_Wine_Exports depends on that." - fi - enable_advapi32_Token_Integrity_Level=1 - enable_ntdll_ThreadTime=1 -fi - if test "$enable_dxdiagn_GetChildContainer_Leaf_Nodes" -eq 1; then if test "$enable_dxdiagn_Enumerate_DirectSound" -gt 1; then abort "Patchset dxdiagn-Enumerate_DirectSound disabled, but dxdiagn-GetChildContainer_Leaf_Nodes depends on that." @@ -3258,80 +3248,28 @@ if test "$enable_ntdll_Junction_Points" -eq 1; then ) >> "$patchlist" fi -# Patchset ntdll-ThreadTime -# | -# | This patchset fixes the following Wine bugs: -# | * [#20230] Return correct values for GetThreadTimes function -# | -# | Modified files: -# | * dlls/ntdll/nt.c, dlls/ntdll/ntdll_misc.h, dlls/ntdll/process.c, dlls/ntdll/thread.c, server/protocol.def, -# | server/snapshot.c, server/thread.c, server/thread.h -# | -if test "$enable_ntdll_ThreadTime" -eq 1; then - patch_apply ntdll-ThreadTime/0001-ntdll-Return-correct-values-in-GetThreadTimes-for-al.patch - patch_apply ntdll-ThreadTime/0002-ntdll-Set-correct-thread-creation-time-for-SystemPro.patch - patch_apply ntdll-ThreadTime/0003-ntdll-Fill-process-kernel-and-user-time.patch - patch_apply ntdll-ThreadTime/0004-ntdll-Set-process-start-time.patch - patch_apply ntdll-ThreadTime/0005-ntdll-Fill-out-thread-times-in-process-enumeration.patch - patch_apply ntdll-ThreadTime/0006-ntdll-Fill-process-virtual-memory-counters-in-NtQuer.patch - ( - printf '%s\n' '+ { "Sebastian Lackner", "ntdll: Return correct values in GetThreadTimes() for all threads.", 1 },'; - printf '%s\n' '+ { "Michael Müller", "ntdll: Set correct thread creation time for SystemProcessInformation in NtQuerySystemInformation.", 1 },'; - printf '%s\n' '+ { "Michael Müller", "ntdll: Fill process kernel and user time.", 1 },'; - printf '%s\n' '+ { "Michael Müller", "ntdll: Set process start time.", 1 },'; - printf '%s\n' '+ { "Michael Müller", "ntdll: Fill out thread times in process enumeration.", 1 },'; - printf '%s\n' '+ { "Michael Müller", "ntdll: Fill process virtual memory counters in NtQuerySystemInformation.", 1 },'; - ) >> "$patchlist" -fi - -# Patchset ntdll-Hide_Wine_Exports -# | -# | This patchset has the following (direct or indirect) dependencies: -# | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level, ntdll-ThreadTime -# | -# | This patchset fixes the following Wine bugs: -# | * [#38656] Add support for hiding wine version information from applications -# | -# | Modified files: -# | * dlls/ntdll/loader.c, dlls/ntdll/ntdll_misc.h -# | -if test "$enable_ntdll_Hide_Wine_Exports" -eq 1; then - patch_apply ntdll-Hide_Wine_Exports/0001-ntdll-Add-support-for-hiding-wine-version-informatio.patch - ( - printf '%s\n' '+ { "Sebastian Lackner", "ntdll: Add support for hiding wine version information from applications.", 1 },'; - ) >> "$patchlist" -fi - # Patchset ntdll-User_Shared_Data # | -# | This patchset has the following (direct or indirect) dependencies: -# | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level, ntdll-ThreadTime, ntdll-Hide_Wine_Exports -# | # | This patchset fixes the following Wine bugs: # | * [#29168] Update user shared data at realtime # | # | Modified files: -# | * dlls/ntdll/loader.c, dlls/ntdll/ntdll.spec, dlls/ntdll/ntdll_misc.h, dlls/ntdll/tests/time.c, dlls/ntdll/thread.c, -# | dlls/ntdll/virtual.c, dlls/ntoskrnl.exe/instr.c +# | * dlls/ntdll/ntdll_misc.h, dlls/ntdll/server.c, dlls/ntdll/tests/time.c, dlls/ntdll/thread.c, dlls/ntoskrnl.exe/instr.c, +# | server/file.h, server/mapping.c, server/process.c, server/protocol.def # | if test "$enable_ntdll_User_Shared_Data" -eq 1; then - patch_apply ntdll-User_Shared_Data/0001-ntdll-Move-code-to-update-user-shared-data-into-a-se.patch - patch_apply ntdll-User_Shared_Data/0002-ntoskrnl-Update-USER_SHARED_DATA-before-accessing-me.patch - patch_apply ntdll-User_Shared_Data/0003-ntdll-Create-thread-to-update-user_shared_data-time-.patch - patch_apply ntdll-User_Shared_Data/0004-ntdll-tests-Test-updating-TickCount-in-user_shared_d.patch + patch_apply ntdll-User_Shared_Data/0001-ntdll-tests-Test-user_shared_data-timestamp-updates.patch + patch_apply ntdll-User_Shared_Data/0002-server-Add-USD-support-with-timestamp-updates.patch ( - printf '%s\n' '+ { "Sebastian Lackner", "ntdll: Move code to update user shared data into a separate function.", 1 },'; - printf '%s\n' '+ { "Sebastian Lackner", "ntoskrnl: Update USER_SHARED_DATA before accessing memory.", 1 },'; - printf '%s\n' '+ { "Michael Müller", "ntdll: Create thread to update user_shared_data time values when necessary.", 1 },'; - printf '%s\n' '+ { "Andrew Wesie", "ntdll/tests: Test updating TickCount in user_shared_data.", 1 },'; + printf '%s\n' '+ { "Rémi Bernon", "ntdll/tests: Test user_shared_data timestamp updates.", 1 },'; + printf '%s\n' '+ { "Rémi Bernon", "server: Add USD support with timestamp updates.", 1 },'; ) >> "$patchlist" fi # Patchset winebuild-Fake_Dlls # | # | This patchset has the following (direct or indirect) dependencies: -# | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level, ntdll-ThreadTime, ntdll-Hide_Wine_Exports, -# | ntdll-User_Shared_Data +# | * ntdll-User_Shared_Data # | # | This patchset fixes the following Wine bugs: # | * [#21232] Chromium-based browser engines (Chrome, Opera, Comodo Dragon, SRWare Iron) crash on startup unless '--no- @@ -3382,8 +3320,7 @@ fi # Patchset ntdll-RtlCreateUserThread # | # | This patchset has the following (direct or indirect) dependencies: -# | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level, ntdll-ThreadTime, ntdll-Hide_Wine_Exports, -# | ntdll-User_Shared_Data, winebuild-Fake_Dlls +# | * ntdll-User_Shared_Data, winebuild-Fake_Dlls # | # | This patchset fixes the following Wine bugs: # | * [#45571] League of Legends 8.12+ fails to start a game (anticheat engine, hooking of NtCreateThread/Ex) @@ -3410,6 +3347,32 @@ if test "$enable_ntdll_SystemRoot_Symlink" -eq 1; then ) >> "$patchlist" fi +# Patchset ntdll-ThreadTime +# | +# | This patchset fixes the following Wine bugs: +# | * [#20230] Return correct values for GetThreadTimes function +# | +# | Modified files: +# | * dlls/ntdll/nt.c, dlls/ntdll/ntdll_misc.h, dlls/ntdll/process.c, dlls/ntdll/thread.c, server/protocol.def, +# | server/snapshot.c, server/thread.c, server/thread.h +# | +if test "$enable_ntdll_ThreadTime" -eq 1; then + patch_apply ntdll-ThreadTime/0001-ntdll-Return-correct-values-in-GetThreadTimes-for-al.patch + patch_apply ntdll-ThreadTime/0002-ntdll-Set-correct-thread-creation-time-for-SystemPro.patch + patch_apply ntdll-ThreadTime/0003-ntdll-Fill-process-kernel-and-user-time.patch + patch_apply ntdll-ThreadTime/0004-ntdll-Set-process-start-time.patch + patch_apply ntdll-ThreadTime/0005-ntdll-Fill-out-thread-times-in-process-enumeration.patch + patch_apply ntdll-ThreadTime/0006-ntdll-Fill-process-virtual-memory-counters-in-NtQuer.patch + ( + printf '%s\n' '+ { "Sebastian Lackner", "ntdll: Return correct values in GetThreadTimes() for all threads.", 1 },'; + printf '%s\n' '+ { "Michael Müller", "ntdll: Set correct thread creation time for SystemProcessInformation in NtQuerySystemInformation.", 1 },'; + printf '%s\n' '+ { "Michael Müller", "ntdll: Fill process kernel and user time.", 1 },'; + printf '%s\n' '+ { "Michael Müller", "ntdll: Set process start time.", 1 },'; + printf '%s\n' '+ { "Michael Müller", "ntdll: Fill out thread times in process enumeration.", 1 },'; + printf '%s\n' '+ { "Michael Müller", "ntdll: Fill process virtual memory counters in NtQuerySystemInformation.", 1 },'; + ) >> "$patchlist" +fi + # Patchset server-Realtime_Priority # | # | This patchset has the following (direct or indirect) dependencies: @@ -3605,8 +3568,8 @@ fi # Patchset server-Shared_Memory # | # | This patchset has the following (direct or indirect) dependencies: -# | * ntdll-Threading, ntdll-ext4-case-folder, server-Key_State, server-PeekMessage, server-Signal_Thread, loader- -# | KeyboardLayouts, winex11.drv-mouse-coorrds, user32-rawinput-mouse, user32-rawinput-nolegacy +# | * ntdll-Threading, ntdll-User_Shared_Data, ntdll-ext4-case-folder, server-Key_State, server-PeekMessage, server- +# | Signal_Thread, loader-KeyboardLayouts, winex11.drv-mouse-coorrds, user32-rawinput-mouse, user32-rawinput-nolegacy # | # | Modified files: # | * dlls/ntdll/ntdll_misc.h, dlls/ntdll/server.c, dlls/ntdll/thread.c, dlls/ntdll/virtual.c, dlls/user32/focus.c, @@ -3657,10 +3620,10 @@ fi # | # | This patchset has the following (direct or indirect) dependencies: # | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level, kernel32-K32GetPerformanceInfo, ntdll- -# | Junction_Points, ntdll-ThreadTime, ntdll-Hide_Wine_Exports, ntdll-User_Shared_Data, winebuild-Fake_Dlls, ntdll- -# | RtlCreateUserThread, ntdll-SystemRoot_Symlink, server-Realtime_Priority, ntdll-Threading, ntdll-ext4-case-folder, -# | server-Key_State, server-PeekMessage, server-Signal_Thread, loader-KeyboardLayouts, winex11.drv-mouse-coorrds, user32 -# | -rawinput-mouse, user32-rawinput-nolegacy, server-Shared_Memory, ws2_32-WSACleanup +# | Junction_Points, ntdll-User_Shared_Data, winebuild-Fake_Dlls, ntdll-RtlCreateUserThread, ntdll-SystemRoot_Symlink, +# | ntdll-ThreadTime, server-Realtime_Priority, ntdll-Threading, ntdll-ext4-case-folder, server-Key_State, server- +# | PeekMessage, server-Signal_Thread, loader-KeyboardLayouts, winex11.drv-mouse-coorrds, user32-rawinput-mouse, user32 +# | -rawinput-nolegacy, server-Shared_Memory, ws2_32-WSACleanup # | # | This patchset fixes the following Wine bugs: # | * [#36692] Many multi-threaded applications have poor performance due to heavy use of synchronization primitives @@ -4407,11 +4370,47 @@ if test "$enable_ntdll_ApiSetMap" -eq 1; then ) >> "$patchlist" fi +# Patchset ntdll-WRITECOPY +# | +# | This patchset fixes the following Wine bugs: +# | * [#29384] Multiple applications expect correct handling of WRITECOPY memory protection (Voobly fails to launch Age of +# | Empires II, MSYS2) +# | +# | Modified files: +# | * dlls/advapi32/crypt.c, dlls/advapi32/tests/security.c, dlls/kernel32/tests/virtual.c, dlls/ntdll/ntdll_misc.h, +# | dlls/ntdll/server.c, dlls/ntdll/signal_arm.c, dlls/ntdll/signal_arm64.c, dlls/ntdll/signal_i386.c, +# | dlls/ntdll/signal_powerpc.c, dlls/ntdll/signal_x86_64.c, dlls/ntdll/thread.c, dlls/ntdll/virtual.c, +# | dlls/psapi/tests/psapi_main.c +# | +if test "$enable_ntdll_WRITECOPY" -eq 1; then + patch_apply ntdll-WRITECOPY/0001-ntdll-Trigger-write-watches-before-passing-userdata-.patch + patch_apply ntdll-WRITECOPY/0002-advapi-Trigger-write-watches-before-passing-userdata.patch + patch_apply ntdll-WRITECOPY/0003-ntdll-Setup-a-temporary-signal-handler-during-proces.patch + patch_apply ntdll-WRITECOPY/0004-ntdll-Properly-handle-PAGE_WRITECOPY-protection.-try.patch + patch_apply ntdll-WRITECOPY/0005-ntdll-Track-if-a-WRITECOPY-page-has-been-modified.patch + patch_apply ntdll-WRITECOPY/0006-ntdll-Support-WRITECOPY-on-x64.patch + patch_apply ntdll-WRITECOPY/0007-ntdll-Always-enable-WRITECOPY-support.patch + patch_apply ntdll-WRITECOPY/0008-ntdll-Report-unmodified-WRITECOPY-pages-as-shared.patch + patch_apply ntdll-WRITECOPY/0009-ntdll-Fallback-to-copy-pages-for-WRITECOPY.patch + patch_apply ntdll-WRITECOPY/0010-kernel32-tests-psapi-tests-Update-tests.patch + ( + printf '%s\n' '+ { "Sebastian Lackner", "ntdll: Trigger write watches before passing userdata pointer to wait_reply.", 1 },'; + printf '%s\n' '+ { "Sebastian Lackner", "advapi: Trigger write watches before passing userdata pointer to read syscall.", 1 },'; + printf '%s\n' '+ { "Michael Müller", "ntdll: Setup a temporary signal handler during process startup to handle page faults.", 2 },'; + printf '%s\n' '+ { "Michael Müller", "ntdll: Properly handle PAGE_WRITECOPY protection.", 5 },'; + printf '%s\n' '+ { "Andrew Wesie", "ntdll: Track if a WRITECOPY page has been modified.", 1 },'; + printf '%s\n' '+ { "Andrew Wesie", "ntdll: Support WRITECOPY on x64.", 1 },'; + printf '%s\n' '+ { "Andrew Wesie", "ntdll: Always enable WRITECOPY support.", 1 },'; + printf '%s\n' '+ { "Andrew Wesie", "ntdll: Report unmodified WRITECOPY pages as shared.", 1 },'; + printf '%s\n' '+ { "Andrew Wesie", "ntdll: Fallback to copy pages for WRITECOPY.", 1 },'; + printf '%s\n' '+ { "Andrew Wesie", "kernel32/tests, psapi/tests: Update tests.", 1 },'; + ) >> "$patchlist" +fi + # Patchset ntdll-Builtin_Prot # | # | This patchset has the following (direct or indirect) dependencies: -# | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level, ntdll-ThreadTime, ntdll-Hide_Wine_Exports, -# | ntdll-User_Shared_Data +# | * ntdll-WRITECOPY # | # | This patchset fixes the following Wine bugs: # | * [#44650] Fix holes in ELF mappings @@ -4633,6 +4632,24 @@ if test "$enable_ntdll_Heap_Improvements" -eq 1; then ) >> "$patchlist" fi +# Patchset ntdll-Hide_Wine_Exports +# | +# | This patchset has the following (direct or indirect) dependencies: +# | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level, ntdll-ThreadTime +# | +# | This patchset fixes the following Wine bugs: +# | * [#38656] Add support for hiding wine version information from applications +# | +# | Modified files: +# | * dlls/ntdll/loader.c, dlls/ntdll/ntdll_misc.h +# | +if test "$enable_ntdll_Hide_Wine_Exports" -eq 1; then + patch_apply ntdll-Hide_Wine_Exports/0001-ntdll-Add-support-for-hiding-wine-version-informatio.patch + ( + printf '%s\n' '+ { "Sebastian Lackner", "ntdll: Add support for hiding wine version information from applications.", 1 },'; + ) >> "$patchlist" +fi + # Patchset ntdll-Interrupt-0x2e # | # | This patchset fixes the following Wine bugs: @@ -4678,8 +4695,7 @@ fi # Patchset ntdll-NtContinue # | # | This patchset has the following (direct or indirect) dependencies: -# | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level, ntdll-ThreadTime, ntdll-Hide_Wine_Exports, -# | ntdll-User_Shared_Data, winebuild-Fake_Dlls +# | * ntdll-User_Shared_Data, winebuild-Fake_Dlls # | # | This patchset fixes the following Wine bugs: # | * [#31910] Add stub for NtContinue @@ -4882,8 +4898,7 @@ fi # Patchset ntdll-Syscall_Emulation # | # | This patchset has the following (direct or indirect) dependencies: -# | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level, ntdll-ThreadTime, ntdll-Hide_Wine_Exports, -# | ntdll-User_Shared_Data, winebuild-Fake_Dlls +# | * ntdll-User_Shared_Data, winebuild-Fake_Dlls # | # | This patchset fixes the following Wine bugs: # | * [#48291] Detroit: Become Human crashes on launch @@ -4966,47 +4981,6 @@ if test "$enable_ntdll_ThreadHideFromDebugger" -eq 1; then ) >> "$patchlist" fi -# Patchset ntdll-WRITECOPY -# | -# | This patchset has the following (direct or indirect) dependencies: -# | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level, ntdll-ThreadTime, ntdll-Hide_Wine_Exports, -# | ntdll-User_Shared_Data -# | -# | This patchset fixes the following Wine bugs: -# | * [#29384] Multiple applications expect correct handling of WRITECOPY memory protection (Voobly fails to launch Age of -# | Empires II, MSYS2) -# | -# | Modified files: -# | * dlls/advapi32/crypt.c, dlls/advapi32/tests/security.c, dlls/kernel32/tests/virtual.c, dlls/ntdll/ntdll_misc.h, -# | dlls/ntdll/server.c, dlls/ntdll/signal_arm.c, dlls/ntdll/signal_arm64.c, dlls/ntdll/signal_i386.c, -# | dlls/ntdll/signal_powerpc.c, dlls/ntdll/signal_x86_64.c, dlls/ntdll/thread.c, dlls/ntdll/virtual.c, -# | dlls/psapi/tests/psapi_main.c -# | -if test "$enable_ntdll_WRITECOPY" -eq 1; then - patch_apply ntdll-WRITECOPY/0001-ntdll-Trigger-write-watches-before-passing-userdata-.patch - patch_apply ntdll-WRITECOPY/0002-advapi-Trigger-write-watches-before-passing-userdata.patch - patch_apply ntdll-WRITECOPY/0003-ntdll-Setup-a-temporary-signal-handler-during-proces.patch - patch_apply ntdll-WRITECOPY/0004-ntdll-Properly-handle-PAGE_WRITECOPY-protection.-try.patch - patch_apply ntdll-WRITECOPY/0005-ntdll-Track-if-a-WRITECOPY-page-has-been-modified.patch - patch_apply ntdll-WRITECOPY/0006-ntdll-Support-WRITECOPY-on-x64.patch - patch_apply ntdll-WRITECOPY/0007-ntdll-Always-enable-WRITECOPY-support.patch - patch_apply ntdll-WRITECOPY/0008-ntdll-Report-unmodified-WRITECOPY-pages-as-shared.patch - patch_apply ntdll-WRITECOPY/0009-ntdll-Fallback-to-copy-pages-for-WRITECOPY.patch - patch_apply ntdll-WRITECOPY/0010-kernel32-tests-psapi-tests-Update-tests.patch - ( - printf '%s\n' '+ { "Sebastian Lackner", "ntdll: Trigger write watches before passing userdata pointer to wait_reply.", 1 },'; - printf '%s\n' '+ { "Sebastian Lackner", "advapi: Trigger write watches before passing userdata pointer to read syscall.", 1 },'; - printf '%s\n' '+ { "Michael Müller", "ntdll: Setup a temporary signal handler during process startup to handle page faults.", 2 },'; - printf '%s\n' '+ { "Michael Müller", "ntdll: Properly handle PAGE_WRITECOPY protection.", 5 },'; - printf '%s\n' '+ { "Andrew Wesie", "ntdll: Track if a WRITECOPY page has been modified.", 1 },'; - printf '%s\n' '+ { "Andrew Wesie", "ntdll: Support WRITECOPY on x64.", 1 },'; - printf '%s\n' '+ { "Andrew Wesie", "ntdll: Always enable WRITECOPY support.", 1 },'; - printf '%s\n' '+ { "Andrew Wesie", "ntdll: Report unmodified WRITECOPY pages as shared.", 1 },'; - printf '%s\n' '+ { "Andrew Wesie", "ntdll: Fallback to copy pages for WRITECOPY.", 1 },'; - printf '%s\n' '+ { "Andrew Wesie", "kernel32/tests, psapi/tests: Update tests.", 1 },'; - ) >> "$patchlist" -fi - # Patchset ntdll-Zero_mod_name # | # | Modified files: @@ -5334,10 +5308,10 @@ fi # | # | This patchset has the following (direct or indirect) dependencies: # | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level, kernel32-K32GetPerformanceInfo, ntdll- -# | Junction_Points, ntdll-ThreadTime, ntdll-Hide_Wine_Exports, ntdll-User_Shared_Data, winebuild-Fake_Dlls, ntdll- -# | RtlCreateUserThread, ntdll-SystemRoot_Symlink, server-Realtime_Priority, ntdll-Threading, ntdll-ext4-case-folder, -# | server-Key_State, server-PeekMessage, server-Signal_Thread, loader-KeyboardLayouts, winex11.drv-mouse-coorrds, user32 -# | -rawinput-mouse, user32-rawinput-nolegacy, server-Shared_Memory, ws2_32-WSACleanup, eventfd_synchronization +# | Junction_Points, ntdll-User_Shared_Data, winebuild-Fake_Dlls, ntdll-RtlCreateUserThread, ntdll-SystemRoot_Symlink, +# | ntdll-ThreadTime, server-Realtime_Priority, ntdll-Threading, ntdll-ext4-case-folder, server-Key_State, server- +# | PeekMessage, server-Signal_Thread, loader-KeyboardLayouts, winex11.drv-mouse-coorrds, user32-rawinput-mouse, user32 +# | -rawinput-nolegacy, server-Shared_Memory, ws2_32-WSACleanup, eventfd_synchronization # | # | This patchset fixes the following Wine bugs: # | * [#46967] GOG Galaxy doesn't run in virtual desktop. @@ -5425,8 +5399,9 @@ fi # Patchset server-Object_Types # | # | This patchset has the following (direct or indirect) dependencies: -# | * ntdll-Threading, ntdll-ext4-case-folder, server-Key_State, server-PeekMessage, server-Signal_Thread, loader- -# | KeyboardLayouts, winex11.drv-mouse-coorrds, user32-rawinput-mouse, user32-rawinput-nolegacy, server-Shared_Memory +# | * ntdll-Threading, ntdll-User_Shared_Data, ntdll-ext4-case-folder, server-Key_State, server-PeekMessage, server- +# | Signal_Thread, loader-KeyboardLayouts, winex11.drv-mouse-coorrds, user32-rawinput-mouse, user32-rawinput-nolegacy, +# | server-Shared_Memory # | # | This patchset fixes the following Wine bugs: # | * [#44629] Process Hacker can't enumerate handles @@ -7111,11 +7086,10 @@ fi # | # | This patchset has the following (direct or indirect) dependencies: # | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level, kernel32-K32GetPerformanceInfo, ntdll- -# | Junction_Points, ntdll-ThreadTime, ntdll-Hide_Wine_Exports, ntdll-User_Shared_Data, winebuild-Fake_Dlls, ntdll- -# | RtlCreateUserThread, ntdll-SystemRoot_Symlink, server-Realtime_Priority, ntdll-Threading, ntdll-ext4-case-folder, -# | server-Key_State, server-PeekMessage, server-Signal_Thread, loader-KeyboardLayouts, winex11.drv-mouse-coorrds, user32 -# | -rawinput-mouse, user32-rawinput-nolegacy, server-Shared_Memory, ws2_32-WSACleanup, eventfd_synchronization, server- -# | Desktop_Refcount +# | Junction_Points, ntdll-User_Shared_Data, winebuild-Fake_Dlls, ntdll-RtlCreateUserThread, ntdll-SystemRoot_Symlink, +# | ntdll-ThreadTime, server-Realtime_Priority, ntdll-Threading, ntdll-ext4-case-folder, server-Key_State, server- +# | PeekMessage, server-Signal_Thread, loader-KeyboardLayouts, winex11.drv-mouse-coorrds, user32-rawinput-mouse, user32 +# | -rawinput-nolegacy, server-Shared_Memory, ws2_32-WSACleanup, eventfd_synchronization, server-Desktop_Refcount # | # | Modified files: # | * dlls/ws2_32/socket.c, dlls/ws2_32/tests/sock.c, include/winsock.h, server/protocol.def, server/sock.c diff --git a/patches/server-Shared_Memory/0006-ntdll-Only-enable-wineserver-shared-memory-communica.patch b/patches/server-Shared_Memory/0006-ntdll-Only-enable-wineserver-shared-memory-communica.patch index 9a6ad021..27d91376 100644 --- a/patches/server-Shared_Memory/0006-ntdll-Only-enable-wineserver-shared-memory-communica.patch +++ b/patches/server-Shared_Memory/0006-ntdll-Only-enable-wineserver-shared-memory-communica.patch @@ -1,4 +1,4 @@ -From 882a6197012149fb44b3751dc24e3d2a222dd46b Mon Sep 17 00:00:00 2001 +From 3225fc5b602f25a2d17ee68b732ec2a59fb29c0f Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Thu, 19 Mar 2015 02:55:36 +0100 Subject: [PATCH] ntdll: Only enable wineserver shared memory communication @@ -9,18 +9,18 @@ Subject: [PATCH] ntdll: Only enable wineserver shared memory communication 1 file changed, 22 insertions(+) diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c -index e138f7c212d..68910fde50c 100644 +index 749e753ae5a..c3f9d11c760 100644 --- a/dlls/ntdll/server.c +++ b/dlls/ntdll/server.c -@@ -92,6 +92,7 @@ - #include "ntdll_misc.h" +@@ -100,6 +100,7 @@ + #include "ddk/wdm.h" WINE_DEFAULT_DEBUG_CHANNEL(server); +WINE_DECLARE_DEBUG_CHANNEL(winediag); /* just in case... */ #undef EXT2_IOC_GETFLAGS -@@ -1162,6 +1163,21 @@ static int server_get_shared_memory_fd( HANDLE thread, int *unix_fd ) +@@ -1177,6 +1178,21 @@ static int server_get_shared_memory_fd( HANDLE thread, int *unix_fd ) return ret; } @@ -42,7 +42,7 @@ index e138f7c212d..68910fde50c 100644 /*********************************************************************** * server_get_shared_memory -@@ -1174,6 +1190,9 @@ void *server_get_shared_memory( HANDLE thread ) +@@ -1189,6 +1205,9 @@ void *server_get_shared_memory( HANDLE thread ) void *mem = NULL; int fd = -1; @@ -52,7 +52,7 @@ index e138f7c212d..68910fde50c 100644 /* The global memory block is only requested once. No locking is * required because this function is called very early during the * process initialization for the first time. */ -@@ -1188,7 +1207,10 @@ void *server_get_shared_memory( HANDLE thread ) +@@ -1203,7 +1222,10 @@ void *server_get_shared_memory( HANDLE thread ) } if (!thread) diff --git a/patches/server-Shared_Memory/definition b/patches/server-Shared_Memory/definition index 644589e6..47fca2c4 100644 --- a/patches/server-Shared_Memory/definition +++ b/patches/server-Shared_Memory/definition @@ -7,3 +7,4 @@ Depends: server-PeekMessage Depends: server-Signal_Thread Depends: user32-rawinput-nolegacy Depends: ntdll-ext4-case-folder +Depends: ntdll-User_Shared_Data diff --git a/patches/winebuild-Fake_Dlls/0010-tools-winebuild-Add-syscall-thunks-for-64-bit.patch b/patches/winebuild-Fake_Dlls/0010-tools-winebuild-Add-syscall-thunks-for-64-bit.patch index 21d86793..7b15a79b 100644 --- a/patches/winebuild-Fake_Dlls/0010-tools-winebuild-Add-syscall-thunks-for-64-bit.patch +++ b/patches/winebuild-Fake_Dlls/0010-tools-winebuild-Add-syscall-thunks-for-64-bit.patch @@ -1,4 +1,4 @@ -From 6037ccdc09121a1602089e7dcf50d7739a69114f Mon Sep 17 00:00:00 2001 +From 61a744694dc9eafb8b92fbb826335bd4468f20f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Thu, 7 Sep 2017 00:38:09 +0200 Subject: [PATCH] tools/winebuild: Add syscall thunks for 64 bit. @@ -6,11 +6,11 @@ Subject: [PATCH] tools/winebuild: Add syscall thunks for 64 bit. --- dlls/kernel32/tests/loader.c | 7 +- dlls/ntdll/signal_x86_64.c | 2 + - dlls/ntdll/thread.c | 10 ++ + dlls/ntdll/thread.c | 6 + libs/wine/loader.c | 4 + tools/winebuild/parser.c | 2 +- tools/winebuild/spec32.c | 285 ++++++++++++++++++++++++++++++++++- - 6 files changed, 302 insertions(+), 8 deletions(-) + 6 files changed, 298 insertions(+), 8 deletions(-) diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c index 5373dc4efe1..67d04876bd6 100644 @@ -60,11 +60,11 @@ index 31af1e98d3f..324a92b41a9 100644 } diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c -index 1650c17295a..0acc4d88524 100644 +index f4da99db760..03229a98bb8 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c -@@ -63,6 +63,8 @@ struct _KUSER_SHARED_DATA *user_shared_data_external; - struct _KUSER_SHARED_DATA *user_shared_data = &user_shared_data_internal; +@@ -59,6 +59,8 @@ struct _KUSER_SHARED_DATA *user_shared_data = NULL; + size_t user_shared_data_size = 0; static const WCHAR default_windirW[] = {'C',':','\\','w','i','n','d','o','w','s',0}; +extern void DECLSPEC_NORETURN __wine_syscall_dispatcher( void ); @@ -72,17 +72,13 @@ index 1650c17295a..0acc4d88524 100644 void (WINAPI *kernel32_start_process)(LPTHREAD_START_ROUTINE,void*) = NULL; /* info passed to a starting thread */ -@@ -327,6 +329,14 @@ TEB *thread_init(void) +@@ -275,6 +277,10 @@ TEB *thread_init(void) InitializeListHead( &ldr.InInitializationOrderModuleList ); *(ULONG_PTR *)peb->Reserved = get_image_addr(); -+#if defined(__APPLE__) && defined(__x86_64__) -+ *((DWORD*)((char*)user_shared_data_external + 0x1000)) = __wine_syscall_dispatcher; -+#endif + /* Pretend we don't support the SYSCALL instruction on x86-64. Needed for + * Chromium; see output_syscall_thunks_x64() in winebuild. */ + user_shared_data->SystemCallPad[0] = 1; -+ user_shared_data_external->SystemCallPad[0] = 1; + /* * Starting with Vista, the first user to log on has session id 1.