2 * Process synchronisation
9 #include "debugtools.h"
12 #include "wine/unicode.h"
15 #include "ntdll_misc.h"
17 DEFAULT_DEBUG_CHANNEL(ntdll
);
24 /******************************************************************************
27 NTSTATUS WINAPI
NtCreateSemaphore( OUT PHANDLE SemaphoreHandle
,
28 IN ACCESS_MASK access
,
29 IN
const OBJECT_ATTRIBUTES
*attr OPTIONAL
,
30 IN ULONG InitialCount
,
31 IN ULONG MaximumCount
)
33 DWORD len
= attr
&& attr
->ObjectName
? attr
->ObjectName
->Length
: 0;
36 if ((MaximumCount
<= 0) || (InitialCount
< 0) || (InitialCount
> MaximumCount
))
37 return STATUS_INVALID_PARAMETER
;
41 struct create_semaphore_request
*req
= server_alloc_req( sizeof(*req
), len
);
42 req
->initial
= InitialCount
;
43 req
->max
= MaximumCount
;
44 req
->inherit
= attr
&& (attr
->Attributes
& OBJ_INHERIT
);
45 if (len
) memcpy( server_data_ptr(req
), attr
->ObjectName
->Buffer
, len
);
46 ret
= server_call_noerr( REQ_CREATE_SEMAPHORE
);
47 *SemaphoreHandle
= req
->handle
;
53 /******************************************************************************
56 NTSTATUS WINAPI
NtOpenSemaphore( OUT PHANDLE SemaphoreHandle
,
57 IN ACCESS_MASK access
,
58 IN
const OBJECT_ATTRIBUTES
*attr
)
60 DWORD len
= attr
&& attr
->ObjectName
? attr
->ObjectName
->Length
: 0;
65 struct open_semaphore_request
*req
= server_alloc_req( sizeof(*req
), len
);
67 req
->inherit
= attr
&& (attr
->Attributes
& OBJ_INHERIT
);
68 if (len
) memcpy( server_data_ptr(req
), attr
->ObjectName
->Buffer
, len
);
69 ret
= server_call_noerr( REQ_OPEN_SEMAPHORE
);
70 *SemaphoreHandle
= req
->handle
;
76 /******************************************************************************
79 NTSTATUS WINAPI
NtQuerySemaphore(
80 HANDLE SemaphoreHandle
,
81 PVOID SemaphoreInformationClass
,
82 OUT PVOID SemaphoreInformation
,
86 FIXME("(0x%08x,%p,%p,0x%08lx,%p) stub!\n",
87 SemaphoreHandle
, SemaphoreInformationClass
, SemaphoreInformation
, Length
, ReturnLength
);
88 return STATUS_SUCCESS
;
91 /******************************************************************************
94 NTSTATUS WINAPI
NtReleaseSemaphore( HANDLE handle
, ULONG count
, PULONG previous
)
99 struct release_semaphore_request
*req
= server_alloc_req( sizeof(*req
), 0 );
100 req
->handle
= handle
;
102 if (!(ret
= server_call_noerr( REQ_RELEASE_SEMAPHORE
)))
104 if (previous
) *previous
= req
->prev_count
;
115 /**************************************************************************
118 NTSTATUS WINAPI
NtCreateEvent(
119 OUT PHANDLE EventHandle
,
120 IN ACCESS_MASK DesiredAccess
,
121 IN
const OBJECT_ATTRIBUTES
*attr
,
122 IN BOOLEAN ManualReset
,
123 IN BOOLEAN InitialState
)
125 DWORD len
= attr
&& attr
->ObjectName
? attr
->ObjectName
->Length
: 0;
130 struct create_event_request
*req
= server_alloc_req( sizeof(*req
), len
);
131 req
->manual_reset
= ManualReset
;
132 req
->initial_state
= InitialState
;
133 req
->inherit
= attr
&& (attr
->Attributes
& OBJ_INHERIT
);
134 if (len
) memcpy( server_data_ptr(req
), attr
->ObjectName
->Buffer
, len
);
135 ret
= server_call_noerr( REQ_CREATE_EVENT
);
136 *EventHandle
= req
->handle
;
142 /******************************************************************************
145 NTSTATUS WINAPI
NtOpenEvent(
146 OUT PHANDLE EventHandle
,
147 IN ACCESS_MASK DesiredAccess
,
148 IN
const OBJECT_ATTRIBUTES
*attr
)
150 DWORD len
= attr
&& attr
->ObjectName
? attr
->ObjectName
->Length
: 0;
155 struct open_event_request
*req
= server_alloc_req( sizeof(*req
), len
);
157 req
->access
= DesiredAccess
;
158 req
->inherit
= attr
&& (attr
->Attributes
& OBJ_INHERIT
);
159 if (len
) memcpy( server_data_ptr(req
), attr
->ObjectName
->Buffer
, len
);
160 ret
= server_call_noerr( REQ_OPEN_EVENT
);
161 *EventHandle
= req
->handle
;
168 /******************************************************************************
171 NTSTATUS WINAPI
NtSetEvent( HANDLE handle
, PULONG NumberOfThreadsReleased
)
175 /* FIXME: set NumberOfThreadsReleased */
179 struct event_op_request
*req
= server_alloc_req( sizeof(*req
), 0 );
180 req
->handle
= handle
;
182 ret
= server_call_noerr( REQ_EVENT_OP
);
188 /******************************************************************************
191 NTSTATUS WINAPI
NtResetEvent( HANDLE handle
, PULONG NumberOfThreadsReleased
)
195 /* resetting an event can't release any thread... */
196 if (NumberOfThreadsReleased
) *NumberOfThreadsReleased
= 0;
200 struct event_op_request
*req
= server_alloc_req( sizeof(*req
), 0 );
201 req
->handle
= handle
;
202 req
->op
= RESET_EVENT
;
203 ret
= server_call_noerr( REQ_EVENT_OP
);
209 /******************************************************************************
213 * same as NtResetEvent ???
215 NTSTATUS WINAPI
NtClearEvent ( HANDLE handle
)
217 return NtResetEvent( handle
, NULL
);
220 /******************************************************************************
226 NTSTATUS WINAPI
NtPulseEvent( HANDLE handle
, PULONG PulseCount
)
229 FIXME("(0x%08x,%p)\n", handle
, PulseCount
);
232 struct event_op_request
*req
= server_alloc_req( sizeof(*req
), 0 );
233 req
->handle
= handle
;
234 req
->op
= PULSE_EVENT
;
235 ret
= server_call_noerr( REQ_EVENT_OP
);
241 /******************************************************************************
244 NTSTATUS WINAPI
NtQueryEvent (
245 IN HANDLE EventHandle
,
246 IN UINT EventInformationClass
,
247 OUT PVOID EventInformation
,
248 IN ULONG EventInformationLength
,
249 OUT PULONG ReturnLength
)
251 FIXME("(0x%08x)\n", EventHandle
);
252 return STATUS_SUCCESS
;