From 3ba119e67c81c2a4f110672814caa289b1c171e3 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Wed, 27 Nov 2019 11:11:51 +1100 Subject: [PATCH] Rebase against ce275f38a02dd5f809eea45ff3fa02f645b56a7c --- ...tlCreateUserThread-into-NtCreateThre.patch | 38 +++++++------- ...ryInformationThread-ThreadHideFromDe.patch | 14 +++--- patches/patchinstall.sh | 2 +- ...-support-for-global-and-local-shared.patch | 49 ++++++++++--------- ...ignal-thread-until-it-is-really-gone.patch | 24 ++++----- 5 files changed, 65 insertions(+), 62 deletions(-) diff --git a/patches/ntdll-RtlCreateUserThread/0001-ntdll-Refactor-RtlCreateUserThread-into-NtCreateThre.patch b/patches/ntdll-RtlCreateUserThread/0001-ntdll-Refactor-RtlCreateUserThread-into-NtCreateThre.patch index 33730789..55c89f17 100644 --- a/patches/ntdll-RtlCreateUserThread/0001-ntdll-Refactor-RtlCreateUserThread-into-NtCreateThre.patch +++ b/patches/ntdll-RtlCreateUserThread/0001-ntdll-Refactor-RtlCreateUserThread-into-NtCreateThre.patch @@ -1,4 +1,4 @@ -From d5665101d6779856aedd2f354021a303a2be21d9 Mon Sep 17 00:00:00 2001 +From 24ba9bf89a735ea3b9d7b775eb271b25d1d43ab3 Mon Sep 17 00:00:00 2001 From: Andrew Wesie Date: Fri, 27 Jul 2018 01:22:59 -0500 Subject: [PATCH] ntdll: Refactor RtlCreateUserThread into NtCreateThreadEx. @@ -8,14 +8,14 @@ reported version), and expects it to be called whenever a thread is created. --- dlls/ntdll/ntdll.spec | 2 +- dlls/ntdll/thread.c | 194 ++++++++++++++++++++++++++++++++++-------- - include/winternl.h | 25 ++++++ - 3 files changed, 185 insertions(+), 36 deletions(-) + include/winternl.h | 27 ++++++ + 3 files changed, 187 insertions(+), 36 deletions(-) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec -index 5d60528b71d..164effb78f3 100644 +index 95ef2d5b744..b87e19cbf50 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec -@@ -175,7 +175,7 @@ +@@ -182,7 +182,7 @@ @ stdcall NtCreateSection(ptr long ptr ptr long long long) @ stdcall NtCreateSemaphore(ptr long ptr long long) @ stdcall NtCreateSymbolicLinkObject(ptr long ptr ptr) @@ -25,10 +25,10 @@ index 5d60528b71d..164effb78f3 100644 @ stdcall NtCreateTimer(ptr long ptr long) @ stub NtCreateToken diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c -index 6552c486824..db291369c08 100644 +index 72c1d14a79a..45a943f5d21 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c -@@ -543,34 +543,18 @@ static void start_thread( struct startup_info *info ) +@@ -594,34 +594,18 @@ static void start_thread( struct startup_info *info ) /*********************************************************************** * NtCreateThreadEx (NTDLL.@) */ @@ -68,7 +68,7 @@ index 6552c486824..db291369c08 100644 HANDLE handle = 0, actctx = 0; TEB *teb = NULL; DWORD tid = 0; -@@ -581,6 +565,33 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr, +@@ -632,6 +616,33 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr, struct object_attributes *objattr = NULL; INITIAL_TEB stack; @@ -102,7 +102,7 @@ index 6552c486824..db291369c08 100644 if (process != NtCurrentProcess()) { apc_call_t call; -@@ -606,12 +617,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr, +@@ -657,12 +668,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr, return result.create_thread.status; } @@ -116,7 +116,7 @@ index 6552c486824..db291369c08 100644 if (server_pipe( request_pipe ) == -1) { -@@ -623,7 +629,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr, +@@ -674,7 +680,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr, SERVER_START_REQ( new_thread ) { req->process = wine_server_obj_handle( process ); @@ -125,7 +125,7 @@ index 6552c486824..db291369c08 100644 req->suspend = suspended; req->request_fd = request_pipe[0]; wine_server_add_data( req, objattr, len ); -@@ -685,20 +691,20 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr, +@@ -736,20 +742,20 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr, thread_data->wait_fd[1] = -1; thread_data->start_stack = (char *)teb->Tib.StackBase; @@ -153,7 +153,7 @@ index 6552c486824..db291369c08 100644 pthread_sigmask( SIG_SETMASK, &sigset, NULL ); if (id) id->UniqueThread = ULongToHandle(tid); -@@ -715,6 +721,124 @@ error: +@@ -766,6 +772,124 @@ error: return status; } @@ -279,12 +279,12 @@ index 6552c486824..db291369c08 100644 /****************************************************************************** * RtlGetNtGlobalFlags (NTDLL.@) diff --git a/include/winternl.h b/include/winternl.h -index c6dbc5931b2..d1937b9f06b 100644 +index 3ace4fcf25e..b6674d75dd9 100644 --- a/include/winternl.h +++ b/include/winternl.h -@@ -2197,6 +2197,31 @@ typedef enum _SYSDBG_COMMAND { - SysDbgWriteBusData - } SYSDBG_COMMAND, *PSYSDBG_COMMAND; +@@ -2228,6 +2228,33 @@ typedef struct _NLSTABLEINFO + USHORT *LowerCaseTable; + } NLSTABLEINFO, *PNLSTABLEINFO; +#define PS_ATTRIBUTE_THREAD 0x00010000 +#define PS_ATTRIBUTE_INPUT 0x00020000 @@ -311,9 +311,11 @@ index c6dbc5931b2..d1937b9f06b 100644 + PS_ATTRIBUTE Attributes[1]; +} PS_ATTRIBUTE_LIST, *PPS_ATTRIBUTE_LIST; + - ++ ++ /************************************************************************* * Loader structures + * -- -2.17.1 +2.24.0 diff --git a/patches/ntdll-ThreadHideFromDebugger/0001-ntdll-Stub-NtQueryInformationThread-ThreadHideFromDe.patch b/patches/ntdll-ThreadHideFromDebugger/0001-ntdll-Stub-NtQueryInformationThread-ThreadHideFromDe.patch index addc320e..07494904 100644 --- a/patches/ntdll-ThreadHideFromDebugger/0001-ntdll-Stub-NtQueryInformationThread-ThreadHideFromDe.patch +++ b/patches/ntdll-ThreadHideFromDebugger/0001-ntdll-Stub-NtQueryInformationThread-ThreadHideFromDe.patch @@ -1,4 +1,4 @@ -From 39813f58fc654ecd12f9ce5cf0d6e356e2e81697 Mon Sep 17 00:00:00 2001 +From f79b3408935d1f4650c7369e0507c223c5f9ed33 Mon Sep 17 00:00:00 2001 From: David Torok Date: Tue, 19 Nov 2019 23:01:46 +0100 Subject: [PATCH] ntdll: Stub NtQueryInformationThread(ThreadHideFromDebugger). @@ -8,13 +8,13 @@ Subject: [PATCH] ntdll: Stub NtQueryInformationThread(ThreadHideFromDebugger). 1 file changed, 5 insertions(+) diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c -index 621aaddfe..512b4814e 100644 +index b913326f796..840b8ffd0b1 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c -@@ -1115,6 +1115,11 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class, - *(BOOL*)data = FALSE; - if (ret_len) *ret_len = sizeof(BOOL); - return STATUS_SUCCESS; +@@ -1460,6 +1460,11 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class, + *ret_len = sizeof(*info) + desc_len; + } + return status; + case ThreadHideFromDebugger: + if (length != sizeof(char)) return STATUS_INFO_LENGTH_MISMATCH; + *(BOOLEAN *)data = TRUE; @@ -24,5 +24,5 @@ index 621aaddfe..512b4814e 100644 case ThreadBasePriority: case ThreadImpersonationToken: -- -2.23.0 +2.24.0 diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index ebb22d16..4406269d 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -52,7 +52,7 @@ usage() # Get the upstream commit sha upstream_commit() { - echo "ddec23013e39b563a3a50c0fe42c2ae8b518d538" + echo "ce275f38a02dd5f809eea45ff3fa02f645b56a7c" } # Show version information diff --git a/patches/server-Shared_Memory/0002-server-Implement-support-for-global-and-local-shared.patch b/patches/server-Shared_Memory/0002-server-Implement-support-for-global-and-local-shared.patch index b4247628..349931b7 100644 --- a/patches/server-Shared_Memory/0002-server-Implement-support-for-global-and-local-shared.patch +++ b/patches/server-Shared_Memory/0002-server-Implement-support-for-global-and-local-shared.patch @@ -1,4 +1,4 @@ -From 02dbd85ade50972fe25bec623ce24d6e65c868ea Mon Sep 17 00:00:00 2001 +From 8e7431126f55f1cfaed86fca2b3a3fea6a3bc1ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Thu, 19 Mar 2015 01:22:34 +0100 Subject: [PATCH] server: Implement support for global and local shared memory @@ -20,10 +20,10 @@ Subject: [PATCH] server: Implement support for global and local shared memory 12 files changed, 215 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h -index 7bbe23d969b..3146f3c150b 100644 +index 25051b58fba..10243926bd1 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h -@@ -116,6 +116,7 @@ extern NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct o +@@ -119,6 +119,7 @@ extern NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct o extern NTSTATUS validate_open_object_attributes( const OBJECT_ATTRIBUTES *attr ) DECLSPEC_HIDDEN; extern int wait_select_reply( void *cookie ) DECLSPEC_HIDDEN; extern BOOL invoke_apc( const apc_call_t *call, apc_result_t *result, sigset_t *user_sigset ) DECLSPEC_HIDDEN; @@ -114,10 +114,10 @@ index cce51683356..72a8ddb1803 100644 ntdll_get_thread_data()->wow64_redir = is_wow64; diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c -index 61b1cce4fe1..89f4e190e75 100644 +index 9c4e84ad313..1eb658ec051 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c -@@ -478,6 +478,7 @@ void exit_thread( int status ) +@@ -529,6 +529,7 @@ void exit_thread( int status ) void WINAPI RtlExitUserThread( ULONG status ) { static void *prev_teb; @@ -125,7 +125,7 @@ index 61b1cce4fe1..89f4e190e75 100644 sigset_t sigset; TEB *teb; -@@ -502,6 +503,9 @@ void WINAPI RtlExitUserThread( ULONG status ) +@@ -553,6 +554,9 @@ void WINAPI RtlExitUserThread( ULONG status ) LdrShutdownThread(); RtlFreeThreadActivationContextStack(); @@ -158,7 +158,7 @@ index ac5dcc6f8bc..5a845f424c2 100644 /* macros for server requests */ diff --git a/include/winternl.h b/include/winternl.h -index fed48eb3638..4c0021555c3 100644 +index b6674d75dd9..e6bc13cbc05 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -401,7 +401,7 @@ typedef struct _TEB @@ -240,7 +240,7 @@ index ee8cadde5da..313039a3082 100644 return 0; } diff --git a/server/mapping.c b/server/mapping.c -index 0728fdc14fc..7b12d2fb1fa 100644 +index 6990a1913d7..3d794bfaaf9 100644 --- a/server/mapping.c +++ b/server/mapping.c @@ -29,8 +29,32 @@ @@ -341,7 +341,7 @@ index 0728fdc14fc..7b12d2fb1fa 100644 static int create_temp_file( file_pos_t size ) { diff --git a/server/protocol.def b/server/protocol.def -index d803976ed94..f9370fbabb4 100644 +index 4e1f1f8ad5f..623871dd6dc 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -69,6 +69,15 @@ struct request_max_size @@ -360,7 +360,7 @@ index d803976ed94..f9370fbabb4 100644 /* debug event data */ typedef union -@@ -1318,6 +1327,12 @@ enum server_fd_type +@@ -1321,6 +1330,12 @@ enum server_fd_type @END @@ -374,44 +374,45 @@ index d803976ed94..f9370fbabb4 100644 @REQ(flush) async_data_t async; /* async I/O parameters */ diff --git a/server/thread.c b/server/thread.c -index 24ce76717ae..982fd76008b 100644 +index f8962221d9a..75679e90faf 100644 --- a/server/thread.c +++ b/server/thread.c -@@ -202,6 +202,8 @@ static inline void init_thread_structure( struct thread *thread ) - thread->desktop_users = 0; - thread->token = NULL; +@@ -204,6 +204,8 @@ static inline void init_thread_structure( struct thread *thread ) + thread->desc = NULL; + thread->desc_len = 0; thread->exit_poll = NULL; + thread->shm_fd = -1; + thread->shm = NULL; thread->creation_time = current_time; thread->exit_time = 0; -@@ -337,6 +339,8 @@ static void cleanup_thread( struct thread *thread ) +@@ -339,7 +341,10 @@ static void cleanup_thread( struct thread *thread ) thread->inflight[i].client = thread->inflight[i].server = -1; } } ++ + free( thread->desc ); + release_shared_memory( thread->shm_fd, thread->shm, sizeof(*thread->shm) ); + thread->req_data = NULL; thread->reply_data = NULL; thread->request_fd = NULL; -@@ -345,6 +349,9 @@ static void cleanup_thread( struct thread *thread ) - thread->context = NULL; - thread->suspend_context = NULL; +@@ -350,6 +355,8 @@ static void cleanup_thread( struct thread *thread ) thread->desktop = 0; + thread->desc = NULL; + thread->desc_len = 0; + thread->shm_fd = -1; + thread->shm = NULL; -+ } /* destroy a thread when its refcount is 0 */ diff --git a/server/thread.h b/server/thread.h -index 0085204c92e..382b10b5b01 100644 +index 880419c5924..2037f775370 100644 --- a/server/thread.h +++ b/server/thread.h -@@ -89,6 +89,8 @@ struct thread - struct token *token; /* security token associated with this thread */ - struct list kernel_object; /* list of kernel object pointers */ +@@ -91,6 +91,8 @@ struct thread + data_size_t desc_len; /* thread description length in bytes */ + WCHAR *desc; /* thread description string */ struct timeout_user *exit_poll; /* poll if the thread/process has exited already */ + int shm_fd; /* file descriptor for thread local shared memory */ + shmlocal_t *shm; /* thread local shared memory pointer */ @@ -419,5 +420,5 @@ index 0085204c92e..382b10b5b01 100644 struct thread_snapshot -- -2.17.1 +2.24.0 diff --git a/patches/server-Signal_Thread/0001-server-Do-not-signal-thread-until-it-is-really-gone.patch b/patches/server-Signal_Thread/0001-server-Do-not-signal-thread-until-it-is-really-gone.patch index e24a34c8..dbac4400 100644 --- a/patches/server-Signal_Thread/0001-server-Do-not-signal-thread-until-it-is-really-gone.patch +++ b/patches/server-Signal_Thread/0001-server-Do-not-signal-thread-until-it-is-really-gone.patch @@ -1,4 +1,4 @@ -From dec47516b5df791ff46909db03fe9752385a97d7 Mon Sep 17 00:00:00 2001 +From a2401a21b78201f2310d571f8d66ac574dd0d830 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Mon, 12 Nov 2018 18:10:32 +0200 Subject: [PATCH] server: Do not signal violently terminated threads until they @@ -27,18 +27,18 @@ Signed-off-by: Gabriel Ivăncescu 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/server/thread.c b/server/thread.c -index b1d324f7d..044d73ca9 100644 +index 1c0fbd4179b..f8962221d9a 100644 --- a/server/thread.c +++ b/server/thread.c @@ -203,6 +203,7 @@ static inline void init_thread_structure( struct thread *thread ) - thread->suspend = 0; - thread->desktop_users = 0; thread->token = NULL; + thread->desc = NULL; + thread->desc_len = 0; + thread->exit_poll = NULL; thread->creation_time = current_time; thread->exit_time = 0; -@@ -358,6 +359,7 @@ static void destroy_thread( struct object *obj ) +@@ -361,6 +362,7 @@ static void destroy_thread( struct object *obj ) list_remove( &thread->entry ); cleanup_thread( thread ); release_object( thread->process ); @@ -46,7 +46,7 @@ index b1d324f7d..044d73ca9 100644 if (thread->id) free_ptid( thread->id ); if (thread->token) release_object( thread->token ); } -@@ -382,7 +384,7 @@ static struct object_type *thread_get_type( struct object *obj ) +@@ -385,7 +387,7 @@ static struct object_type *thread_get_type( struct object *obj ) static int thread_signaled( struct object *obj, struct wait_queue_entry *entry ) { struct thread *mythread = (struct thread *)obj; @@ -55,7 +55,7 @@ index b1d324f7d..044d73ca9 100644 } static unsigned int thread_map_access( struct object *obj, unsigned int access ) -@@ -1143,6 +1145,26 @@ int thread_get_inflight_fd( struct thread *thread, int client ) +@@ -1171,6 +1173,26 @@ int thread_get_inflight_fd( struct thread *thread, int client ) return -1; } @@ -82,7 +82,7 @@ index b1d324f7d..044d73ca9 100644 /* kill a thread on the spot */ void kill_thread( struct thread *thread, int violent_death ) { -@@ -1163,8 +1185,12 @@ void kill_thread( struct thread *thread, int violent_death ) +@@ -1191,8 +1213,12 @@ void kill_thread( struct thread *thread, int violent_death ) kill_console_processes( thread, 0 ); debug_exit_thread( thread ); abandon_mutexes( thread ); @@ -98,17 +98,17 @@ index b1d324f7d..044d73ca9 100644 remove_process_thread( thread->process, thread ); release_object( thread ); diff --git a/server/thread.h b/server/thread.h -index bafc08ed4..4e7f794c0 100644 +index 7957557b6cc..880419c5924 100644 --- a/server/thread.h +++ b/server/thread.h @@ -90,6 +90,7 @@ struct thread - timeout_t exit_time; /* Thread exit time */ - struct token *token; /* security token associated with this thread */ struct list kernel_object; /* list of kernel object pointers */ + data_size_t desc_len; /* thread description length in bytes */ + WCHAR *desc; /* thread description string */ + struct timeout_user *exit_poll; /* poll if the thread/process has exited already */ }; struct thread_snapshot -- -2.21.0 +2.24.0