From 6f1e25e1c0b3fe23e199b363ae80ee53fa09d26d Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Sat, 20 Apr 2019 18:45:05 +1000 Subject: [PATCH] Rebase against 9d7d68747b06a03893df99c4beea36b762508603 --- ...entfd-file-descriptors-for-process-o.patch | 33 +- ...o-wait-on-the-queue-fd-when-waiting-.patch | 28 +- patches/eventfd_synchronization/definition | 1 - ...32-Make-K32GetPerformanceInfo-faster.patch | 39 +- ...NtSuspendProcess-and-NtResumeProcess.patch | 365 ------------------ patches/ntdll-NtSuspendProcess/definition | 2 - patches/patchinstall.sh | 71 +--- ...lt-security-descriptor-ownership-for.patch | 27 +- ...ice-Load-some-common-drivers-and-fix.patch | 26 +- 9 files changed, 102 insertions(+), 490 deletions(-) delete mode 100644 patches/ntdll-NtSuspendProcess/0001-ntdll-Implement-NtSuspendProcess-and-NtResumeProcess.patch delete mode 100644 patches/ntdll-NtSuspendProcess/definition diff --git a/patches/eventfd_synchronization/0015-server-Create-eventfd-file-descriptors-for-process-o.patch b/patches/eventfd_synchronization/0015-server-Create-eventfd-file-descriptors-for-process-o.patch index a29e3c34..533a255f 100644 --- a/patches/eventfd_synchronization/0015-server-Create-eventfd-file-descriptors-for-process-o.patch +++ b/patches/eventfd_synchronization/0015-server-Create-eventfd-file-descriptors-for-process-o.patch @@ -1,8 +1,7 @@ -From 4473e26d9c3177ee7a42f023fcbe48edc672f9bc Mon Sep 17 00:00:00 2001 +From e6e0ef574ce53d5b5e94068ae9dc137c2c7dee92 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Fri, 8 Jun 2018 18:57:12 -0500 -Subject: [PATCH 15/83] server: Create eventfd file descriptors for process - objects. +Subject: [PATCH] server: Create eventfd file descriptors for process objects. --- server/esync.c | 33 +++++++++++++++++++++++++++++++++ @@ -13,7 +12,7 @@ Subject: [PATCH 15/83] server: Create eventfd file descriptors for process create mode 100644 server/esync.h diff --git a/server/esync.c b/server/esync.c -index 351da1a7c..da26d27cb 100644 +index 351da1a7cb2..da26d27cbc8 100644 --- a/server/esync.c +++ b/server/esync.c @@ -35,6 +35,21 @@ @@ -65,7 +64,7 @@ index 351da1a7c..da26d27cb 100644 struct esync *esync; diff --git a/server/esync.h b/server/esync.h new file mode 100644 -index 000000000..f93535b7b +index 00000000000..f93535b7b4c --- /dev/null +++ b/server/esync.h @@ -0,0 +1,22 @@ @@ -92,7 +91,7 @@ index 000000000..f93535b7b +extern int do_esync(void); +int esync_create_fd( int initval, int flags ); diff --git a/server/process.c b/server/process.c -index a96972e6b..0bb220dba 100644 +index c4cb041f293..ed03210a5f5 100644 --- a/server/process.c +++ b/server/process.c @@ -48,6 +48,7 @@ @@ -103,15 +102,15 @@ index a96972e6b..0bb220dba 100644 /* process structure */ -@@ -66,6 +67,7 @@ static unsigned int process_map_access( struct object *obj, unsigned int access - static struct security_descriptor *process_get_sd( struct object *obj ); +@@ -67,6 +68,7 @@ static struct security_descriptor *process_get_sd( struct object *obj ); static void process_poll_event( struct fd *fd, int event ); + static struct list *process_get_kernel_obj_list( struct object *obj ); static void process_destroy( struct object *obj ); +static int process_get_esync_fd( struct object *obj ); static void terminate_process( struct process *process, struct thread *skip, int exit_code ); static const struct object_ops process_ops = -@@ -76,7 +78,7 @@ static const struct object_ops process_ops = +@@ -77,7 +79,7 @@ static const struct object_ops process_ops = add_queue, /* add_queue */ remove_queue, /* remove_queue */ process_signaled, /* signaled */ @@ -120,15 +119,15 @@ index a96972e6b..0bb220dba 100644 no_satisfied, /* satisfied */ no_signal, /* signal */ no_get_fd, /* get_fd */ -@@ -529,6 +531,7 @@ struct process *create_process( int fd, struct process *parent, int inherit_all, +@@ -531,6 +533,7 @@ struct process *create_process( int fd, struct process *parent, int inherit_all, process->trace_data = 0; process->rawinput_mouse = NULL; process->rawinput_kbd = NULL; + process->esync_fd = -1; + list_init( &process->kernel_object ); list_init( &process->thread_list ); list_init( &process->locks ); - list_init( &process->asyncs ); -@@ -572,6 +575,9 @@ struct process *create_process( int fd, struct process *parent, int inherit_all, +@@ -575,6 +578,9 @@ struct process *create_process( int fd, struct process *parent, int inherit_all, } if (!process->handles || !process->token) goto error; @@ -138,7 +137,7 @@ index a96972e6b..0bb220dba 100644 set_fd_events( process->msg_fd, POLLIN ); /* start listening to events */ return process; -@@ -620,6 +626,9 @@ static void process_destroy( struct object *obj ) +@@ -623,6 +629,9 @@ static void process_destroy( struct object *obj ) if (process->id) free_ptid( process->id ); if (process->token) release_object( process->token ); free( process->dir_cache ); @@ -148,7 +147,7 @@ index a96972e6b..0bb220dba 100644 } /* dump a process on stdout for debugging purposes */ -@@ -643,6 +652,12 @@ static int process_signaled( struct object *obj, struct wait_queue_entry *entry +@@ -647,6 +656,12 @@ static int process_signaled( struct object *obj, struct wait_queue_entry *entry return !process->running_threads; } @@ -162,13 +161,13 @@ index a96972e6b..0bb220dba 100644 { if (access & GENERIC_READ) access |= STANDARD_RIGHTS_READ | PROCESS_QUERY_INFORMATION | PROCESS_VM_READ; diff --git a/server/process.h b/server/process.h -index ea2809194..f8fd12833 100644 +index 41267a27df5..02765f2f122 100644 --- a/server/process.h +++ b/server/process.h -@@ -96,6 +96,7 @@ struct process - struct list rawinput_devices;/* list of registered rawinput devices */ +@@ -97,6 +97,7 @@ struct process const struct rawinput_device *rawinput_mouse; /* rawinput mouse device, if any */ const struct rawinput_device *rawinput_kbd; /* rawinput keyboard device, if any */ + struct list kernel_object; /* list of kernel object pointers */ + int esync_fd; /* esync file descriptor (signaled on exit) */ }; diff --git a/patches/eventfd_synchronization/0024-server-ntdll-Also-wait-on-the-queue-fd-when-waiting-.patch b/patches/eventfd_synchronization/0024-server-ntdll-Also-wait-on-the-queue-fd-when-waiting-.patch index 422a4c04..3fef9600 100644 --- a/patches/eventfd_synchronization/0024-server-ntdll-Also-wait-on-the-queue-fd-when-waiting-.patch +++ b/patches/eventfd_synchronization/0024-server-ntdll-Also-wait-on-the-queue-fd-when-waiting-.patch @@ -1,4 +1,4 @@ -From 29517778d9000de8de3217bcd6f1a2bb933123c6 Mon Sep 17 00:00:00 2001 +From 91c96ca57892577e20be532ae58b423fea1750b2 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Sat, 9 Jun 2018 14:44:54 -0500 Subject: [PATCH] server, ntdll: Also wait on the queue fd when waiting for @@ -23,7 +23,7 @@ fix the 'drives' tab. 8 files changed, 60 insertions(+), 23 deletions(-) diff --git a/dlls/ntdll/esync.c b/dlls/ntdll/esync.c -index 5d8dbac2d..dcb7801d9 100644 +index 5d8dbac2df4..dcb7801d912 100644 --- a/dlls/ntdll/esync.c +++ b/dlls/ntdll/esync.c @@ -80,17 +80,9 @@ void __wine_esync_set_queue_fd( int fd ) @@ -140,7 +140,7 @@ index 5d8dbac2d..dcb7801d9 100644 * we were waiting for. So keep waiting. */ NtQuerySystemTime( &now ); diff --git a/server/esync.c b/server/esync.c -index 4f7ff6bda..1f8c0d516 100644 +index 4f7ff6bdaed..1f8c0d5167a 100644 --- a/server/esync.c +++ b/server/esync.c @@ -150,11 +150,12 @@ int esync_create_fd( int initval, int flags ) @@ -176,7 +176,7 @@ index 4f7ff6bda..1f8c0d516 100644 } else diff --git a/server/event.c b/server/event.c -index d2f9e378c..79287e7ed 100644 +index d2f9e378cb1..79287e7edc0 100644 --- a/server/event.c +++ b/server/event.c @@ -50,7 +50,7 @@ static void event_dump( struct object *obj, int verbose ); @@ -201,7 +201,7 @@ index d2f9e378c..79287e7ed 100644 } diff --git a/server/object.h b/server/object.h -index ee0f1f776..ca5a191f9 100644 +index ee0f1f776e3..ca5a191f975 100644 --- a/server/object.h +++ b/server/object.h @@ -69,7 +69,7 @@ struct object_ops @@ -214,19 +214,19 @@ index ee0f1f776..ca5a191f9 100644 void (*satisfied)(struct object *,struct wait_queue_entry *); /* signal an object */ diff --git a/server/process.c b/server/process.c -index 1ce2fb05c..6e6dfc41c 100644 +index ed03210a5f5..7fdbfb98cae 100644 --- a/server/process.c +++ b/server/process.c -@@ -67,7 +67,7 @@ static unsigned int process_map_access( struct object *obj, unsigned int access - static struct security_descriptor *process_get_sd( struct object *obj ); +@@ -68,7 +68,7 @@ static struct security_descriptor *process_get_sd( struct object *obj ); static void process_poll_event( struct fd *fd, int event ); + static struct list *process_get_kernel_obj_list( struct object *obj ); static void process_destroy( struct object *obj ); -static int process_get_esync_fd( struct object *obj ); +static int process_get_esync_fd( struct object *obj, enum esync_type *type ); static void terminate_process( struct process *process, struct thread *skip, int exit_code ); static const struct object_ops process_ops = -@@ -654,9 +654,10 @@ static int process_signaled( struct object *obj, struct wait_queue_entry *entry +@@ -656,9 +656,10 @@ static int process_signaled( struct object *obj, struct wait_queue_entry *entry return !process->running_threads; } @@ -239,10 +239,10 @@ index 1ce2fb05c..6e6dfc41c 100644 } diff --git a/server/protocol.def b/server/protocol.def -index 17959c233..8d2df1f97 100644 +index 7a383590c55..7644a25b8ec 100644 --- a/server/protocol.def +++ b/server/protocol.def -@@ -4012,4 +4012,14 @@ struct handle_info +@@ -4011,4 +4011,14 @@ struct handle_info @REQ(get_esync_fd) obj_handle_t handle; /* handle to the object */ @REPLY @@ -258,7 +258,7 @@ index 17959c233..8d2df1f97 100644 + ESYNC_QUEUE, +}; diff --git a/server/queue.c b/server/queue.c -index 0ea95291c..91de4a3a8 100644 +index 0ea95291c34..91de4a3a85f 100644 --- a/server/queue.c +++ b/server/queue.c @@ -165,7 +165,7 @@ static void msg_queue_dump( struct object *obj, int verbose ); @@ -283,7 +283,7 @@ index 0ea95291c..91de4a3a8 100644 } diff --git a/server/thread.c b/server/thread.c -index 35bddeeaa..7c8ff1d5d 100644 +index 83781f0d712..ae2112486b2 100644 --- a/server/thread.c +++ b/server/thread.c @@ -133,7 +133,7 @@ static const struct object_ops thread_apc_ops = @@ -308,5 +308,5 @@ index 35bddeeaa..7c8ff1d5d 100644 } -- -2.21.0 +2.20.1 diff --git a/patches/eventfd_synchronization/definition b/patches/eventfd_synchronization/definition index c053ac4c..8da3c187 100644 --- a/patches/eventfd_synchronization/definition +++ b/patches/eventfd_synchronization/definition @@ -2,7 +2,6 @@ Fixes: [36692] Many multi-threaded applications have poor performance due to hea # Note: the following dependencies are essentially artificial; in particular # these patches do not make use of the Staging shared memory infrastructure. Depends: server-Shared_Memory -Depends: ntdll-NtSuspendProcess Depends: ntdll-SystemRoot_Symlink Depends: ws2_32-WSACleanup Depends: ntdll-RtlCreateUserThread diff --git a/patches/kernel32-K32GetPerformanceInfo/0001-kernel32-Make-K32GetPerformanceInfo-faster.patch b/patches/kernel32-K32GetPerformanceInfo/0001-kernel32-Make-K32GetPerformanceInfo-faster.patch index b163eb3e..9f10eb78 100644 --- a/patches/kernel32-K32GetPerformanceInfo/0001-kernel32-Make-K32GetPerformanceInfo-faster.patch +++ b/patches/kernel32-K32GetPerformanceInfo/0001-kernel32-Make-K32GetPerformanceInfo-faster.patch @@ -1,19 +1,19 @@ -From 9685685419231b0a3f8a2e454e4c963564629332 Mon Sep 17 00:00:00 2001 +From 8bf339727f8c444f72a9b0c26d08a80f227e6b9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Sun, 19 Feb 2017 05:38:40 +0100 -Subject: kernel32: Make K32GetPerformanceInfo faster. +Subject: [PATCH] kernel32: Make K32GetPerformanceInfo faster. --- - dlls/kernel32/cpu.c | 68 ++++++++++++++++++++--------------------------------- - server/process.c | 18 ++++++++++++++ - server/protocol.def | 9 +++++++ - 3 files changed, 52 insertions(+), 43 deletions(-) + dlls/kernel32/cpu.c | 68 +++++++++++++++++---------------------------- + server/process.c | 18 ++++++++++++ + server/protocol.def | 8 ++++++ + 3 files changed, 51 insertions(+), 43 deletions(-) diff --git a/dlls/kernel32/cpu.c b/dlls/kernel32/cpu.c -index 5fb806746a0..01cb469b8db 100644 +index 9445d0bc056..6e198badb66 100644 --- a/dlls/kernel32/cpu.c +++ b/dlls/kernel32/cpu.c -@@ -216,14 +216,8 @@ BOOL WINAPI IsProcessorFeaturePresent ( +@@ -209,14 +209,8 @@ BOOL WINAPI IsProcessorFeaturePresent ( DWORD feature ) */ BOOL WINAPI K32GetPerformanceInfo(PPERFORMANCE_INFORMATION info, DWORD size) { @@ -30,7 +30,7 @@ index 5fb806746a0..01cb469b8db 100644 NTSTATUS status; TRACE( "(%p, %d)\n", info, size ); -@@ -237,53 +231,41 @@ BOOL WINAPI K32GetPerformanceInfo(PPERFORMANCE_INFORMATION info, DWORD size) +@@ -230,53 +224,41 @@ BOOL WINAPI K32GetPerformanceInfo(PPERFORMANCE_INFORMATION info, DWORD size) memset( info, 0, sizeof(*info) ); info->cb = sizeof(*info); @@ -108,12 +108,12 @@ index 5fb806746a0..01cb469b8db 100644 { SetLastError( RtlNtStatusToDosError( status ) ); diff --git a/server/process.c b/server/process.c -index eaf61eaea99..a59be6cfad7 100644 +index 6690b9d2f26..f0b44a8c6f4 100644 --- a/server/process.c +++ b/server/process.c -@@ -1754,3 +1754,21 @@ DECL_HANDLER(set_job_completion_port) - - release_object( job ); +@@ -1852,3 +1852,21 @@ DECL_HANDLER(resume_process) + release_object( process ); + } } + +/* Retrieve process, thread and handle count */ @@ -134,14 +134,13 @@ index eaf61eaea99..a59be6cfad7 100644 + } +} diff --git a/server/protocol.def b/server/protocol.def -index c26b24edc5f..85137ab3b52 100644 +index dc5186c877b..3ed38245d4a 100644 --- a/server/protocol.def +++ b/server/protocol.def -@@ -3866,3 +3866,12 @@ struct handle_info - obj_handle_t handle; /* handle to the job */ - int status; /* process exit code */ - @END -+ +@@ -4042,3 +4042,11 @@ enum esync_type + ESYNC_MANUAL_SERVER, + ESYNC_QUEUE, + }; + +/* Return system information values */ +@REQ(get_system_info) @@ -151,5 +150,5 @@ index c26b24edc5f..85137ab3b52 100644 + unsigned int handles; /* number of handles */ +@END -- -2.11.0 +2.20.1 diff --git a/patches/ntdll-NtSuspendProcess/0001-ntdll-Implement-NtSuspendProcess-and-NtResumeProcess.patch b/patches/ntdll-NtSuspendProcess/0001-ntdll-Implement-NtSuspendProcess-and-NtResumeProcess.patch deleted file mode 100644 index 991fd5cc..00000000 --- a/patches/ntdll-NtSuspendProcess/0001-ntdll-Implement-NtSuspendProcess-and-NtResumeProcess.patch +++ /dev/null @@ -1,365 +0,0 @@ -From 34f55cc1771af01e49322148c89710f965d0197d Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Michael=20M=C3=BCller?= -Date: Tue, 21 Mar 2017 23:12:09 +0100 -Subject: ntdll: Implement NtSuspendProcess and NtResumeProcess. - ---- - dlls/ntdll/process.c | 28 ++++- - dlls/ntdll/tests/Makefile.in | 1 + - dlls/ntdll/tests/process.c | 207 +++++++++++++++++++++++++++++++++++ - server/protocol.def | 12 ++ - server/thread.c | 49 +++++++++ - 5 files changed, 293 insertions(+), 4 deletions(-) - create mode 100644 dlls/ntdll/tests/process.c - -diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c -index 623bf653..6cd16a42 100644 ---- a/dlls/ntdll/process.c -+++ b/dlls/ntdll/process.c -@@ -763,8 +763,18 @@ NTSTATUS WINAPI NtOpenProcess(PHANDLE handle, ACCESS_MASK access, - */ - NTSTATUS WINAPI NtResumeProcess( HANDLE handle ) - { -- FIXME("stub: %p\n", handle); -- return STATUS_NOT_IMPLEMENTED; -+ NTSTATUS status; -+ -+ TRACE("(%p)\n", handle); -+ -+ SERVER_START_REQ( resume_process ) -+ { -+ req->handle = wine_server_obj_handle( handle ); -+ status = wine_server_call( req ); -+ } -+ SERVER_END_REQ; -+ -+ return status; - } - - /****************************************************************************** -@@ -773,8 +783,18 @@ NTSTATUS WINAPI NtResumeProcess( HANDLE handle ) - */ - NTSTATUS WINAPI NtSuspendProcess( HANDLE handle ) - { -- FIXME("stub: %p\n", handle); -- return STATUS_NOT_IMPLEMENTED; -+ NTSTATUS status; -+ -+ TRACE("(%p)\n", handle); -+ -+ SERVER_START_REQ( suspend_process ) -+ { -+ req->handle = wine_server_obj_handle( handle ); -+ status = wine_server_call( req ); -+ } -+ SERVER_END_REQ; -+ -+ return status; - } - - -diff --git a/dlls/ntdll/tests/Makefile.in b/dlls/ntdll/tests/Makefile.in -index 5c70f3f0..a1b85883 100644 ---- a/dlls/ntdll/tests/Makefile.in -+++ b/dlls/ntdll/tests/Makefile.in -@@ -16,6 +16,7 @@ C_SRCS = \ - path.c \ - pipe.c \ - port.c \ -+ process.c \ - reg.c \ - rtl.c \ - rtlbitmap.c \ -diff --git a/dlls/ntdll/tests/process.c b/dlls/ntdll/tests/process.c -new file mode 100644 -index 00000000..41303b7e ---- /dev/null -+++ b/dlls/ntdll/tests/process.c -@@ -0,0 +1,207 @@ -+/* -+ * Unit test suite for process functions -+ * -+ * Copyright 2017 Michael Müller -+ * -+ * This library is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with this library; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA -+ */ -+ -+#include -+ -+#include "ntdll_test.h" -+ -+#include "windef.h" -+#include "winbase.h" -+ -+static NTSTATUS (WINAPI *pNtResumeProcess)(HANDLE); -+static NTSTATUS (WINAPI *pNtSuspendProcess)(HANDLE); -+static NTSTATUS (WINAPI *pNtSuspendThread)(HANDLE,PULONG); -+static NTSTATUS (WINAPI *pNtResumeThread)(HANDLE); -+ -+static void test_NtSuspendProcess(char *process_name) -+{ -+ PROCESS_INFORMATION info; -+ DEBUG_EVENT ev; -+ STARTUPINFOA startup; -+ NTSTATUS status; -+ HANDLE event; -+ char buffer[MAX_PATH]; -+ ULONG count; -+ DWORD ret; -+ -+ status = pNtResumeProcess(GetCurrentProcess()); -+ ok(status == STATUS_SUCCESS, "NtResumeProcess failed: %x\n", status); -+ -+ event = CreateEventA(NULL, TRUE, FALSE, "wine_suspend_event"); -+ ok(!!event, "Failed to create event: %u\n", GetLastError()); -+ -+ memset(&startup, 0, sizeof(startup)); -+ startup.cb = sizeof(startup); -+ -+ sprintf(buffer, "%s tests/process.c dummy_process wine_suspend_event", process_name); -+ ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info); -+ ok(ret, "CreateProcess failed with error %u\n", GetLastError()); -+ -+ ret = WaitForSingleObject(event, 500); -+ ok(ret == WAIT_OBJECT_0, "Event was not signaled: %d\n", ret); -+ -+ status = pNtSuspendProcess(info.hProcess); -+ ok(status == STATUS_SUCCESS, "NtResumeProcess failed: %x\n", status); -+ -+ ResetEvent(event); -+ -+ ret = WaitForSingleObject(event, 200); -+ ok(ret == WAIT_TIMEOUT, "Expected timeout, got: %d\n", ret); -+ -+ status = NtResumeThread(info.hThread, &count); -+ ok(status == STATUS_SUCCESS, "NtResumeProcess failed: %x\n", status); -+ ok(count == 1, "Expected count 1, got %d\n", count); -+ -+ ret = WaitForSingleObject(event, 200); -+ ok(ret == WAIT_OBJECT_0, "Event was not signaled: %d\n", ret); -+ -+ status = pNtResumeProcess(info.hProcess); -+ ok(status == STATUS_SUCCESS, "NtResumeProcess failed: %x\n", status); -+ -+ status = pNtSuspendThread(info.hThread, &count); -+ ok(status == STATUS_SUCCESS, "NtSuspendThread failed: %x\n", status); -+ ok(count == 0, "Expected count 0, got %d\n", count); -+ -+ ResetEvent(event); -+ -+ ret = WaitForSingleObject(event, 200); -+ ok(ret == WAIT_TIMEOUT, "Expected timeout, got: %d\n", ret); -+ -+ status = pNtResumeProcess(info.hProcess); -+ ok(status == STATUS_SUCCESS, "NtResumeProcess failed: %x\n", status); -+ -+ ret = WaitForSingleObject(event, 200); -+ ok(ret == WAIT_OBJECT_0, "Event was not signaled: %d\n", ret); -+ -+ status = pNtSuspendThread(info.hThread, &count); -+ ok(status == STATUS_SUCCESS, "NtSuspendThread failed: %x\n", status); -+ ok(count == 0, "Expected count 0, got %d\n", count); -+ -+ status = pNtSuspendThread(info.hThread, &count); -+ ok(status == STATUS_SUCCESS, "NtSuspendThread failed: %x\n", status); -+ ok(count == 1, "Expected count 1, got %d\n", count); -+ -+ ResetEvent(event); -+ -+ ret = WaitForSingleObject(event, 200); -+ ok(ret == WAIT_TIMEOUT, "Expected timeout, got: %d\n", ret); -+ -+ status = pNtResumeProcess(info.hProcess); -+ ok(status == STATUS_SUCCESS, "NtResumeProcess failed: %x\n", status); -+ -+ ret = WaitForSingleObject(event, 200); -+ ok(ret == WAIT_TIMEOUT, "Expected timeout, got: %d\n", ret); -+ -+ status = pNtResumeProcess(info.hProcess); -+ ok(status == STATUS_SUCCESS, "NtResumeProcess failed: %x\n", status); -+ -+ ret = WaitForSingleObject(event, 200); -+ ok(ret == WAIT_OBJECT_0, "Event was not signaled: %d\n", ret); -+ -+ ret = DebugActiveProcess(info.dwProcessId); -+ ok(ret, "Failed to debug process: %d\n", GetLastError()); -+ -+ ResetEvent(event); -+ -+ ret = WaitForSingleObject(event, 200); -+ ok(ret == WAIT_TIMEOUT, "Expected timeout, got: %d\n", ret); -+ -+ for (;;) -+ { -+ ret = WaitForDebugEvent(&ev, INFINITE); -+ ok(ret, "WaitForDebugEvent failed, last error %#x.\n", GetLastError()); -+ if (!ret) break; -+ -+ if (ev.dwDebugEventCode == OUTPUT_DEBUG_STRING_EVENT) break; -+ -+ ret = ContinueDebugEvent(ev.dwProcessId, ev.dwThreadId, DBG_CONTINUE); -+ ok(ret, "ContinueDebugEvent failed, last error %#x.\n", GetLastError()); -+ if (!ret) break; -+ } -+ -+ ResetEvent(event); -+ -+ ret = WaitForSingleObject(event, 200); -+ ok(ret == WAIT_TIMEOUT, "Expected timeout, got: %d\n", ret); -+ -+ status = pNtResumeProcess(info.hProcess); -+ ok(status == STATUS_SUCCESS, "NtResumeProcess failed: %x\n", status); -+ -+ ret = WaitForSingleObject(event, 200); -+ ok(ret == WAIT_TIMEOUT, "Expected timeout, got: %d\n", ret); -+ -+ status = NtResumeThread(info.hThread, &count); -+ ok(status == STATUS_SUCCESS, "NtResumeProcess failed: %x\n", status); -+ ok(count == 0, "Expected count 0, got %d\n", count); -+ -+ ret = WaitForSingleObject(event, 200); -+ ok(ret == WAIT_TIMEOUT, "Expected timeout, got: %d\n", ret); -+ -+ ret = ContinueDebugEvent(ev.dwProcessId, ev.dwThreadId, DBG_CONTINUE); -+ ok(ret, "ContinueDebugEvent failed, last error %#x.\n", GetLastError()); -+ -+ ret = WaitForSingleObject(event, 200); -+ ok(ret == WAIT_OBJECT_0, "Event was not signaled: %d\n", ret); -+ -+ TerminateProcess(info.hProcess, 0); -+ -+ CloseHandle(info.hProcess); -+ CloseHandle(info.hThread); -+} -+ -+static void dummy_process(char *event_name) -+{ -+ HANDLE event = OpenEventA(EVENT_ALL_ACCESS, FALSE, event_name); -+ -+ while (TRUE) -+ { -+ SetEvent(event); -+ OutputDebugStringA("test"); -+ Sleep(5); -+ } -+} -+ -+START_TEST(process) -+{ -+ HMODULE mod; -+ char **argv; -+ int argc; -+ -+ argc = winetest_get_mainargs(&argv); -+ if (argc >= 4 && strcmp(argv[2], "dummy_process") == 0) -+ { -+ dummy_process(argv[3]); -+ return; -+ } -+ -+ mod = GetModuleHandleA("ntdll.dll"); -+ if (!mod) -+ { -+ win_skip("Not running on NT, skipping tests\n"); -+ return; -+ } -+ -+ pNtResumeProcess = (void*)GetProcAddress(mod, "NtResumeProcess"); -+ pNtSuspendProcess = (void*)GetProcAddress(mod, "NtSuspendProcess"); -+ pNtResumeThread = (void*)GetProcAddress(mod, "NtResumeThread"); -+ pNtSuspendThread = (void*)GetProcAddress(mod, "NtSuspendThread"); -+ -+ test_NtSuspendProcess(argv[0]); -+} -diff --git a/server/protocol.def b/server/protocol.def -index 41d8f5a4..2aa76bdc 100644 ---- a/server/protocol.def -+++ b/server/protocol.def -@@ -3864,3 +3864,15 @@ struct handle_info - unsigned int threads; /* number of threads */ - unsigned int handles; /* number of handles */ - @END -+ -+ -+/* Suspend a process */ -+@REQ(suspend_process) -+ obj_handle_t handle; /* process handle */ -+@END -+ -+ -+/* Resume a process */ -+@REQ(resume_process) -+ obj_handle_t handle; /* process handle */ -+@END -diff --git a/server/thread.c b/server/thread.c -index 7162fc33..8bdfe41d 100644 ---- a/server/thread.c -+++ b/server/thread.c -@@ -1824,3 +1824,52 @@ DECL_HANDLER(get_selector_entry) - release_object( thread ); - } - } -+ -+/* Suspend a process */ -+DECL_HANDLER(suspend_process) -+{ -+ struct process *process; -+ -+ if ((process = get_process_from_handle( req->handle, PROCESS_SUSPEND_RESUME ))) -+ { -+ struct list *ptr, *next; -+ -+ LIST_FOR_EACH( ptr, &process->thread_list ) -+ { -+ struct thread *thread = LIST_ENTRY( ptr, struct thread, proc_entry ); -+ if (thread->suspend >= MAXIMUM_SUSPEND_COUNT) -+ { -+ set_error( STATUS_SUSPEND_COUNT_EXCEEDED ); -+ release_object( process ); -+ return; -+ } -+ } -+ -+ LIST_FOR_EACH_SAFE( ptr, next, &process->thread_list ) -+ { -+ struct thread *thread = LIST_ENTRY( ptr, struct thread, proc_entry ); -+ suspend_thread( thread ); -+ } -+ -+ release_object( process ); -+ } -+} -+ -+/* Resume a process */ -+DECL_HANDLER(resume_process) -+{ -+ struct process *process; -+ -+ if ((process = get_process_from_handle( req->handle, PROCESS_SUSPEND_RESUME ))) -+ { -+ struct list *ptr, *next; -+ -+ LIST_FOR_EACH_SAFE( ptr, next, &process->thread_list ) -+ { -+ struct thread *thread = LIST_ENTRY( ptr, struct thread, proc_entry ); -+ resume_thread( thread ); -+ } -+ -+ release_object( process ); -+ } -+} --- -2.19.1 - diff --git a/patches/ntdll-NtSuspendProcess/definition b/patches/ntdll-NtSuspendProcess/definition deleted file mode 100644 index 62b0ba05..00000000 --- a/patches/ntdll-NtSuspendProcess/definition +++ /dev/null @@ -1,2 +0,0 @@ -Fixes: [44656] Implement NtSuspendProcess and NtResumeProcess -Depends: kernel32-K32GetPerformanceInfo diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index e3541158..72edd1ef 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -52,7 +52,7 @@ usage() # Get the upstream commit sha upstream_commit() { - echo "f9301c2b66450a1cdd986e9052fcaa76535ba8b7" + echo "9d7d68747b06a03893df99c4beea36b762508603" } # Show version information @@ -207,7 +207,6 @@ patch_enable_all () enable_ntdll_NtQuerySection="$1" enable_ntdll_NtQueryVirtualMemory="$1" enable_ntdll_NtSetLdtEntries="$1" - enable_ntdll_NtSuspendProcess="$1" enable_ntdll_Pipe_SpecialCharacters="$1" enable_ntdll_ProcessQuotaLimits="$1" enable_ntdll_RtlCaptureStackBackTrace="$1" @@ -760,9 +759,6 @@ patch_enable () ntdll-NtSetLdtEntries) enable_ntdll_NtSetLdtEntries="$2" ;; - ntdll-NtSuspendProcess) - enable_ntdll_NtSuspendProcess="$2" - ;; ntdll-Pipe_SpecialCharacters) enable_ntdll_Pipe_SpecialCharacters="$2" ;; @@ -1895,9 +1891,6 @@ if test "$enable_eventfd_synchronization" -eq 1; then if test "$enable_advapi32_Token_Integrity_Level" -gt 1; then abort "Patchset advapi32-Token_Integrity_Level disabled, but eventfd_synchronization depends on that." fi - if test "$enable_ntdll_NtSuspendProcess" -gt 1; then - abort "Patchset ntdll-NtSuspendProcess disabled, but eventfd_synchronization depends on that." - fi if test "$enable_ntdll_RtlCreateUserThread" -gt 1; then abort "Patchset ntdll-RtlCreateUserThread disabled, but eventfd_synchronization depends on that." fi @@ -1920,7 +1913,6 @@ if test "$enable_eventfd_synchronization" -eq 1; then abort "Patchset ws2_32-WSACleanup disabled, but eventfd_synchronization depends on that." fi enable_advapi32_Token_Integrity_Level=1 - enable_ntdll_NtSuspendProcess=1 enable_ntdll_RtlCreateUserThread=1 enable_ntdll_SystemRoot_Symlink=1 enable_ntdll_User_Shared_Data=1 @@ -1981,13 +1973,6 @@ if test "$enable_ntdll_SystemRoot_Symlink" -eq 1; then enable_ntdll_Exception=1 fi -if test "$enable_ntdll_NtSuspendProcess" -eq 1; then - if test "$enable_kernel32_K32GetPerformanceInfo" -gt 1; then - abort "Patchset kernel32-K32GetPerformanceInfo disabled, but ntdll-NtSuspendProcess depends on that." - fi - enable_kernel32_K32GetPerformanceInfo=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." @@ -3418,36 +3403,6 @@ if test "$enable_dxva2_Video_Decoder" -eq 1; then ) >> "$patchlist" fi -# Patchset kernel32-K32GetPerformanceInfo -# | -# | Modified files: -# | * dlls/kernel32/cpu.c, server/process.c, server/protocol.def -# | -if test "$enable_kernel32_K32GetPerformanceInfo" -eq 1; then - patch_apply kernel32-K32GetPerformanceInfo/0001-kernel32-Make-K32GetPerformanceInfo-faster.patch - ( - printf '%s\n' '+ { "Michael Müller", "kernel32: Make K32GetPerformanceInfo faster.", 1 },'; - ) >> "$patchlist" -fi - -# Patchset ntdll-NtSuspendProcess -# | -# | This patchset has the following (direct or indirect) dependencies: -# | * kernel32-K32GetPerformanceInfo -# | -# | This patchset fixes the following Wine bugs: -# | * [#44656] Implement NtSuspendProcess and NtResumeProcess -# | -# | Modified files: -# | * dlls/ntdll/process.c, dlls/ntdll/tests/Makefile.in, dlls/ntdll/tests/process.c, server/protocol.def, server/thread.c -# | -if test "$enable_ntdll_NtSuspendProcess" -eq 1; then - patch_apply ntdll-NtSuspendProcess/0001-ntdll-Implement-NtSuspendProcess-and-NtResumeProcess.patch - ( - printf '%s\n' '+ { "Michael Müller", "ntdll: Implement NtSuspendProcess and NtResumeProcess.", 1 },'; - ) >> "$patchlist" -fi - # Patchset ntdll-RtlCreateUserThread # | # | This patchset fixes the following Wine bugs: @@ -3702,11 +3657,10 @@ fi # Patchset eventfd_synchronization # | # | This patchset has the following (direct or indirect) dependencies: -# | * Staging, advapi32-CreateRestrictedToken, server-Misc_ACL, advapi32-Token_Integrity_Level, -# | kernel32-K32GetPerformanceInfo, ntdll-NtSuspendProcess, ntdll-RtlCreateUserThread, ntdll-Exception, ntdll- -# | SystemRoot_Symlink, ntdll-ThreadTime, ntdll-Hide_Wine_Exports, ntdll-User_Shared_Data, server-Realtime_Priority, ntdll- -# | Threading, ntdll-Wait_User_APC, server-Key_State, server-PeekMessage, server-Signal_Thread, server-Shared_Memory, -# | ws2_32-WSACleanup +# | * Staging, advapi32-CreateRestrictedToken, server-Misc_ACL, advapi32-Token_Integrity_Level, ntdll-RtlCreateUserThread, +# | ntdll-Exception, ntdll-SystemRoot_Symlink, ntdll-ThreadTime, ntdll-Hide_Wine_Exports, ntdll-User_Shared_Data, server- +# | Realtime_Priority, ntdll-Threading, ntdll-Wait_User_APC, server-Key_State, server-PeekMessage, server-Signal_Thread, +# | 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 @@ -4259,6 +4213,18 @@ if test "$enable_kernel32_Job_Tests" -eq 1; then ) >> "$patchlist" fi +# Patchset kernel32-K32GetPerformanceInfo +# | +# | Modified files: +# | * dlls/kernel32/cpu.c, server/process.c, server/protocol.def +# | +if test "$enable_kernel32_K32GetPerformanceInfo" -eq 1; then + patch_apply kernel32-K32GetPerformanceInfo/0001-kernel32-Make-K32GetPerformanceInfo-faster.patch + ( + printf '%s\n' '+ { "Michael Müller", "kernel32: Make K32GetPerformanceInfo faster.", 1 },'; + ) >> "$patchlist" +fi + # Patchset kernel32-NeedCurrentDirectoryForExePath # | # | This patchset fixes the following Wine bugs: @@ -4758,7 +4724,8 @@ fi # | # | Modified files: # | * configure.ac, dlls/kernel32/path.c, dlls/kernel32/tests/path.c, dlls/kernel32/volume.c, dlls/ntdll/file.c, -# | dlls/ntdll/tests/file.c, include/Makefile.in, include/wine/port.h, libs/port/Makefile.in, server/fd.c +# | dlls/ntdll/tests/file.c, include/Makefile.in, include/ntifs.h, include/wine/port.h, libs/port/Makefile.in, +# | libs/port/renameat2.c, server/fd.c # | if test "$enable_ntdll_Junction_Points" -eq 1; then patch_apply ntdll-Junction_Points/0001-ntdll-Add-support-for-junction-point-creation.patch diff --git a/patches/server-Misc_ACL/0001-server-Add-default-security-descriptor-ownership-for.patch b/patches/server-Misc_ACL/0001-server-Add-default-security-descriptor-ownership-for.patch index 9970f96c..3227f41a 100644 --- a/patches/server-Misc_ACL/0001-server-Add-default-security-descriptor-ownership-for.patch +++ b/patches/server-Misc_ACL/0001-server-Add-default-security-descriptor-ownership-for.patch @@ -1,4 +1,4 @@ -From 3bc077fcf2d73665b8838bf23e989ed248af823e Mon Sep 17 00:00:00 2001 +From 0672c3d257e7e70d48edafde6e8a286b8e7c2c85 Mon Sep 17 00:00:00 2001 From: "Erich E. Hoover" Date: Wed, 25 Jun 2014 11:49:12 -0600 Subject: [PATCH] server: Add default security descriptor ownership for @@ -6,13 +6,13 @@ Subject: [PATCH] server: Add default security descriptor ownership for --- dlls/advapi32/tests/security.c | 35 ++++++++++++++++++++++++++++++++++ - server/process.c | 26 ++++++++++++++++++++++++- + server/process.c | 27 +++++++++++++++++++++++++- server/security.h | 1 + server/token.c | 2 ++ - 4 files changed, 63 insertions(+), 1 deletion(-) + 4 files changed, 64 insertions(+), 1 deletion(-) diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c -index d9cae64d..3097a64f 100644 +index 62aa556846a..eb106daab1d 100644 --- a/dlls/advapi32/tests/security.c +++ b/dlls/advapi32/tests/security.c @@ -4682,11 +4682,15 @@ static void test_acls(void) @@ -70,7 +70,7 @@ index d9cae64d..3097a64f 100644 static void test_GetSidSubAuthority(void) diff --git a/server/process.c b/server/process.c -index 77bd1e74..e3596942 100644 +index 2d6394a9183..0a77130b613 100644 --- a/server/process.c +++ b/server/process.c @@ -63,6 +63,7 @@ static void process_dump( struct object *obj, int verbose ); @@ -79,9 +79,9 @@ index 77bd1e74..e3596942 100644 static unsigned int process_map_access( struct object *obj, unsigned int access ); +static struct security_descriptor *process_get_sd( struct object *obj ); static void process_poll_event( struct fd *fd, int event ); + static struct list *process_get_kernel_obj_list( struct object *obj ); static void process_destroy( struct object *obj ); - static void terminate_process( struct process *process, struct thread *skip, int exit_code ); -@@ -79,7 +80,7 @@ static const struct object_ops process_ops = +@@ -80,7 +81,7 @@ static const struct object_ops process_ops = no_signal, /* signal */ no_get_fd, /* get_fd */ process_map_access, /* map_access */ @@ -90,10 +90,17 @@ index 77bd1e74..e3596942 100644 default_set_sd, /* set_sd */ no_lookup_name, /* lookup_name */ no_link_name, /* link_name */ -@@ -658,6 +659,29 @@ static unsigned int process_map_access( struct object *obj, unsigned int access +@@ -663,12 +664,36 @@ static unsigned int process_map_access( struct object *obj, unsigned int access return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL); } ++ + static struct list *process_get_kernel_obj_list( struct object *obj ) + { + struct process *process = (struct process *)obj; + return &process->kernel_object; + } + +static struct security_descriptor *process_get_sd( struct object *obj ) +{ + static struct security_descriptor *key_default_sd; @@ -121,7 +128,7 @@ index 77bd1e74..e3596942 100644 { struct process *process = get_fd_user( fd ); diff --git a/server/security.h b/server/security.h -index 873bbc6a..606dbb2a 100644 +index bc4a8f64daa..6c337143c3d 100644 --- a/server/security.h +++ b/server/security.h @@ -47,6 +47,7 @@ extern const PSID security_local_user_sid; @@ -133,7 +140,7 @@ index 873bbc6a..606dbb2a 100644 diff --git a/server/token.c b/server/token.c -index e440d489..f236084b 100644 +index de76939831e..0e124e8fe0c 100644 --- a/server/token.c +++ b/server/token.c @@ -83,6 +83,7 @@ static const SID_N(5) local_user_sid = { SID_REVISION, 5, { SECURITY_NT_AUTHORIT diff --git a/patches/winedevice-Default_Drivers/0004-programs-winedevice-Load-some-common-drivers-and-fix.patch b/patches/winedevice-Default_Drivers/0004-programs-winedevice-Load-some-common-drivers-and-fix.patch index 543a4e98..3bcb4aff 100644 --- a/patches/winedevice-Default_Drivers/0004-programs-winedevice-Load-some-common-drivers-and-fix.patch +++ b/patches/winedevice-Default_Drivers/0004-programs-winedevice-Load-some-common-drivers-and-fix.patch @@ -1,19 +1,19 @@ -From 6f57fd23096d854ac448817cbe69747e7265f9fb Mon Sep 17 00:00:00 2001 +From e0c12afb9d1c7d0fb82cde48d5a92ed7e2ad77f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Thu, 8 Jun 2017 23:50:03 +0200 Subject: [PATCH] programs/winedevice: Load some common drivers and fix ldr order. --- - dlls/ntoskrnl.exe/tests/driver.c | 51 ++++++++++++++++++++++++++++++++ + dlls/ntoskrnl.exe/tests/driver.c | 52 ++++++++++++++++++++++++++++++++ programs/winedevice/device.c | 26 ++++++++++++++++ - 2 files changed, 77 insertions(+) + 2 files changed, 78 insertions(+) diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c -index b2ac5fc8a0e..c2675eadca7 100644 +index d7083f7fa5a..ede3054deda 100644 --- a/dlls/ntoskrnl.exe/tests/driver.c +++ b/dlls/ntoskrnl.exe/tests/driver.c -@@ -38,6 +38,8 @@ static const WCHAR driver_device[] = {'\\','D','e','v','i','c','e', +@@ -39,6 +39,8 @@ static const WCHAR driver_device[] = {'\\','D','e','v','i','c','e', static const WCHAR driver_link[] = {'\\','D','o','s','D','e','v','i','c','e','s', '\\','W','i','n','e','T','e','s','t','D','r','i','v','e','r',0}; @@ -22,10 +22,18 @@ index b2ac5fc8a0e..c2675eadca7 100644 static HANDLE okfile; static LONG successes; static LONG failures; -@@ -1071,6 +1073,52 @@ static void test_resource(void) +@@ -1168,6 +1170,7 @@ static void test_resource(void) ok(status == STATUS_SUCCESS, "got status %#x\n", status); } ++ + static void test_lookup_thread(void) + { + NTSTATUS status; +@@ -1182,6 +1185,52 @@ static void test_lookup_thread(void) + ok(status == STATUS_INVALID_PARAMETER, "PsLookupThreadByThreadId returned %#x\n", status); + } + +static void test_default_modules(void) +{ + BOOL win32k = FALSE, dxgkrnl = FALSE, dxgmms1 = FALSE; @@ -75,15 +83,15 @@ index b2ac5fc8a0e..c2675eadca7 100644 static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info) { ULONG length = stack->Parameters.DeviceIoControl.OutputBufferLength; -@@ -1113,6 +1161,7 @@ static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *st +@@ -1224,6 +1273,7 @@ static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *st test_stack_callout(); test_lookaside_list(); test_ob_reference(test_input->path); + test_default_modules(); test_resource(); + test_lookup_thread(); - /* print process report */ -@@ -1226,6 +1275,8 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, PUNICODE_STRING registry) +@@ -1338,6 +1388,8 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, PUNICODE_STRING registry) DbgPrint("loading driver\n");