Make sure to return an error if the file generation fails.
[wine.git] / dlls / ntdll / thread.c
blob0978cd3a02e6577ed04570880690905691493f30
1 /*
2 * NT threads support
4 * Copyright 1996, 2003 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "winternl.h"
22 #include "wine/server.h"
25 /***********************************************************************
26 * NtOpenThread (NTDLL.@)
27 * ZwOpenThread (NTDLL.@)
29 NTSTATUS WINAPI NtOpenThread( HANDLE *handle, ACCESS_MASK access,
30 const OBJECT_ATTRIBUTES *attr, const CLIENT_ID *id )
32 NTSTATUS ret;
34 SERVER_START_REQ( open_thread )
36 req->tid = (thread_id_t)id->UniqueThread;
37 req->access = access;
38 req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
39 ret = wine_server_call( req );
40 *handle = reply->handle;
42 SERVER_END_REQ;
43 return ret;
47 /******************************************************************************
48 * NtSuspendThread (NTDLL.@)
49 * ZwSuspendThread (NTDLL.@)
51 NTSTATUS WINAPI NtSuspendThread( HANDLE handle, PULONG count )
53 NTSTATUS ret;
55 SERVER_START_REQ( suspend_thread )
57 req->handle = handle;
58 if (!(ret = wine_server_call( req ))) *count = reply->count;
60 SERVER_END_REQ;
61 return ret;
65 /******************************************************************************
66 * NtResumeThread (NTDLL.@)
67 * ZwResumeThread (NTDLL.@)
69 NTSTATUS WINAPI NtResumeThread( HANDLE handle, PULONG count )
71 NTSTATUS ret;
73 SERVER_START_REQ( resume_thread )
75 req->handle = handle;
76 if (!(ret = wine_server_call( req ))) *count = reply->count;
78 SERVER_END_REQ;
79 return ret;
83 /******************************************************************************
84 * NtTerminateThread (NTDLL.@)
85 * ZwTerminateThread (NTDLL.@)
87 NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code )
89 NTSTATUS ret;
90 BOOL self, last;
92 SERVER_START_REQ( terminate_thread )
94 req->handle = handle;
95 req->exit_code = exit_code;
96 ret = wine_server_call( req );
97 self = !ret && reply->self;
98 last = reply->last;
100 SERVER_END_REQ;
102 if (self)
104 if (last) exit( exit_code );
105 else SYSDEPS_ExitThread( exit_code );
107 return ret;
111 /******************************************************************************
112 * NtQueueApcThread (NTDLL.@)
114 NTSTATUS WINAPI NtQueueApcThread( HANDLE handle, PNTAPCFUNC func, ULONG_PTR arg1,
115 ULONG_PTR arg2, ULONG_PTR arg3 )
117 NTSTATUS ret;
118 SERVER_START_REQ( queue_apc )
120 req->handle = handle;
121 req->user = 1;
122 req->func = func;
123 req->arg1 = (void *)arg1;
124 req->arg2 = (void *)arg2;
125 req->arg3 = (void *)arg3;
126 ret = wine_server_call( req );
128 SERVER_END_REQ;
129 return ret;
133 /***********************************************************************
134 * NtSetContextThread (NTDLL.@)
135 * ZwSetContextThread (NTDLL.@)
137 NTSTATUS WINAPI NtSetContextThread( HANDLE handle, const CONTEXT *context )
139 NTSTATUS ret;
141 SERVER_START_REQ( set_thread_context )
143 req->handle = handle;
144 req->flags = context->ContextFlags;
145 wine_server_add_data( req, context, sizeof(*context) );
146 ret = wine_server_call( req );
148 SERVER_END_REQ;
149 return ret;
153 /***********************************************************************
154 * NtGetContextThread (NTDLL.@)
155 * ZwGetContextThread (NTDLL.@)
157 NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context )
159 NTSTATUS ret;
161 SERVER_START_REQ( get_thread_context )
163 req->handle = handle;
164 req->flags = context->ContextFlags;
165 wine_server_add_data( req, context, sizeof(*context) );
166 wine_server_set_reply( req, context, sizeof(*context) );
167 ret = wine_server_call( req );
169 SERVER_END_REQ;
170 return ret;