ReactOS  0.4.12-dev-945-g5a2911d
synch.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Win32 Base API
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: dll/win32/kernel32/client/synch.c
5  * PURPOSE: Wrappers for the NT Wait Implementation
6  * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7  */
8 
9 /* INCLUDES *****************************************************************/
10 #include <k32.h>
11 
12 #define NDEBUG
13 #include <debug.h>
14 
15 #undef InterlockedIncrement
16 #undef InterlockedDecrement
17 #undef InterlockedExchange
18 #undef InterlockedExchangeAdd
19 #undef InterlockedCompareExchange
20 
21 /* FUNCTIONS *****************************************************************/
22 
23 /*
24  * @implemented
25  */
26 LONG
27 WINAPI
28 InterlockedIncrement(IN OUT LONG volatile *lpAddend)
29 {
30  return _InterlockedIncrement(lpAddend);
31 }
32 
33 /*
34  * @implemented
35  */
36 LONG
37 WINAPI
38 InterlockedDecrement(IN OUT LONG volatile *lpAddend)
39 {
40  return _InterlockedDecrement(lpAddend);
41 }
42 
43 /*
44  * @implemented
45  */
46 LONG
47 WINAPI
49  IN LONG Value)
50 {
52 }
53 
54 /*
55  * @implemented
56  */
57 LONG
58 WINAPI
60  IN LONG Value)
61 {
63 }
64 
65 /*
66  * @implemented
67  */
68 LONG
69 WINAPI
71  IN LONG Exchange,
72  IN LONG Comperand)
73 {
74  return _InterlockedCompareExchange(Destination, Exchange, Comperand);
75 }
76 
77 /*
78  * @implemented
79  */
80 DWORD
81 WINAPI
83  IN DWORD dwMilliseconds)
84 {
85  /* Call the extended API */
86  return WaitForSingleObjectEx(hHandle, dwMilliseconds, FALSE);
87 }
88 
89 /*
90  * @implemented
91  */
92 DWORD
93 WINAPI
95  IN DWORD dwMilliseconds,
96  IN BOOL bAlertable)
97 {
98  PLARGE_INTEGER TimePtr;
101  RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME ActCtx;
102 
103  /* APCs must execute with the default activation context */
104  if (bAlertable)
105  {
106  /* Setup the frame */
107  RtlZeroMemory(&ActCtx, sizeof(ActCtx));
108  ActCtx.Size = sizeof(ActCtx);
111  }
112 
113  /* Get real handle */
114  hHandle = TranslateStdHandle(hHandle);
115 
116  /* Check for console handle */
117  if ((IsConsoleHandle(hHandle)) && (VerifyConsoleIoHandle(hHandle)))
118  {
119  /* Get the real wait handle */
120  hHandle = GetConsoleInputWaitHandle();
121  }
122 
123  /* Convert the timeout */
124  TimePtr = BaseFormatTimeOut(&Time, dwMilliseconds);
125 
126  /* Start wait loop */
127  do
128  {
129  /* Do the wait */
130  Status = NtWaitForSingleObject(hHandle, (BOOLEAN)bAlertable, TimePtr);
131  if (!NT_SUCCESS(Status))
132  {
133  /* The wait failed */
136  }
137  } while ((Status == STATUS_ALERTED) && (bAlertable));
138 
139  /* Cleanup the activation context */
141 
142  /* Return wait status */
143  return Status;
144 }
145 
146 /*
147  * @implemented
148  */
149 DWORD
150 WINAPI
152  IN CONST HANDLE *lpHandles,
153  IN BOOL bWaitAll,
154  IN DWORD dwMilliseconds)
155 {
156  /* Call the extended API */
157  return WaitForMultipleObjectsEx(nCount,
158  lpHandles,
159  bWaitAll,
160  dwMilliseconds,
161  FALSE);
162 }
163 
164 /*
165  * @implemented
166  */
167 DWORD
168 WINAPI
170  IN CONST HANDLE *lpHandles,
171  IN BOOL bWaitAll,
172  IN DWORD dwMilliseconds,
173  IN BOOL bAlertable)
174 {
175  PLARGE_INTEGER TimePtr;
177  PHANDLE HandleBuffer;
178  HANDLE Handle[8];
179  DWORD i;
181  RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME ActCtx;
182 
183  /* APCs must execute with the default activation context */
184  if (bAlertable)
185  {
186  /* Setup the frame */
187  RtlZeroMemory(&ActCtx, sizeof(ActCtx));
188  ActCtx.Size = sizeof(ActCtx);
191  }
192 
193  /* Check if we have more handles then we locally optimize */
194  if (nCount > 8)
195  {
196  /* Allocate a buffer for them */
197  HandleBuffer = RtlAllocateHeap(RtlGetProcessHeap(),
198  0,
199  nCount * sizeof(HANDLE));
200  if (!HandleBuffer)
201  {
202  /* No buffer, fail the wait */
205  return WAIT_FAILED;
206  }
207  }
208  else
209  {
210  /* Otherwise, use our local buffer */
211  HandleBuffer = Handle;
212  }
213 
214  /* Copy the handles into our buffer and loop them all */
215  RtlCopyMemory(HandleBuffer, (LPVOID)lpHandles, nCount * sizeof(HANDLE));
216  for (i = 0; i < nCount; i++)
217  {
218  /* Check what kind of handle this is */
219  HandleBuffer[i] = TranslateStdHandle(HandleBuffer[i]);
220 
221  /* Check for console handle */
222  if ((IsConsoleHandle(HandleBuffer[i])) &&
223  (VerifyConsoleIoHandle(HandleBuffer[i])))
224  {
225  /* Get the real wait handle */
226  HandleBuffer[i] = GetConsoleInputWaitHandle();
227  }
228  }
229 
230  /* Convert the timeout */
231  TimePtr = BaseFormatTimeOut(&Time, dwMilliseconds);
232 
233  /* Start wait loop */
234  do
235  {
236  /* Do the wait */
238  HandleBuffer,
239  bWaitAll ? WaitAll : WaitAny,
240  (BOOLEAN)bAlertable,
241  TimePtr);
242  if (!NT_SUCCESS(Status))
243  {
244  /* Wait failed */
247  }
248  } while ((Status == STATUS_ALERTED) && (bAlertable));
249 
250  /* Check if we didn't use our local buffer */
251  if (HandleBuffer != Handle)
252  {
253  /* Free the allocated one */
254  RtlFreeHeap(RtlGetProcessHeap(), 0, HandleBuffer);
255  }
256 
257  /* Cleanup the activation context */
259 
260  /* Return wait status */
261  return Status;
262 }
263 
264 /*
265  * @implemented
266  */
267 DWORD
268 WINAPI
269 SignalObjectAndWait(IN HANDLE hObjectToSignal,
270  IN HANDLE hObjectToWaitOn,
271  IN DWORD dwMilliseconds,
272  IN BOOL bAlertable)
273 {
274  PLARGE_INTEGER TimePtr;
277  RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME ActCtx;
278 
279  /* APCs must execute with the default activation context */
280  if (bAlertable)
281  {
282  /* Setup the frame */
283  RtlZeroMemory(&ActCtx, sizeof(ActCtx));
284  ActCtx.Size = sizeof(ActCtx);
287  }
288 
289  /* Get real handle */
290  hObjectToWaitOn = TranslateStdHandle(hObjectToWaitOn);
291 
292  /* Check for console handle */
293  if ((IsConsoleHandle(hObjectToWaitOn)) &&
294  (VerifyConsoleIoHandle(hObjectToWaitOn)))
295  {
296  /* Get the real wait handle */
297  hObjectToWaitOn = GetConsoleInputWaitHandle();
298  }
299 
300  /* Convert the timeout */
301  TimePtr = BaseFormatTimeOut(&Time, dwMilliseconds);
302 
303  /* Start wait loop */
304  do
305  {
306  /* Do the wait */
307  Status = NtSignalAndWaitForSingleObject(hObjectToSignal,
308  hObjectToWaitOn,
309  (BOOLEAN)bAlertable,
310  TimePtr);
311  if (!NT_SUCCESS(Status))
312  {
313  /* The wait failed */
316  }
317  } while ((Status == STATUS_ALERTED) && (bAlertable));
318 
319  /* Cleanup the activation context */
321 
322  /* Return wait status */
323  return Status;
324 }
325 
326 /*
327  * @implemented
328  */
329 HANDLE
330 WINAPI
332  IN BOOL bManualReset,
333  IN LPCWSTR lpTimerName OPTIONAL)
334 {
336  lpTimerAttributes,
337  lpTimerName,
338  bManualReset ? NotificationTimer : SynchronizationTimer);
339 }
340 
341 /*
342  * @implemented
343  */
344 HANDLE
345 WINAPI
347  IN BOOL bManualReset,
348  IN LPCSTR lpTimerName OPTIONAL)
349 {
350  ConvertWin32AnsiObjectApiToUnicodeApi(WaitableTimer, lpTimerName, lpTimerAttributes, bManualReset);
351 }
352 
353 /*
354  * @implemented
355  */
356 HANDLE
357 WINAPI
358 OpenWaitableTimerW(IN DWORD dwDesiredAccess,
360  IN LPCWSTR lpTimerName)
361 {
362  OpenNtObjectFromWin32Api(Timer, dwDesiredAccess, bInheritHandle, lpTimerName);
363 }
364 
365 /*
366  * @implemented
367  */
368 HANDLE
369 WINAPI
370 OpenWaitableTimerA(IN DWORD dwDesiredAccess,
372  IN LPCSTR lpTimerName)
373 {
375 }
376 
377 /*
378  * @implemented
379  */
380 BOOL
381 WINAPI
383  IN const LARGE_INTEGER *pDueTime,
384  IN LONG lPeriod,
385  IN PTIMERAPCROUTINE pfnCompletionRoutine OPTIONAL,
386  IN OPTIONAL LPVOID lpArgToCompletionRoutine,
387  IN BOOL fResume)
388 {
390 
391  /* Set the timer */
392  Status = NtSetTimer(hTimer,
393  (PLARGE_INTEGER)pDueTime,
394  (PTIMER_APC_ROUTINE)pfnCompletionRoutine,
395  lpArgToCompletionRoutine,
396  (BOOLEAN)fResume,
397  lPeriod,
398  NULL);
399  if (NT_SUCCESS(Status)) return TRUE;
400 
401  /* If we got here, then we failed */
403  return FALSE;
404 }
405 
406 /*
407  * @implemented
408  */
409 BOOL
410 WINAPI
412 {
414 
415  /* Cancel the timer */
416  Status = NtCancelTimer(hTimer, NULL);
417  if (NT_SUCCESS(Status)) return TRUE;
418 
419  /* If we got here, then we failed */
421  return FALSE;
422 }
423 
424 /*
425  * @implemented
426  */
427 HANDLE
428 WINAPI
431  IN LONG lInitialCount,
432  IN LONG lMaximumCount,
434 {
435  ConvertWin32AnsiObjectApiToUnicodeApi(Semaphore, lpName, lpSemaphoreAttributes, lInitialCount, lMaximumCount);
436 }
437 
438 /*
439  * @implemented
440  */
441 HANDLE
442 WINAPI
445  IN LONG lInitialCount,
446  IN LONG lMaximumCount,
448 {
449  CreateNtObjectFromWin32Api(Semaphore, Semaphore, SEMAPHORE,
450  lpSemaphoreAttributes,
451  lpName,
452  lInitialCount,
453  lMaximumCount);
454 }
455 
456 /*
457  * @implemented
458  */
459 HANDLE
460 WINAPI
462 OpenSemaphoreA(IN DWORD dwDesiredAccess,
464  IN LPCSTR lpName)
465 {
467 }
468 
469 /*
470  * @implemented
471  */
472 HANDLE
473 WINAPI
475 OpenSemaphoreW(IN DWORD dwDesiredAccess,
477  IN LPCWSTR lpName)
478 {
479  OpenNtObjectFromWin32Api(Semaphore, dwDesiredAccess, bInheritHandle, lpName);
480 }
481 
482 /*
483  * @implemented
484  */
485 BOOL
486 WINAPI
489  IN LONG lReleaseCount,
490  IN LPLONG lpPreviousCount)
491 {
493 
494  /* Release the semaphore */
495  Status = NtReleaseSemaphore(hSemaphore, lReleaseCount, lpPreviousCount);
496  if (NT_SUCCESS(Status)) return TRUE;
497 
498  /* If we got here, then we failed */
500  return FALSE;
501 }
502 
503 /*
504  * @implemented
505  */
506 HANDLE
507 WINAPI
510  IN BOOL bInitialOwner,
512 {
513  ConvertWin32AnsiObjectApiToUnicodeApi(Mutex, lpName, lpMutexAttributes, bInitialOwner);
514 }
515 
516 /*
517  * @implemented
518  */
519 HANDLE
520 WINAPI
523  IN BOOL bInitialOwner,
525 {
526  CreateNtObjectFromWin32Api(Mutex, Mutant, MUTEX,
527  lpMutexAttributes,
528  lpName,
529  bInitialOwner);
530 }
531 
532 /*
533  * @implemented
534  */
535 HANDLE
536 WINAPI
538 OpenMutexA(IN DWORD dwDesiredAccess,
540  IN LPCSTR lpName)
541 {
543 }
544 
545 /*
546  * @implemented
547  */
548 HANDLE
549 WINAPI
551 OpenMutexW(IN DWORD dwDesiredAccess,
553  IN LPCWSTR lpName)
554 {
555  OpenNtObjectFromWin32Api(Mutant, dwDesiredAccess, bInheritHandle, lpName);
556 }
557 
558 /*
559  * @implemented
560  */
561 BOOL
562 WINAPI
565 {
567 
568  /* Release the mutant */
570  if (NT_SUCCESS(Status)) return TRUE;
571 
572  /* If we got here, then we failed */
574  return FALSE;
575 }
576 
577 /*
578  * @implemented
579  */
580 HANDLE
581 WINAPI
584  IN BOOL bManualReset,
585  IN BOOL bInitialState,
587 {
588  ConvertWin32AnsiObjectApiToUnicodeApi(Event, lpName, lpEventAttributes, bManualReset, bInitialState);
589 }
590 
591 /*
592  * @implemented
593  */
594 HANDLE
595 WINAPI
598  IN BOOL bManualReset,
599  IN BOOL bInitialState,
601 {
603  lpEventAttributes,
604  lpName,
605  bManualReset ? NotificationEvent : SynchronizationEvent,
606  bInitialState);
607 }
608 
609 /*
610  * @implemented
611  */
612 HANDLE
613 WINAPI
615 OpenEventA(IN DWORD dwDesiredAccess,
617  IN LPCSTR lpName)
618 {
620 }
621 
622 /*
623  * @implemented
624  */
625 HANDLE
626 WINAPI
628 OpenEventW(IN DWORD dwDesiredAccess,
630  IN LPCWSTR lpName)
631 {
633 }
634 
635 /*
636  * @implemented
637  */
638 BOOL
639 WINAPI
642 {
644 
645  /* Pulse the event */
647  if (NT_SUCCESS(Status)) return TRUE;
648 
649  /* If we got here, then we failed */
651  return FALSE;
652 }
653 
654 /*
655  * @implemented
656  */
657 BOOL
658 WINAPI
661 {
663 
664  /* Clear the event */
666  if (NT_SUCCESS(Status)) return TRUE;
667 
668  /* If we got here, then we failed */
670  return FALSE;
671 }
672 
673 /*
674  * @implemented
675  */
676 BOOL
677 WINAPI
680 {
682 
683  /* Set the event */
685  if (NT_SUCCESS(Status)) return TRUE;
686 
687  /* If we got here, then we failed */
689  return FALSE;
690 }
691 
692 /*
693  * @implemented
694  */
695 VOID
696 WINAPI
698 {
700 
701  /* Initialize the critical section and raise an exception if we failed */
702  Status = RtlInitializeCriticalSection((PVOID)lpCriticalSection);
704 }
705 
706 /*
707  * @implemented
708  */
709 BOOL
710 WINAPI
712  IN DWORD dwSpinCount)
713 {
715 
716  /* Initialize the critical section */
718  dwSpinCount);
719  if (!NT_SUCCESS(Status))
720  {
721  /* Set failure code */
723  return FALSE;
724  }
725 
726  /* Success */
727  return TRUE;
728 }
729 
730 /*
731  * @implemented
732  */
733 VOID
734 WINAPI
736 Sleep(IN DWORD dwMilliseconds)
737 {
738  /* Call the new API */
739  SleepEx(dwMilliseconds, FALSE);
740 }
741 
742 
743 /*
744  * @implemented
745  */
746 DWORD
747 WINAPI
748 SleepEx(IN DWORD dwMilliseconds,
749  IN BOOL bAlertable)
750 {
752  PLARGE_INTEGER TimePtr;
753  NTSTATUS errCode;
754  RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME ActCtx;
755 
756  /* APCs must execute with the default activation context */
757  if (bAlertable)
758  {
759  /* Setup the frame */
760  RtlZeroMemory(&ActCtx, sizeof(ActCtx));
761  ActCtx.Size = sizeof(ActCtx);
764  }
765 
766  /* Convert the timeout */
767  TimePtr = BaseFormatTimeOut(&Time, dwMilliseconds);
768  if (!TimePtr)
769  {
770  /* Turn an infinite wait into a really long wait */
771  Time.LowPart = 0;
772  Time.HighPart = 0x80000000;
773  TimePtr = &Time;
774  }
775 
776  /* Loop the delay while APCs are alerting us */
777  do
778  {
779  /* Do the delay */
780  errCode = NtDelayExecution((BOOLEAN)bAlertable, TimePtr);
781  }
782  while ((bAlertable) && (errCode == STATUS_ALERTED));
783 
784  /* Cleanup the activation context */
786 
787  /* Return the correct code */
788  return (errCode == STATUS_USER_APC) ? WAIT_IO_COMPLETION : 0;
789 }
790 
791 /*
792  * @implemented
793  */
794 BOOL
795 WINAPI
797  IN HANDLE hObject,
799  IN PVOID Context,
800  IN ULONG dwMilliseconds,
801  IN ULONG dwFlags)
802 {
804 
805  /* Get real handle */
806  hObject = TranslateStdHandle(hObject);
807 
808  /* Check for console handle */
809  if ((IsConsoleHandle(hObject)) && (VerifyConsoleIoHandle(hObject)))
810  {
811  /* Get the real wait handle */
812  hObject = GetConsoleInputWaitHandle();
813  }
814 
815  /* Register the wait now */
816  Status = RtlRegisterWait(phNewWaitObject,
817  hObject,
818  Callback,
819  Context,
820  dwMilliseconds,
821  dwFlags);
822  if (!NT_SUCCESS(Status))
823  {
824  /* Return failure */
826  return FALSE;
827  }
828 
829  /* All good */
830  return TRUE;
831 }
832 
833 /*
834  * @implemented
835  */
836 HANDLE
837 WINAPI
840  IN PVOID Context,
841  IN ULONG dwMilliseconds,
842  IN ULONG dwFlags)
843 {
845  HANDLE hNewWaitObject;
846 
847  /* Get real handle */
848  hObject = TranslateStdHandle(hObject);
849 
850  /* Check for console handle */
851  if ((IsConsoleHandle(hObject)) && (VerifyConsoleIoHandle(hObject)))
852  {
853  /* Get the real wait handle */
854  hObject = GetConsoleInputWaitHandle();
855  }
856 
857  /* Register the wait */
858  Status = RtlRegisterWait(&hNewWaitObject,
859  hObject,
860  Callback,
861  Context,
862  dwMilliseconds,
863  dwFlags);
864  if (!NT_SUCCESS(Status))
865  {
866  /* Return failure */
868  return NULL;
869  }
870 
871  /* Return the object */
872  return hNewWaitObject;
873 }
874 
875 /*
876  * @implemented
877  */
878 BOOL
879 WINAPI
881 {
883 
884  /* Check for invalid handle */
885  if (!WaitHandle)
886  {
887  /* Fail */
889  return FALSE;
890  }
891 
892  /* Deregister the wait and check status */
893  Status = RtlDeregisterWaitEx(WaitHandle, NULL);
894  if (!(NT_SUCCESS(Status)) || (Status == STATUS_PENDING))
895  {
896  /* Failure or non-blocking call */
898  return FALSE;
899  }
900 
901  /* All good */
902  return TRUE;
903 }
904 
905 /*
906  * @implemented
907  */
908 BOOL
909 WINAPI
911  IN HANDLE CompletionEvent)
912 {
914 
915  /* Check for invalid handle */
916  if (!WaitHandle)
917  {
918  /* Fail */
920  return FALSE;
921  }
922 
923  /* Deregister the wait and check status */
924  Status = RtlDeregisterWaitEx(WaitHandle, CompletionEvent);
925  if (!(NT_SUCCESS(Status)) ||
926  ((CompletionEvent != INVALID_HANDLE_VALUE) && (Status == STATUS_PENDING)))
927  {
928  /* Failure or non-blocking call */
930  return FALSE;
931  }
932 
933  /* All good */
934  return TRUE;
935 }
936 
937 /* EOF */
NTSYSAPI NTSTATUS NTAPI RtlDeregisterWaitEx(_In_ HANDLE hWaitHandle, _In_opt_ HANDLE hCompletionEvent)
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
HANDLE WaitableTimer
Definition: notevil.c:39
DWORD WINAPI WaitForSingleObjectEx(IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:94
#define IN
Definition: typedefs.h:38
DECLSPEC_NORETURN NTSYSAPI VOID NTAPI RtlRaiseStatus(_In_ NTSTATUS Status)
BOOL WINAPI InitializeCriticalSectionAndSpinCount(OUT LPCRITICAL_SECTION lpCriticalSection, IN DWORD dwSpinCount)
Definition: synch.c:711
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
long __cdecl _InterlockedCompareExchange(_Interlocked_operand_ long volatile *_Destination, long _Exchange, long _Comparand)
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
LONG WINAPI InterlockedExchangeAdd(IN OUT LONG volatile *Addend, IN LONG Value)
Definition: synch.c:59
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreW(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:444
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreA(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:430
long __cdecl _InterlockedExchange(_Interlocked_operand_ long volatile *_Target, long _Value)
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
_In_ LPCSTR lpName
Definition: winbase.h:2729
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
HANDLE TranslateStdHandle(IN HANDLE hHandle)
Definition: handle.c:19
NTSTATUS NTAPI NtWaitForMultipleObjects(IN ULONG ObjectCount, IN PHANDLE HandleArray, IN WAIT_TYPE WaitType, IN BOOLEAN Alertable, IN PLARGE_INTEGER TimeOut OPTIONAL)
Definition: obwait.c:46
HANDLE WINAPI OpenWaitableTimerW(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpTimerName)
Definition: synch.c:358
HANDLE WINAPI CreateWaitableTimerW(IN LPSECURITY_ATTRIBUTES lpTimerAttributes OPTIONAL, IN BOOL bManualReset, IN LPCWSTR lpTimerName OPTIONAL)
Definition: synch.c:331
HANDLE WINAPI DECLSPEC_HOTPATCH OpenMutexA(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCSTR lpName)
Definition: synch.c:538
#define STATUS_ALERTED
Definition: ntstatus.h:80
DWORD WINAPI WaitForMultipleObjects(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds)
Definition: synch.c:151
IN OUT PLONG Addend
Definition: CrNtStubs.h:22
PLARGE_INTEGER WINAPI BaseFormatTimeOut(OUT PLARGE_INTEGER Timeout, IN DWORD dwMilliseconds)
Definition: utils.c:288
HANDLE WINAPI OpenWaitableTimerA(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCSTR lpTimerName)
Definition: synch.c:370
Definition: Mutex.h:15
NTSTATUS NTAPI NtResetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:389
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:597
VOID(CALLBACK * PTIMER_APC_ROUTINE)(PVOID, ULONG, LONG)
Definition: winternl.h:2018
#define OpenNtObjectFromWin32Api(ntobj, acc, inh, name)
Definition: base_x.h:148
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSectionAndSpinCount(_In_ PRTL_CRITICAL_SECTION CriticalSection, _In_ ULONG SpinCount)
BOOL WINAPI DECLSPEC_HOTPATCH VerifyConsoleIoHandle(HANDLE hIoHandle)
Definition: console.c:1110
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventW(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
Definition: synch.c:628
static HANDLE hEvent
Definition: comm.c:54
BOOL WINAPI UnregisterWaitEx(IN HANDLE WaitHandle, IN HANDLE CompletionEvent)
Definition: synch.c:910
LONG WINAPI InterlockedIncrement(IN OUT LONG volatile *lpAddend)
Definition: synch.c:28
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOL WINAPI UnregisterWait(IN HANDLE WaitHandle)
Definition: synch.c:880
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
long __cdecl _InterlockedIncrement(_Interlocked_operand_ long volatile *_Addend)
static BOOL bInheritHandle
Definition: pipe.c:82
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ConvertWin32AnsiObjectApiToUnicodeApi(obj, name,...)
Definition: base_x.h:54
long LONG
Definition: pedump.c:60
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventA(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCSTR lpName)
Definition: synch.c:615
NTSTATUS NTAPI NtCancelTimer(IN HANDLE TimerHandle, OUT PBOOLEAN CurrentState OPTIONAL)
Definition: timer.c:252
BOOL WINAPI DECLSPEC_HOTPATCH PulseEvent(IN HANDLE hEvent)
Definition: synch.c:641
BOOL WINAPI CancelWaitableTimer(IN HANDLE hTimer)
Definition: synch.c:411
Definition: timer.h:3
HANDLE WINAPI DECLSPEC_HOTPATCH OpenMutexW(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
Definition: synch.c:551
DWORD WINAPI SignalObjectAndWait(IN HANDLE hObjectToSignal, IN HANDLE hObjectToWaitOn, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:269
unsigned char BOOLEAN
long __cdecl _InterlockedDecrement(_Interlocked_operand_ long volatile *_Addend)
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:697
smooth NULL
Definition: ftsmooth.c:416
HANDLE WINAPI GetConsoleInputWaitHandle(VOID)
Definition: console.c:683
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:583
#define RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_FORMAT_WHISTLER
Definition: rtltypes.h:101
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
const char * LPCSTR
Definition: xmlstorage.h:183
HANDLE hMutex
Definition: mutex.c:11
#define WAIT_IO_COMPLETION
Definition: winbase.h:392
void(CALLBACK * PTIMERAPCROUTINE)(PVOID, DWORD, DWORD)
Definition: winbase.h:1408
NTSTATUS NTAPI NtDelayExecution(IN BOOLEAN Alertable, IN PLARGE_INTEGER DelayInterval)
Definition: wait.c:879
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
#define DECLSPEC_HOTPATCH
Definition: _mingw.h:224
_In_ HANDLE Handle
Definition: extypes.h:390
DWORD WINAPI SleepEx(IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:748
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:458
HANDLE WINAPI CreateWaitableTimerA(IN LPSECURITY_ATTRIBUTES lpTimerAttributes OPTIONAL, IN BOOL bManualReset, IN LPCSTR lpTimerName OPTIONAL)
Definition: synch.c:346
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
DWORD WINAPI WaitForMultipleObjectsEx(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:169
NTSTATUS NTAPI NtReleaseSemaphore(IN HANDLE SemaphoreHandle, IN LONG ReleaseCount, OUT PLONG PreviousCount OPTIONAL)
Definition: sem.c:294
#define WINAPI
Definition: msvc.h:8
Definition: msgtrace.h:9
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WAIT_FAILED
Definition: winbase.h:394
PRTL_ACTIVATION_CONTEXT_STACK_FRAME FASTCALL RtlDeactivateActivationContextUnsafeFast(IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame)
Definition: actctx.c:5934
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2875
#define SetLastError(x)
Definition: compat.h:409
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1067
_In_ PCWSTR _Out_ PVOID * ActCtx
Definition: ldrtypes.h:246
#define IsConsoleHandle(h)
Definition: console.h:14
#define CreateNtObjectFromWin32Api(obj, ntobj, capsobj, sec, name,...)
Definition: base_x.h:140
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:564
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
NTSYSAPI NTSTATUS NTAPI RtlRegisterWait(_In_ PHANDLE phNewWaitObject, _In_ HANDLE hObject, _In_ WAITORTIMERCALLBACKFUNC Callback, _In_ PVOID pvContext, _In_ ULONG ulMilliseconds, _In_ ULONG ulFlags)
ULONG LowPart
Definition: typedefs.h:104
LONG WINAPI InterlockedExchange(IN OUT LONG volatile *Target, IN LONG Value)
Definition: synch.c:48
#define ConvertOpenWin32AnsiObjectApiToUnicodeApi(obj, acc, inh, name)
Definition: base_x.h:86
Status
Definition: gdiplustypes.h:24
#define STATUS_USER_APC
Definition: ntstatus.h:78
int32_t * LPLONG
Definition: typedefs.h:56
HANDLE WINAPI RegisterWaitForSingleObjectEx(IN HANDLE hObject, IN WAITORTIMERCALLBACK Callback, IN PVOID Context, IN ULONG dwMilliseconds, IN ULONG dwFlags)
Definition: synch.c:838
static WAITORTIMERCALLBACK
Definition: thread.c:86
NTSTATUS NTAPI NtSetTimer(IN HANDLE TimerHandle, IN PLARGE_INTEGER DueTime, IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL, IN PVOID TimerContext OPTIONAL, IN BOOLEAN WakeTimer, IN LONG Period OPTIONAL, OUT PBOOLEAN PreviousState OPTIONAL)
Definition: timer.c:582
BOOL WINAPI RegisterWaitForSingleObject(OUT PHANDLE phNewWaitObject, IN HANDLE hObject, IN WAITORTIMERCALLBACK Callback, IN PVOID Context, IN ULONG dwMilliseconds, IN ULONG dwFlags)
Definition: synch.c:796
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:522
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:660
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:488
PRTL_ACTIVATION_CONTEXT_STACK_FRAME FASTCALL RtlActivateActivationContextUnsafeFast(IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame, IN PVOID Context)
Definition: actctx.c:5857
#define OUT
Definition: typedefs.h:39
HANDLE WINAPI DECLSPEC_HOTPATCH OpenSemaphoreA(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCSTR lpName)
Definition: synch.c:462
LONG WINAPI InterlockedCompareExchange(IN OUT LONG volatile *Destination, IN LONG Exchange, IN LONG Comperand)
Definition: synch.c:70
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexA(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:509
LONG WINAPI InterlockedDecrement(IN OUT LONG volatile *lpAddend)
Definition: synch.c:38
NTSTATUS NTAPI NtSignalAndWaitForSingleObject(IN HANDLE ObjectHandleToSignal, IN HANDLE WaitableObjectHandle, IN BOOLEAN Alertable, IN PLARGE_INTEGER TimeOut OPTIONAL)
Definition: obwait.c:473
NTSTATUS NTAPI NtPulseEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:248
BOOL WINAPI SetWaitableTimer(IN HANDLE hTimer, IN const LARGE_INTEGER *pDueTime, IN LONG lPeriod, IN PTIMERAPCROUTINE pfnCompletionRoutine OPTIONAL, IN OPTIONAL LPVOID lpArgToCompletionRoutine, IN BOOL fResume)
Definition: synch.c:382
LPFNPSPCALLBACK Callback
Definition: desk.c:111
long __cdecl _InterlockedExchangeAdd(_Interlocked_operand_ long volatile *_Addend, long _Value)
NTSTATUS NTAPI NtReleaseMutant(IN HANDLE MutantHandle, IN PLONG PreviousCount OPTIONAL)
Definition: mutant.c:299
#define CONST
Definition: pedump.c:81
static PLARGE_INTEGER Time
Definition: time.c:105
HANDLE WINAPI DECLSPEC_HOTPATCH OpenSemaphoreW(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
Definition: synch.c:475
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)