Commit 93c59714 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

ntdll: Inherit default activation context from creation thread.

parent ab08d2a5
......@@ -287,7 +287,6 @@ static DWORD WINAPI thread_actctx_func(void *p)
cur = (void*)0xdeadbeef;
ret = pGetCurrentActCtx(&cur);
ok(ret, "thread GetCurrentActCtx failed, %u\n", GetLastError());
todo_wine
ok(cur == param->handle, "got %p, expected %p\n", cur, param->handle);
param->thread_context = cur;
......@@ -1550,6 +1549,17 @@ static void test_thread_actctx(void)
ok(b, "GetCurentActCtx failed: %u\n", GetLastError());
ok(handle == 0, "active context %p\n", handle);
/* without active context */
param.thread_context = (void*)0xdeadbeef;
param.handle = NULL;
thread = CreateThread(NULL, 0, thread_actctx_func, &param, 0, &tid);
ok(thread != NULL, "failed, got %u\n", GetLastError());
ret = WaitForSingleObject(thread, 1000);
ok(ret == WAIT_OBJECT_0, "wait timeout\n");
ok(param.thread_context == NULL, "got wrong thread context %p\n", param.thread_context);
CloseHandle(thread);
b = pActivateActCtx(context, &cookie);
ok(b, "activation failed: %u\n", GetLastError());
......@@ -1568,7 +1578,6 @@ static void test_thread_actctx(void)
ret = WaitForSingleObject(thread, 1000);
ok(ret == WAIT_OBJECT_0, "wait timeout\n");
todo_wine
ok(param.thread_context == context, "got wrong thread context %p, %p\n", param.thread_context, context);
CloseHandle(thread);
......@@ -1579,7 +1588,6 @@ todo_wine
ret = WaitForSingleObject(thread, 1000);
ok(ret == WAIT_OBJECT_0, "wait timeout\n");
todo_wine
ok(param.thread_context == context, "got wrong thread context %p, %p\n", param.thread_context, context);
CloseHandle(thread);
......
......@@ -432,7 +432,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR *
pthread_attr_t attr;
struct ntdll_thread_data *thread_data;
struct startup_info *info = NULL;
HANDLE handle = 0;
HANDLE handle = 0, actctx = 0;
TEB *teb = NULL;
DWORD tid = 0;
int request_pipe[2];
......@@ -497,6 +497,21 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR *
teb->StaticUnicodeString.Buffer = teb->StaticUnicodeBuffer;
teb->StaticUnicodeString.MaximumLength = sizeof(teb->StaticUnicodeBuffer);
/* create default activation context frame for new thread */
RtlGetActiveActivationContext(&actctx);
if (actctx)
{
RTL_ACTIVATION_CONTEXT_STACK_FRAME *frame;
frame = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(*frame));
frame->Previous = NULL;
frame->ActivationContext = actctx;
frame->Flags = 0;
teb->ActivationContextStack.ActiveFrame = frame;
RtlAddRefActivationContext(actctx);
}
info = (struct startup_info *)(teb + 1);
info->teb = teb;
info->entry_point = start;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment