Nikolay Sivov : ntdll: Inherit default activation context from creation thread.
Alexandre Julliard
julliard at winehq.org
Thu Sep 5 13:28:19 CDT 2013
Module: wine
Branch: master
Commit: 93c59714c0ba67cb9215433125a414eeee8633e4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=93c59714c0ba67cb9215433125a414eeee8633e4
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Thu Sep 5 11:35:17 2013 +0400
ntdll: Inherit default activation context from creation thread.
---
dlls/kernel32/tests/thread.c | 14 +++++++++++---
dlls/ntdll/thread.c | 17 ++++++++++++++++-
2 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/dlls/kernel32/tests/thread.c b/dlls/kernel32/tests/thread.c
index 0f3564f..33797d8 100644
--- a/dlls/kernel32/tests/thread.c
+++ b/dlls/kernel32/tests/thread.c
@@ -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, ¶m, 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);
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 703e83c..9c34c0c 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -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;
More information about the wine-cvs
mailing list