wine/dlls/ntdll/thread.c
Alexandre Julliard 088bcf9ca5 Implemented NtQueueApcThread, and changed the server APC interface to
always take 3 parameters.
Implemented a number of other ntdll thread functions, and use them
from the kernel ones.
2003-04-04 22:26:34 +00:00

172 lines
4.7 KiB
C

/*
* NT threads support
*
* Copyright 1996, 2003 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "winternl.h"
#include "wine/server.h"
/***********************************************************************
* NtOpenThread (NTDLL.@)
* ZwOpenThread (NTDLL.@)
*/
NTSTATUS WINAPI NtOpenThread( HANDLE *handle, ACCESS_MASK access,
const OBJECT_ATTRIBUTES *attr, const CLIENT_ID *id )
{
NTSTATUS ret;
SERVER_START_REQ( open_thread )
{
req->tid = (thread_id_t)id->UniqueThread;
req->access = access;
req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
ret = wine_server_call( req );
*handle = reply->handle;
}
SERVER_END_REQ;
return ret;
}
/******************************************************************************
* NtSuspendThread (NTDLL.@)
* ZwSuspendThread (NTDLL.@)
*/
NTSTATUS WINAPI NtSuspendThread( HANDLE handle, PULONG count )
{
NTSTATUS ret;
SERVER_START_REQ( suspend_thread )
{
req->handle = handle;
if (!(ret = wine_server_call( req ))) *count = reply->count;
}
SERVER_END_REQ;
return ret;
}
/******************************************************************************
* NtResumeThread (NTDLL.@)
* ZwResumeThread (NTDLL.@)
*/
NTSTATUS WINAPI NtResumeThread( HANDLE handle, PULONG count )
{
NTSTATUS ret;
SERVER_START_REQ( resume_thread )
{
req->handle = handle;
if (!(ret = wine_server_call( req ))) *count = reply->count;
}
SERVER_END_REQ;
return ret;
}
/******************************************************************************
* NtTerminateThread (NTDLL.@)
* ZwTerminateThread (NTDLL.@)
*/
NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code )
{
NTSTATUS ret;
BOOL self, last;
SERVER_START_REQ( terminate_thread )
{
req->handle = handle;
req->exit_code = exit_code;
ret = wine_server_call( req );
self = !ret && reply->self;
last = reply->last;
}
SERVER_END_REQ;
if (self)
{
if (last) exit( exit_code );
else SYSDEPS_ExitThread( exit_code );
}
return ret;
}
/******************************************************************************
* NtQueueApcThread (NTDLL.@)
*/
NTSTATUS WINAPI NtQueueApcThread( HANDLE handle, PNTAPCFUNC func, ULONG_PTR arg1,
ULONG_PTR arg2, ULONG_PTR arg3 )
{
NTSTATUS ret;
SERVER_START_REQ( queue_apc )
{
req->handle = handle;
req->user = 1;
req->func = func;
req->arg1 = (void *)arg1;
req->arg2 = (void *)arg2;
req->arg3 = (void *)arg3;
ret = wine_server_call( req );
}
SERVER_END_REQ;
return ret;
}
/***********************************************************************
* NtSetContextThread (NTDLL.@)
* ZwSetContextThread (NTDLL.@)
*/
NTSTATUS WINAPI NtSetContextThread( HANDLE handle, const CONTEXT *context )
{
NTSTATUS ret;
SERVER_START_REQ( set_thread_context )
{
req->handle = handle;
req->flags = context->ContextFlags;
wine_server_add_data( req, context, sizeof(*context) );
ret = wine_server_call( req );
}
SERVER_END_REQ;
return ret;
}
/***********************************************************************
* NtGetContextThread (NTDLL.@)
* ZwGetContextThread (NTDLL.@)
*/
NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context )
{
NTSTATUS ret;
SERVER_START_REQ( get_thread_context )
{
req->handle = handle;
req->flags = context->ContextFlags;
wine_server_add_data( req, context, sizeof(*context) );
wine_server_set_reply( req, context, sizeof(*context) );
ret = wine_server_call( req );
}
SERVER_END_REQ;
return ret;
}