ReactOS 0.4.15-dev-7705-g2320c37
fxcallbackmutexlock.hpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxCallbackMutexLock.hpp
8
9Abstract:
10
11 This is the C++ header for the FxCallbackMutexLock
12
13 This represents a container for handling locking
14 when we callback into the device driver at thread
15 level.
16
17Author:
18
19
20
21
22Revision History:
23
24
25--*/
26
27#ifndef _FXCALLBACKMUTEXLOCK_H_
28#define _FXCALLBACKMUTEXLOCK_H_
29
30extern "C" {
31// #include "FxCallbackMutexLock.hpp.tmh"
32}
33
35
36private:
37
38
39
40
41
42
43
45
46public:
47
49 PFX_DRIVER_GLOBALS FxDriverGlobals
50 ) :
51 FxCallbackLock(FxDriverGlobals)
52 {
54 }
55
56 virtual
58 {
59 if (m_Verifier) {
60 delete m_Verifier;
61 }
62 }
63
64 virtual
65 void
67 FxObject* ParentObject
68 )
69 {
71
74
76
77 //
78 // VerifierLock CreateAndInitialize failure is not fatal,
79 // we just won't track anything
80 //
83 ParentObject,
84 TRUE);
85 }
86 }
87
88 virtual
89 void
91 __out PKIRQL PreviousIrql
92 )
93 {
95
96 if (m_OwnerThread == cur) {
98
101
102 //
103 // For now we have decided not to allow this.
104 //
105
106
107
108
109
110
111
112 //
114 "Recursive acquire of callback lock 0x%p", this);
115
118 (ULONG_PTR)this);
119 }
120 else {
121 if (m_Verifier != NULL) {
122 m_Verifier->Lock(PreviousIrql, FALSE);
123 }
124 else {
125 Mx::MxEnterCriticalRegion();
127 }
129 }
130 }
131
132 virtual
133 void
135 __in KIRQL PreviousIrql
136 )
137 {
139
140 if (m_RecursionCount > 0) {
142 }
143 else {
145 if (m_Verifier) {
146 m_Verifier->Unlock(PreviousIrql, FALSE);
147 }
148 else {
150 Mx::MxLeaveCriticalRegion();
151 }
152 }
153 }
154
156 virtual
157 BOOLEAN
159 VOID
160 )
161 {
163
164 if (m_OwnerThread == cur) {
165 return TRUE;
166 }
167 else {
168 return FALSE;
169 }
170 }
171};
172
173#endif // _FXCALLBACKMUTEXLOCK_H_
unsigned char BOOLEAN
VOID CheckOwnership(VOID)
FxVerifierLock * m_Verifier
MxThread m_OwnerThread
virtual void Lock(__out PKIRQL PreviousIrql)
virtual void Unlock(__in KIRQL PreviousIrql)
virtual _Must_inspect_result_ BOOLEAN IsOwner(VOID)
FxCallbackMutexLock(PFX_DRIVER_GLOBALS FxDriverGlobals)
virtual void Initialize(FxObject *ParentObject)
VOID Unlock(__in KIRQL PreviousIrql, __in BOOLEAN AtDpc)
_Must_inspect_result_ static __inline NTSTATUS CreateAndInitialize(__out FxVerifierLock **VerifierLock, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *ParentObject, __in BOOLEAN UseMutex)
VOID Lock(__out PKIRQL PreviousIrql, __in BOOLEAN AtDpc)
__inline VOID AcquireUnsafe()
Definition: mxpagedlockkm.h:78
_Must_inspect_result_ __inline NTSTATUS Initialize()
Definition: mxpagedlockkm.h:52
__inline VOID ReleaseUnsafe()
static __inline MxThread MxGetCurrentThread()
Definition: mxgeneralkm.h:61
#define __in
Definition: dbghelp.h:35
#define __out
Definition: dbghelp.h:62
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
UCHAR KIRQL
Definition: env_spec_w32.h:591
KIRQL * PKIRQL
Definition: env_spec_w32.h:592
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
PFX_DRIVER_GLOBALS fxDriverGlobals
FxCollectionEntry * cur
#define FxVerifierBugCheck(FxDriverGlobals, Error,...)
Definition: fxverifier.h:58
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define TRACE_LEVEL_FATAL
Definition: storswtr.h:26
PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxstump.hpp:98
BOOLEAN FxVerifierLock
Definition: fxglobals.h:451
uint32_t ULONG_PTR
Definition: typedefs.h:65
@ WDF_RECURSIVE_LOCK
Definition: wdfbugcodes.h:59