ReactOS  0.4.15-dev-3163-gf17c2c0
fxcallbackmutexlock.hpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxCallbackMutexLock.hpp
8 
9 Abstract:
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 
17 Author:
18 
19 
20 
21 
22 Revision History:
23 
24 
25 --*/
26 
27 #ifndef _FXCALLBACKMUTEXLOCK_H_
28 #define _FXCALLBACKMUTEXLOCK_H_
29 
30 extern "C" {
31 // #include "FxCallbackMutexLock.hpp.tmh"
32 }
33 
35 
36 private:
37 
38 
39 
40 
41 
42 
43 
45 
46 public:
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 
72  m_Verifier = NULL;
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  }
128  m_OwnerThread = cur;
129  }
130  }
131 
132  virtual
133  void
135  __in KIRQL PreviousIrql
136  )
137  {
138  CheckOwnership();
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_
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
MxThread m_OwnerThread
#define TRUE
Definition: types.h:120
__inline VOID ReleaseUnsafe()
__inline VOID AcquireUnsafe()
Definition: mxpagedlockkm.h:78
VOID Unlock(__in KIRQL PreviousIrql, __in BOOLEAN AtDpc)
#define FxVerifierBugCheck(FxDriverGlobals, Error,...)
Definition: fxverifier.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
#define TRACE_LEVEL_FATAL
Definition: storswtr.h:26
VOID Lock(__out PKIRQL PreviousIrql, __in BOOLEAN AtDpc)
#define __out
Definition: dbghelp.h:62
unsigned char BOOLEAN
BOOLEAN FxVerifierLock
Definition: fxglobals.h:451
#define TRACINGDEVICE
Definition: dbgtrace.h:58
virtual void Lock(__out PKIRQL PreviousIrql)
virtual _Must_inspect_result_ BOOLEAN IsOwner(VOID)
FxVerifierLock * m_Verifier
_Must_inspect_result_ __inline NTSTATUS Initialize()
Definition: mxpagedlockkm.h:52
virtual void Initialize(FxObject *ParentObject)
FxCallbackMutexLock(PFX_DRIVER_GLOBALS FxDriverGlobals)
KIRQL * PKIRQL
Definition: env_spec_w32.h:592
#define _Must_inspect_result_
Definition: ms_sal.h:558
FxCollectionEntry * cur
static __inline MxThread MxGetCurrentThread()
Definition: mxgeneralkm.h:61
VOID CheckOwnership(VOID)
PFX_DRIVER_GLOBALS fxDriverGlobals
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
_Must_inspect_result_ static __inline NTSTATUS CreateAndInitialize(__out FxVerifierLock **VerifierLock, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *ParentObject, __in BOOLEAN UseMutex)
virtual void Unlock(__in KIRQL PreviousIrql)
#define __in
Definition: dbghelp.h:35
PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxstump.hpp:98