ReactOS  r76032
synch.c File Reference
#include <k32.h>
#include <debug.h>
Include dependency graph for synch.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

LONG WINAPI InterlockedIncrement (IN OUT LONG volatile *lpAddend)
 
LONG WINAPI InterlockedDecrement (IN OUT LONG volatile *lpAddend)
 
LONG WINAPI InterlockedExchange (IN OUT LONG volatile *Target, IN LONG Value)
 
LONG WINAPI InterlockedExchangeAdd (IN OUT LONG volatile *Addend, IN LONG Value)
 
LONG WINAPI InterlockedCompareExchange (IN OUT LONG volatile *Destination, IN LONG Exchange, IN LONG Comperand)
 
DWORD WINAPI WaitForSingleObject (IN HANDLE hHandle, IN DWORD dwMilliseconds)
 
DWORD WINAPI WaitForSingleObjectEx (IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
 
DWORD WINAPI WaitForMultipleObjects (IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds)
 
DWORD WINAPI WaitForMultipleObjectsEx (IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds, IN BOOL bAlertable)
 
DWORD WINAPI SignalObjectAndWait (IN HANDLE hObjectToSignal, IN HANDLE hObjectToWaitOn, IN DWORD dwMilliseconds, IN BOOL bAlertable)
 
HANDLE WINAPI CreateWaitableTimerW (IN LPSECURITY_ATTRIBUTES lpTimerAttributes OPTIONAL, IN BOOL bManualReset, IN LPCWSTR lpTimerName OPTIONAL)
 
HANDLE WINAPI CreateWaitableTimerA (IN LPSECURITY_ATTRIBUTES lpTimerAttributes OPTIONAL, IN BOOL bManualReset, IN LPCSTR lpTimerName OPTIONAL)
 
HANDLE WINAPI OpenWaitableTimerW (IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpTimerName)
 
HANDLE WINAPI OpenWaitableTimerA (IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCSTR lpTimerName)
 
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)
 
BOOL WINAPI CancelWaitableTimer (IN HANDLE hTimer)
 
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreA (IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCSTR lpName OPTIONAL)
 
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreW (IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCWSTR lpName OPTIONAL)
 
HANDLE WINAPI DECLSPEC_HOTPATCH OpenSemaphoreA (IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCSTR lpName)
 
HANDLE WINAPI DECLSPEC_HOTPATCH OpenSemaphoreW (IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
 
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore (IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
 
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexA (IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCSTR lpName OPTIONAL)
 
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW (IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCWSTR lpName OPTIONAL)
 
HANDLE WINAPI DECLSPEC_HOTPATCH OpenMutexA (IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCSTR lpName)
 
HANDLE WINAPI DECLSPEC_HOTPATCH OpenMutexW (IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
 
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex (IN HANDLE hMutex)
 
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA (IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
 
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW (IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
 
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventA (IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCSTR lpName)
 
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventW (IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
 
BOOL WINAPI DECLSPEC_HOTPATCH PulseEvent (IN HANDLE hEvent)
 
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent (IN HANDLE hEvent)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent (IN HANDLE hEvent)
 
VOID WINAPI InitializeCriticalSection (OUT LPCRITICAL_SECTION lpCriticalSection)
 
BOOL WINAPI InitializeCriticalSectionAndSpinCount (OUT LPCRITICAL_SECTION lpCriticalSection, IN DWORD dwSpinCount)
 
VOID WINAPI DECLSPEC_HOTPATCH Sleep (IN DWORD dwMilliseconds)
 
DWORD WINAPI SleepEx (IN DWORD dwMilliseconds, IN BOOL bAlertable)
 
BOOL WINAPI RegisterWaitForSingleObject (OUT PHANDLE phNewWaitObject, IN HANDLE hObject, IN WAITORTIMERCALLBACK Callback, IN PVOID Context, IN ULONG dwMilliseconds, IN ULONG dwFlags)
 
HANDLE WINAPI RegisterWaitForSingleObjectEx (IN HANDLE hObject, IN WAITORTIMERCALLBACK Callback, IN PVOID Context, IN ULONG dwMilliseconds, IN ULONG dwFlags)
 
BOOL WINAPI UnregisterWait (IN HANDLE WaitHandle)
 
BOOL WINAPI UnregisterWaitEx (IN HANDLE WaitHandle, IN HANDLE CompletionEvent)
 

Macro Definition Documentation

#define NDEBUG

Definition at line 12 of file synch.c.

Function Documentation

BOOL WINAPI CancelWaitableTimer ( IN HANDLE  hTimer)

Definition at line 411 of file synch.c.

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 */
420  BaseSetLastNTError(Status);
421  return FALSE;
422 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI NtCancelTimer(IN HANDLE TimerHandle, OUT PBOOLEAN CurrentState OPTIONAL)
Definition: timer.c:252
smooth NULL
Definition: ftsmooth.c:557
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA ( IN LPSECURITY_ATTRIBUTES lpEventAttributes  OPTIONAL,
IN BOOL  bManualReset,
IN BOOL  bInitialState,
IN LPCSTR lpName  OPTIONAL 
)

Definition at line 583 of file synch.c.

Referenced by create_function_addr_events(), DllMain(), do_test(), get_events(), init_event(), init_procs(), MCICDA_Play(), overlapped_server(), read_file_test(), release_host_object(), service_process(), start_host_object2(), START_TEST(), test_accept(), test_AcceptEx(), test_AddMandatoryAce(), test_apc_deadlock(), test_CoCreateInstance(), test_CoGetClassObject(), test_CoGetContextToken(), test_CoGetObjectContext(), test_ConnectEx(), test_CreateThread_basic(), test_dde(), test_debug_children(), test_default_dacl_owner_sid(), test_defwinproc(), test_DragQueryFile(), test_event(), test_event_security(), test_events(), test_FakeDLL(), test_foregroundwindow(), test_getservbyname(), test_ImmThreads(), test_Input_mouse(), test_interthread_messages(), test_ip_pktinfo(), test_layered_window(), test_local_server(), test_name_collisions(), test_no_couninitialize_server(), test_ntncdf(), test_ntncdf_async(), test_null_device(), test_open_url_async(), test_overlapped(), test_overlapped_error(), test_PdhCollectQueryDataEx(), test_PeekMessage(), test_process_security(), test_query_handle(), test_query_object(), test_readfileex_pending(), test_register_local_server(), test_runner(), test_select(), test_send(), test_SendMessage_other_thread(), test_sioAddressListChange(), test_smresult(), test_tableweak_and_normal_marshal_and_releasedata(), test_tableweak_and_normal_marshal_and_unmarshal(), test_TerminateThread(), test_thread_objects(), test_two_tableweak_marshal_and_releasedata(), test_WaitForInputIdle(), test_window_from_point(), test_winevents(), test_write_watch(), test_WSARecv(), and testCtrlHandler().

587 {
588  ConvertWin32AnsiObjectApiToUnicodeApi(Event, lpName, lpEventAttributes, bManualReset, bInitialState);
589 }
_In_ LPCSTR lpName
Definition: winbase.h:2677
#define ConvertWin32AnsiObjectApiToUnicodeApi(obj, name,...)
Definition: base_x.h:54
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW ( IN LPSECURITY_ATTRIBUTES lpEventAttributes  OPTIONAL,
IN BOOL  bManualReset,
IN BOOL  bInitialState,
IN LPCWSTR lpName  OPTIONAL 
)

Definition at line 597 of file synch.c.

Referenced by _overlapped_read_async(), _overlapped_read_sync(), _overlapped_write_async(), _overlapped_write_sync(), AllocEventData(), ANIMATE_Play(), apartment_hostobject_in_hostapt(), AVISplitter_ProcessStreamList(), BackgroundCopyJobConstructor(), BaseRenderer_Init(), check_hook_thread(), child_process(), ClientRpcChannelBuffer_GetEventHandle(), ClientSideInstallW(), ConDrvInitConsole(), create_overlapped_pipe(), CreateGPEvent(), CreatePublicEvent(), CreateRenderingSubsystem(), CreateTestThread(), CRYPT_MakeInetContext(), DEVENUM_CreateSpecialCategories(), dispatch_rpc(), DosStartProcess32(), download_url(), DP_MSG_BuildAndLinkReplyStruct(), DPL_CreateAndSetLobbyHandles(), DSoundRender_create(), EmulatorInitialize(), EventsQueue_Init(), FileAsyncReader_RequestAllocator(), FileAsyncReader_SyncRead(), FilterGraph_create(), get_np_event(), GUIDisplayStatusMessage(), GuiInit(), GuiInitFrontEnd(), IDirectPlay4Impl_EnumSessions(), init(), init_async(), init_events(), init_thread_sync_helpers(), init_urlcache(), CDesktopThread::Initialize(), COutputPin::InitializeIOThread(), InitializePnPManager(), InitializeScreenSaver(), InstallDevice(), KsSynchronousDeviceControl(), local_server_thread(), LsapInitLsa(), main(), ManualResetEvent_Construct(), MCI_SendCommandAsync(), MCIAVI_drvOpen(), MCIAVI_OpenAudio(), MCIQTZ_drvOpen(), midiStreamOpen(), mmTaskCreate(), NBCmdQueueCancel(), OutputQueue_Construct(), CKsClockForwarder::Pause(), PdhCollectQueryDataEx(), proc_PlaySound(), ProcessPage_OnDebug(), PullPin_Init(), queue_task(), ReferenceClock_AdvisePeriodic(), ReferenceClock_AdviseTime(), RPC_StartLocalServer(), rpcrt4_conn_release_and_wait(), rpcrt4_ncacn_http_alloc(), rpcrt4_ncacn_http_open(), rpcrt4_protseq_np_alloc(), rpcrt4_protseq_sock_alloc(), rpcrt4_sock_wait_init(), RPCRT4_start_listen(), RPCRT4_start_listen_protseq(), RpcServerUnregisterIf(), RPCSS_Initialize(), ScmWaitForLsa(), ScreenSaverThreadMain(), serv_main(), server(), serverThreadMain3(), serverThreadMain5(), service_main(), ServiceMain(), SHCreateThread(), START_TEST(), CProgressDialog::StartProgressDialog(), StartStopEnumEventsThread(), TCPSendIoctl(), test_AbortWaitCts(), test_activateapp(), test_alertable(), test_async(), test_async_HttpSendRequestEx(), test_attach_input(), test_audioclient(), test_cancelio(), test_concurrent_header_access(), test_connection_cache(), test_CreateRemoteThread(), test_deletecontext(), test_event(), test_fragmentsize(), test_http_connection(), test_inet_ntoa(), test_interthread_messages(), test_mixerOpen(), test_NamedPipe_2(), test_nonalertable(), test_notify(), test_overlapped(), test_persistent_connection(), test_QueueUserWorkItem(), test_read_write(), test_readdirectorychanges(), test_readdirectorychanges_filedir(), test_readdirectorychanges_null(), test_redirect(), test_RegisterWaitForSingleObject(), test_RegNotifyChangeKeyValue(), test_SetFocus(), test_SetForegroundWindow(), test_ShowCursor(), test_signalandwait(), test_stop_wait_for_call(), test_threads(), test_timer_queue(), test_timers(), test_TransmitFile(), test_uninitialized(), test_WaitBreak(), test_WaitCommEvent(), test_WaitCts(), test_WaitDcd(), test_WaitDsr(), test_WaitForMultipleObjects(), test_WaitForSingleObject(), test_WaitRing(), test_WaitRx(), test_waittxempty(), test_worst_case(), TestKM(), testNotifyAddrChange(), TestRead(), testWaitForConsoleInput(), TestWrite(), ThemeServiceMain(), ThemeWatchForStart(), TIME_MMTimeStart(), TIME_SetEventInternal(), VMR9DefaultAllocatorPresenterImpl_create(), WaitForLsass(), WaitForSCManager(), wave_in_test_deviceIn(), WAVE_mciPlay(), WAVE_mciRecord(), wave_out_test_deviceOut(), WdmAudCommitWaveBufferByLegacy(), WdmAudSetMixerDeviceFormatByLegacy(), wined3d_cs_create(), winhttp_request_Send(), WINMM_CreateIData(), WriteFileEx_Remixer(), WSACreateEvent(), and wWinMain().

601 {
603  lpEventAttributes,
604  lpName,
605  bManualReset ? NotificationEvent : SynchronizationEvent,
606  bInitialState);
607 }
_In_ LPCSTR lpName
Definition: winbase.h:2677
Definition: msgtrace.h:9
#define CreateNtObjectFromWin32Api(obj, ntobj, capsobj, sec, name,...)
Definition: base_x.h:140
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexA ( IN LPSECURITY_ATTRIBUTES lpMutexAttributes  OPTIONAL,
IN BOOL  bInitialOwner,
IN LPCSTR lpName  OPTIONAL 
)

Definition at line 509 of file synch.c.

Referenced by _tWinMain(), get_base_dir(), test_handles(), test_mutex(), test_mutex_security(), and test_name_collisions().

512 {
513  ConvertWin32AnsiObjectApiToUnicodeApi(Mutex, lpName, lpMutexAttributes, bInitialOwner);
514 }
_In_ LPCSTR lpName
Definition: winbase.h:2677
Definition: Mutex.h:15
#define ConvertWin32AnsiObjectApiToUnicodeApi(obj, name,...)
Definition: base_x.h:54
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW ( IN LPSECURITY_ATTRIBUTES lpMutexAttributes  OPTIONAL,
IN BOOL  bInitialOwner,
IN LPCWSTR lpName  OPTIONAL 
)

Definition at line 522 of file synch.c.

Referenced by cache_containers_add(), child_process(), ComDBOpen(), CreateAssemblyCache(), EnterCriticalPolicySection(), INetCfg_fnQueryInterface(), K32CreateDBMonMutex(), main(), proxy_manager_construct(), RPCRT4_start_listen_protseq(), and wWinMain().

525 {
526  CreateNtObjectFromWin32Api(Mutex, Mutant, MUTEX,
527  lpMutexAttributes,
528  lpName,
529  bInitialOwner);
530 }
_In_ LPCSTR lpName
Definition: winbase.h:2677
Definition: Mutex.h:15
#define CreateNtObjectFromWin32Api(obj, ntobj, capsobj, sec, name,...)
Definition: base_x.h:140
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreA ( IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes  OPTIONAL,
IN LONG  lInitialCount,
IN LONG  lMaximumCount,
IN LPCSTR lpName  OPTIONAL 
)

Definition at line 430 of file synch.c.

Referenced by DPLAYX_ConstructData(), test_CoWaitForMultipleHandles(), test_GetKeyState(), test_name_collisions(), test_semaphore(), and test_semaphore_security().

434 {
435  ConvertWin32AnsiObjectApiToUnicodeApi(Semaphore, lpName, lpSemaphoreAttributes, lInitialCount, lMaximumCount);
436 }
_In_ LPCSTR lpName
Definition: winbase.h:2677
#define ConvertWin32AnsiObjectApiToUnicodeApi(obj, name,...)
Definition: base_x.h:54
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreW ( IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes  OPTIONAL,
IN LONG  lInitialCount,
IN LONG  lMaximumCount,
IN LPCWSTR lpName  OPTIONAL 
)

Definition at line 444 of file synch.c.

Referenced by BaseMemAllocator_Commit(), child_process(), CRYPT_ImportSystemRootCertsToReg(), DllMain(), init_urlcache(), Initialize(), SHGlobalCounterCreateNamedW(), test_alertable_wait(), test_async_file_errors(), test_iocp_callback(), test_RtlIsCriticalSectionLocked(), test_signalandwait(), and test_WM_DISPLAYCHANGE().

448 {
449  CreateNtObjectFromWin32Api(Semaphore, Semaphore, SEMAPHORE,
450  lpSemaphoreAttributes,
451  lpName,
452  lInitialCount,
453  lMaximumCount);
454 }
_In_ LPCSTR lpName
Definition: winbase.h:2677
#define CreateNtObjectFromWin32Api(obj, ntobj, capsobj, sec, name,...)
Definition: base_x.h:140
HANDLE WINAPI CreateWaitableTimerA ( IN LPSECURITY_ATTRIBUTES lpTimerAttributes  OPTIONAL,
IN BOOL  bManualReset,
IN LPCSTR lpTimerName  OPTIONAL 
)

Definition at line 346 of file synch.c.

349 {
350  ConvertWin32AnsiObjectApiToUnicodeApi(WaitableTimer, lpTimerName, lpTimerAttributes, bManualReset);
351 }
HANDLE WaitableTimer
Definition: notevil.c:39
#define ConvertWin32AnsiObjectApiToUnicodeApi(obj, name,...)
Definition: base_x.h:54
HANDLE WINAPI CreateWaitableTimerW ( IN LPSECURITY_ATTRIBUTES lpTimerAttributes  OPTIONAL,
IN BOOL  bManualReset,
IN LPCWSTR lpTimerName  OPTIONAL 
)

Definition at line 331 of file synch.c.

334 {
336  lpTimerAttributes,
337  lpTimerName,
338  bManualReset ? NotificationTimer : SynchronizationTimer);
339 }
HANDLE WaitableTimer
Definition: notevil.c:39
Definition: timer.h:3
#define CreateNtObjectFromWin32Api(obj, ntobj, capsobj, sec, name,...)
Definition: base_x.h:140
VOID WINAPI InitializeCriticalSection ( OUT LPCRITICAL_SECTION  lpCriticalSection)

Definition at line 697 of file synch.c.

Referenced by __mingw_TLScallback(), __xmlGlobalInitMutexLock(), _Locale_init(), _tmain(), alloc_device(), alloc_serverprotoseq(), ANIMATE_Create(), apartment_construct(), ApiInit(), AtlModuleInit(), BackgroundCopyJobConstructor(), BaseFilter_Init(), BaseRenderer_Init(), Binding_Create(), BitmapClipper_Create(), BitmapImpl_Create(), BitmapScaler_Create(), BmpDecoder_Create(), chm_dup(), chm_openW(), CKsAllocator::CKsAllocator(), CKsProxy::CKsProxy(), ClientThreadSetupHelper(), ComponentEnum_Clone(), ConDrvInitConsole(), ConStreamInitEx(), ContextPropertyList_Create(), COutputPin::COutputPin(), CProgressDialog::CProgressDialog(), create_binding_protocol(), create_open_state(), CreateComponentEnumerator(), CreateD3D9(), CreateIProp(), CreateSidCacheMgr(), createtestfilter(), CreateTextServices(), CRYPT_CollectionOpenStore(), CRYPT_MemOpenStore(), CRYPT_RegOpenStore(), CryptInitOIDFunctionSet(), DirectSoundCaptureDevice_Create(), DirectSoundDevice_Create(), DllMain(), dplay_create(), dplobby_create(), DriverProc(), EventsQueue_Init(), file_device_create(), FileAsyncReader_Construct(), FilterGraph_create(), FlipRotator_Create(), FormatConverter_CreateInstance(), GdiProcessSetup(), get_or_create_threaddata(), GifDecoder_CreateInstance(), GifEncoder_CreateInstance(), GuiInitFrontEnd(), handle_create(), HTTP_HttpOpenRequestW(), IcoDecoder_CreateInstance(), ATL::CComCriticalSection::Init(), init_handle_table(), init_tests(), InitD3D9BaseDevice(), InitEventSourceList(), initialize_directinput_instance(), InitializeGPNotifications(), InitializePrintMonitor2(), IWICStreamImpl_InitializeFromIStreamRegion(), IWICStreamImpl_InitializeFromMemory(), LogfListInitialize(), main(), MCIAVI_drvOpen(), MCICDA_drvOpen(), MessageInit(), MetadataReader_Create(), MimeInternational_Construct(), MMDevice_Create(), msvcrt_init_fp(), msvcrt_initialize_mlock(), NBCmdQueueCreate(), NBNameCacheCreate(), NetBIOSInit(), NetBIOSRegisterAdapter(), NetBTCall(), new_stub_manager(), NewPrimarySoundBuffer(), nfs41_client_create(), nfs41_root_create(), nfs41_server_list_init(), OutputQueue_Construct(), PaletteImpl_Create(), PerfDataInitialize(), pnfs_file_device_list_create(), pnfs_layout_list_create(), PosPassThru_Construct(), PropertyStorage_BaseConstruct(), PropertyStore_CreateInstance(), proxy_manager_construct(), PSFacBuf_CreateProxy(), PullPin_Init(), QUARTZ_CreateSystemClock(), queue_task(), RpcAssoc_Alloc(), rpcrt4_ncacn_http_alloc(), RpcThreadRoutine(), RunningObjectTableImpl_Initialize(), RuntimeHost_Construct(), ScmInitNamedPipeCriticalSection(), session_alloc(), START_TEST(), StdMemAllocator_create(), SvcNetBiosInit(), test_async_HttpSendRequestEx(), test_condvars_base(), test_condvars_consumer_producer(), test_messages(), test_RtlIsCriticalSectionLocked(), test_winmodule(), TestMessages(), TgaDecoder_CreateInstance(), TransformFilter_Init(), WbemPath_create(), WbemServices_create(), WinHttpRequest_create(), WINMM_CreateIData(), wmainCRTStartup(), WsAsyncGlobalInitialize(), WsCreateStartupSynchronization(), WsNcOpen(), WsNqInitialize(), WsProcInitialize(), WsRasInitializeAutodial(), WsTcOpen(), xmlInitThreads(), and xmlNewRMutex().

698 {
700 
701  /* Initialize the critical section and raise an exception if we failed */
702  Status = RtlInitializeCriticalSection((PVOID)lpCriticalSection);
703  if (!NT_SUCCESS(Status)) RtlRaiseStatus(Status);
704 }
DWORD *typedef PVOID
Definition: winlogon.h:52
DECLSPEC_NORETURN NTSYSAPI VOID NTAPI RtlRaiseStatus(_In_ NTSTATUS Status)
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
BOOL WINAPI InitializeCriticalSectionAndSpinCount ( OUT LPCRITICAL_SECTION  lpCriticalSection,
IN DWORD  dwSpinCount 
)

Definition at line 711 of file synch.c.

Referenced by _kbhit(), and WahCreateHandleContextTable().

713 {
715 
716  /* Initialize the critical section */
717  Status = RtlInitializeCriticalSectionAndSpinCount((PVOID)lpCriticalSection,
718  dwSpinCount);
719  if (!NT_SUCCESS(Status))
720  {
721  /* Set failure code */
722  BaseSetLastNTError(Status);
723  return FALSE;
724  }
725 
726  /* Success */
727  return TRUE;
728 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSectionAndSpinCount(_In_ PRTL_CRITICAL_SECTION CriticalSection, _In_ ULONG SpinCount)
#define FALSE
Definition: types.h:117
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
LONG WINAPI InterlockedCompareExchange ( IN OUT LONG volatile Destination,
IN LONG  Exchange,
IN LONG  Comperand 
)

Definition at line 70 of file synch.c.

73 {
74  return _InterlockedCompareExchange(Destination, Exchange, Comperand);
75 }
long __cdecl _InterlockedCompareExchange(_Interlocked_operand_ long volatile *_Destination, long _Exchange, long _Comparand)
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2875
LONG WINAPI InterlockedDecrement ( IN OUT LONG volatile lpAddend)

Definition at line 38 of file synch.c.

39 {
40  return _InterlockedDecrement(lpAddend);
41 }
long __cdecl _InterlockedDecrement(_Interlocked_operand_ long volatile *_Addend)
LONG WINAPI InterlockedExchange ( IN OUT LONG volatile Target,
IN LONG  Value 
)

Definition at line 48 of file synch.c.

50 {
52 }
long __cdecl _InterlockedExchange(_Interlocked_operand_ long volatile *_Target, long _Value)
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1067
UINTN UINT8 Value
Definition: acefiex.h:751
LONG WINAPI InterlockedExchangeAdd ( IN OUT LONG volatile Addend,
IN LONG  Value 
)

Definition at line 59 of file synch.c.

61 {
63 }
IN OUT PLONG Addend
Definition: CrNtStubs.h:22
UINTN UINT8 Value
Definition: acefiex.h:751
long __cdecl _InterlockedExchangeAdd(_Interlocked_operand_ long volatile *_Addend, long _Value)
LONG WINAPI InterlockedIncrement ( IN OUT LONG volatile lpAddend)

Definition at line 28 of file synch.c.

29 {
30  return _InterlockedIncrement(lpAddend);
31 }
long __cdecl _InterlockedIncrement(_Interlocked_operand_ long volatile *_Addend)
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventA ( IN DWORD  dwDesiredAccess,
IN BOOL  bInheritHandle,
IN LPCSTR  lpName 
)

Definition at line 615 of file synch.c.

Referenced by do_wait_idle_child(), doChild(), doChildren(), ole_server(), test_event(), test_event_security(), and window_from_point_proc().

618 {
620 }
_In_ LPCSTR lpName
Definition: winbase.h:2677
static BOOL bInheritHandle
Definition: pipe.c:80
#define ConvertOpenWin32AnsiObjectApiToUnicodeApi(obj, acc, inh, name)
Definition: base_x.h:86
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventW ( IN DWORD  dwDesiredAccess,
IN BOOL  bInheritHandle,
IN LPCWSTR  lpName 
)

Definition at line 628 of file synch.c.

Referenced by CMP_WaitNoPendingInstallEvents(), LsapInitLsa(), OutputDebugStringA(), RefreshPolicy(), RefreshPolicyEx(), SetShellReadyEvent(), WaitForLsass(), WaitForMachinePolicyForegroundProcessing(), WaitForSCManager(), and WaitForUserPolicyForegroundProcessing().

631 {
633 }
_In_ LPCSTR lpName
Definition: winbase.h:2677
#define OpenNtObjectFromWin32Api(ntobj, acc, inh, name)
Definition: base_x.h:148
static BOOL bInheritHandle
Definition: pipe.c:80
HANDLE WINAPI DECLSPEC_HOTPATCH OpenMutexA ( IN DWORD  dwDesiredAccess,
IN BOOL  bInheritHandle,
IN LPCSTR  lpName 
)

Definition at line 538 of file synch.c.

Referenced by _tWinMain(), test_mutex(), and test_mutex_security().

541 {
543 }
_In_ LPCSTR lpName
Definition: winbase.h:2677
Definition: Mutex.h:15
static BOOL bInheritHandle
Definition: pipe.c:80
#define ConvertOpenWin32AnsiObjectApiToUnicodeApi(obj, acc, inh, name)
Definition: base_x.h:86
HANDLE WINAPI DECLSPEC_HOTPATCH OpenMutexW ( IN DWORD  dwDesiredAccess,
IN BOOL  bInheritHandle,
IN LPCWSTR  lpName 
)

Definition at line 551 of file synch.c.

Referenced by K32CreateDBMonMutex().

554 {
555  OpenNtObjectFromWin32Api(Mutant, dwDesiredAccess, bInheritHandle, lpName);
556 }
_In_ LPCSTR lpName
Definition: winbase.h:2677
#define OpenNtObjectFromWin32Api(ntobj, acc, inh, name)
Definition: base_x.h:148
static BOOL bInheritHandle
Definition: pipe.c:80
HANDLE WINAPI DECLSPEC_HOTPATCH OpenSemaphoreA ( IN DWORD  dwDesiredAccess,
IN BOOL  bInheritHandle,
IN LPCSTR  lpName 
)

Definition at line 462 of file synch.c.

Referenced by test_semaphore(), and test_semaphore_security().

465 {
467 }
_In_ LPCSTR lpName
Definition: winbase.h:2677
static BOOL bInheritHandle
Definition: pipe.c:80
#define ConvertOpenWin32AnsiObjectApiToUnicodeApi(obj, acc, inh, name)
Definition: base_x.h:86
HANDLE WINAPI DECLSPEC_HOTPATCH OpenSemaphoreW ( IN DWORD  dwDesiredAccess,
IN BOOL  bInheritHandle,
IN LPCWSTR  lpName 
)

Definition at line 475 of file synch.c.

Referenced by SHGlobalCounterCreateNamedW().

478 {
479  OpenNtObjectFromWin32Api(Semaphore, dwDesiredAccess, bInheritHandle, lpName);
480 }
_In_ LPCSTR lpName
Definition: winbase.h:2677
#define OpenNtObjectFromWin32Api(ntobj, acc, inh, name)
Definition: base_x.h:148
static BOOL bInheritHandle
Definition: pipe.c:80
HANDLE WINAPI OpenWaitableTimerA ( IN DWORD  dwDesiredAccess,
IN BOOL  bInheritHandle,
IN LPCSTR  lpTimerName 
)

Definition at line 370 of file synch.c.

373 {
375 }
HANDLE WaitableTimer
Definition: notevil.c:39
static BOOL bInheritHandle
Definition: pipe.c:80
#define ConvertOpenWin32AnsiObjectApiToUnicodeApi(obj, acc, inh, name)
Definition: base_x.h:86
HANDLE WINAPI OpenWaitableTimerW ( IN DWORD  dwDesiredAccess,
IN BOOL  bInheritHandle,
IN LPCWSTR  lpTimerName 
)

Definition at line 358 of file synch.c.

361 {
362  OpenNtObjectFromWin32Api(Timer, dwDesiredAccess, bInheritHandle, lpTimerName);
363 }
#define OpenNtObjectFromWin32Api(ntobj, acc, inh, name)
Definition: base_x.h:148
static BOOL bInheritHandle
Definition: pipe.c:80
BOOL WINAPI DECLSPEC_HOTPATCH PulseEvent ( IN HANDLE  hEvent)

Definition at line 641 of file synch.c.

Referenced by ReleaseReadLock(), test_noprivileges(), test_parameters(), test_parametersEx(), and TIME_TriggerCallBack().

642 {
644 
645  /* Pulse the event */
646  Status = NtPulseEvent(hEvent, NULL);
647  if (NT_SUCCESS(Status)) return TRUE;
648 
649  /* If we got here, then we failed */
650  BaseSetLastNTError(Status);
651  return FALSE;
652 }
#define TRUE
Definition: types.h:120
static HANDLE hEvent
Definition: comm.c:54
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:557
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
NTSTATUS NTAPI NtPulseEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:248
BOOL WINAPI RegisterWaitForSingleObject ( OUT PHANDLE  phNewWaitObject,
IN HANDLE  hObject,
IN WAITORTIMERCALLBACK  Callback,
IN PVOID  Context,
IN ULONG  dwMilliseconds,
IN ULONG  dwFlags 
)

Definition at line 796 of file synch.c.

Referenced by init_funcs(), SvcRegisterStopCallback(), testWaitForConsoleInput(), ThemeStartCallback(), and ThemeWatchForStart().

802 {
804 
805  /* Get real handle */
807 
808  /* Check for console handle */
810  {
811  /* Get the real wait handle */
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 */
825  BaseSetLastNTError(Status);
826  return FALSE;
827  }
828 
829  /* All good */
830  return TRUE;
831 }
#define TRUE
Definition: types.h:120
HANDLE TranslateStdHandle(IN HANDLE hHandle)
Definition: handle.c:19
HANDLE hObject
Definition: wglext.h:924
BOOL WINAPI DECLSPEC_HOTPATCH VerifyConsoleIoHandle(HANDLE hIoHandle)
Definition: console.c:1110
#define FALSE
Definition: types.h:117
HANDLE WINAPI GetConsoleInputWaitHandle(VOID)
Definition: console.c:683
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define IsConsoleHandle(h)
Definition: console.h:14
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1170
NTSYSAPI NTSTATUS NTAPI RtlRegisterWait(_In_ PHANDLE phNewWaitObject, _In_ HANDLE hObject, _In_ WAITORTIMERCALLBACKFUNC Callback, _In_ PVOID pvContext, _In_ ULONG ulMilliseconds, _In_ ULONG ulFlags)
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
LPFNPSPCALLBACK Callback
Definition: desk.c:111
HANDLE WINAPI RegisterWaitForSingleObjectEx ( IN HANDLE  hObject,
IN WAITORTIMERCALLBACK  Callback,
IN PVOID  Context,
IN ULONG  dwMilliseconds,
IN ULONG  dwFlags 
)

Definition at line 838 of file synch.c.

843 {
845  HANDLE hNewWaitObject;
846 
847  /* Get real handle */
849 
850  /* Check for console handle */
852  {
853  /* Get the real wait handle */
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 */
867  BaseSetLastNTError(Status);
868  return NULL;
869  }
870 
871  /* Return the object */
872  return hNewWaitObject;
873 }
HANDLE TranslateStdHandle(IN HANDLE hHandle)
Definition: handle.c:19
HANDLE hObject
Definition: wglext.h:924
BOOL WINAPI DECLSPEC_HOTPATCH VerifyConsoleIoHandle(HANDLE hIoHandle)
Definition: console.c:1110
smooth NULL
Definition: ftsmooth.c:557
HANDLE WINAPI GetConsoleInputWaitHandle(VOID)
Definition: console.c:683
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define IsConsoleHandle(h)
Definition: console.h:14
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1170
NTSYSAPI NTSTATUS NTAPI RtlRegisterWait(_In_ PHANDLE phNewWaitObject, _In_ HANDLE hObject, _In_ WAITORTIMERCALLBACKFUNC Callback, _In_ PVOID pvContext, _In_ ULONG ulMilliseconds, _In_ ULONG ulFlags)
Status
Definition: gdiplustypes.h:24
DWORD *typedef HANDLE
Definition: winlogon.h:52
LONG NTSTATUS
Definition: DriverTester.h:11
LPFNPSPCALLBACK Callback
Definition: desk.c:111
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex ( IN HANDLE  hMutex)

Definition at line 564 of file synch.c.

Referenced by cache_container_lock_index(), cache_container_open_index(), cache_container_unlock_index(), cache_unlock(), CardRegion::CanDragCards(), CardRegion::CanDropCards(), CloseSharedMemory(), ComDBClaimNextFreePort(), ComDBClaimPort(), ComDBGetCurrentPortUsage(), ComDBOpen(), ComDBReleasePort(), ComDBResizeDatabase(), FreeUrlCacheSpaceW(), ifproxy_get_public_ref(), ifproxy_release_public_refs(), INetCfgLock_fnReleaseWriteLock(), LeaveCriticalPolicySection(), MouseEventHandler(), MouseGetDataFast(), MouseGetPacket(), CardButton::OnLButtonDown(), OpenSharedMemory(), OutputDebugStringA(), PS2PortQueueRead(), PS2QueuePush(), ReleaseEntrypointMutex(), RPCRT4_sync_with_server_thread(), test_mutex(), thread1(), thread2(), CardButton::UnLock(), Mutex::Unlock(), CardRegion::UnLock(), UnlockAudioDeviceList(), VgaConsoleDestroyGraphicsScreen(), VgaUpdateFramebuffer(), and xmlMutexUnlock().

565 {
567 
568  /* Release the mutant */
569  Status = NtReleaseMutant(hMutex, NULL);
570  if (NT_SUCCESS(Status)) return TRUE;
571 
572  /* If we got here, then we failed */
573  BaseSetLastNTError(Status);
574  return FALSE;
575 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:557
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
HANDLE hMutex
Definition: mutex.c:11
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
NTSTATUS NTAPI NtReleaseMutant(IN HANDLE MutantHandle, IN PLONG PreviousCount OPTIONAL)
Definition: mutant.c:299
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore ( IN HANDLE  hSemaphore,
IN LONG  lReleaseCount,
IN LPLONG  lpPreviousCount 
)

Definition at line 488 of file synch.c.

Referenced by alertable_wait_apc(), alertable_wait_thread(), BaseMemAllocator_Decommit(), BaseMemAllocator_ReleaseBuffer(), critsect_locked_thread(), CRYPT_ImportSystemRootCertsToReg(), DSoundAdviseThread(), EnumPwrSchemes(), FileIOComplete(), free_urlcache(), get_key_state_thread(), GetPwrDiskSpindownRange(), handle_full_cache(), handle_full_cache_worker(), iocp_callback(), ReadGlobalPwrPolicy(), ReadPwrScheme(), release_semaphore_thread(), SHGlobalCounterGetValue(), SHGlobalCounterIncrement(), SysParamsTestWndProc(), SystemClockAdviseThread(), test_alertable_wait(), test_CoWaitForMultipleHandles(), test_GetKeyState(), test_RtlIsCriticalSectionLocked(), and test_signalandwait().

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 */
499  BaseSetLastNTError(Status);
500  return FALSE;
501 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
NTSTATUS NTAPI NtReleaseSemaphore(IN HANDLE SemaphoreHandle, IN LONG ReleaseCount, OUT PLONG PreviousCount OPTIONAL)
Definition: sem.c:294
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent ( IN HANDLE  hEvent)

Definition at line 660 of file synch.c.

Referenced by AVISplitter_done_process(), AVISplitter_first_request(), AVISplitter_Flush(), BaseRendererImpl_EndFlush(), BaseRendererImpl_Pause(), BaseRendererImpl_Run(), child_process(), ConDrvFlushConsoleInputBuffer(), ConDrvGetConsoleInput(), ConDrvReadConsole(), ConSrvTermReadStream(), DeviceInstallThread(), DoEcho(), DSoundRender_EndFlush(), DSoundRender_OnStartStreaming(), DSoundRender_Pause(), EventsQueue_GetEvent(), FileAsyncReader_EndFlush(), FileAsyncReader_WaitForNext(), fileTransfer(), GPNotificationThreadProc(), IDirectSoundCaptureBufferImpl_Stop(), init_bind_test(), init_test(), ISynchronize_fnReset(), main(), MCIAVI_PlayAudioBlocks(), MCIQTZ_mciPlay(), MULTIMEDIA_PlaySound(), Netbios(), open_socket_request(), PauseEventThread(), PlaySound_WaitDone(), prepare_async_request(), PullPin_PauseProcessing(), PullPin_StartProcessing(), PullPin_StopProcessing(), read_file_test(), reset_events(), Telnet::Resume(), resync_after_run(), SendFilterMessage(), server_thread(), serverThreadMain5(), ServiceControlHandler(), setup_test(), StartScreenSaver(), sync_threads_and_run_one(), telProcessConsole(), test_async_read(), test_capture(), test_connection_cache(), test_event(), test_GetAddrInfoExW(), test_noprivileges(), test_open_url_async(), test_overlapped(), test_parameters(), test_parametersEx(), test_persistent_connection(), test_readdirectorychanges(), test_readfileex_pending(), test_RegisterWaitForSingleObject(), test_signalandwait(), test_WaitForInputIdle(), test_WaitForMultipleObjects(), test_WSARecv(), TestKM(), TestRead(), TestTerminateProcess(), TestWrite(), ThemeServiceDiedCallback(), ThemeServiceMain(), TIME_MMSysTimeCallback(), VideoRenderer_EndFlush(), VideoRenderer_OnStartStreaming(), VideoRenderer_Pause(), WAVE_mciPlayWaitDone(), WAVE_mciRecordWaitDone(), and WSAResetEvent().

661 {
663 
664  /* Clear the event */
665  Status = NtResetEvent(hEvent, NULL);
666  if (NT_SUCCESS(Status)) return TRUE;
667 
668  /* If we got here, then we failed */
669  BaseSetLastNTError(Status);
670  return FALSE;
671 }
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI NtResetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:389
static HANDLE hEvent
Definition: comm.c:54
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:557
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent ( IN HANDLE  hEvent)

Definition at line 679 of file synch.c.

Referenced by AcceptKillThread(), AcceptProc(), AdapterDiscoveryThread(), ANIMATE_DoStop(), apartment_hostobject_thread(), apc_deadlock_thread(), async_notifier_proc(), async_proc(), AVISplitter_done_process(), AVISplitter_next_request(), AVISplitter_Sample(), BackgroundCopyJob_Cancel(), BackgroundCopyJob_Resume(), BaseRendererImpl_BeginFlush(), BaseRendererImpl_EndOfStream(), BaseRendererImpl_Receive(), BaseRendererImpl_Run(), BaseRendererImpl_Stop(), callback(), callback_func(), callback_thread(), CallSessionThread(), CallSoundThread(), cancel_request(), capture_CheckNotify(), cb(), cbt_global_hook_thread_proc(), check_notification(), child_process(), cleanReq(), client_start(), ClientSideInstallW(), Telnet::Close(), audio_wavein::close(), close_connection(), CloseUserEventLog(), collect_query_thread(), CommandThreadProc(), completion_routine(), ConioProcessInputEvent(), ConioUnpause(), COutputPin_SetState(), crash_and_debug(), create_grand_child_thread(), create_static_win(), create_window(), create_window_thread(), CRYPT_InetStatusCallback(), ctrl_handler(), DereferenceSidCacheMgr(), CDesktopThread::DesktopThreadProc(), DEVENUM_CreateSpecialCategories(), DeviceInstallThread(), dialog_proc(), DispatchSAS(), DlgProc(), do_wait_idle_child(), doChild(), doChildren(), doDebugger(), DoEcho(), DoNotifyPositionEvents(), downloadcb_OnStopBinding(), DP_KillEnumSessionThread(), DP_MSG_ReplyReceived(), DPLAYX_ConstructData(), DPLAYX_DestructData(), DPLAYX_GetConnectionSettingsA(), DPLAYX_GetConnectionSettingsW(), DriverCallback(), drop_window_therad(), DSLeaseIpAddress(), DSOUND_CheckEvent(), DSoundAdviseThread(), DSoundRender_BeginFlush(), DSoundRender_OnStartStreaming(), DSoundRender_OnStopStreaming(), DSReleaseIpAddressLease(), DSRenewIpAddressLease(), DSStaticRefreshParams(), duo_marshal_thread_proc(), EnumEvents(), EventsQueue_PutEvent(), FileAsyncReader_BeginFlush(), free_urlcache(), GetDeviceData(), TTelnetHandler::Go(), GuiConsoleGuiThread(), GuiConsoleHandleNcCreate(), header_cb(), hook_thread_proc(), host_object_proc(), IDirectPlaySPImpl_HandleMessage(), ImmGetContextThreadFunc(), inet_ntoa_thread_proc(), init(), COutputPin::IoProcessRoutine(), ISynchronize_fnSignal(), KillService(), CKsInterfaceHandler::KsProcessMediaSamples(), logMess(), LsapInitLsa(), main(), main_window_procA(), mch(), MCIAVI_mciStop(), MCIAVI_waveCallback(), MCICDA_Play(), MCICDA_playLoop(), MCICDA_Stop(), MCIQTZ_mciStop(), MediaEventSink_Notify(), MessageLoop(), MixerThreadRoutine(), MMSYSTEM_MidiStream_MessageHandler(), MMSYSTEM_MidiStream_Player(), mmTaskRun(), mouse_ll_global_thread_proc(), MsgCheckProc(), MULTIMEDIA_PlaySound(), mutex_thread_proc(), NBCmdQueueComplete(), nbCmdThread(), no_couninitialize_server_proc(), no_stop_handler(), NotifyGPEvents(), COutputPin::NotifyRelease(), ole_initialize_thread(), ole_server(), oob_server(), OutputDebugStringA(), OutputQueue_Destroy(), OutputQueue_ReceiveMultiple(), OutputQueue_SendAnyway(), overlapped_server(), PdhCloseQuery(), PdhCollectQueryDataEx(), pipe_thread(), audio_waveout::play(), PlaySound_Callback(), PlaySound_Free(), PNP_ReportLogOn(), PnpEventThread(), ProcessPlayingNotes(), processRequest(), progress_callback_http(), Protocol_LockRequest(), Protocol_Read(), Protocol_Start(), Protocol_Terminate(), ProtocolSink_ReportData(), ProtocolSink_Switch(), PullPin_EndOfStream(), PullPin_InitProcessing(), PullPin_PauseProcessing(), PullPin_StartProcessing(), PullPin_StopProcessing(), PullPin_Thread_Pause(), PullPin_Thread_Process(), PullPin_Thread_Stop(), queue_event(), queue_task(), QueueSidLookup(), read_file_test(), readex_callback(), audio_wavein::recording_procedure(), ReferenceClock_AdviseTime(), RefreshPolicy(), RefreshPolicyEx(), RegisterGPNotification(), request_destroy(), Telnet::Resume(), ResumeEventThread(), resync_after_run(), RPC_ExecuteCall(), rpc_renew_in_progress(), rpc_sendreceive_thread(), RPC_StopLocalServer(), rpcrt4_conn_tcp_cancel_call(), rpcrt4_http_internet_callback(), rpcrt4_ncacn_http_cancel_call(), rpcrt4_ncacn_http_close(), rpcrt4_protseq_np_get_wait_array(), rpcrt4_protseq_np_signal_state_changed(), rpcrt4_protseq_sock_signal_state_changed(), RPCRT4_release_server_interface(), RPCRT4_ReleaseConnection(), RPCRT4_server_thread(), RPCRT4_stop_listen(), RPCSS_Initialize(), CKsClockForwarder::Run(), runProg(), s_stop(), SASWindowProc(), select_server(), SelectReadThread(), semaphore_thread_proc(), send_msg_thread_2(), server_thread(), service_handler(), ServiceControlHandler(), ServiceHandler(), ServiceMain(), ServiceStop(), session_destroy(), set_foreground_thread(), SetShellReadyEvent(), SHLWAPI_ThreadWrapper(), show_cursor_thread(), ShutdownHandlerRoutine(), signaled_function(), simple_server(), smresult_thread_proc(), smresult_wndproc(), SoundThreadMain(), audio_wavein::start_recording(), START_TEST(), StartScreenSaver(), StartStopEnumEventsThread(), statusclb_OnDataAvailable(), statusclb_OnProgress(), statusclb_OnStopBinding(), StatusMessageWindowProc(), CKsClockForwarder::Stop(), sync_threads_and_run_one(), SystemClockAdviseThread(), telProcessConsole(), TerminateSoundThread(), Test1(), Test2(), Test3(), test_async_read(), test_attach_input(), test_binding(), test_CoCreateInstance(), test_CoGetClassObject(), test_CoGetContextToken(), test_CoGetObjectContext(), test_conn_close(), test_dde_default_app(), test_debug_children(), test_defwinproc(), test_getservbyname(), test_http_protocol_url(), test_inet_ntoa(), test_Input_mouse(), test_interthread_messages(), test_local_server(), test_NamedPipe_2(), test_no_couninitialize_server(), test_PeekMessage(), test_persistent_connection(), test_readdirectorychanges(), test_register_local_server(), test_request_content_length(), test_SendMessage_other_thread(), test_SetForegroundWindow(), test_ShowCursor(), test_stop_wait_for_call(), test_tableweak_and_normal_marshal_and_releasedata(), test_tableweak_and_normal_marshal_and_unmarshal(), test_thread_objects(), test_two_tableweak_marshal_and_releasedata(), test_WaitForInputIdle(), test_WaitForMultipleObjects(), test_window_from_point(), TestEventConcurrent(), ThemeServiceMain(), thread(), thread_cb(), thread_proc(), ThreadEntry(), threadFunc1(), threadFunc4(), threadFunc_SetEvent(), TIME_MMSysTimeCallback(), TIME_MMTimeStop(), TIME_SetEventInternal(), TIME_TriggerCallBack(), timeout_function(), timer_thread_proc(), TimerCallback1(), TimerCallback2(), TimerCallback3(), transfer_file_http(), transfer_file_local(), UninitializeGPNotifications(), UninitializeSAS(), UnlockModuleOOP(), UnregisterGPNotification(), update_layered_proc(), UpdateStatus(), VideoRenderer_DoRenderSample(), VideoRenderer_OnStopStreaming(), wait_status_callback(), WAVE_mciPlay(), WAVE_mciPlayCallback(), WAVE_mciRecord(), WAVE_mciRecordCallback(), WaveThread(), wbem_services_CancelAsyncCall(), wbem_services_Release(), WdmAudCloseSoundDeviceByLegacy(), wgl_thread(), win_event_global_thread_proc(), window_from_point_proc(), WindowThreadProc(), wined3d_cs_queue_submit(), work_function(), WSASetEvent(), WsAsyncQueueRequest(), WSPIoctl(), and wWinMain().

680 {
682 
683  /* Set the event */
684  Status = NtSetEvent(hEvent, NULL);
685  if (NT_SUCCESS(Status)) return TRUE;
686 
687  /* If we got here, then we failed */
688  BaseSetLastNTError(Status);
689  return FALSE;
690 }
#define TRUE
Definition: types.h:120
static HANDLE hEvent
Definition: comm.c:54
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:557
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:458
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
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 at line 382 of file synch.c.

Referenced by InputWait(), main(), and wmain().

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 */
402  BaseSetLastNTError(Status);
403  return FALSE;
404 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:557
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
VOID(NTAPI * PTIMER_APC_ROUTINE)(_In_ PVOID TimerContext, _In_ ULONG TimerLowValue, _In_ LONG TimerHighValue)
Definition: ketypes.h:1081
unsigned char BOOLEAN
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
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
DWORD WINAPI SignalObjectAndWait ( IN HANDLE  hObjectToSignal,
IN HANDLE  hObjectToWaitOn,
IN DWORD  dwMilliseconds,
IN BOOL  bAlertable 
)

Definition at line 269 of file synch.c.

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 */
314  BaseSetLastNTError(Status);
315  Status = WAIT_FAILED;
316  }
317  } while ((Status == STATUS_ALERTED) && (bAlertable));
318 
319  /* Cleanup the activation context */
320  if (bAlertable) RtlDeactivateActivationContextUnsafeFast(&ActCtx);
321 
322  /* Return wait status */
323  return Status;
324 }
HANDLE TranslateStdHandle(IN HANDLE hHandle)
Definition: handle.c:19
#define STATUS_ALERTED
Definition: ntstatus.h:80
PLARGE_INTEGER WINAPI BaseFormatTimeOut(OUT PLARGE_INTEGER Timeout, IN DWORD dwMilliseconds)
Definition: utils.c:288
BOOL WINAPI DECLSPEC_HOTPATCH VerifyConsoleIoHandle(HANDLE hIoHandle)
Definition: console.c:1110
smooth NULL
Definition: ftsmooth.c:557
HANDLE WINAPI GetConsoleInputWaitHandle(VOID)
Definition: console.c:683
#define RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_FORMAT_WHISTLER
Definition: rtltypes.h:101
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
unsigned char BOOLEAN
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define WAIT_FAILED
Definition: winbase.h:385
PRTL_ACTIVATION_CONTEXT_STACK_FRAME FASTCALL RtlDeactivateActivationContextUnsafeFast(IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame)
Definition: actctx.c:5501
_In_ PCWSTR _Out_ PVOID * ActCtx
Definition: ldrtypes.h:245
#define IsConsoleHandle(h)
Definition: console.h:14
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
PRTL_ACTIVATION_CONTEXT_STACK_FRAME FASTCALL RtlActivateActivationContextUnsafeFast(IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame, IN PVOID Context)
Definition: actctx.c:5424
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
NTSTATUS NTAPI NtSignalAndWaitForSingleObject(IN HANDLE ObjectHandleToSignal, IN HANDLE WaitableObjectHandle, IN BOOLEAN Alertable, IN PLARGE_INTEGER TimeOut OPTIONAL)
Definition: obwait.c:473
static PLARGE_INTEGER Time
Definition: time.c:28
VOID WINAPI DECLSPEC_HOTPATCH Sleep ( IN DWORD  dwMilliseconds)

Definition at line 736 of file synch.c.

Referenced by __declspec(), _locking(), _sleep(), _test_flush_async(), AdapterDiscoveryThread(), CheckWindowCreated(), child_process(), child_process_write_pipe(), ClipTestProc(), Telnet::Close(), audio_wavein::close(), CloseProcessAndVerify_(), CmdRemoveService(), CMP_Report_LogOn(), collect_connections_proc(), CommandDelay(), CompleteProgressBar(), compound_encode_send_decode(), condvar_base_consumer(), condvar_base_producer(), condvar_consumer(), condvar_producer(), connection_collector(), ConsoleEventThread(), create_tabcontrol(), createFilledTabControl(), DECLARE_INTERFACE_(), detectChange(), Display(), do_bind(), do_events(), do_wait_idle_child(), do_wait_idle_child_thread(), doChild(), DoControlService(), DoStartService(), DoStopService(), DoStuff(), DoWaitForReaders(), drain_socket_thread(), Driver(), EnumJoysticks(), CThread::Execute(), exercizeServer(), force_redraw(), FreeUrlCacheSpaceW(), getnetconfigent(), gl_cleanup(), gl_getpass(), InputWait(), IopAllocateIrpMustSucceed(), ITERATE_StartService(), keep_responsive(), keyed_event_thread(), KsFilterRegisterPowerCallbacks(), KsPinRegisterPowerCallbacks(), LauncherRoutine2(), MailSlotWriter(), main(), MainDialogProc(), MCIAVI_mciStop(), MCIAVI_player(), MCICDA_playLoop(), MIDI_player(), MixerThreadRoutine(), MonitorChildThread(), MultiWndProc(), my_test_server(), ok_event_sequence(), openlog(), pipeServer(), PlayLogonSoundThread(), playStream(), post_message_thread(), proc_PlaySound(), ProcessKeys(), read_file_test(), read_pipe(), ReadFromPipeThread(), release_avisplitter(), renew_session(), reset_CommMask(), Telnet::Resume(), RPC_GetLocalClassObject(), rungraph(), runProg(), SelectCloseThread(), send_message_thread(), send_msg_delay_proc(), service_main_common(), service_process(), ServiceMain(), set_CommBreak(), set_foreground(), SockAsyncThread(), srwlock_base_thread1(), srwlock_base_thread2(), srwlock_base_thread3(), srwlock_example_thread(), Defragment::Start(), start_rpcss(), START_TEST(), stopService(), StorageImpl_LockRegionSync(), SystemClockPostMessageToAdviseThread(), test_AbortWaitCts(), test_accept(), test_alertable_wait(), test_apc_deadlock(), test_api(), test_async_HttpSendRequestEx(), test_asyncWAVE(), test_asyncWaveTypeMpegvideo(), test_AutoOpenWAVE(), test_capture(), test_clock(), Test_CloseWhileSelectDuplicatedSocket(), Test_CloseWhileSelectSameSocket(), test_CompleteLocal(), test_CompleteLocalURL(), test_completion_port(), test_condvars_base(), test_condvars_consumer_producer(), test_create_delete_svc(), test_dde(), test_EnumSessions(), test_events(), test_get_displayname(), test_get_state(), test_GetFileInformationByHandleEx(), test_GetPrivateProfileString(), test_handles(), test_HttpOptions(), test_Input_mouse(), test_InputObject(), test_ioctlsocket(), test_IReferenceClock_methods(), test_keyed_events(), Test_LockUnlockServiceDatabaseWithServiceStart(), Test_LongTests(), test_menu_input_thread(), test_midi_infns(), test_midi_outfns(), test_midiOut_device(), test_midiStream(), test_no_stop(), test_openCloseWAVE(), test_overlapped(), test_PeekMessage2(), test_pipes(), test_pipes_child(), test_play(), test_playWAVE(), test_priority(), test_protocol_terminate(), test_queryconfig2(), Test_QueryLockStatusA(), Test_QueryLockStatusW(), test_readwrite(), test_refcount(), test_RegisterWaitForSingleObject(), test_select(), test_send(), Test_SendInput(), test_SendMessage_other_thread(), test_SendMessageTimeout(), test_sequence(), test_set_state(), test_SetSite(), test_SHCreateStreamOnFileEx(), test_shortcut(), test_srwlock_base(), test_srwlock_example(), test_start_stop(), test_startA(), test_startW(), test_SuspendFlag(), test_SuspendThread(), test_thread_handle_close(), test_timer(), test_timer_queue(), test_timers_no_wnd(), test_Toolhelp(), Test_TrackMouseEvent(), test_TrackMouseEvent(), test_TreatAsClass(), Test_UnaffectedMessages(), test_urlcacheA(), Test_VeryLongTests(), test_WaitBreak(), test_WaitCts(), test_WaitRx(), test_worst_case(), TestPrivMoveFileIdentityW(), TestProc(), testWaitForConsoleInput(), ThemeWaitForServiceReady(), thread(), thread_1(), thread_main1(), thread_main2(), threadfunc(), threadFunc4(), ThreadProc(), timer_message_dlg_proc(), timer_queue_cb5(), timer_queue_cb6(), TimerCallback2(), TimerCallback3(), toggle_ctlLine(), Desktops::ToggleMinimize(), VdmShutdown(), wait_for_window(), wait_idle_proc(), wait_move_event(), WaitForService(), WaitService(), WAVE_mciStop(), wave_out_test_deviceOut(), WinMain(), WlanScan(), wmain(), WSPCloseSocket(), CardRegion::ZoomCard(), and Defragment::~Defragment().

737 {
738  /* Call the new API */
739  SleepEx(dwMilliseconds, FALSE);
740 }
#define FALSE
Definition: types.h:117
DWORD WINAPI SleepEx(IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:748
DWORD WINAPI SleepEx ( IN DWORD  dwMilliseconds,
IN BOOL  bAlertable 
)

Definition at line 748 of file synch.c.

Referenced by Beep(), gl_getcx(), IDirectPlay4Impl_EnumSessions(), main(), pipeserver(), ProcessPlayingNotes(), read_file_test(), serverThreadMain2(), Sleep(), START_TEST(), StopStreamingInSoundThread(), test_alertable(), test_cancelio(), test_CreatePipe(), test_nonalertable(), test_overlapped(), test_read_write(), test_readdirectorychanges_cr(), test_servicenotify(), test_WSARecv(), thread_main1(), and ui_select().

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 */
785  if (bAlertable) RtlDeactivateActivationContextUnsafeFast(&ActCtx);
786 
787  /* Return the correct code */
788  return (errCode == STATUS_USER_APC) ? WAIT_IO_COMPLETION : 0;
789 }
#define STATUS_ALERTED
Definition: ntstatus.h:80
PLARGE_INTEGER WINAPI BaseFormatTimeOut(OUT PLARGE_INTEGER Timeout, IN DWORD dwMilliseconds)
Definition: utils.c:288
smooth NULL
Definition: ftsmooth.c:557
#define RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_FORMAT_WHISTLER
Definition: rtltypes.h:101
#define WAIT_IO_COMPLETION
Definition: winbase.h:383
NTSTATUS NTAPI NtDelayExecution(IN BOOLEAN Alertable, IN PLARGE_INTEGER DelayInterval)
Definition: wait.c:879
unsigned char BOOLEAN
PRTL_ACTIVATION_CONTEXT_STACK_FRAME FASTCALL RtlDeactivateActivationContextUnsafeFast(IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame)
Definition: actctx.c:5501
_In_ PCWSTR _Out_ PVOID * ActCtx
Definition: ldrtypes.h:245
ULONG LowPart
Definition: typedefs.h:104
#define STATUS_USER_APC
Definition: ntstatus.h:78
LONG NTSTATUS
Definition: DriverTester.h:11
PRTL_ACTIVATION_CONTEXT_STACK_FRAME FASTCALL RtlActivateActivationContextUnsafeFast(IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame, IN PVOID Context)
Definition: actctx.c:5424
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
static PLARGE_INTEGER Time
Definition: time.c:28
BOOL WINAPI UnregisterWait ( IN HANDLE  WaitHandle)

Definition at line 880 of file synch.c.

Referenced by init_funcs(), testWaitForConsoleInput(), ThemeStartCallback(), and ThemeStopCallback().

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 */
897  BaseSetLastNTError(Status);
898  return FALSE;
899  }
900 
901  /* All good */
902  return TRUE;
903 }
NTSYSAPI NTSTATUS NTAPI RtlDeregisterWaitEx(_In_ HANDLE hWaitHandle, _In_opt_ HANDLE hCompletionEvent)
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:557
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define STATUS_PENDING
Definition: ntstatus.h:82
#define SetLastError(x)
Definition: compat.h:409
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
BOOL WINAPI UnregisterWaitEx ( IN HANDLE  WaitHandle,
IN HANDLE  CompletionEvent 
)

Definition at line 910 of file synch.c.

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 */
929  BaseSetLastNTError(Status);
930  return FALSE;
931  }
932 
933  /* All good */
934  return TRUE;
935 }
NTSYSAPI NTSTATUS NTAPI RtlDeregisterWaitEx(_In_ HANDLE hWaitHandle, _In_opt_ HANDLE hCompletionEvent)
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define FALSE
Definition: types.h:117
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define STATUS_PENDING
Definition: ntstatus.h:82
#define SetLastError(x)
Definition: compat.h:409
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
DWORD WINAPI WaitForMultipleObjectsEx ( IN DWORD  nCount,
IN CONST HANDLE lpHandles,
IN BOOL  bWaitAll,
IN DWORD  dwMilliseconds,
IN BOOL  bAlertable 
)

Definition at line 169 of file synch.c.

Referenced by alertable_wait_thread(), CoWaitForMultipleHandles(), FileAsyncReader_WaitForNext(), NotifyTopLevelWindow(), RealMsgWaitForMultipleObjectsEx(), rpcrt4_protseq_np_wait_for_new_connection(), rpcrt4_protseq_sock_wait_for_new_connection(), WaitForMultipleObjects(), and WSAWaitForMultipleEvents().

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 */
204  if (bAlertable) RtlDeactivateActivationContextUnsafeFast(&ActCtx);
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 */
237  Status = NtWaitForMultipleObjects(nCount,
238  HandleBuffer,
239  bWaitAll ? WaitAll : WaitAny,
240  (BOOLEAN)bAlertable,
241  TimePtr);
242  if (!NT_SUCCESS(Status))
243  {
244  /* Wait failed */
245  BaseSetLastNTError(Status);
246  Status = 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 */
258  if (bAlertable) RtlDeactivateActivationContextUnsafeFast(&ActCtx);
259 
260  /* Return wait status */
261  return Status;
262 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
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
#define STATUS_ALERTED
Definition: ntstatus.h:80
DWORD DWORD
Definition: winlogon.h:75
PLARGE_INTEGER WINAPI BaseFormatTimeOut(OUT PLARGE_INTEGER Timeout, IN DWORD dwMilliseconds)
Definition: utils.c:288
BOOL WINAPI DECLSPEC_HOTPATCH VerifyConsoleIoHandle(HANDLE hIoHandle)
Definition: console.c:1110
GLenum GLclampf GLint i
Definition: glfuncs.h:14
smooth NULL
Definition: ftsmooth.c:557
HANDLE WINAPI GetConsoleInputWaitHandle(VOID)
Definition: console.c:683
#define RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_FORMAT_WHISTLER
Definition: rtltypes.h:101
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
_In_ HANDLE Handle
Definition: extypes.h:390
unsigned char BOOLEAN
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define WAIT_FAILED
Definition: winbase.h:385
PRTL_ACTIVATION_CONTEXT_STACK_FRAME FASTCALL RtlDeactivateActivationContextUnsafeFast(IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame)
Definition: actctx.c:5501
#define SetLastError(x)
Definition: compat.h:409
_In_ PCWSTR _Out_ PVOID * ActCtx
Definition: ldrtypes.h:245
#define IsConsoleHandle(h)
Definition: console.h:14
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:411
Status
Definition: gdiplustypes.h:24
DWORD *typedef HANDLE
Definition: winlogon.h:52
LONG NTSTATUS
Definition: DriverTester.h:11
PRTL_ACTIVATION_CONTEXT_STACK_FRAME FASTCALL RtlActivateActivationContextUnsafeFast(IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame, IN PVOID Context)
Definition: actctx.c:5424
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
static PLARGE_INTEGER Time
Definition: time.c:28
DWORD WINAPI WaitForSingleObject ( IN HANDLE  hHandle,
IN DWORD  dwMilliseconds 
)

Definition at line 82 of file synch.c.

Referenced by _cwait(), _pclose(), _read_request_data(), _send_response_and_wait(), _test_flush_done(), _test_not_signaled(), _test_signaled(), _tmain(), _tWinMain(), AcquireEntrypointMutex(), AcsHlpSendCommand(), alarmThreadMain(), alertable_wait_apc2(), alertable_wait_thread(), ANIMATE_AnimationThread(), ANIMATE_DoStop(), apartment_hostobject_in_hostapt(), async_proc(), AVISplitter_done_process(), AVISplitter_Sample(), AVISplitter_thread_reader(), BackgroundCopyJob_Cancel(), BaseMemAllocator_GetBuffer(), BasepDoTapeOperation(), BaseRendererImpl_GetState(), cache_container_lock_index(), cache_container_open_index(), cache_lock(), CallSessionThread(), CallSoundThread(), cancel_request(), CardRegion::CanDragCards(), CardRegion::CanDropCards(), cfgets(), check_dinput_hooks(), check_hook_thread(), check_thread_instance(), child_process(), CKsClockForwarder_ThreadStartup(), cleanReq(), client_start(), ClientRpcChannelBuffer_SendReceive(), clipboard_wnd_proc(), clnt_vc_destroy(), close_async_handle(), close_request(), CloseDevice(), cmd_start(), CMP_WaitNoPendingInstallEvents(), collect_query_thread(), ComDBClaimNextFreePort(), ComDBClaimPort(), ComDBGetCurrentPortUsage(), ComDBOpen(), ComDBReleasePort(), ComDBResizeDatabase(), CommandThreadProc(), ConDrvConsoleCtrlEventTimeout(), ConSrvConsoleCtrlEventTimeout(), COutputPin_SetState(), crash_and_debug(), crash_and_winedbg(), create_child_thread(), create_file_test(), create_window_thread(), CreateClientProcess(), CreateContext(), CreateRenderingSubsystem(), CreateRenderingWindow(), CreateServiceThread(), CreateTestThread(), critsect_locked_thread(), CRYPT_DownloadObject(), CRYPT_ImportSystemRootCertsToReg(), detectChange(), DEVENUM_CreateSpecialCategories(), BtrfsVolPropSheet::DeviceDlgProc(), DeviceInstallThread(), dispatch_rpc(), dll_entry_point(), do_getservbyname(), do_register_dll(), do_spawnT(), do_test(), do_wait_idle_child(), doChildren(), doDebugger(), CWineTest::DoListCommand(), TMouse::doMouse(), DosShutdown(), DosStartProcess32(), DoWaitForReaders(), download_url(), DP_EnumSessionsSendAsyncRequestThread(), DP_MSG_ExpectReply(), DPL_MSG_ThreadMain(), DSoundRender_BreakConnect(), DSoundRender_HandleEndOfStream(), DSoundRender_Release(), DSoundRender_SendSampleData(), end_host_object(), EndLocalThread(), ensurePlayerThread(), EnterCriticalPolicySection(), EnumEventsThread(), event_client(), EventsQueue_GetEvent(), Execute(), exercizeServer(), expect_event(), FinishNotificationThread(), flush_events(), free_urlcache(), FreeUrlCacheSpaceW(), get_key_state_thread(), GetCharacterTimeout(), GetOverlappedResult(), GetPwrDiskSpindownRange(), GetSocketInformation(), TTelnetHandler::Go(), GUIDisplayStatusMessage(), GuiInit(), GuiInitFrontEnd(), handle_full_cache(), HandleLogoff(), HandleShutdown(), hooked_WaitForInputIdle(), HTTP_RetrieveEncodedObjectW(), IDirectSoundCaptureBufferImpl_Stop(), ifproxy_get_public_ref(), ifproxy_release_public_refs(), inet_ntoa_thread_proc(), INetCfgLock_fnAcquireWriteLock(), init(), InputWait(), install_wine_gecko(), InstallDevice(), InternetReadFile_test(), InternetReadFileExA_test(), BtrfsContextMenu::InvokeCommand(), COutputPin::IoProcessRoutine(), is_signaled(), ITERATE_RemoveExistingProducts(), launch_exe(), LauncherRoutine2(), Mutex::Lock(), CardButton::Lock(), CardRegion::Lock(), LockAudioDeviceList(), logMess(), LogToFile(), LookupThreadProc(), LS_ThreadProc(), MailSlotReader(), main(), main_window_procA(), MainLoop(), MCICDA_GetStatus(), MCICDA_Pause(), MCICDA_Play(), MCICDA_playLoop(), MCICDA_Resume(), MCICDA_Stop(), MCIQTZ_mciStatus(), MCIQTZ_mciStop(), MediaEvent_WaitForCompletion(), MIDI_mciPlay(), MIDI_mciStop(), midiStreamOpen(), MMSYSTEM_MidiStream_PostMessage(), MonitorChildThread(), MouseEventHandler(), MouseGetDataFast(), MouseGetPacket(), StringTest::mt(), MULTIMEDIA_PlaySound(), mutex_thread_proc(), NBCmdQueueCancel(), netconn_resolve(), nfs41_send_compound(), no_couninitialize_server_proc(), NotificationThread(), ok_event_sequence(), ole_initialize_thread(), ole_server(), CardButton::OnLButtonDown(), oob_client(), BtrfsPropSheet::open_as_admin(), open_read_test_request(), open_socket_request(), OpenMidiDevice(), OpenSharedMemory(), OutputDebugStringA(), OutputQueueImpl_ThreadProc(), BtrfsBalance::PauseBalance(), PdhCloseQuery(), PdhCollectQueryDataEx(), audio_waveout::playing_procedure(), PlaySound_WaitDone(), post_rbuttonup_msg(), proc_PlaySound(), processRequest(), ProtocolSink_Switch(), PS2PortQueueRead(), PS2QueuePush(), PullPin_InitProcessing(), PullPin_PauseProcessing(), PullPin_Release(), PullPin_StartProcessing(), PullPin_StopProcessing(), PullPin_Thread_Main(), PullPin_WaitForStateChange(), QualityControlRender_WaitFor(), r_exec_import_str(), r_exec_import_wstr(), read_file_test(), read_pipe(), audio_wavein::recording_procedure(), recv_thread(), ReferenceClock_AdvisePeriodic(), ReferenceClock_AdviseTime(), release_host_object(), release_semaphore_thread(), report(), BtrfsVolPropSheet::ResetStats(), resync_after_run(), RPC_StopLocalServer(), RpcMgmtWaitServerListen(), RpcReadFile(), rpcrt4_conn_np_read(), rpcrt4_conn_np_write(), rpcrt4_conn_release_and_wait(), rpcrt4_http_timer_thread(), rpcrt4_sock_wait_for_send(), RPCRT4_sync_with_server_thread(), RpcServerUnregisterIf(), run_cmd(), run_ex(), run_reg_exe_(), run_script_file(), runcmd(), runCmd(), runProg(), RunSetupThreadProc(), RunTests(), s_stop(), SchedServiceMain(), ScmControlService(), ScmSendStartCommand(), ScmWaitForLsa(), ScmWaitForServiceConnect(), ScreensaverPreview(), scrollkeys(), semaphore_thread_proc(), send_socket_request(), SendMessage_thread_1(), SendMessage_thread_2(), serv_main(), server(), server_send_reply(), server_thread(), service_main(), ServiceExecutionThread(), ServiceMain(), ServiceStart(), SetSocketInformation(), SHCreateThread(), shell(), shell_execute_(), shell_execute_ex_(), SHGlobalCounterDecrement(), SHGlobalCounterGetValue(), show_cursor_thread(), BtrfsVolPropSheet::ShowScrub(), simple_client(), simple_mixed_client(), smresult_thread_proc(), smresult_wndproc(), start_host_object2(), START_TEST(), BtrfsBalance::StartBalance(), StartChild(), StartClients(), CProgressDialog::StartProgressDialog(), StartSessionThread(), StartStopEnumEventsThread(), StartTestCORE10188(), statusclb_OnStopBinding(), CKsClockForwarder::Stop(), audio_wavein::stop_recording(), BtrfsBalance::StopBalance(), sub_thread(), sync_threads_and_run_one(), SystemClockImpl_Release(), TerminateShell(), TerminateSoundThread(), Test2(), Test3(), test_accept(), test_AcceptEx(), test_activateapp(), test_alertable(), test_alertable_wait(), test_apc_deadlock(), test_async(), test_async_HttpSendRequestEx(), test_async_read(), test_attach_input(), test_binding(), test_BindToStorage(), test_BreakawayOk(), test_buffer(), test_buffer8(), test_cancelio(), test_capture(), Test_CloseWhileSelectDuplicatedSocket(), Test_CloseWhileSelectSameSocket(), test_CoCreateInstance(), test_CoFreeUnusedLibraries(), test_CoGetClassObject(), test_CoGetContextToken(), test_CoGetObjectContext(), Test_CommandLine(), test_CommandLine(), test_CompletionPort(), test_concurrent_header_access(), test_condvars_base(), test_condvars_consumer_producer(), test_conn_close(), test_ConnectEx(), test_connection_cache(), test_connection_closing(), test_Console(), test_CoRegisterPSClsid(), test_CoWaitForMultipleHandles(), test_crash_couninitialize(), test_CreateProcessWithDesktop(), test_CreateRemoteThread(), test_CreateThread_basic(), test_CreateThread_stack(), test_CreateThread_suspended(), test_debug_children(), test_DebuggingFlag(), test_default_ime_window_creation(), test_defwinproc(), test_deletecontext(), test_DetachConsoleHandles(), test_DetachStdHandles(), test_Directory(), test_DisconnectNamedPipe(), test_DragQueryFile(), test_enum_thread_windows(), test_Environment(), test_event(), test_events(), test_ExitCode(), test_ExitProcess(), test_FakeDLL(), test_ffcn(), test_foregroundwindow(), test_fragmentsize(), test_ftp_protocol(), test_GetAddrInfoExW(), test_GetKeyState(), test_getservbyname(), test_GetThreadExitCode(), test_GetThreadTimes(), test_handles(), test_http_connection(), test_http_protocol_url(), test_ImmDefaultHwnd(), test_ImmThreads(), test_ImpersonateNamedPipeClient(), test_inet_ntoa(), test_Input_mouse(), test_InSendMessage(), test_interthread_messages(), test_iocp_callback(), test_ip_pktinfo(), test_IsProcessInJob(), test_jobInheritance(), test_keyed_events(), test_KillOnJobClose(), test_layered_window(), test_local_server(), test_menu_input(), test_MessageBox(), test_messages(), test_mixerOpen(), test_multithreaded_clipboard(), test_mutex(), test_no_content(), test_no_couninitialize_client(), test_no_couninitialize_server(), test_nonalertable(), test_NonExistentPath(), test_noprivileges(), test_NtAtom(), test_ntncdf(), test_ntncdf_async(), test_open_url_async(), test_overlapped(), test_parameters(), test_parametersEx(), test_PdhCollectQueryDataEx(), test_PeekMessage(), test_persistent_connection(), test_proxy_used_in_wrong_thread(), test_QueryInformationJobObject(), test_QueueUserWorkItem(), test_read_write(), test_readdirectorychanges(), test_readdirectorychanges_filedir(), test_readdirectorychanges_null(), test_readfileex_pending(), Test_recv(), test_redirect(), test_registered_object_thread_affinity(), test_RegisterWaitForSingleObject(), test_RegNotifyChangeKeyValue(), test_render_with_multithread(), test_RtlIsCriticalSectionLocked(), test_runner(), test_section_access(), test_security_flags(), test_select(), test_send(), test_set_clipboard_DRAWCLIPBOARD(), test_SetCursor(), test_SetFocus(), test_SetForegroundWindow(), test_shell_window(), test_ShowCursor(), test_signalandwait(), test_sioAddressListChange(), test_smresult(), test_srwlock_base(), test_srwlock_example(), test_Startup(), test_StartupNoConsole(), test_stop_wait_for_call(), test_successive_HttpSendRequest(), test_SuspendFlag(), test_SuspendThread(), test_tableweak_and_normal_marshal_and_releasedata(), test_tableweak_and_normal_marshal_and_unmarshal(), test_TerminateJobObject(), test_TerminateThread(), test_thread_actctx(), test_thread_handle_close(), test_thread_objects(), test_thread_start_address(), test_threads(), test_timer_queue(), test_timers(), test_Toolhelp(), test_TransmitFile(), test_two_tableweak_marshal_and_releasedata(), test_WaitCommEvent(), test_WaitForInputIdle(), test_WaitForJobObject(), test_WaitForSingleObject(), test_waittxempty(), test_winevents(), test_WM_DISPLAYCHANGE(), test_worst_case(), test_write_watch(), test_WSAPoll(), test_WSARecv(), testCtrlHandler(), TestRead(), TestShellExecuteEx(), testWaitForConsoleInput(), TestWrite(), thread(), thread1(), thread2(), thread_proc(), CDownloadManager::ThreadFunc(), TIME_MMSysTimeThread(), TIME_MMTimeStop(), timeKillEvent(), UninitializeGPNotifications(), VgaUpdateFramebuffer(), VideoRenderer_EndFlush(), VideoRendererInner_Release(), VMR9_SurfaceAllocator_TerminateDevice(), WaitExpect_(), waitforkey(), WaitForLsass(), WaitForMachinePolicyForegroundProcessing(), WaitForSCManager(), WaitForUserPolicyForegroundProcessing(), wave_in_test_deviceIn(), WAVE_mciPlayWaitDone(), WAVE_mciRecordWaitDone(), wave_out_test_deviceOut(), wbem_services_CancelAsyncCall(), wbem_services_Release(), window_from_point_proc(), wined3d_cs_wait_event(), WinMain(), WsAsyncThread(), WsCheckCatalogState(), WshExec_Terminate(), WSPAccept(), WSPBind(), WSPCloseSocket(), WSPConnect(), WSPEnumNetworkEvents(), WSPEventSelect(), WSPGetPeerName(), WSPGetSockName(), WSPListen(), WSPRecv(), WSPRecvFrom(), WSPSelect(), WSPSend(), WSPSendTo(), WSPShutdown(), WsSetupCatalogProtection(), wWinMain(), xmlMutexLock(), and CThread::~CThread().

84 {
85  /* Call the extended API */
86  return WaitForSingleObjectEx(hHandle, dwMilliseconds, FALSE);
87 }
DWORD WINAPI WaitForSingleObjectEx(IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:94
#define FALSE
Definition: types.h:117
DWORD WINAPI WaitForSingleObjectEx ( IN HANDLE  hHandle,
IN DWORD  dwMilliseconds,
IN BOOL  bAlertable 
)

Definition at line 94 of file synch.c.

Referenced by _tWinMain(), DeleteNode(), GetDeviceData(), main(), NotifyTopLevelWindow(), overlapped_server(), serverThreadMain3(), serverThreadMain5(), SoundThreadMain(), StartApplication(), tcp_recv(), tcp_send(), test_AbortWaitCts(), test_alertable(), test_async_file_errors(), test_readfileex_pending(), test_WaitBreak(), test_WaitCts(), test_WaitDcd(), test_WaitDsr(), test_WaitRing(), test_WaitRx(), toggle_ctlLine(), WaitForSingleObject(), WaveThread(), WdmAudCommitWaveBufferByLegacy(), and WriteFileEx_Remixer().

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 */
134  BaseSetLastNTError(Status);
135  Status = WAIT_FAILED;
136  }
137  } while ((Status == STATUS_ALERTED) && (bAlertable));
138 
139  /* Cleanup the activation context */
140  if (bAlertable) RtlDeactivateActivationContextUnsafeFast(&ActCtx);
141 
142  /* Return wait status */
143  return Status;
144 }
HANDLE TranslateStdHandle(IN HANDLE hHandle)
Definition: handle.c:19
#define STATUS_ALERTED
Definition: ntstatus.h:80
PLARGE_INTEGER WINAPI BaseFormatTimeOut(OUT PLARGE_INTEGER Timeout, IN DWORD dwMilliseconds)
Definition: utils.c:288
BOOL WINAPI DECLSPEC_HOTPATCH VerifyConsoleIoHandle(HANDLE hIoHandle)
Definition: console.c:1110
smooth NULL
Definition: ftsmooth.c:557
HANDLE WINAPI GetConsoleInputWaitHandle(VOID)
Definition: console.c:683
#define RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_FORMAT_WHISTLER
Definition: rtltypes.h:101
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
unsigned char BOOLEAN
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define WAIT_FAILED
Definition: winbase.h:385
PRTL_ACTIVATION_CONTEXT_STACK_FRAME FASTCALL RtlDeactivateActivationContextUnsafeFast(IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame)
Definition: actctx.c:5501
_In_ PCWSTR _Out_ PVOID * ActCtx
Definition: ldrtypes.h:245
#define IsConsoleHandle(h)
Definition: console.h:14
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
PRTL_ACTIVATION_CONTEXT_STACK_FRAME FASTCALL RtlActivateActivationContextUnsafeFast(IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame, IN PVOID Context)
Definition: actctx.c:5424
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
static PLARGE_INTEGER Time
Definition: time.c:28
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)