2 * Process synchronisation
9 #include "debugtools.h"
14 #include "ntdll_misc.h"
16 DEFAULT_DEBUG_CHANNEL(ntdll
);
18 /* copy a key name into the request buffer */
19 static inline NTSTATUS
copy_nameU( LPWSTR Dest
, const OBJECT_ATTRIBUTES
*attr
)
21 if (attr
&& attr
->ObjectName
&& attr
->ObjectName
->Buffer
)
23 if ((attr
->ObjectName
->Length
) > MAX_PATH
) return STATUS_BUFFER_OVERFLOW
;
24 lstrcpyW( Dest
, attr
->ObjectName
->Buffer
);
27 return STATUS_SUCCESS
;
34 /******************************************************************************
37 NTSTATUS WINAPI
NtCreateSemaphore(
38 OUT PHANDLE SemaphoreHandle
,
39 IN ACCESS_MASK DesiredAccess
,
40 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL
,
41 IN ULONG InitialCount
,
42 IN ULONG MaximumCount
)
44 struct create_semaphore_request
*req
= get_req_buffer();
47 if ((MaximumCount
<= 0) || (InitialCount
< 0) || (InitialCount
> MaximumCount
))
48 return STATUS_INVALID_PARAMETER
;
51 req
->initial
= InitialCount
;
52 req
->max
= MaximumCount
;
53 req
->inherit
= ObjectAttributes
&& (ObjectAttributes
->Attributes
& OBJ_INHERIT
);
54 if (!(ret
= copy_nameU( req
->name
, ObjectAttributes
)) &&
55 !(ret
= server_call_noerr( REQ_CREATE_SEMAPHORE
))) *SemaphoreHandle
= req
->handle
;
59 /******************************************************************************
62 NTSTATUS WINAPI
NtOpenSemaphore(
63 OUT PHANDLE SemaphoreHandle
,
64 IN ACCESS_MASK DesiredAcces
,
65 IN POBJECT_ATTRIBUTES ObjectAttributes
)
67 struct open_semaphore_request
*req
= get_req_buffer();
71 req
->access
= DesiredAcces
;
72 req
->inherit
= ObjectAttributes
&& (ObjectAttributes
->Attributes
& OBJ_INHERIT
);
73 if (!(ret
= copy_nameU( req
->name
, ObjectAttributes
)) &&
74 !(ret
= server_call_noerr( REQ_OPEN_SEMAPHORE
))) *SemaphoreHandle
= req
->handle
;
78 /******************************************************************************
81 NTSTATUS WINAPI
NtQuerySemaphore(
82 HANDLE SemaphoreHandle
,
83 PVOID SemaphoreInformationClass
,
84 OUT PVOID SemaphoreInformation
,
88 FIXME("(0x%08x,%p,%p,0x%08lx,%p) stub!\n",
89 SemaphoreHandle
, SemaphoreInformationClass
, SemaphoreInformation
, Length
, ReturnLength
);
90 return STATUS_SUCCESS
;
92 /******************************************************************************
95 NTSTATUS WINAPI
NtReleaseSemaphore(
96 IN HANDLE SemaphoreHandle
,
97 IN ULONG ReleaseCount
,
98 IN PULONG PreviousCount
)
100 struct release_semaphore_request
*req
= get_req_buffer();
103 if (ReleaseCount
< 0) return STATUS_INVALID_PARAMETER
;
105 req
->handle
= SemaphoreHandle
;
106 req
->count
= ReleaseCount
;
107 if (!(ret
= server_call_noerr( REQ_RELEASE_SEMAPHORE
)))
109 if (PreviousCount
) *PreviousCount
= req
->prev_count
;
118 /**************************************************************************
121 NTSTATUS WINAPI
NtCreateEvent(
122 OUT PHANDLE EventHandle
,
123 IN ACCESS_MASK DesiredAccess
,
124 IN POBJECT_ATTRIBUTES ObjectAttributes
,
125 IN BOOLEAN ManualReset
,
126 IN BOOLEAN InitialState
)
128 struct create_event_request
*req
= get_req_buffer();
132 req
->manual_reset
= ManualReset
;
133 req
->initial_state
= InitialState
;
134 req
->inherit
= ObjectAttributes
&& (ObjectAttributes
->Attributes
& OBJ_INHERIT
);
135 if (!(ret
= copy_nameU( req
->name
, ObjectAttributes
)) &&
136 !(ret
= server_call_noerr( REQ_CREATE_EVENT
))) *EventHandle
= req
->handle
;
140 /******************************************************************************
143 NTSTATUS WINAPI
NtOpenEvent(
144 OUT PHANDLE EventHandle
,
145 IN ACCESS_MASK DesiredAccess
,
146 IN POBJECT_ATTRIBUTES ObjectAttributes
)
148 struct open_event_request
*req
= get_req_buffer();
152 req
->access
= DesiredAccess
;
153 req
->inherit
= ObjectAttributes
&& (ObjectAttributes
->Attributes
& OBJ_INHERIT
);
154 if (!(ret
= copy_nameU( req
->name
, ObjectAttributes
)) &&
155 !(ret
= server_call_noerr( REQ_OPEN_EVENT
))) *EventHandle
= req
->handle
;
160 /******************************************************************************
163 NTSTATUS WINAPI
NtSetEvent(
164 IN HANDLE EventHandle
,
165 PULONG NumberOfThreadsReleased
)
167 struct event_op_request
*req
= get_req_buffer();
168 FIXME("(0x%08x,%p)\n", EventHandle
, NumberOfThreadsReleased
);
169 req
->handle
= EventHandle
;
171 return server_call_noerr( REQ_EVENT_OP
);
174 /******************************************************************************
177 NTSTATUS WINAPI
NtResetEvent(
178 IN HANDLE EventHandle
,
179 PULONG NumberOfThreadsReleased
)
181 struct event_op_request
*req
= get_req_buffer();
182 FIXME("(0x%08x,%p)\n", EventHandle
, NumberOfThreadsReleased
);
183 req
->handle
= EventHandle
;
184 req
->op
= RESET_EVENT
;
185 return server_call_noerr( REQ_EVENT_OP
);
188 /******************************************************************************
192 * same as NtResetEvent ???
194 NTSTATUS WINAPI
NtClearEvent (
195 IN HANDLE EventHandle
)
197 return NtResetEvent( EventHandle
, NULL
);
200 /******************************************************************************
206 NTSTATUS WINAPI
NtPulseEvent(
207 IN HANDLE EventHandle
,
208 IN PULONG PulseCount
)
210 struct event_op_request
*req
= get_req_buffer();
211 FIXME("(0x%08x,%p)\n", EventHandle
, PulseCount
);
212 req
->handle
= EventHandle
;
213 req
->op
= PULSE_EVENT
;
214 return server_call_noerr( REQ_EVENT_OP
);
217 /******************************************************************************
220 NTSTATUS WINAPI
NtQueryEvent (
221 IN HANDLE EventHandle
,
222 IN UINT EventInformationClass
,
223 OUT PVOID EventInformation
,
224 IN ULONG EventInformationLength
,
225 OUT PULONG ReturnLength
)
227 FIXME("(0x%08x)\n", EventHandle
);
228 return STATUS_SUCCESS
;