2 * Process synchronisation
9 #include "debugtools.h"
12 #include "wine/unicode.h"
13 #include "wine/server.h"
15 #include "ntdll_misc.h"
17 DEFAULT_DEBUG_CHANNEL(ntdll);
24 /******************************************************************************
25 * NtCreateSemaphore (NTDLL.@)
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 > MaximumCount))
37 return STATUS_INVALID_PARAMETER;
39 SERVER_START_VAR_REQ( create_semaphore, len )
41 req->initial = InitialCount;
42 req->max = MaximumCount;
43 req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
44 if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
46 *SemaphoreHandle = req->handle;
52 /******************************************************************************
53 * NtOpenSemaphore (NTDLL.@)
55 NTSTATUS WINAPI NtOpenSemaphore( OUT PHANDLE SemaphoreHandle,
56 IN ACCESS_MASK access,
57 IN const OBJECT_ATTRIBUTES *attr )
59 DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
62 SERVER_START_VAR_REQ( open_semaphore, len )
65 req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
66 if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
68 *SemaphoreHandle = req->handle;
74 /******************************************************************************
75 * NtQuerySemaphore (NTDLL.@)
77 NTSTATUS WINAPI NtQuerySemaphore(
78 HANDLE SemaphoreHandle,
79 PVOID SemaphoreInformationClass,
80 OUT PVOID SemaphoreInformation,
84 FIXME("(0x%08x,%p,%p,0x%08lx,%p) stub!\n",
85 SemaphoreHandle, SemaphoreInformationClass, SemaphoreInformation, Length, ReturnLength);
86 return STATUS_SUCCESS;
89 /******************************************************************************
90 * NtReleaseSemaphore (NTDLL.@)
92 NTSTATUS WINAPI NtReleaseSemaphore( HANDLE handle, ULONG count, PULONG previous )
95 SERVER_START_REQ( release_semaphore )
99 if (!(ret = SERVER_CALL()))
101 if (previous) *previous = req->prev_count;
112 /**************************************************************************
113 * NtCreateEvent (NTDLL.@)
114 * ZwCreateEvent (NTDLL.@)
116 NTSTATUS WINAPI NtCreateEvent(
117 OUT PHANDLE EventHandle,
118 IN ACCESS_MASK DesiredAccess,
119 IN const OBJECT_ATTRIBUTES *attr,
120 IN BOOLEAN ManualReset,
121 IN BOOLEAN InitialState)
123 DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
126 SERVER_START_VAR_REQ( create_event, len )
128 req->manual_reset = ManualReset;
129 req->initial_state = InitialState;
130 req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
131 if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
133 *EventHandle = req->handle;
139 /******************************************************************************
140 * NtOpenEvent (NTDLL.@)
141 * ZwOpenEvent (NTDLL.@)
143 NTSTATUS WINAPI NtOpenEvent(
144 OUT PHANDLE EventHandle,
145 IN ACCESS_MASK DesiredAccess,
146 IN const OBJECT_ATTRIBUTES *attr )
148 DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
151 SERVER_START_VAR_REQ( open_event, len )
153 req->access = DesiredAccess;
154 req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
155 if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
157 *EventHandle = req->handle;
164 /******************************************************************************
165 * NtSetEvent (NTDLL.@)
166 * ZwSetEvent (NTDLL.@)
168 NTSTATUS WINAPI NtSetEvent( HANDLE handle, PULONG NumberOfThreadsReleased )
172 /* FIXME: set NumberOfThreadsReleased */
174 SERVER_START_REQ( event_op )
176 req->handle = handle;
184 /******************************************************************************
185 * NtResetEvent (NTDLL.@)
187 NTSTATUS WINAPI NtResetEvent( HANDLE handle, PULONG NumberOfThreadsReleased )
191 /* resetting an event can't release any thread... */
192 if (NumberOfThreadsReleased) *NumberOfThreadsReleased = 0;
194 SERVER_START_REQ( event_op )
196 req->handle = handle;
197 req->op = RESET_EVENT;
204 /******************************************************************************
205 * NtClearEvent (NTDLL.@)
208 * same as NtResetEvent ???
210 NTSTATUS WINAPI NtClearEvent ( HANDLE handle )
212 return NtResetEvent( handle, NULL );
215 /******************************************************************************
216 * NtPulseEvent (NTDLL.@)
221 NTSTATUS WINAPI NtPulseEvent( HANDLE handle, PULONG PulseCount )
224 FIXME("(0x%08x,%p)\n", handle, PulseCount);
225 SERVER_START_REQ( event_op )
227 req->handle = handle;
228 req->op = PULSE_EVENT;
235 /******************************************************************************
236 * NtQueryEvent (NTDLL.@)
238 NTSTATUS WINAPI NtQueryEvent (
239 IN HANDLE EventHandle,
240 IN UINT EventInformationClass,
241 OUT PVOID EventInformation,
242 IN ULONG EventInformationLength,
243 OUT PULONG ReturnLength)
245 FIXME("(0x%08x)\n", EventHandle);
246 return STATUS_SUCCESS;