ReactOS 0.4.15-dev-8417-gb6b82fe
fxnonpagedobject.hpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxNonPagedObject.hpp
8
9Abstract:
10
11 This module defines the abstract FxNonPagedObject class.
12
13Author:
14
15
16
17Environment:
18
19 Both kernel and user mode
20
21Revision 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
37extern "C" {
38
39#if defined(EVENT_TRACING)
40#include "FxNonPagedObject.hpp.tmh"
41#endif
42
43}
44
46{
47private:
48
50
51public:
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
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_
Type
Definition: Type.h:7
FxNonPagedObject(__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType ObjectType)
_Acquires_lock_(this->m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) VOID LockAtDispatch(VOID)
virtual ~FxNonPagedObject(VOID)
FxNonPagedObject(__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
_Releases_lock_(this->m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) __inline VOID Unlock(__in __drv_restoresIRQL KIRQL PreviousIrql)
_Acquires_lock_(this->m_NPLock.m_Lock) __drv_maxIRQL(DISPATCH_LEVEL) __drv_setsIRQL(DISPATCH_LEVEL) VOID Lock(__out __drv_deref(__drv_savesIRQL) PKIRQL PreviousIrql)
_Requires_lock_held_(this->m_NPLock.m_Lock) _Releases_lock_(this -> m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) __inline VOID UnlockFromDispatch(VOID)
FxObjectDebugExtension * GetDebugExtension(VOID)
Definition: fxobject.hpp:401
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
BOOLEAN IsDebug(VOID)
Definition: fxobject.hpp:409
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)
MdLock m_Lock
Definition: mxlock.h:40
Definition: mxlock.h:102
#define _Releases_lock_(lock)
#define __in
Definition: dbghelp.h:35
#define __out
Definition: dbghelp.h:62
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define __drv_savesIRQL
Definition: driverspecs.h:326
#define __drv_deref(annotes)
Definition: driverspecs.h:265
#define __drv_setsIRQL(irql)
Definition: driverspecs.h:328
#define __drv_restoresIRQL
Definition: driverspecs.h:322
#define __drv_requiresIRQL(irql)
Definition: driverspecs.h:321
#define __drv_maxIRQL(irql)
Definition: driverspecs.h:291
UCHAR KIRQL
Definition: env_spec_w32.h:591
KIRQL * PKIRQL
Definition: env_spec_w32.h:592
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
FxObjectType
Definition: fxobject.hpp:117
USHORT WDFTYPE
Definition: fxtypes.h:29
#define ASSERT(a)
Definition: mode.c:44
ObjectType
Definition: metafile.c:81
unsigned short USHORT
Definition: pedump.c:61
FxVerifierLock * VerifierLock
Definition: fxobject.hpp:210
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:127