ntdll-RtlCreateUserThread: Fix a compiler warning.

This commit is contained in:
Zebediah Figura 2020-06-02 18:30:51 -05:00
parent 92d52c3f4c
commit 2fd3b9fdfd

View File

@ -1,4 +1,4 @@
From 325be924c400a713b5122b7de800e197ddc3f8b7 Mon Sep 17 00:00:00 2001
From 9fdc6855fed56b4b6baa0c5bd0f4633fec536c06 Mon Sep 17 00:00:00 2001
From: Andrew Wesie <awesie@gmail.com>
Date: Fri, 27 Jul 2018 01:22:59 -0500
Subject: [PATCH] ntdll: Refactor RtlCreateUserThread into NtCreateThreadEx.
@ -7,9 +7,9 @@ League of Legends hooks NtCreateThread or NtCreateThreadEx (depending on the
reported version), and expects it to be called whenever a thread is created.
---
dlls/ntdll/ntdll.spec | 2 +-
dlls/ntdll/thread.c | 194 ++++++++++++++++++++++++++++++++++--------
dlls/ntdll/thread.c | 196 ++++++++++++++++++++++++++++++++++--------
include/winternl.h | 27 ++++++
3 files changed, 187 insertions(+), 36 deletions(-)
3 files changed, 188 insertions(+), 37 deletions(-)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 42532bd9f1c..65fdc30d7a4 100644
@ -25,16 +25,17 @@ index 42532bd9f1c..65fdc30d7a4 100644
@ stdcall NtCreateTimer(ptr long ptr long)
@ stub NtCreateToken
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 20934448fa3..9deb4397ba9 100644
index c9a2240a4da..f04b8bb337e 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -390,34 +390,18 @@ static void start_thread( struct startup_info *info )
@@ -406,34 +406,18 @@ static void start_thread( struct startup_info *info )
/***********************************************************************
* NtCreateThreadEx (NTDLL.@)
*/
-NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle_ptr, ACCESS_MASK access, OBJECT_ATTRIBUTES *attr,
- HANDLE process, LPTHREAD_START_ROUTINE start, void *param,
+NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle_ptr, ACCESS_MASK access, OBJECT_ATTRIBUTES *thread_attr,
HANDLE process, LPTHREAD_START_ROUTINE start, void *param,
+ HANDLE process, PRTL_THREAD_START_ROUTINE start, void *param,
ULONG flags, ULONG zero_bits, ULONG stack_commit,
- ULONG stack_reserve, void *attribute_list )
-{
@ -68,7 +69,7 @@ index 20934448fa3..9deb4397ba9 100644
HANDLE handle = 0, actctx = 0;
TEB *teb = NULL;
DWORD tid = 0;
@@ -428,6 +412,33 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr,
@@ -444,6 +428,33 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr,
struct object_attributes *objattr = NULL;
INITIAL_TEB stack;
@ -102,7 +103,7 @@ index 20934448fa3..9deb4397ba9 100644
if (process != NtCurrentProcess())
{
apc_call_t call;
@@ -453,12 +464,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr,
@@ -469,12 +480,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr,
return result.create_thread.status;
}
@ -116,7 +117,7 @@ index 20934448fa3..9deb4397ba9 100644
if (unix_funcs->server_pipe( request_pipe ) == -1)
{
@@ -470,7 +476,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr,
@@ -486,7 +492,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr,
SERVER_START_REQ( new_thread )
{
req->process = wine_server_obj_handle( process );
@ -125,7 +126,7 @@ index 20934448fa3..9deb4397ba9 100644
req->suspend = suspended;
req->request_fd = request_pipe[0];
wine_server_add_data( req, objattr, len );
@@ -529,20 +535,20 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr,
@@ -547,20 +553,20 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr,
thread_data->wait_fd[1] = -1;
thread_data->start_stack = (char *)teb->Tib.StackBase;
@ -153,32 +154,32 @@ index 20934448fa3..9deb4397ba9 100644
pthread_sigmask( SIG_SETMASK, &sigset, NULL );
if (id) id->UniqueThread = ULongToHandle(tid);
@@ -559,6 +565,124 @@ error:
@@ -577,6 +583,124 @@ error:
return status;
}
+NTSTATUS WINAPI NtCreateThread( HANDLE *handle_ptr, ACCESS_MASK access, OBJECT_ATTRIBUTES *attr, HANDLE process,
+ CLIENT_ID *id, CONTEXT *context, INITIAL_TEB *teb, BOOLEAN suspended )
+{
+ LPTHREAD_START_ROUTINE entry;
+ PRTL_THREAD_START_ROUTINE entry;
+ void *arg;
+ ULONG flags = suspended ? THREAD_CREATE_FLAGS_CREATE_SUSPENDED : 0;
+ PS_ATTRIBUTE_LIST attr_list, *pattr_list = NULL;
+
+#if defined(__i386__)
+ entry = (LPTHREAD_START_ROUTINE) context->Eax;
+ entry = (PRTL_THREAD_START_ROUTINE) context->Eax;
+ arg = (void *)context->Ebx;
+#elif defined(__x86_64__)
+ entry = (LPTHREAD_START_ROUTINE) context->Rcx;
+ entry = (PRTL_THREAD_START_ROUTINE) context->Rcx;
+ arg = (void *)context->Rdx;
+#elif defined(__arm__)
+ entry = (LPTHREAD_START_ROUTINE) context->R0;
+ entry = (PRTL_THREAD_START_ROUTINE) context->R0;
+ arg = (void *)context->R1;
+#elif defined(__aarch64__)
+ entry = (LPTHREAD_START_ROUTINE) context->u.X0;
+ entry = (PRTL_THREAD_START_ROUTINE) context->u.X0;
+ arg = (void *)context->u.X1;
+#elif defined(__powerpc__)
+ entry = (LPTHREAD_START_ROUTINE) context->Gpr3;
+ entry = (PRTL_THREAD_START_ROUTINE) context->Gpr3;
+ arg = (void *)context->Gpr4;
+#endif
+