ReactOS 0.4.15-dev-7842-g558ab78
mxeventum.h File Reference
#include "DbgMacros.h"
#include "MxEvent.h"
Include dependency graph for mxeventum.h:

Go to the source code of this file.

Classes

struct  MdEvent
 

Functions

 __drv_when (Timeout !=NULL, _Must_inspect_result_) __inline NTSTATUS MxEvent
 

Function Documentation

◆ __drv_when()

__drv_when ( Timeout = NULL,
_Must_inspect_result_   
)

Definition at line 145 of file mxeventum.h.

173{
175
176 DWORD retVal;
177
178 UNREFERENCED_PARAMETER(WaitReason);
179 UNREFERENCED_PARAMETER(WaitMode);
180
181 LONGLONG relativeTimeOut = 0;
182 LONGLONG timeoutInMs = 0;
183 DWORD dwTimeout = 0;
184
185 if (NULL != Timeout)
186 {
187 //
188 // Make sure that timeout is 0 or -ve (which implies relative timeout)
189 //
190 if (Timeout->QuadPart > 0)
191 {
193 "Absolute wait not supported in user mode",
194 FALSE
195 );
196
198 }
199
200 //
201 // Remove the -ve sign
202 //
203 if (Timeout->QuadPart < 0)
204 {
205 relativeTimeOut = -1 * Timeout->QuadPart;
206 }
207
208 //
209 // Convert from 100ns units to milliseconds
210 //
211 timeoutInMs = (relativeTimeOut / (10 * 1000));
212
213 if (timeoutInMs > ULONG_MAX)
214 {
215 Mx::MxAssertMsg("Timeout too large", FALSE);
216
218 }
219 else
220 {
221 dwTimeout = (DWORD) timeoutInMs;
222 }
223 }
224
225 retVal = WaitForSingleObjectEx(
226 m_Event.Event,
229 );
230
231 switch(retVal)
232 {
233 case WAIT_ABANDONED:
234 return STATUS_ABANDONED;
235 case WAIT_OBJECT_0:
236 return STATUS_SUCCESS;
237 case WAIT_TIMEOUT:
238 return STATUS_TIMEOUT;
239 case WAIT_FAILED:
240 {
242 return WinErrorToNtStatus(err);
243 }
244 default:
245 {
246 //
247 // We shoudn't get here
248 //
250 return STATUS_UNSUCCESSFUL;
251 }
252 }
253}
static __inline VOID MxAssertMsg(__in LPSTR Message, __in BOOLEAN Condition)
Definition: mxgeneralkm.h:176
static __inline VOID MxAssert(__in BOOLEAN Condition)
Definition: mxgeneralkm.h:165
#define ASSERT_DBGFLAG_INITIALIZED
Definition: dbgmacros.h:58
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define INFINITE
Definition: serial.h:102
NTSTATUS WinErrorToNtStatus(__in ULONG WinError)
Definition: errtostatus.cpp:60
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ULONG_MAX
Definition: limits.h:44
_In_ PVOID _In_ BOOLEAN Alertable
Definition: exfuncs.h:453
#define DWORD
Definition: nt_native.h:44
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
#define STATUS_ABANDONED
Definition: ntstatus.h:75
static ULONG Timeout
Definition: ping.c:61
#define err(...)
#define STATUS_SUCCESS
Definition: shellext.h:65
DWORD WINAPI WaitForSingleObjectEx(IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:94
int64_t LONGLONG
Definition: typedefs.h:68
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define WAIT_ABANDONED
Definition: winbase.h:412
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define WAIT_OBJECT_0
Definition: winbase.h:406
#define WAIT_FAILED
Definition: winbase.h:413
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD dwTimeout
Definition: wincrypt.h:6081