mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-15 09:40:20 +00:00
ntdll: Move the activation context initialization out of NtCreateThreadEx().
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
c71da19d24
commit
fdb09f4523
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue