Alexandre Julliard : ntdll: Move the activation context initialization out of NtCreateThreadEx().
Alexandre Julliard
julliard at winehq.org
Mon Jul 13 16:08:50 CDT 2020
Module: wine
Branch: master
Commit: fdb09f452376ead1fceeb04dc5407095467418c1
URL: https://source.winehq.org/git/wine.git/?a=commit;h=fdb09f452376ead1fceeb04dc5407095467418c1
Author: Alexandre Julliard <julliard at winehq.org>
Date: Mon Jul 13 18:38:10 2020 +0200
ntdll: Move the activation context initialization out of NtCreateThreadEx().
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/thread.c | 31 +++++++++++++++++++++++++------
dlls/ntdll/unix/thread.c | 12 ------------
2 files changed, 25 insertions(+), 18 deletions(-)
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 02dddfacb5..76e314841b 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -190,26 +190,45 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr,
HANDLE *handle_ptr, CLIENT_ID *id )
{
ULONG flags = suspended ? THREAD_CREATE_FLAGS_CREATE_SUSPENDED : 0;
- HANDLE handle;
+ ULONG_PTR buffer[offsetof( PS_ATTRIBUTE_LIST, Attributes[2] ) / sizeof(ULONG_PTR)];
+ PS_ATTRIBUTE_LIST *attr_list = (PS_ATTRIBUTE_LIST *)buffer;
+ HANDLE handle, actctx;
+ TEB *teb;
+ ULONG ret;
NTSTATUS status;
CLIENT_ID client_id;
OBJECT_ATTRIBUTES attr;
- PS_ATTRIBUTE_LIST attr_list = { sizeof(attr_list) };
- attr_list.Attributes[0].Attribute = PS_ATTRIBUTE_CLIENT_ID;
- attr_list.Attributes[0].Size = sizeof(client_id);
- attr_list.Attributes[0].ValuePtr = &client_id;
+ attr_list->TotalLength = sizeof(buffer);
+ attr_list->Attributes[0].Attribute = PS_ATTRIBUTE_CLIENT_ID;
+ attr_list->Attributes[0].Size = sizeof(client_id);
+ attr_list->Attributes[0].ValuePtr = &client_id;
+ attr_list->Attributes[0].ReturnLength = NULL;
+ attr_list->Attributes[1].Attribute = PS_ATTRIBUTE_TEB_ADDRESS;
+ attr_list->Attributes[1].Size = sizeof(teb);
+ attr_list->Attributes[1].ValuePtr = &teb;
+ attr_list->Attributes[1].ReturnLength = NULL;
InitializeObjectAttributes( &attr, NULL, 0, NULL, descr );
+ RtlGetActiveActivationContext( &actctx );
+ if (actctx) flags |= THREAD_CREATE_FLAGS_CREATE_SUSPENDED;
+
status = NtCreateThreadEx( &handle, THREAD_ALL_ACCESS, &attr, process, start, param,
- flags, 0, stack_commit, stack_reserve, &attr_list );
+ flags, 0, stack_commit, stack_reserve, attr_list );
if (!status)
{
+ if (actctx)
+ {
+ ULONG_PTR cookie;
+ RtlActivateActivationContextEx( 0, teb, actctx, &cookie );
+ if (!suspended) NtResumeThread( handle, &ret );
+ }
if (id) *id = client_id;
if (handle_ptr) *handle_ptr = handle;
else NtClose( handle );
}
+ if (actctx) RtlReleaseActivationContext( actctx );
return status;
}
diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c
index 6c64eecf1f..3b451a2257 100644
--- a/dlls/ntdll/unix/thread.c
+++ b/dlls/ntdll/unix/thread.c
@@ -88,7 +88,6 @@ struct startup_info
{
PRTL_THREAD_START_ROUTINE entry;
void *arg;
- HANDLE actctx;
};
/***********************************************************************
@@ -102,18 +101,12 @@ static void start_thread( TEB *teb )
struct ntdll_thread_data *thread_data = (struct ntdll_thread_data *)&teb->GdiTebBatch;
struct debug_info debug_info;
BOOL suspend;
- ULONG_PTR cookie;
debug_info.str_pos = debug_info.out_pos = 0;
thread_data->debug_info = &debug_info;
thread_data->pthread_id = pthread_self();
signal_init_thread( teb );
server_init_thread( info->entry, &suspend );
- if (info->actctx)
- {
- RtlActivateActivationContext( 0, info->actctx, &cookie );
- RtlReleaseActivationContext( info->actctx );
- }
signal_start_thread( info->entry, info->arg, suspend, pRtlUserThreadStart, teb );
}
@@ -164,7 +157,6 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT
int request_pipe[2];
SIZE_T extra_stack = PTHREAD_STACK_MIN;
CLIENT_ID client_id;
- HANDLE actctx;
TEB *teb;
INITIAL_TEB stack;
NTSTATUS status;
@@ -230,8 +222,6 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT
return status;
}
- RtlGetActiveActivationContext( &actctx );
-
pthread_sigmask( SIG_BLOCK, &server_block_set, &sigset );
if ((status = virtual_alloc_teb( &teb ))) goto done;
@@ -249,7 +239,6 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT
info = (struct startup_info *)(teb + 1);
info->entry = start;
info->arg = param;
- info->actctx = actctx;
teb->Tib.StackBase = stack.StackBase;
teb->Tib.StackLimit = stack.StackLimit;
@@ -278,7 +267,6 @@ done:
if (status)
{
NtClose( *handle );
- RtlReleaseActivationContext( actctx );
close( request_pipe[1] );
return status;
}
More information about the wine-cvs
mailing list