2 * Process synchronisation
4 * Copyright 1999, 2000 Juergen Schmied
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
25 #include "wine/debug.h"
28 #include "wine/unicode.h"
29 #include "wine/server.h"
31 #include "ntdll_misc.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(ntdll
);
40 /******************************************************************************
41 * NtCreateSemaphore (NTDLL.@)
43 NTSTATUS WINAPI
NtCreateSemaphore( OUT PHANDLE SemaphoreHandle
,
44 IN ACCESS_MASK access
,
45 IN
const OBJECT_ATTRIBUTES
*attr OPTIONAL
,
46 IN ULONG InitialCount
,
47 IN ULONG MaximumCount
)
49 DWORD len
= attr
&& attr
->ObjectName
? attr
->ObjectName
->Length
: 0;
52 if ((MaximumCount
<= 0) || (InitialCount
> MaximumCount
))
53 return STATUS_INVALID_PARAMETER
;
55 SERVER_START_REQ( create_semaphore
)
57 req
->initial
= InitialCount
;
58 req
->max
= MaximumCount
;
59 req
->inherit
= attr
&& (attr
->Attributes
& OBJ_INHERIT
);
60 if (len
) wine_server_add_data( req
, attr
->ObjectName
->Buffer
, len
);
61 ret
= wine_server_call( req
);
62 *SemaphoreHandle
= reply
->handle
;
68 /******************************************************************************
69 * NtOpenSemaphore (NTDLL.@)
71 NTSTATUS WINAPI
NtOpenSemaphore( OUT PHANDLE SemaphoreHandle
,
72 IN ACCESS_MASK access
,
73 IN
const OBJECT_ATTRIBUTES
*attr
)
75 DWORD len
= attr
&& attr
->ObjectName
? attr
->ObjectName
->Length
: 0;
78 SERVER_START_REQ( open_semaphore
)
81 req
->inherit
= attr
&& (attr
->Attributes
& OBJ_INHERIT
);
82 if (len
) wine_server_add_data( req
, attr
->ObjectName
->Buffer
, len
);
83 ret
= wine_server_call( req
);
84 *SemaphoreHandle
= reply
->handle
;
90 /******************************************************************************
91 * NtQuerySemaphore (NTDLL.@)
93 NTSTATUS WINAPI
NtQuerySemaphore(
94 HANDLE SemaphoreHandle
,
95 PVOID SemaphoreInformationClass
,
96 OUT PVOID SemaphoreInformation
,
100 FIXME("(0x%08x,%p,%p,0x%08lx,%p) stub!\n",
101 SemaphoreHandle
, SemaphoreInformationClass
, SemaphoreInformation
, Length
, ReturnLength
);
102 return STATUS_SUCCESS
;
105 /******************************************************************************
106 * NtReleaseSemaphore (NTDLL.@)
108 NTSTATUS WINAPI
NtReleaseSemaphore( HANDLE handle
, ULONG count
, PULONG previous
)
111 SERVER_START_REQ( release_semaphore
)
113 req
->handle
= handle
;
115 if (!(ret
= wine_server_call( req
)))
117 if (previous
) *previous
= reply
->prev_count
;
128 /**************************************************************************
129 * NtCreateEvent (NTDLL.@)
130 * ZwCreateEvent (NTDLL.@)
132 NTSTATUS WINAPI
NtCreateEvent(
133 OUT PHANDLE EventHandle
,
134 IN ACCESS_MASK DesiredAccess
,
135 IN
const OBJECT_ATTRIBUTES
*attr
,
136 IN BOOLEAN ManualReset
,
137 IN BOOLEAN InitialState
)
139 DWORD len
= attr
&& attr
->ObjectName
? attr
->ObjectName
->Length
: 0;
142 SERVER_START_REQ( create_event
)
144 req
->manual_reset
= ManualReset
;
145 req
->initial_state
= InitialState
;
146 req
->inherit
= attr
&& (attr
->Attributes
& OBJ_INHERIT
);
147 if (len
) wine_server_add_data( req
, attr
->ObjectName
->Buffer
, len
);
148 ret
= wine_server_call( req
);
149 *EventHandle
= reply
->handle
;
155 /******************************************************************************
156 * NtOpenEvent (NTDLL.@)
157 * ZwOpenEvent (NTDLL.@)
159 NTSTATUS WINAPI
NtOpenEvent(
160 OUT PHANDLE EventHandle
,
161 IN ACCESS_MASK DesiredAccess
,
162 IN
const OBJECT_ATTRIBUTES
*attr
)
164 DWORD len
= attr
&& attr
->ObjectName
? attr
->ObjectName
->Length
: 0;
167 SERVER_START_REQ( open_event
)
169 req
->access
= DesiredAccess
;
170 req
->inherit
= attr
&& (attr
->Attributes
& OBJ_INHERIT
);
171 if (len
) wine_server_add_data( req
, attr
->ObjectName
->Buffer
, len
);
172 ret
= wine_server_call( req
);
173 *EventHandle
= reply
->handle
;
180 /******************************************************************************
181 * NtSetEvent (NTDLL.@)
182 * ZwSetEvent (NTDLL.@)
184 NTSTATUS WINAPI
NtSetEvent( HANDLE handle
, PULONG NumberOfThreadsReleased
)
188 /* FIXME: set NumberOfThreadsReleased */
190 SERVER_START_REQ( event_op
)
192 req
->handle
= handle
;
194 ret
= wine_server_call( req
);
200 /******************************************************************************
201 * NtResetEvent (NTDLL.@)
203 NTSTATUS WINAPI
NtResetEvent( HANDLE handle
, PULONG NumberOfThreadsReleased
)
207 /* resetting an event can't release any thread... */
208 if (NumberOfThreadsReleased
) *NumberOfThreadsReleased
= 0;
210 SERVER_START_REQ( event_op
)
212 req
->handle
= handle
;
213 req
->op
= RESET_EVENT
;
214 ret
= wine_server_call( req
);
220 /******************************************************************************
221 * NtClearEvent (NTDLL.@)
224 * same as NtResetEvent ???
226 NTSTATUS WINAPI
NtClearEvent ( HANDLE handle
)
228 return NtResetEvent( handle
, NULL
);
231 /******************************************************************************
232 * NtPulseEvent (NTDLL.@)
237 NTSTATUS WINAPI
NtPulseEvent( HANDLE handle
, PULONG PulseCount
)
240 FIXME("(0x%08x,%p)\n", handle
, PulseCount
);
241 SERVER_START_REQ( event_op
)
243 req
->handle
= handle
;
244 req
->op
= PULSE_EVENT
;
245 ret
= wine_server_call( req
);
251 /******************************************************************************
252 * NtQueryEvent (NTDLL.@)
254 NTSTATUS WINAPI
NtQueryEvent (
255 IN HANDLE EventHandle
,
256 IN UINT EventInformationClass
,
257 OUT PVOID EventInformation
,
258 IN ULONG EventInformationLength
,
259 OUT PULONG ReturnLength
)
261 FIXME("(0x%08x)\n", EventHandle
);
262 return STATUS_SUCCESS
;