ReactOS  0.4.15-dev-3181-g4acf100
mxevent.h
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 ModuleName:
6 
7  MxEvent.h
8 
9 Abstract:
10 
11  Mode agnostic definition of event
12 
13  See MxEventKm.h and MxEventUm.h for mode
14  specific implementations
15 
16 Author:
17 
18 
19 
20 Revision History:
21 
22 
23 
24 --*/
25 
26 #pragma once
27 
28 class MxEvent
29 {
30 
31 private:
32  //
33  // MdEvent is typedef'ed to appropriate type for the mode
34  // in the mode specific file
35  //
37 
39 
40 public:
41  __inline
42  MxEvent(
43  );
44 
45  __inline
46  ~MxEvent(
47  );
48 
50  __inline
51  NTSTATUS
52  Initialize(
55  );
56 
57  //
58  // GetEvent will return the underlying primitive event
59  // PKEVENT in case of kernel mode and event HANDLE in case of user-mode
60  //
61  __inline
62  PVOID
63  GetEvent(
64  );
65 
66  __inline
67  VOID
68  Set(
69  );
70 
71  __inline
72  VOID
75  );
76 
77  __inline
78  VOID
79  Clear(
80  );
81 
83  __drv_when(Timeout != NULL && Alertable == FALSE, __drv_valueIs(==0;==258))
85  __inline
86  NTSTATUS
87  WaitFor(
88  __in KWAIT_REASON WaitReason,
89  __in KPROCESSOR_MODE WaitMode,
92  );
93 
94  //
95  // NOTE: In user mode this function can only be called
96  // for a notification event (and not for a
97  // synchronization event)
98  //
99  __inline
100  LONG
101  ReadState(
102  );
103 
104  __inline
105  VOID
106  Uninitialize(
107  );
108 
109  MxEvent*
111  VOID
112  )
113  {
114  //
115  // Since operator& is hidden, we still need to be able to get a pointer
116  // to this object, so we must make it an explicit method.
117  //
118  return this;
119  }
120 
121 private:
123  VOID
124  )
125  {
126  //
127  // By making the address of operator private, we make it harder
128  // to accidentally use this object in an improper fashion, ie
129  // something like this is prevented:
130  //
131  // MxEvent event;
132  // KeWaitForSingleObject(&event, ...);
133  //
134  // However please note that in some cases event pointer is needed when
135  // event is passed around, in which case, GetSelfPointer() is used and
136  // this protection is circumvented. Calling code should be careful
137  // not to pass the pointer to KeWaitForSingleObject in such cases.
138  //
139  ASSERT(FALSE);
140  return NULL;
141  }
142 
143 };
__inline VOID Uninitialize()
Definition: mxeventkm.h:146
_In_ PVOID _In_ BOOLEAN Alertable
Definition: exfuncs.h:452
#define __in_opt
Definition: dbghelp.h:38
#define TRUE
Definition: types.h:120
#define CHECK_RETURN_IF_USER_MODE
Definition: mxmacros.h:26
LONG NTSTATUS
Definition: precomp.h:26
__inline VOID Set()
Definition: mxeventkm.h:91
LONG KPRIORITY
Definition: compat.h:662
__inline PVOID GetEvent()
Definition: mxeventkm.h:69
MxEvent * GetSelfPointer(VOID)
Definition: mxevent.h:110
CHECK_RETURN_IF_USER_MODE __inline NTSTATUS Initialize(__in EVENT_TYPE Type, __in BOOLEAN InitialState)
Definition: mxeventkm.h:55
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
MdEvent m_Event
Definition: mxevent.h:36
unsigned char BOOLEAN
__drv_when(Timeout==NULL &&Alertable==FALSE, __drv_valueIs(==0)) __drv_when(Timeout !
__inline VOID Clear()
Definition: mxeventkm.h:102
enum _EVENT_TYPE EVENT_TYPE
_Must_inspect_result_ __inline NTSTATUS WaitFor(__in KWAIT_REASON WaitReason, __in KPROCESSOR_MODE WaitMode, __in BOOLEAN Alertable, __in_opt PLARGE_INTEGER Timeout)
Definition: mxeventkm.h:115
MxEvent * operator &(VOID)
Definition: mxevent.h:122
#define ASSERT(a)
Definition: mode.c:44
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_ EVENT_TYPE _In_ BOOLEAN InitialState
Definition: exfuncs.h:165
Type
Definition: Type.h:6
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
__drv_valueIs(==0;==258)) __drv_when(Timeout !
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
Definition: wdfinterrupt.h:651
__inline ~MxEvent()
Definition: mxeventkm.h:46
__inline LONG ReadState()
Definition: mxeventkm.h:135
#define _Must_inspect_result_
Definition: ms_sal.h:558
static ULONG Timeout
Definition: ping.c:61
__inline MxEvent()
Definition: mxeventkm.h:31
#define NULL
Definition: types.h:112
__inline VOID SetWithIncrement(__in KPRIORITY Priority)
Definition: mxeventkm.h:80
enum _KWAIT_REASON KWAIT_REASON
DECLARE_DBGFLAG_INITIALIZED
Definition: mxevent.h:38
#define __in
Definition: dbghelp.h:35