ReactOS 0.4.15-dev-7788-g1ad9096
fxdriver.hpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxDriver.hpp
8
9Abstract:
10
11 This is the definition of the FxDriver object.
12
13Author:
14
15
16
17Environment:
18
19 Both kernel and user mode
20
21Revision History:
22
23--*/
24
25#ifndef _FXDRIVER_H_
26#define _FXDRIVER_H_
27
28#include "fxdrivercallbacks.hpp"
29
30
31//
32// Unique value to retrieve the FxDriver* from the PDEVICE_OBJECT.
33//
34#define FX_TRACE_INFO_ID (FxDriver::_GetTraceInfoExtension)
35
36//
37// Structure to hold WMI Callback info
38//
43};
44
45//
46// Unique value to retrieve the FxDriver* from the MdDriverObject. Use a value
47// that is not exposed to the driver writer through the dispatch table or WDM.
48//
49#define FX_DRIVER_ID ((PVOID)FxDriver::GetFxDriver)
50
51//
52// The following are support classes for FxDriver
53//
55{
56friend class FxDevice;
57friend class FxPackage;
58friend class FxWmiIrpHandler;
59
60private:
61
64
66
67 //
68 // Callbacks to device driver
69 //
71
72 //
73 // This represents any constraints on callbacks
74 // to the device driver that may be inherited
75 // by child devices and their objects
76 //
79
80 //
81 // Frameworks objects that raise event callbacks into the device
82 // driver provide spinlock and mutex based callback locks
83 // to allow proper synchronization between the driver and
84 // these callbacks.
85 //
86 // Some events must be passive level, while others at dispatch
87 // level, thus the need for two locks.
88 //
89 // The objects internal state is protected by the FxNonPagedObject
90 // lock inherited by the object, and is different from the callback
91 // locks.
92 //
94
95 //
96 // These pointers allow the proper lock to be acquired
97 // based on the configuration with a minimal of runtime
98 // checks. This is configured by ConfigureConstraints()
99 //
102
103 //
104 // This is the Driver-wide configuration
105 //
107
108 //
109 // Deferred Disposal List
110 //
112
113#if FX_IS_USER_MODE
114 //
115 // A handle to the driver service parameters key.
116 // The framework does not have permission to open it with
117 // write access from user mode, so we keep a pre-opened one.
118 //
119 HKEY m_DriverParametersKey;
120#endif
121
122private:
123
124 static
126
127public:
128
129 // This is public to allow the C function FxCoreDriverUnload to call it
131
132 FxDriver(
135 __in PFX_DRIVER_GLOBALS FxDriverGlobals
136 );
137
138 ~FxDriver();
139
140 static
141 VOID
145 );
146
147 static
148 VOID
152 );
153
154 static
155 FxDriver*
158 );
159
163 VOID
164 );
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200 __inline
201 WDFDRIVER
203 VOID
204 )
205 {
206 return (WDFDRIVER) GetObjectHandle();
207 }
208
209#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
210
215 );
216
217#else
218
222 _In_ IWudfDeviceStack * DevStack,
223 _In_ LPCWSTR KernelDeviceName,
224 _In_opt_ HKEY PdoKey,
226 _In_ LPCWSTR DevInstanceID,
227 _In_ ULONG DriverID
228 );
229#endif
230
231 VOID
233 VOID
234 );
235
237 FxString *
239 VOID
240 );
241
244 VOID
245 )
246 {
247 return &m_RegistryPath;
248 }
249
250 __inline
253 VOID
254 )
255 {
256 return m_DriverObject.GetObject();
257 }
258
265 );
266
267 //
268 // The following methods support the callback constraints
269 // and handle locking and deferral
270 //
271 VOID
274 );
275
276 //
277 // IFxHasCallbacks Support
278 //
279
280 virtual
281 VOID
283 __out WDF_EXECUTION_LEVEL* ExecutionLevel,
284 __out WDF_SYNCHRONIZATION_SCOPE* SynchronizationScope
285 ) {
286
287 if (ExecutionLevel != NULL) {
288 *ExecutionLevel = m_ExecutionLevel;
289 }
290
291 if (SynchronizationScope != NULL) {
292 *SynchronizationScope = m_SynchronizationScope;
293 }
294 }
295
296 virtual
300 ) {
301
302 if (LockObject != NULL) {
304 }
305
306 return m_CallbackLockPtr;
307 }
308
309 //
310 // IFxAssociation Support
311 //
312 virtual
316 )
317 {
318 switch (Params->Type) {
319 case FX_TYPE_DRIVER:
320 *Params->Object = (FxDriver*) this;
321 break;
322
323 default:
324 return FxNonPagedObject::QueryInterface(Params); // __super call
325 }
326
327 return STATUS_SUCCESS;
328 }
329
330 virtual
331 VOID
333 VOID
334 )
335 {
336 //
337 // If diposed at > PASSIVE, we will cause a deadlock in FxDriver::Dispose
338 // when we call into the dispose list to wait for empty when we are in
339 // the context of the dispose list's work item.
340 //
342
343 FxNonPagedObject::DeleteObject(); // __super call
344 }
345
346 virtual
347 BOOLEAN
348 Dispose(
349 VOID
350 );
351
352 __inline
355 )
356 {
357 return m_DisposeList;
358 }
359
360 __inline
363 )
364 {
366 }
367
368 static
370
371#if FX_IS_USER_MODE
372private:
373
374 //
375 // Open the handle to the driver service parameters key
376 // that we keep opened for use from user mode.
377 //
379 OpenParametersKey(
380 VOID
381 );
382
383 VOID
384 ClearDriverObjectFxDriver(
385 VOID
386 );
387
388public:
389
390 __inline
391 HKEY
392 GetDriverParametersKey(
393 VOID
394 )
395 {
396 return m_DriverParametersKey;
397 }
398#endif
399
400#if (FX_CORE_MODE == FX_CORE_USER_MODE)
401
402 VOID
405 )
406 {
408 }
409
410 BOOLEAN
413 )
414 {
416 }
417
418#endif
419
420};
421
422#endif // _FXDRIVER_H_
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
static WCHAR ServiceName[]
Definition: browser.c:19
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
PFN_WDF_DRIVER_DEVICE_ADD Method
VOID ConfigureConstraints(__in_opt PWDF_OBJECT_ATTRIBUTES DriverAttributes)
Definition: fxdriver.cpp:564
virtual VOID DeleteObject(VOID)
Definition: fxdriver.hpp:332
PUNICODE_STRING GetRegistryPathUnicodeString(VOID)
Definition: fxdriver.hpp:243
virtual FxCallbackLock * GetCallbackLockPtr(__deref_out FxObject **LockObject)
Definition: fxdriver.hpp:298
static VOID _InitializeTag(__in PFX_DRIVER_GLOBALS Globals, __in PWDF_DRIVER_CONFIG Config)
Definition: fxdriver.cpp:266
BOOLEAN m_DebuggerConnected
Definition: fxdriver.hpp:65
__inline MdDriverObject GetDriverObject(VOID)
Definition: fxdriver.hpp:252
static VOID _InitializeDriverName(__in PFX_DRIVER_GLOBALS Globals, __in PCUNICODE_STRING RegistryPath)
Definition: fxdriver.cpp:180
_Must_inspect_result_ NTSTATUS AllocateDriverObjectExtensionAndStoreFxDriver(VOID)
Definition: fxdriverkm.cpp:130
__inline PFN_WDF_DRIVER_DEVICE_ADD GetDriverDeviceAddMethod()
Definition: fxdriver.hpp:362
BOOLEAN IsDriverObjectFlagSet(_In_ FxDriverObjectUmFlags Flag)
Definition: fxdriver.hpp:411
static MdDriverAddDeviceType AddDevice
Definition: fxdriver.hpp:125
FxDisposeList * m_DisposeList
Definition: fxdriver.hpp:111
FxObject * m_CallbackLockObjectPtr
Definition: fxdriver.hpp:101
FxCallbackMutexLock m_CallbackMutexLock
Definition: fxdriver.hpp:93
_Must_inspect_result_ NTSTATUS AddDevice(__in MdDeviceObject PhysicalDeviceObject)
VOID SetDriverObjectFlag(_In_ FxDriverObjectUmFlags Flag)
Definition: fxdriver.hpp:403
FxCallbackLock * m_CallbackLockPtr
Definition: fxdriver.hpp:100
_Must_inspect_result_ FxString * GetRegistryPath(VOID)
Definition: fxdriver.cpp:539
FxDriverDeviceAdd m_DriverDeviceAdd
Definition: fxdriver.hpp:70
__inline WDFDRIVER GetHandle(VOID)
Definition: fxdriver.hpp:202
static FxDriver * GetFxDriver(__in MdDriverObject DriverObject)
Definition: fxdriverkm.cpp:159
MxDriverObject m_DriverObject
Definition: fxdriver.hpp:62
virtual VOID GetConstraints(__out WDF_EXECUTION_LEVEL *ExecutionLevel, __out WDF_SYNCHRONIZATION_SCOPE *SynchronizationScope)
Definition: fxdriver.hpp:282
virtual BOOLEAN Dispose(VOID)
Definition: fxdriver.cpp:128
VOID InitializeInternal(VOID)
__inline FxDisposeList * GetDisposeList()
Definition: fxdriver.hpp:354
~FxDriver()
Definition: fxdriver.cpp:78
WDF_EXECUTION_LEVEL m_ExecutionLevel
Definition: fxdriver.hpp:77
FxDriverUnload m_DriverUnload
Definition: fxdriver.hpp:130
WDF_SYNCHRONIZATION_SCOPE m_SynchronizationScope
Definition: fxdriver.hpp:78
virtual NTSTATUS QueryInterface(__inout FxQueryInterfaceParams *Params)
Definition: fxdriver.hpp:314
WDF_DRIVER_CONFIG m_Config
Definition: fxdriver.hpp:106
static MdDriverUnloadType Unload
Definition: fxdriver.hpp:369
UNICODE_STRING m_RegistryPath
Definition: fxdriver.hpp:63
virtual VOID DeleteObject(VOID)
virtual _Must_inspect_result_ NTSTATUS QueryInterface(__in FxQueryInterfaceParams *Params)
Definition: fxobject.cpp:255
__inline MdDriverObject GetObject(VOID)
BOOLEAN IsDriverObjectFlagSet(_In_ FxDriverObjectUmFlags Flag)
VOID SetDriverObjectFlag(_In_ FxDriverObjectUmFlags Flag)
static __inline KIRQL MxGetCurrentIrql()
Definition: mxgeneralkm.h:86
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define __in
Definition: dbghelp.h:35
#define __deref_out
Definition: dbghelp.h:26
#define __inout
Definition: dbghelp.h:50
#define __in_opt
Definition: dbghelp.h:38
#define __out
Definition: dbghelp.h:62
#define NULL
Definition: types.h:112
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
return pObject GetObjectHandle()
FxDriverObjectUmFlags
Definition: fxldrum.h:125
@ FX_TYPE_DRIVER
Definition: fxtypes.h:46
#define ASSERT(a)
Definition: mode.c:44
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
DRIVER_UNLOAD MdDriverUnloadType
DRIVER_ADD_DEVICE MdDriverAddDeviceType
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: xml2sdb.h:80
MdDriverObject DriverObject
Definition: fxdriver.hpp:40
PFN_WDF_TRACE_CALLBACK Callback
Definition: fxdriver.hpp:41
PVOID Context
Definition: fxdriver.hpp:42
#define LockObject(Object)
Definition: titypes.h:34
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_CHILD_LIST_CONFIG Config
Definition: wdfchildlist.h:476
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING _In_opt_ PWDF_OBJECT_ATTRIBUTES DriverAttributes
Definition: wdfdriver.h:217
EVT_WDF_DRIVER_DEVICE_ADD * PFN_WDF_DRIVER_DEVICE_ADD
Definition: wdfdriver.h:78
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ PWDF_DRIVER_CONFIG DriverConfig
Definition: wdfdriver.h:219
EVT_WDF_TRACE_CALLBACK * PFN_WDF_TRACE_CALLBACK
Definition: wdfdriver.h:118
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
WDF_EXTERN_C_START enum _WDF_EXECUTION_LEVEL WDF_EXECUTION_LEVEL
enum _WDF_SYNCHRONIZATION_SCOPE WDF_SYNCHRONIZATION_SCOPE
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:308
static void Initialize()
Definition: xlate.c:212
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185