ReactOS  0.4.14-dev-55-g2da92ac
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_ALL_ACCESS,
450  lpSemaphoreAttributes,
451  lpName,
452  lInitialCount,
453  lMaximumCount);
454 }
455 
456 HANDLE
457 WINAPI
460  IN LONG lInitialCount,
461  IN LONG lMaximumCount,
464  IN DWORD dwDesiredAccess OPTIONAL)
465 {
466  CreateNtObjectFromWin32Api(Semaphore, Semaphore, dwDesiredAccess,
467  lpSemaphoreAttributes,
468  lpName,
469  lInitialCount,
470  lMaximumCount);
471 }
472 
473 HANDLE
474 WINAPI
477  IN LONG lInitialCount,
478  IN LONG lMaximumCount,
481  IN DWORD dwDesiredAccess OPTIONAL)
482 {
484 
485  if (!lpName)
486  {
487  return CreateSemaphoreExW(lpSemaphoreAttributes,
488  lInitialCount,
489  lMaximumCount,
490  NULL,
491  dwFlags,
492  dwDesiredAccess);
493  }
494 
496 
497  if (NT_SUCCESS(Status))
498  {
499  return CreateSemaphoreExW(lpSemaphoreAttributes,
500  lInitialCount,
501  lMaximumCount,
502  UnicodeCache->Buffer,
503  dwFlags,
504  dwDesiredAccess);
505  }
506 
508 }
509 
510 /*
511  * @implemented
512  */
513 HANDLE
514 WINAPI
516 OpenSemaphoreA(IN DWORD dwDesiredAccess,
518  IN LPCSTR lpName)
519 {
521 }
522 
523 /*
524  * @implemented
525  */
526 HANDLE
527 WINAPI
529 OpenSemaphoreW(IN DWORD dwDesiredAccess,
531  IN LPCWSTR lpName)
532 {
533  OpenNtObjectFromWin32Api(Semaphore, dwDesiredAccess, bInheritHandle, lpName);
534 }
535 
536 /*
537  * @implemented
538  */
539 BOOL
540 WINAPI
543  IN LONG lReleaseCount,
544  IN LPLONG lpPreviousCount)
545 {
547 
548  /* Release the semaphore */
549  Status = NtReleaseSemaphore(hSemaphore, lReleaseCount, lpPreviousCount);
550  if (NT_SUCCESS(Status)) return TRUE;
551 
552  /* If we got here, then we failed */
554  return FALSE;
555 }
556 
557 /*
558  * @implemented
559  */
560 HANDLE
561 WINAPI
564  IN BOOL bInitialOwner,
566 {
567  ConvertWin32AnsiObjectApiToUnicodeApi(Mutex, lpName, lpMutexAttributes, bInitialOwner);
568 }
569 
570 /*
571  * @implemented
572  */
573 HANDLE
574 WINAPI
577  IN BOOL bInitialOwner,
579 {
581  lpMutexAttributes,
582  lpName,
583  bInitialOwner);
584 }
585 
586 /*
587  * @implemented
588  */
589 HANDLE
590 WINAPI
592 OpenMutexA(IN DWORD dwDesiredAccess,
594  IN LPCSTR lpName)
595 {
597 }
598 
599 /*
600  * @implemented
601  */
602 HANDLE
603 WINAPI
605 OpenMutexW(IN DWORD dwDesiredAccess,
607  IN LPCWSTR lpName)
608 {
609  OpenNtObjectFromWin32Api(Mutant, dwDesiredAccess, bInheritHandle, lpName);
610 }
611 
612 /*
613  * @implemented
614  */
615 BOOL
616 WINAPI
619 {
621 
622  /* Release the mutant */
624  if (NT_SUCCESS(Status)) return TRUE;
625 
626  /* If we got here, then we failed */
628  return FALSE;
629 }
630 
631 /*
632  * @implemented
633  */
634 HANDLE
635 WINAPI
638  IN BOOL bManualReset,
639  IN BOOL bInitialState,
641 {
642  ConvertWin32AnsiObjectApiToUnicodeApi(Event, lpName, lpEventAttributes, bManualReset, bInitialState);
643 }
644 
645 /*
646  * @implemented
647  */
648 HANDLE
649 WINAPI
652  IN BOOL bManualReset,
653  IN BOOL bInitialState,
655 {
657  lpEventAttributes,
658  lpName,
659  bManualReset ? NotificationEvent : SynchronizationEvent,
660  bInitialState);
661 }
662 
663 /*
664  * @implemented
665  */
666 HANDLE
667 WINAPI
669 OpenEventA(IN DWORD dwDesiredAccess,
671  IN LPCSTR lpName)
672 {
674 }
675 
676 /*
677  * @implemented
678  */
679 HANDLE
680 WINAPI
682 OpenEventW(IN DWORD dwDesiredAccess,
684  IN LPCWSTR lpName)
685 {
687 }
688 
689 /*
690  * @implemented
691  */
692 BOOL
693 WINAPI
696 {
698 
699  /* Pulse the event */
701  if (NT_SUCCESS(Status)) return TRUE;
702 
703  /* If we got here, then we failed */
705  return FALSE;
706 }
707 
708 /*
709  * @implemented
710  */
711 BOOL
712 WINAPI
715 {
717 
718  /* Clear the event */
720  if (NT_SUCCESS(Status)) return TRUE;
721 
722  /* If we got here, then we failed */
724  return FALSE;
725 }
726 
727 /*
728  * @implemented
729  */
730 BOOL
731 WINAPI
734 {
736 
737  /* Set the event */
739  if (NT_SUCCESS(Status)) return TRUE;
740 
741  /* If we got here, then we failed */
743  return FALSE;
744 }
745 
746 /*
747  * @implemented
748  */
749 VOID
750 WINAPI
752 {
754 
755  /* Initialize the critical section and raise an exception if we failed */
756  Status = RtlInitializeCriticalSection((PVOID)lpCriticalSection);
758 }
759 
760 /*
761  * @implemented
762  */
763 BOOL
764 WINAPI
766  IN DWORD dwSpinCount)
767 {
769 
770  /* Initialize the critical section */
772  dwSpinCount);
773  if (!NT_SUCCESS(Status))
774  {
775  /* Set failure code */
777  return FALSE;
778  }
779 
780  /* Success */
781  return TRUE;
782 }
783 
784 /*
785  * @implemented
786  */
787 VOID
788 WINAPI
790 Sleep(IN DWORD dwMilliseconds)
791 {
792  /* Call the new API */
793  SleepEx(dwMilliseconds, FALSE);
794 }
795 
796 
797 /*
798  * @implemented
799  */
800 DWORD
801 WINAPI
802 SleepEx(IN DWORD dwMilliseconds,
803  IN BOOL bAlertable)
804 {
806  PLARGE_INTEGER TimePtr;
807  NTSTATUS errCode;
808  RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME ActCtx;
809 
810  /* APCs must execute with the default activation context */
811  if (bAlertable)
812  {
813  /* Setup the frame */
814  RtlZeroMemory(&ActCtx, sizeof(ActCtx));
815  ActCtx.Size = sizeof(ActCtx);
818  }
819 
820  /* Convert the timeout */
821  TimePtr = BaseFormatTimeOut(&Time, dwMilliseconds);
822  if (!TimePtr)
823  {
824  /* Turn an infinite wait into a really long wait */
825  Time.LowPart = 0;
826  Time.HighPart = 0x80000000;
827  TimePtr = &Time;
828  }
829 
830  /* Loop the delay while APCs are alerting us */
831  do
832  {
833  /* Do the delay */
834  errCode = NtDelayExecution((BOOLEAN)bAlertable, TimePtr);
835  }
836  while ((bAlertable) && (errCode == STATUS_ALERTED));
837 
838  /* Cleanup the activation context */
840 
841  /* Return the correct code */
842  return (errCode == STATUS_USER_APC) ? WAIT_IO_COMPLETION : 0;
843 }
844 
845 /*
846  * @implemented
847  */
848 BOOL
849 WINAPI
851  IN HANDLE hObject,
853  IN PVOID Context,
854  IN ULONG dwMilliseconds,
855  IN ULONG dwFlags)
856 {
858 
859  /* Get real handle */
860  hObject = TranslateStdHandle(hObject);
861 
862  /* Check for console handle */
863  if ((IsConsoleHandle(hObject)) && (VerifyConsoleIoHandle(hObject)))
864  {
865  /* Get the real wait handle */
866  hObject = GetConsoleInputWaitHandle();
867  }
868 
869  /* Register the wait now */
870  Status = RtlRegisterWait(phNewWaitObject,
871  hObject,
872  Callback,
873  Context,
874  dwMilliseconds,
875  dwFlags);
876  if (!NT_SUCCESS(Status))
877  {
878  /* Return failure */
880  return FALSE;
881  }
882 
883  /* All good */
884  return TRUE;
885 }
886 
887 /*
888  * @implemented
889  */
890 HANDLE
891 WINAPI
894  IN PVOID Context,
895  IN ULONG dwMilliseconds,
896  IN ULONG dwFlags)
897 {
899  HANDLE hNewWaitObject;
900 
901  /* Get real handle */
902  hObject = TranslateStdHandle(hObject);
903 
904  /* Check for console handle */
905  if ((IsConsoleHandle(hObject)) && (VerifyConsoleIoHandle(hObject)))
906  {
907  /* Get the real wait handle */
908  hObject = GetConsoleInputWaitHandle();
909  }
910 
911  /* Register the wait */
912  Status = RtlRegisterWait(&hNewWaitObject,
913  hObject,
914  Callback,
915  Context,
916  dwMilliseconds,
917  dwFlags);
918  if (!NT_SUCCESS(Status))
919  {
920  /* Return failure */
922  return NULL;
923  }
924 
925  /* Return the object */
926  return hNewWaitObject;
927 }
928 
929 /*
930  * @implemented
931  */
932 BOOL
933 WINAPI
935 {
937 
938  /* Check for invalid handle */
939  if (!WaitHandle)
940  {
941  /* Fail */
943  return FALSE;
944  }
945 
946  /* Deregister the wait and check status */
947  Status = RtlDeregisterWaitEx(WaitHandle, NULL);
948  if (!(NT_SUCCESS(Status)) || (Status == STATUS_PENDING))
949  {
950  /* Failure or non-blocking call */
952  return FALSE;
953  }
954 
955  /* All good */
956  return TRUE;
957 }
958 
959 /*
960  * @implemented
961  */
962 BOOL
963 WINAPI
965  IN HANDLE CompletionEvent)
966 {
968 
969  /* Check for invalid handle */
970  if (!WaitHandle)
971  {
972  /* Fail */
974  return FALSE;
975  }
976 
977  /* Deregister the wait and check status */
978  Status = RtlDeregisterWaitEx(WaitHandle, CompletionEvent);
979  if (!(NT_SUCCESS(Status)) ||
980  ((CompletionEvent != INVALID_HANDLE_VALUE) && (Status == STATUS_PENDING)))
981  {
982  /* Failure or non-blocking call */
984  return FALSE;
985  }
986 
987  /* All good */
988  return TRUE;
989 }
990 
991 /* EOF */
NTSYSAPI NTSTATUS NTAPI RtlDeregisterWaitEx(_In_ HANDLE hWaitHandle, _In_opt_ HANDLE hCompletionEvent)
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
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:765
#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:790
long __cdecl _InterlockedCompareExchange(_Interlocked_operand_ long volatile *_Destination, long _Exchange, long _Comparand)
#define ConvertAnsiToUnicodePrologue
Definition: base_x.h:33
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:606
_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:733
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:592
#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
#define MUTEX_ALL_ACCESS
Definition: winbase.h:158
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:651
VOID(CALLBACK * PTIMER_APC_ROUTINE)(PVOID, ULONG, LONG)
Definition: winternl.h:2018
#define OpenNtObjectFromWin32Api(ntobj, acc, inh, name)
Definition: base_x.h:143
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSectionAndSpinCount(_In_ PRTL_CRITICAL_SECTION CriticalSection, _In_ ULONG SpinCount)
BOOL WINAPI DECLSPEC_HOTPATCH VerifyConsoleIoHandle(HANDLE hIoHandle)
Definition: console.c:1110
#define CreateNtObjectFromWin32Api(obj, ntobj, access, sec, name,...)
Definition: base_x.h:135
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventW(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
Definition: synch.c:682
static HANDLE hEvent
Definition: comm.c:54
BOOL WINAPI UnregisterWaitEx(IN HANDLE WaitHandle, IN HANDLE CompletionEvent)
Definition: synch.c:964
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:934
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:669
NTSTATUS NTAPI NtCancelTimer(IN HANDLE TimerHandle, OUT PBOOLEAN CurrentState OPTIONAL)
Definition: timer.c:252
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
BOOL WINAPI DECLSPEC_HOTPATCH PulseEvent(IN HANDLE hEvent)
Definition: synch.c:695
BOOL WINAPI CancelWaitableTimer(IN HANDLE hTimer)
Definition: synch.c:411
HANDLE WINAPI DECLSPEC_HOTPATCH OpenMutexW(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
Definition: synch.c:605
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:751
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:637
#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:588
#define ConvertAnsiToUnicodeEpilogue
Definition: base_x.h:42
#define DECLSPEC_HOTPATCH
Definition: _mingw.h:240
_In_ HANDLE Handle
Definition: extypes.h:390
DWORD WINAPI SleepEx(IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:802
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
#define TIMER_ALL_ACCESS
Definition: extypes.h:116
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
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:5939
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2891
#define SetLastError(x)
Definition: compat.h:409
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1068
_In_ PCWSTR _Out_ PVOID * ActCtx
Definition: ldrtypes.h:247
#define IsConsoleHandle(h)
Definition: console.h:14
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
_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 DECLSPEC_HOTPATCH CreateSemaphoreExW(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCWSTR lpName OPTIONAL, IN DWORD dwFlags OPTIONAL, IN DWORD dwDesiredAccess OPTIONAL)
Definition: synch.c:459
HANDLE WINAPI RegisterWaitForSingleObjectEx(IN HANDLE hObject, IN WAITORTIMERCALLBACK Callback, IN PVOID Context, IN ULONG dwMilliseconds, IN ULONG dwFlags)
Definition: synch.c:892
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:850
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:576
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:542
#define ConvertAnsiToUnicodeBody(name)
Definition: base_x.h:38
PRTL_ACTIVATION_CONTEXT_STACK_FRAME FASTCALL RtlActivateActivationContextUnsafeFast(IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame, IN PVOID Context)
Definition: actctx.c:5862
#define OUT
Definition: typedefs.h:39
HANDLE WINAPI DECLSPEC_HOTPATCH OpenSemaphoreA(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCSTR lpName)
Definition: synch.c:516
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:563
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
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreExA(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCSTR lpName OPTIONAL, IN DWORD dwFlags OPTIONAL, IN DWORD dwDesiredAccess OPTIONAL)
Definition: synch.c:476
long __cdecl _InterlockedExchangeAdd(_Interlocked_operand_ long volatile *_Addend, long _Value)
#define SEMAPHORE_ALL_ACCESS
Definition: winbase.h:160
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:529
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)