From 9b57a950d7ad0ba394d0a7301647d1853ea63e0b Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sun, 5 Jun 2005 18:24:35 +0000 Subject: [PATCH] Avoid accessing the htask16 TEB field from ntdll. --- dlls/kernel/task.c | 9 +++++---- dlls/ntdll/thread.c | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dlls/kernel/task.c b/dlls/kernel/task.c index c1c4e37fa40..cbe6295b8c5 100644 --- a/dlls/kernel/task.c +++ b/dlls/kernel/task.c @@ -79,7 +79,7 @@ THHOOK *pThhook = &DefaultThhook; static UINT16 nTaskCount = 0; -static HTASK16 initial_task; +static HTASK16 initial_task, main_task; /*********************************************************************** * TASK_InstallTHHook @@ -419,11 +419,10 @@ void TASK_CreateMainTask(void) pTask->hPrevInstance = 0; pTask->teb = NtCurrentTeb(); - NtCurrentTeb()->htask16 = pTask->hSelf; - /* Add the task to the linked list */ /* (no need to get the win16 lock, we are the only thread at this point) */ TASK_LinkTask( pTask->hSelf ); + main_task = pTask->hSelf; } @@ -1177,7 +1176,9 @@ void WINAPI GetTaskQueueES16(void) */ HTASK16 WINAPI GetCurrentTask(void) { - return NtCurrentTeb()->htask16; + HTASK16 ret = NtCurrentTeb()->htask16; + if (!ret) ret = main_task; + return ret; } /*********************************************************************** diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c index 712e3c38221..8bf831d9524 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -266,7 +266,6 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR * teb->reply_fd = -1; teb->wait_fd[0] = -1; teb->wait_fd[1] = -1; - teb->htask16 = NtCurrentTeb()->htask16; info->pthread_info.teb_base = teb; NtAllocateVirtualMemory( NtCurrentProcess(), &info->pthread_info.teb_base, 0, &size,