1 // event.hpp --------------------------------------------------------------//
3 // Copyright 2010 Vicente J. Botet Escriba
4 // Copyright 2015 Andrey Semashev
6 // Distributed under the Boost Software License, Version 1.0.
7 // See http://www.boost.org/LICENSE_1_0.txt
10 #ifndef BOOST_DETAIL_WINAPI_EVENT_HPP
11 #define BOOST_DETAIL_WINAPI_EVENT_HPP
13 #include <boost/detail/winapi/basic_types.hpp>
14 #include <boost/predef/platform.h>
16 #ifdef BOOST_HAS_PRAGMA_ONCE
20 #if !defined( BOOST_USE_WINDOWS_H )
22 #if !defined( BOOST_NO_ANSI_APIS )
23 #if !defined( BOOST_PLAT_WINDOWS_RUNTIME_AVALIABLE )
24 BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
26 ::_SECURITY_ATTRIBUTES* lpEventAttributes,
27 boost::detail::winapi::BOOL_ bManualReset,
28 boost::detail::winapi::BOOL_ bInitialState,
29 boost::detail::winapi::LPCSTR_ lpName);
32 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
33 BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
35 ::_SECURITY_ATTRIBUTES *lpEventAttributes,
36 boost::detail::winapi::LPCSTR_ lpName,
37 boost::detail::winapi::DWORD_ dwFlags,
38 boost::detail::winapi::DWORD_ dwDesiredAccess);
41 BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
43 boost::detail::winapi::DWORD_ dwDesiredAccess,
44 boost::detail::winapi::BOOL_ bInheritHandle,
45 boost::detail::winapi::LPCSTR_ lpName);
48 BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
50 ::_SECURITY_ATTRIBUTES* lpEventAttributes,
51 boost::detail::winapi::BOOL_ bManualReset,
52 boost::detail::winapi::BOOL_ bInitialState,
53 boost::detail::winapi::LPCWSTR_ lpName);
55 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
56 BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
58 ::_SECURITY_ATTRIBUTES *lpEventAttributes,
59 boost::detail::winapi::LPCWSTR_ lpName,
60 boost::detail::winapi::DWORD_ dwFlags,
61 boost::detail::winapi::DWORD_ dwDesiredAccess);
64 BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
66 boost::detail::winapi::DWORD_ dwDesiredAccess,
67 boost::detail::winapi::BOOL_ bInheritHandle,
68 boost::detail::winapi::LPCWSTR_ lpName);
70 // Windows CE define SetEvent/ResetEvent as inline functions in kfuncs.h
71 #if !defined( UNDER_CE )
72 BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
73 SetEvent(boost::detail::winapi::HANDLE_ hEvent);
75 BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
76 ResetEvent(boost::detail::winapi::HANDLE_ hEvent);
85 #if !defined( BOOST_NO_ANSI_APIS )
92 #if defined( BOOST_USE_WINDOWS_H )
94 const DWORD_ EVENT_ALL_ACCESS_ = EVENT_ALL_ACCESS;
95 const DWORD_ EVENT_MODIFY_STATE_ = EVENT_MODIFY_STATE;
96 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
97 const DWORD_ CREATE_EVENT_INITIAL_SET_ = CREATE_EVENT_INITIAL_SET;
98 const DWORD_ CREATE_EVENT_MANUAL_RESET_ = CREATE_EVENT_MANUAL_RESET;
101 #else // defined( BOOST_USE_WINDOWS_H )
103 const DWORD_ EVENT_ALL_ACCESS_ = 0x001F0003;
104 const DWORD_ EVENT_MODIFY_STATE_ = 0x00000002;
105 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
106 const DWORD_ CREATE_EVENT_INITIAL_SET_ = 0x00000002;
107 const DWORD_ CREATE_EVENT_MANUAL_RESET_ = 0x00000001;
110 #endif // defined( BOOST_USE_WINDOWS_H )
112 // Undocumented and not present in Windows SDK. Enables NtQueryEvent.
113 // http://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FNT%20Objects%2FEvent%2FNtQueryEvent.html
114 const DWORD_ EVENT_QUERY_STATE_ = 0x00000001;
116 const DWORD_ event_all_access = EVENT_ALL_ACCESS_;
117 const DWORD_ event_modify_state = EVENT_MODIFY_STATE_;
118 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
119 const DWORD_ create_event_initial_set = CREATE_EVENT_INITIAL_SET_;
120 const DWORD_ create_event_manual_reset = CREATE_EVENT_MANUAL_RESET_;
123 #if !defined( BOOST_NO_ANSI_APIS )
124 BOOST_FORCEINLINE HANDLE_ CreateEventA(SECURITY_ATTRIBUTES_* lpEventAttributes, BOOL_ bManualReset, BOOL_ bInitialState, LPCSTR_ lpName)
126 #if BOOST_PLAT_WINDOWS_RUNTIME && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
127 const DWORD_ flags = (bManualReset ? create_event_manual_reset : 0u) | (bInitialState ? create_event_initial_set : 0u);
128 return ::CreateEventExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), lpName, flags, event_all_access);
130 return ::CreateEventA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), bManualReset, bInitialState, lpName);
134 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
135 BOOST_FORCEINLINE HANDLE_ CreateEventExA(SECURITY_ATTRIBUTES_* lpEventAttributes, LPCSTR_ lpName, DWORD_ dwFlags, DWORD_ dwDesiredAccess)
137 return ::CreateEventExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), lpName, dwFlags, dwDesiredAccess);
142 BOOST_FORCEINLINE HANDLE_ CreateEventW(SECURITY_ATTRIBUTES_* lpEventAttributes, BOOL_ bManualReset, BOOL_ bInitialState, LPCWSTR_ lpName)
144 #if BOOST_PLAT_WINDOWS_RUNTIME && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
145 const DWORD_ flags = (bManualReset ? create_event_manual_reset : 0u) | (bInitialState ? create_event_initial_set : 0u);
146 return ::CreateEventExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), lpName, flags, event_all_access);
148 return ::CreateEventW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), bManualReset, bInitialState, lpName);
152 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
153 BOOST_FORCEINLINE HANDLE_ CreateEventExW(SECURITY_ATTRIBUTES_* lpEventAttributes, LPCWSTR_ lpName, DWORD_ dwFlags, DWORD_ dwDesiredAccess)
155 return ::CreateEventExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), lpName, dwFlags, dwDesiredAccess);
159 #if !defined( BOOST_NO_ANSI_APIS )
160 BOOST_FORCEINLINE HANDLE_ create_event(SECURITY_ATTRIBUTES_* lpEventAttributes, BOOL_ bManualReset, BOOL_ bInitialState, LPCSTR_ lpName)
162 return winapi::CreateEventA(lpEventAttributes, bManualReset, bInitialState, lpName);
165 BOOST_FORCEINLINE HANDLE_ open_event(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCSTR_ lpName)
167 return ::OpenEventA(dwDesiredAccess, bInheritHandle, lpName);
171 BOOST_FORCEINLINE HANDLE_ create_event(SECURITY_ATTRIBUTES_* lpEventAttributes, BOOL_ bManualReset, BOOL_ bInitialState, LPCWSTR_ lpName)
173 return winapi::CreateEventW(lpEventAttributes, bManualReset, bInitialState, lpName);
176 BOOST_FORCEINLINE HANDLE_ open_event(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCWSTR_ lpName)
178 return ::OpenEventW(dwDesiredAccess, bInheritHandle, lpName);
181 BOOST_FORCEINLINE HANDLE_ create_anonymous_event(SECURITY_ATTRIBUTES_* lpEventAttributes, BOOL_ bManualReset, BOOL_ bInitialState)
183 return winapi::CreateEventW(lpEventAttributes, bManualReset, bInitialState, 0);
190 #endif // BOOST_DETAIL_WINAPI_EVENT_HPP