ReactOS  0.4.15-dev-3287-gfec35dc
fxnonpagedobject.hpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxNonPagedObject.hpp
8 
9 Abstract:
10 
11  This module defines the abstract FxNonPagedObject class.
12 
13 Author:
14 
15 
16 
17 Environment:
18 
19  Both kernel and user mode
20 
21 Revision History:
22 
23 
24  Made mode agnostic
25 
26  IMPORTANT: Common code must call Initialize method of
27  FxNonPagedObject before using it
28 
29  Cannot put CreateAndInitialize method on this class as it
30  cannot be instantiated
31 
32 --*/
33 
34 #ifndef _FXNONPAGEDOBJECT_H_
35 #define _FXNONPAGEDOBJECT_H_
36 
37 extern "C" {
38 
39 #if defined(EVENT_TRACING)
40 #include "FxNonPagedObject.hpp.tmh"
41 #endif
42 
43 }
44 
45 class FxNonPagedObject : public FxObject
46 {
47 private:
48 
50 
51 public:
55  __in PFX_DRIVER_GLOBALS FxDriverGlobals
56  ) :
57  FxObject(Type, Size, FxDriverGlobals)
58  {
59  if (IsDebug()) {
61  //
62  // VerifierLock CreateAndInitialize failure is not fatal,
63  // we just won't track anything
64  //
65  FxVerifierLock * verifierLock = NULL;
68  this);
69  GetDebugExtension()->VerifierLock = verifierLock;
70  }
71  }
72  }
73 
77  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
79  ) :
80  FxObject(Type, Size, FxDriverGlobals, ObjectType)
81  {
82  if (IsDebug()) {
84  //
85  // VerifierLock CreateAndInitialize failure is not fatal,
86  // we just won't track anything
87  //
88  FxVerifierLock * verifierLock = NULL;
91  this);
92  GetDebugExtension()->VerifierLock = verifierLock;
93  }
94  }
95  }
96 
97  virtual
99  VOID
100  )
101  {
102  if (IsDebug()) {
103  FxObjectDebugExtension* pExtension;
104 
105  pExtension = GetDebugExtension();
106 
107  if (pExtension->VerifierLock != NULL) {
108  delete pExtension->VerifierLock;
109  pExtension->VerifierLock = NULL;
110  }
111  }
112  }
113 
114  _Acquires_lock_(this->m_NPLock.m_Lock)
117  VOID
118  Lock(
120  )
121  {
122  if (IsDebug()) {
123  FxObjectDebugExtension* pExtension;
124 
125  pExtension = GetDebugExtension();
126 
127  if (pExtension->VerifierLock != NULL) {
128  pExtension->VerifierLock->Lock(PreviousIrql, FALSE);
129  //
130  // return here so that we don't acquire the non verified lock
131  // below
132  //
133  return;
134  }
135  }
136 
137  m_NPLock.Acquire(PreviousIrql);
138  }
139 
140  _Releases_lock_(this->m_NPLock.m_Lock)
142  __inline
143  VOID
144  Unlock(
145  __in __drv_restoresIRQL KIRQL PreviousIrql
146  )
147  {
148  if (IsDebug()) {
149  FxObjectDebugExtension* pExtension;
150 
151  pExtension = GetDebugExtension();
152 
153  if (pExtension->VerifierLock != NULL) {
154  pExtension->VerifierLock->Unlock(PreviousIrql, FALSE);
155 
156  //
157  // return here so that we don't release the non verified lock
158  // below
159  //
160  return;
161  }
162  }
163 
164  m_NPLock.Release(PreviousIrql);
165  }
166 
167 #if FX_CORE_MODE==FX_CORE_KERNEL_MODE
168 
169  _Acquires_lock_(this->m_NPLock.m_Lock)
171  VOID
172  LockAtDispatch(
173  VOID
174  )
175  {
176  if (IsDebug()) {
177  FxObjectDebugExtension* pExtension;
178 
179  pExtension = GetDebugExtension();
180 
181  if (pExtension->VerifierLock != NULL) {
182  KIRQL previousIrql;
183 
184  pExtension->VerifierLock->Lock(&previousIrql, TRUE);
185 
186  ASSERT(previousIrql == DISPATCH_LEVEL);
187  //
188  // return here so that we don't acquire the non verified lock
189  // below
190  //
191  return;
192  }
193  }
194 
195  m_NPLock.AcquireAtDpcLevel();
196  }
197 
198  _Requires_lock_held_(this->m_NPLock.m_Lock)
199  _Releases_lock_(this->m_NPLock.m_Lock)
201  __inline
202  VOID
203  UnlockFromDispatch(
204  VOID
205  )
206  {
207  if (IsDebug()) {
208  FxObjectDebugExtension* pExtension;
209 
210  pExtension = GetDebugExtension();
211 
212  if (pExtension->VerifierLock != NULL) {
213  pExtension->VerifierLock->Unlock(DISPATCH_LEVEL, TRUE);
214 
215  //
216  // return here so that we don't acquire the non verified lock
217  // below
218  //
219  return;
220  }
221  }
222 
223  m_NPLock.ReleaseFromDpcLevel();
224  }
225 
226 #endif //FX_CORE_MODE==FX_CORE_KERNEL_MODE
227 };
228 
229 #endif // _FXNONPAGEDOBJECT_H_
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
FxNonPagedObject(__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType ObjectType)
ObjectType
Definition: metafile.c:80
FxNonPagedObject(__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
_Acquires_lock_(this->m_NPLock.m_Lock) __drv_maxIRQL(DISPATCH_LEVEL) __drv_setsIRQL(DISPATCH_LEVEL) VOID Lock(__out __drv_deref(__drv_savesIRQL) PKIRQL PreviousIrql)
#define TRUE
Definition: types.h:120
#define __drv_restoresIRQL
Definition: driverspecs.h:321
MdLock m_Lock
Definition: mxlock.h:40
_Acquires_lock_(this->m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) VOID LockAtDispatch(VOID)
#define __drv_maxIRQL(irql)
Definition: driverspecs.h:290
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
_Requires_lock_held_(this->m_NPLock.m_Lock) _Releases_lock_(this -> m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) __inline VOID UnlockFromDispatch(VOID)
VOID Unlock(__in KIRQL PreviousIrql, __in BOOLEAN AtDpc)
UCHAR KIRQL
Definition: env_spec_w32.h:591
FxObjectType
Definition: fxobject.hpp:117
#define FALSE
Definition: types.h:117
VOID Lock(__out PKIRQL PreviousIrql, __in BOOLEAN AtDpc)
#define __out
Definition: dbghelp.h:62
#define ASSERT(a)
Definition: mode.c:44
Type
Definition: Type.h:6
_Must_inspect_result_ this m_Lock __drv_setsIRQL(APC_LEVEL)) _When_(return
__drv_requiresIRQL(DISPATCH_LEVEL)) VOID DeletedAndDisposedWorkerLocked(__in __drv_when(Unlock
FxObjectDebugExtension * GetDebugExtension(VOID)
Definition: fxobject.hpp:401
KIRQL * PKIRQL
Definition: env_spec_w32.h:592
#define __drv_deref(annotes)
Definition: driverspecs.h:264
Definition: mxlock.h:101
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
virtual ~FxNonPagedObject(VOID)
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
unsigned short USHORT
Definition: pedump.c:61
USHORT WDFTYPE
Definition: fxtypes.h:29
#define __drv_savesIRQL
Definition: driverspecs.h:325
#define NULL
Definition: types.h:112
_Releases_lock_(this->m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) __inline VOID Unlock(__in __drv_restoresIRQL KIRQL PreviousIrql)
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
BOOLEAN IsDebug(VOID)
Definition: fxobject.hpp:409
FxVerifierLock * VerifierLock
Definition: fxobject.hpp:210
_Must_inspect_result_ static __inline NTSTATUS CreateAndInitialize(__out FxVerifierLock **VerifierLock, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *ParentObject, __in BOOLEAN UseMutex)
#define __in
Definition: dbghelp.h:35