ReactOS 0.4.15-dev-8093-g3285f69
FxDriver Class Reference

#include <fxdriver.hpp>

Inheritance diagram for FxDriver:
Collaboration diagram for FxDriver:

Public Member Functions

 FxDriver (__in MdDriverObject DriverObject, __in PWDF_DRIVER_CONFIG DriverConfig, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
 ~FxDriver ()
 
_Must_inspect_result_ NTSTATUS AllocateDriverObjectExtensionAndStoreFxDriver (VOID)
 
__inline WDFDRIVER GetHandle (VOID)
 
_Must_inspect_result_ NTSTATUS AddDevice (__in MdDeviceObject PhysicalDeviceObject)
 
VOID InitializeInternal (VOID)
 
_Must_inspect_result_ FxStringGetRegistryPath (VOID)
 
PUNICODE_STRING GetRegistryPathUnicodeString (VOID)
 
__inline MdDriverObject GetDriverObject (VOID)
 
_Must_inspect_result_ NTSTATUS Initialize (__in PCUNICODE_STRING RegistryPath, __in PWDF_DRIVER_CONFIG Config, __in_opt PWDF_OBJECT_ATTRIBUTES DriverAttributes)
 
VOID ConfigureConstraints (__in_opt PWDF_OBJECT_ATTRIBUTES DriverAttributes)
 
virtual VOID GetConstraints (__out WDF_EXECUTION_LEVEL *ExecutionLevel, __out WDF_SYNCHRONIZATION_SCOPE *SynchronizationScope)
 
virtual FxCallbackLockGetCallbackLockPtr (__deref_out FxObject **LockObject)
 
virtual NTSTATUS QueryInterface (__inout FxQueryInterfaceParams *Params)
 
virtual VOID DeleteObject (VOID)
 
virtual BOOLEAN Dispose (VOID)
 
__inline FxDisposeListGetDisposeList ()
 
__inline PFN_WDF_DRIVER_DEVICE_ADD GetDriverDeviceAddMethod ()
 
VOID SetDriverObjectFlag (_In_ FxDriverObjectUmFlags Flag)
 
BOOLEAN IsDriverObjectFlagSet (_In_ FxDriverObjectUmFlags Flag)
 
- Public Member Functions inherited from FxNonPagedObject
 FxNonPagedObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
 FxNonPagedObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType ObjectType)
 
virtual ~FxNonPagedObject (VOID)
 
 _Acquires_lock_ (this->m_NPLock.m_Lock) __drv_maxIRQL(DISPATCH_LEVEL) __drv_setsIRQL(DISPATCH_LEVEL) VOID Lock(__out __drv_deref(__drv_savesIRQL) PKIRQL PreviousIrql)
 
 _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_requiresIRQL(DISPATCH_LEVEL) VOID LockAtDispatch(VOID)
 
 _Requires_lock_held_ (this->m_NPLock.m_Lock) _Releases_lock_(this -> m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) __inline VOID UnlockFromDispatch(VOID)
 
- Public Member Functions inherited from FxObject
PVOID GetCOMWrapper ()
 
void SetCOMWrapper (__drv_aliasesMem PVOID Wrapper)
 
 FxObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
virtual ~FxObject (VOID)
 
PVOID __inline operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType Type)
 
PVOID __inline operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in USHORT ExtraSize=0)
 
VOID operator delete (__in PVOID Memory)
 
VOID SetNoContextHeader (VOID)
 
PVOID __inline GetObjectHandle (VOID)
 
__inline FxContextHeaderGetContextHeader (VOID)
 
__inline PFX_DRIVER_GLOBALS GetDriverGlobals (VOID)
 
WDFTYPE GetType (VOID)
 
USHORT GetObjectSize (VOID)
 
LONG GetRefCnt (VOID)
 
FxTagTrackerGetTagTracker (VOID)
 
CfxDeviceGetDevice (VOID)
 
CfxDeviceBaseGetDeviceBase (VOID)
 
VOID SetDeviceBase (__in CfxDeviceBase *DeviceBase)
 
__inline VOID CallCleanup (VOID)
 
ULONG __inline AddRef (__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG Release (__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG AddRefOverride (__in WDFOBJECT_OFFSET Offset, __in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG ReleaseOverride (__in WDFOBJECT_OFFSET Offset, __in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual _Must_inspect_result_ NTSTATUS QueryInterface (__in FxQueryInterfaceParams *Params)
 
VOID MarkTraceState (VOID)
 
BOOLEAN __inline IsTraceState (VOID)
 
VOID __inline TraceDroppedEvent (__in FxObjectDroppedEvent Event)
 
VOID MarkPassiveDispose (__in FxObjectLockState State=ObjectLock)
 
VOID MarkPassiveCallbacks (__in FxObjectLockState State=ObjectLock)
 
VOID MarkForceDisposeThread (__in FxObjectLockState State=ObjectLock)
 
BOOLEAN IsPassiveCallbacks (__in BOOLEAN AcquireLock=TRUE)
 
BOOLEAN IsPassiveDispose (__in BOOLEAN AcquireLock=TRUE)
 
BOOLEAN IsForceDisposeThread (__in BOOLEAN AcquireLock=TRUE)
 
VOID MarkCommitted (VOID)
 
BOOLEAN IsCommitted (VOID)
 
VOID MarkDisposeOverride (__in FxObjectLockState State=ObjectLock)
 
VOID MarkNoDeleteDDI (__in FxObjectLockState State=ObjectLock)
 
BOOLEAN IsNoDeleteDDI (VOID)
 
_Must_inspect_result_ NTSTATUS Commit (__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
 
VOID DeleteFromFailedCreate (VOID)
 
VOID ClearEvtCallbacks (VOID)
 
BOOLEAN EarlyDispose (VOID)
 
virtual VOID DeleteObject (VOID)
 
virtual BOOLEAN Dispose (VOID)
 
_Must_inspect_result_ NTSTATUS AssignParentObject (__in FxObject *ParentObject)
 
_Must_inspect_result_ NTSTATUS AddContext (__in FxContextHeader *Header, __in PVOID *Context, __in PWDF_OBJECT_ATTRIBUTES Attributes)
 
_Must_inspect_result_ NTSTATUS RemoveParentAssignment (VOID)
 
_Must_inspect_result_ FxObjectGetParentObjectReferenced (__in PVOID Tag)
 
BOOLEAN IsDisposed (VOID)
 
- Public Member Functions inherited from IFxHasCallbacks
virtual VOID GetConstraints (__out WDF_EXECUTION_LEVEL *ExecutionLevel, __out WDF_SYNCHRONIZATION_SCOPE *SynchronizationScope)=0
 
virtual _Must_inspect_result_ FxCallbackLockGetCallbackLockPtr (__out_opt FxObject **LockObject)=0
 

Static Public Member Functions

static VOID _InitializeDriverName (__in PFX_DRIVER_GLOBALS Globals, __in PCUNICODE_STRING RegistryPath)
 
static VOID _InitializeTag (__in PFX_DRIVER_GLOBALS Globals, __in PWDF_DRIVER_CONFIG Config)
 
static FxDriverGetFxDriver (__in MdDriverObject DriverObject)
 
- Static Public Member Functions inherited from FxObject
static FxObject_FromDisposeEntry (__in PSINGLE_LIST_ENTRY Entry)
 
static FxObject_GetObjectFromHandle (__in WDFOBJECT Handle, __inout PWDFOBJECT_OFFSET ObjectOffset)
 
static PVOID __inline _ToHandle (__in FxObject *Object)
 
static VOID __inline _ReferenceActual (__in WDFOBJECT Object, __in_opt PVOID Tag, __in LONG Line, __in PSTR File)
 
static VOID __inline _DereferenceActual (__in WDFOBJECT Object, __in_opt PVOID Tag, __in LONG Line, __in PSTR File)
 
static PVOID _GetDebugBase (__in FxObject *Object)
 
static PFX_POOL_HEADER _CleanupPointer (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *Object)
 
static _Must_inspect_result_ NTSTATUS _GetEffectiveLock (__in FxObject *Object, __in_opt IFxHasCallbacks *Callbacks, __in BOOLEAN AutomaticLocking, __in BOOLEAN PassiveCallbacks, __out FxCallbackLock **CallbackLock, __out_opt FxObject **CallbackLockObject)
 
static _Must_inspect_result_ NTSTATUS _ObjectQuery (_In_ FxObject *Object, _In_ CONST GUID *Guid, _In_ ULONG QueryBufferLength, _Out_writes_bytes_(QueryBufferLength) PVOID QueryBuffer)
 

Public Attributes

FxDriverUnload m_DriverUnload
 

Static Public Attributes

static MdDriverUnloadType Unload
 

Private Attributes

MxDriverObject m_DriverObject
 
UNICODE_STRING m_RegistryPath
 
BOOLEAN m_DebuggerConnected
 
FxDriverDeviceAdd m_DriverDeviceAdd
 
WDF_EXECUTION_LEVEL m_ExecutionLevel
 
WDF_SYNCHRONIZATION_SCOPE m_SynchronizationScope
 
FxCallbackMutexLock m_CallbackMutexLock
 
FxCallbackLockm_CallbackLockPtr
 
FxObjectm_CallbackLockObjectPtr
 
WDF_DRIVER_CONFIG m_Config
 
FxDisposeListm_DisposeList
 

Static Private Attributes

static MdDriverAddDeviceType AddDevice
 

Friends

class FxDevice
 
class FxPackage
 
class FxWmiIrpHandler
 

Additional Inherited Members

- Protected Member Functions inherited from FxObject
 FxObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType ObjectType)
 
FxObjectDebugExtensionGetDebugExtension (VOID)
 
BOOLEAN IsDebug (VOID)
 
VOID AllocateTagTracker (__in WDFTYPE Type)
 
virtual VOID SelfDestruct (VOID)
 
PVOID __inline GetObjectHandleUnchecked (VOID)
 
VOID __inline DestroyChildren (VOID)
 
VOID DeleteEarlyDisposedObject (VOID)
 
- Static Protected Member Functions inherited from FxObject
static PVOID _GetBase (__in FxObject *Object)
 
- Protected Attributes inherited from FxObject
union {
   CfxDeviceBase *   m_DeviceBase
 
   CfxDevice *   m_Device
 
}; 
 

Detailed Description

Definition at line 54 of file fxdriver.hpp.

Constructor & Destructor Documentation

◆ FxDriver()

FxDriver::FxDriver ( __in MdDriverObject  DriverObject,
__in PWDF_DRIVER_CONFIG  DriverConfig,
__in PFX_DRIVER_GLOBALS  FxDriverGlobals 
)

Definition at line 33 of file fxdriver.cpp.

37 :
38 FxNonPagedObject(FX_TYPE_DRIVER, sizeof(FxDriver), FxDriverGlobals),
39 m_DriverObject(ArgDriverObject),
40 m_CallbackMutexLock(FxDriverGlobals)
41{
43
44
45
46
47
48
49#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
51#else
53#endif
54
56
59
61
62 //
63 // These are initialized up front so that sub objects
64 // can have the right configuration
65 //
67
68 // Only copy the smallest of what is specified and our size
70
72
73#if FX_IS_USER_MODE
74 m_DriverParametersKey = NULL;
75#endif
76}
BOOLEAN m_DebuggerConnected
Definition: fxdriver.hpp:65
FxDisposeList * m_DisposeList
Definition: fxdriver.hpp:111
FxObject * m_CallbackLockObjectPtr
Definition: fxdriver.hpp:101
FxCallbackMutexLock m_CallbackMutexLock
Definition: fxdriver.hpp:93
FxCallbackLock * m_CallbackLockPtr
Definition: fxdriver.hpp:100
MxDriverObject m_DriverObject
Definition: fxdriver.hpp:62
WDF_EXECUTION_LEVEL m_ExecutionLevel
Definition: fxdriver.hpp:77
WDF_SYNCHRONIZATION_SCOPE m_SynchronizationScope
Definition: fxdriver.hpp:78
WDF_DRIVER_CONFIG m_Config
Definition: fxdriver.hpp:106
UNICODE_STRING m_RegistryPath
Definition: fxdriver.hpp:63
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
@ FX_TYPE_DRIVER
Definition: fxtypes.h:46
#define min(a, b)
Definition: monoChain.cc:55
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ PWDF_DRIVER_CONFIG DriverConfig
Definition: wdfdriver.h:219
FORCEINLINE VOID WDF_DRIVER_CONFIG_INIT(_Out_ PWDF_DRIVER_CONFIG Config, _In_opt_ PFN_WDF_DRIVER_DEVICE_ADD EvtDriverDeviceAdd)
Definition: wdfdriver.h:148
@ WdfSynchronizationScopeNone
Definition: wdfobject.h:66
@ WdfExecutionLevelPassive
Definition: wdfobject.h:54
@ WdfExecutionLevelDispatch
Definition: wdfobject.h:55

◆ ~FxDriver()

FxDriver::~FxDriver ( )

Definition at line 78 of file fxdriver.cpp.

79{
80 // Make it always present right now even on free builds
81 if (IsDisposed() == FALSE) {
84 "FxDriver 0x%p not disposed: this maybe a driver reference count "
85 "problem with WDFDRIVER 0x%p", this, GetObjectHandleUnchecked());
86
90 (ULONG_PTR) this);
91 }
92
93 //
94 // Free the memory for the registry path if required.
95 //
98 }
99
100 if (m_DisposeList != NULL) {
102 }
103
104#if FX_IS_USER_MODE
105 //
106 // Close the R/W handle to the driver's service parameters key
107 // that we opened during Initialize.
108 //
109 if (m_DriverParametersKey != NULL) {
110 NTSTATUS status = FxRegKey::_Close(m_DriverParametersKey);
111 if (!NT_SUCCESS(status)) {
113 "Cannot close Driver Parameters key %!STATUS!",
114 status);
115 }
116 m_DriverParametersKey = NULL;
117 }
118
119 //
120 // The host-created driver object holds a reference to this
121 // FxDriver object. Clear it, since this object was deleted.
122 //
123 ClearDriverObjectFxDriver();
124#endif
125}
LONG NTSTATUS
Definition: precomp.h:26
virtual VOID DeleteObject(VOID)
BOOLEAN IsDisposed(VOID)
Definition: fxobject.hpp:1241
PVOID __inline GetObjectHandleUnchecked(VOID)
Definition: fxobject.hpp:446
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
#define TRACINGDRIVER
Definition: dbgtrace.h:68
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
Definition: wdfpool.cpp:361
#define FxVerifierBugCheck(FxDriverGlobals, Error,...)
Definition: fxverifier.h:58
#define TRACE_LEVEL_FATAL
Definition: storswtr.h:26
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
Definition: ps.c:97
uint32_t ULONG_PTR
Definition: typedefs.h:65
@ WDF_OBJECT_ERROR
Definition: wdfbugcodes.h:64

Member Function Documentation

◆ _InitializeDriverName()

FxDriver::_InitializeDriverName ( __in PFX_DRIVER_GLOBALS  Globals,
__in PCUNICODE_STRING  RegistryPath 
)
static

Definition at line 180 of file fxdriver.cpp.

196{
197 PWCHAR pCur, pBegin, pEnd;
198
199 RtlZeroMemory(&FxDriverGlobals->Public.DriverName[0],
200 sizeof(FxDriverGlobals->Public.DriverName) );
201
202 if (RegistryPath == NULL) {
203 return;
204 }
205
206 pBegin = RegistryPath->Buffer;
207
208 //
209 // pEnd is one past the end of the string, while pCur is a pointer to the
210 // last character of the string. We will decrement pCur down towards the
211 // beginning of the string.
212 //
213 pEnd = pBegin + (RegistryPath->Length / sizeof(WCHAR));
214 pCur = pEnd - 1;
215
216 for ( ; *pCur != L'\\' && pCur != pBegin; pCur--) {
217 DO_NOTHING();
218 }
219
220 if (pCur != pBegin && *pCur == L'\\') {
221 size_t regLen;
222 ULONG i;
223
224 pCur++;
225
226 //
227 // Can't use wcslen becuase this is a UNICODE_STRING which means that it
228 // does not necessarily have a terminating NULL in the buffer.
229 //
230 regLen = pEnd - pCur;
231 if (regLen > WDF_DRIVER_GLOBALS_NAME_LEN-1) {
233 }
234
235
236 for (i = 0; i < regLen; i++) {
237 FxDriverGlobals->Public.DriverName[i] = (CHAR) pCur[i];
238 }
239 }
240 else {
242
243#if FX_CORE_MODE==FX_CORE_KERNEL_MODE
244 status = RtlStringCbCopyA(FxDriverGlobals->Public.DriverName,
245 sizeof(FxDriverGlobals->Public.DriverName),
246 "WDF");
247#else // USER_MODE
248 HRESULT hr;
249 hr = StringCbCopyA(FxDriverGlobals->Public.DriverName,
250 sizeof(FxDriverGlobals->Public.DriverName),
251 "WDF");
254 }
255 else {
257 }
258#endif
259
262 }
263}
#define CHAR(Char)
NTSTATUS WinErrorToNtStatus(__in ULONG WinError)
Definition: errtostatus.cpp:60
SINGLE_LIST_ENTRY * pCur
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define ASSERT(a)
Definition: mode.c:44
#define DO_NOTHING()
Definition: mxgeneral.h:32
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
NTSTRSAFEAPI RtlStringCbCopyA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:156
#define L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
HRESULT hr
Definition: shlfolder.c:183
STRSAFEAPI StringCbCopyA(STRSAFE_LPSTR pszDest, size_t cbDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:161
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
#define WDF_DRIVER_GLOBALS_NAME_LEN
Definition: wdfglobals.h:51
#define HRESULT_FACILITY(hr)
Definition: winerror.h:79
#define FACILITY_WIN32
Definition: winerror.h:27
#define HRESULT_CODE(hr)
Definition: winerror.h:76
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ _InitializeTag()

VOID FxDriver::_InitializeTag ( __in PFX_DRIVER_GLOBALS  Globals,
__in PWDF_DRIVER_CONFIG  Config 
)
static

Definition at line 266 of file fxdriver.cpp.

285{
286 PCHAR pBegin;
287 size_t length;
288
290
291 length = strlen(FxDriverGlobals->Public.DriverName);
292 pBegin = &FxDriverGlobals->Public.DriverName[0];
293
294 if (length >= 3) {
295 //
296 // If the driver name begins with "WDF" (case insensitive), start after
297 // "WDF"
298 //
299 if ((pBegin[0] == 'w' || pBegin[0] == 'W') &&
300 (pBegin[1] == 'd' || pBegin[1] == 'D') &&
301 (pBegin[2] == 'f' || pBegin[2] == 'F')) {
302 length -=3;
303 pBegin += 3;
304 }
305 }
306
307 if (length <= 2) {
308 //
309 // 2 or less characters is not a unique enough tag, just use the default
310 // tag.
311 //
312 FxDriverGlobals->Tag = FX_TAG;
313 }
314 else {
315
316 if (length > sizeof(ULONG)) {
317 length = sizeof(ULONG);
318 }
319
320 //
321 // This copies the bytes in the right order (so that they appear correct
322 // when dumped as a sequence of chars)
323 //
324 RtlCopyMemory(&FxDriverGlobals->Tag,
325 pBegin,
326 length);
327
328 FxDriverGlobals->Public.DriverTag = FxDriverGlobals->Tag;
329 }
330}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define FX_TAG
Definition: fxmacros.hpp:155
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_CHILD_LIST_CONFIG Config
Definition: wdfchildlist.h:476

◆ AddDevice()

_Must_inspect_result_ NTSTATUS FxDriver::AddDevice ( __in MdDeviceObject  PhysicalDeviceObject)

◆ AllocateDriverObjectExtensionAndStoreFxDriver()

_Must_inspect_result_ NTSTATUS FxDriver::AllocateDriverObjectExtensionAndStoreFxDriver ( VOID  )

Definition at line 130 of file fxdriverkm.cpp.

133{
135 FxDriver** ppDriver;
136
137 //
138 // Prefast is much happier if we take the size of the type rather then
139 // the size of the variable.
140 //
143 sizeof(FxDriver**),
144 (PVOID*)&ppDriver);
145 if (!NT_SUCCESS(status)) {
146 return status;
147 }
148
149 //
150 // If we succeeded in creating the driver object extension,
151 // then store our FxDriver pointer in the DriverObjectExtension.
152 //
153 *ppDriver = this;
154
155 return STATUS_SUCCESS;
156}
__inline MdDriverObject GetObject(VOID)
static __inline NTSTATUS MxAllocateDriverObjectExtension(_In_ MdDriverObject DriverObject, _In_ PVOID ClientIdentificationAddress, _In_ ULONG DriverObjectExtensionSize, _Post_ _At_(*DriverObjectExtension, _When_(return==0, __drv_aliasesMem __drv_allocatesMem(Mem) _Post_notnull_)) _When_(return==0, _Outptr_result_bytebuffer_(DriverObjectExtensionSize)) PVOID *DriverObjectExtension)
Definition: mxgeneralkm.h:396
#define FX_DRIVER_ID
Definition: fxdriver.hpp:49

Referenced by Initialize().

◆ ConfigureConstraints()

VOID FxDriver::ConfigureConstraints ( __in_opt PWDF_OBJECT_ATTRIBUTES  DriverAttributes)

Definition at line 564 of file fxdriver.cpp.

583{
584 BOOLEAN automaticLockingRequired;
585
586 automaticLockingRequired = FALSE;
587
588 // Initialize the mutex lock
590
591
592
593
594
595
596
597
598
600
603
604 //
605 // Use the caller supplied scope and level only if they are not
606 // InheritFromParent.
607 //
608 if (DriverAttributes != NULL) {
609
610 if (DriverAttributes->ExecutionLevel !=
612 m_ExecutionLevel = DriverAttributes->ExecutionLevel;
613 }
614
615 if (DriverAttributes->SynchronizationScope !=
617 m_SynchronizationScope = DriverAttributes->SynchronizationScope;
618 }
619 }
620
621 //
622 // If the driver asks for any synchronization, we synchronize the
623 // WDFDRIVER object's own callbacks as well.
624 //
625 // (No option to extend synchronization for regular operations
626 // across all WDFDEVICE objects)
627 //
630
631 automaticLockingRequired = TRUE;
632 }
633
634 //
635 // No FxDriver events are delivered from a thread that is
636 // not already at PASSIVE_LEVEL, so we don't need to
637 // allocate an FxSystemWorkItem if the execution level
638 // constraint is WdfExecutionLevelPassive.
639 //
640 // If any events are added FxDriver that could occur on a thread
641 // that is above PASSIVE_LEVEL, then an FxSystemWorkItem would
642 // need to be allocated to deliver those events similar to the
643 // code in FxIoQueue.
644 //
645
646 //
647 // Configure FxDriver event callback locks
648 //
649 if (automaticLockingRequired) {
651 }
652 else {
654 }
655}
unsigned char BOOLEAN
virtual void Initialize(FxObject *ParentObject)
FxDriverDeviceAdd m_DriverDeviceAdd
Definition: fxdriver.hpp:70
void SetCallbackLockPtr(FxCallbackLock *Lock)
Definition: fxcallback.hpp:105
VOID MarkPassiveCallbacks(__in FxObjectLockState State=ObjectLock)
Definition: fxobject.hpp:972
#define TRUE
Definition: types.h:120
@ ObjectDoNotLock
Definition: fxobject.hpp:128
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING _In_opt_ PWDF_OBJECT_ATTRIBUTES DriverAttributes
Definition: wdfdriver.h:217
@ WdfSynchronizationScopeInheritFromParent
Definition: wdfobject.h:63
@ WdfSynchronizationScopeQueue
Definition: wdfobject.h:65
@ WdfSynchronizationScopeDevice
Definition: wdfobject.h:64
@ WdfExecutionLevelInheritFromParent
Definition: wdfobject.h:53

Referenced by Initialize().

◆ DeleteObject()

virtual VOID FxDriver::DeleteObject ( VOID  )
inlinevirtual

Reimplemented from FxObject.

Definition at line 332 of file fxdriver.hpp.

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 }
static __inline KIRQL MxGetCurrentIrql()
Definition: mxgeneralkm.h:86
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693

Referenced by FxLibraryCommonUnregisterClient().

◆ Dispose()

BOOLEAN FxDriver::Dispose ( VOID  )
virtual

Reimplemented from FxObject.

Definition at line 128 of file fxdriver.cpp.

131{
132 if (m_DisposeList != NULL) {
134 }
135
136 return FxNonPagedObject::Dispose(); // __super call
137}
VOID WaitForEmpty(VOID)
virtual BOOLEAN Dispose(VOID)

◆ GetCallbackLockPtr()

virtual FxCallbackLock * FxDriver::GetCallbackLockPtr ( __deref_out FxObject **  LockObject)
inlinevirtual

Definition at line 298 of file fxdriver.hpp.

300 {
301
302 if (LockObject != NULL) {
304 }
305
306 return m_CallbackLockPtr;
307 }
#define LockObject(Object)
Definition: titypes.h:34

◆ GetConstraints()

virtual VOID FxDriver::GetConstraints ( __out WDF_EXECUTION_LEVEL ExecutionLevel,
__out WDF_SYNCHRONIZATION_SCOPE SynchronizationScope 
)
inlinevirtual

Implements IFxHasCallbacks.

Definition at line 282 of file fxdriver.hpp.

285 {
286
287 if (ExecutionLevel != NULL) {
288 *ExecutionLevel = m_ExecutionLevel;
289 }
290
291 if (SynchronizationScope != NULL) {
292 *SynchronizationScope = m_SynchronizationScope;
293 }
294 }

Referenced by FxDeviceBase::ConfigureConstraints().

◆ GetDisposeList()

__inline FxDisposeList * FxDriver::GetDisposeList ( )
inline

Definition at line 354 of file fxdriver.hpp.

356 {
357 return m_DisposeList;
358 }

Referenced by FxObject::FinalRelease(), and FxObject::QueueDeferredDisposeLocked().

◆ GetDriverDeviceAddMethod()

◆ GetDriverObject()

◆ GetFxDriver()

FxDriver * FxDriver::GetFxDriver ( __in MdDriverObject  DriverObject)
static

Definition at line 159 of file fxdriverkm.cpp.

162{
163 FxDriver* objExt;
166 ASSERT(objExt != NULL);
167
168 return objExt;
169}
static __inline PVOID MxGetDriverObjectExtension(__in MdDriverObject DriverObject, __in PVOID ClientIdentificationAddress)
Definition: mxgeneralkm.h:385
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213

◆ GetHandle()

__inline WDFDRIVER FxDriver::GetHandle ( VOID  )
inline

Definition at line 202 of file fxdriver.hpp.

205 {
206 return (WDFDRIVER) GetObjectHandle();
207 }
return pObject GetObjectHandle()

Referenced by FxPkgGeneral::ConfigureConstraints(), FxPkgGeneral::ConfigureFileObjectClass(), and FxPkgGeneral::OnCreate().

◆ GetRegistryPath()

_Must_inspect_result_ FxString * FxDriver::GetRegistryPath ( VOID  )

Definition at line 539 of file fxdriver.cpp.

542{
544
547
548 if (pString != NULL) {
550
552
553 if (!NT_SUCCESS(status)) {
554 pString->Release();
555 pString = NULL;
556 }
557 }
558
559 return pString;
560}
virtual ULONG Release(__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxobject.hpp:853
_Must_inspect_result_ NTSTATUS Assign(__in PCWSTR SourceString)
Definition: fxstring.cpp:57
FxString * pString
#define WDF_NO_OBJECT_ATTRIBUTES
Definition: wdftypes.h:105

◆ GetRegistryPathUnicodeString()

PUNICODE_STRING FxDriver::GetRegistryPathUnicodeString ( VOID  )
inline

Definition at line 243 of file fxdriver.hpp.

246 {
247 return &m_RegistryPath;
248 }

Referenced by FxWmiIrpHandler::_RegInfo(), and if().

◆ Initialize()

_Must_inspect_result_ NTSTATUS FxDriver::Initialize ( __in PCUNICODE_STRING  RegistryPath,
__in PWDF_DRIVER_CONFIG  Config,
__in_opt PWDF_OBJECT_ATTRIBUTES  DriverAttributes 
)

Definition at line 334 of file fxdriver.cpp.

339{
340 PFX_DRIVER_GLOBALS FxDriverGlobals = GetDriverGlobals();
342
343 // WDFDRIVER can not be deleted by the device driver
345
347
348 //
349 // Configure Constraints
350 //
352
353 if (m_DriverObject.GetObject() == NULL) {
354 return STATUS_UNSUCCESSFUL;
355 }
356
357 // Allocate FxDisposeList
359 if (!NT_SUCCESS(status)) {
360 return status;
361 }
362
363 //
364 // Store FxDriver in Driver object extension
365 //
367 if (!NT_SUCCESS(status)) {
368 return status;
369 }
370
371 //
372 // Store away the callback functions.
373 //
374 if ((Config->DriverInitFlags & WdfDriverInitNoDispatchOverride) == 0) {
375 //
376 // Caller doesn't want to override the dispatch table. That
377 // means that they want to create everything and still be in
378 // control (or at least the port driver will take over)
379 //
380 m_DriverDeviceAdd.Method = Config->EvtDriverDeviceAdd;
381 m_DriverUnload.Method = Config->EvtDriverUnload;
382 }
383
384 if (ArgRegistryPath != NULL) {
386
387 length = ArgRegistryPath->Length + sizeof(UNICODE_NULL);
388
389 m_RegistryPath.Length = ArgRegistryPath->Length;
391 m_RegistryPath.Buffer = (PWSTR) FxPoolAllocate(
393
394 if (m_RegistryPath.Buffer != NULL) {
396 ArgRegistryPath->Buffer,
397 ArgRegistryPath->Length);
398
399 //
400 // other parts of WDF assumes m_RegistryPath.Buffer is
401 // a null terminated string. make sure it is.
402 //
404 }
405 else {
406 //
407 // We failed to allocate space for the registry path
408 // so set the length to 0.
409 //
412
414 }
415 }
416
417 if (NT_SUCCESS(status)) {
418 if ((Config->DriverInitFlags & WdfDriverInitNoDispatchOverride) == 0) {
419 UCHAR i;
420
421 //
422 // Set up dispatch routines.
423 //
424 if (Config->DriverInitFlags & WdfDriverInitNonPnpDriver) {
425 //
426 // NT4 style drivers must clear the AddDevice field in the
427 // driver object so that they can be unloaded while still
428 // having device objects around.
429 //
430 // If AddDevice is set, NT considers the driver a pnp driver
431 // and will not allow net stop to unload the driver.
432 //
434
435 //
436 // Unload for an NT4 driver is still optional if the driver
437 // does not want to be stopped (through net stop for
438 // instance).
439 //
440 if (Config->EvtDriverUnload != NULL) {
442 }
443 else {
445 }
446
447 }
448 else {
449 //
450 // PnP driver, set our routines up
451 //
454 }
455
456 //
457 // For any major control code that we use a remove lock, the
458 // following locations must be updated:
459 //
460 // 1) FxDevice::_RequiresRemLock() which decides if the remlock
461 // is required
462 // 2) FxDefaultIrpHandler::Dispatch might need to be changed if
463 // there is catchall generic post processing that must be done
464 // 3) Whereever the major code irp handler completes the irp or
465 // sends it down the stack. A good design would have all
466 // spots in the irp handler where this is done to call a
467 // common function.
468 //
470
471#if ((FX_CORE_MODE)==(FX_CORE_KERNEL_MODE))
472 for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++) {
475 }
476 else {
478 }
479 }
480#else // USER_MODE
481 for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++) {
484 }
485 else {
487 }
488 }
489#endif
490 }
491
492 //
493 // Determine if the debugger is connected.
494 //
495#if ((FX_CORE_MODE)==(FX_CORE_KERNEL_MODE))
498 }
499#endif
500
501 //
502 // Log this notable event after tracing has been initialized.
503 //
504
505
506
507
508
509
510 if ((Config->DriverInitFlags & WdfDriverInitNonPnpDriver) &&
511 Config->EvtDriverUnload == NULL) {
512
514 FxDriverGlobals, TRACE_LEVEL_INFORMATION, TRACINGDRIVER,
515 "Driver Object %p, reg path %wZ cannot be "
516 "unloaded, no DriverUnload routine specified",
518 }
519
520#if FX_IS_USER_MODE
521 //
522 // Open a R/W handle to the driver's service parameters key
523 //
524 status = OpenParametersKey();
525 if (!NT_SUCCESS(status)) {
527 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDRIVER,
528 "Cannot open Driver Parameters key %!STATUS!",
529 status);
530 }
531#endif
532 }
533
534 return status;
535}
static FxDeviceRemLockAction __inline _RequiresRemLock(__in UCHAR MajorCode, __in UCHAR MinorCode)
Definition: fxdevice.hpp:933
static VOID DispatchWithLockUm(_In_ MdDeviceObject DeviceObject, _In_ MdIrp Irp, _In_opt_ IUnknown *Context)
Definition: fxdeviceum.cpp:48
static _Must_inspect_result_ NTSTATUS STDCALL DispatchWithLock(__in MdDeviceObject DeviceObject, __in MdIrp OriginalIrp)
Definition: fxdevice.cpp:1336
static VOID DispatchUm(_In_ MdDeviceObject DeviceObject, _In_ MdIrp Irp, _In_opt_ IUnknown *Context)
Definition: fxdeviceum.cpp:32
static _Must_inspect_result_ NTSTATUS STDCALL Dispatch(__in MdDeviceObject DeviceObject, __in MdIrp OriginalIrp)
Definition: fxdevice.cpp:1551
static NTSTATUS _Create(PFX_DRIVER_GLOBALS FxDriverGlobals, PVOID WdmObject, FxDisposeList **pObject)
PFN_WDF_DRIVER_UNLOAD Method
VOID ConfigureConstraints(__in_opt PWDF_OBJECT_ATTRIBUTES DriverAttributes)
Definition: fxdriver.cpp:564
_Must_inspect_result_ NTSTATUS AllocateDriverObjectExtensionAndStoreFxDriver(VOID)
Definition: fxdriverkm.cpp:130
static MdDriverAddDeviceType AddDevice
Definition: fxdriver.hpp:125
FxDriverUnload m_DriverUnload
Definition: fxdriver.hpp:130
static MdDriverUnloadType Unload
Definition: fxdriver.hpp:369
VOID MarkNoDeleteDDI(__in FxObjectLockState State=ObjectLock)
Definition: fxobject.hpp:1118
VOID MarkDisposeOverride(__in FxObjectLockState State=ObjectLock)
Definition: fxobject.hpp:1101
VOID SetDriverUnload(_In_ MdDriverUnload Value)
VOID SetDriverExtensionAddDevice(_In_ MdDriverAddDevice Value)
VOID SetMajorFunction(_In_ UCHAR i, _In_ MdDriverDispatch Value)
#define PagedPool
Definition: env_spec_w32.h:308
@ FxDeviceRemLockNotRequired
Definition: fxdevice.hpp:79
#define UNICODE_NULL
unsigned short USHORT
Definition: pedump.c:61
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint16_t * PWSTR
Definition: typedefs.h:56
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define WDFCASSERT(c)
Definition: wdfassert.h:93
@ WdfDriverInitNonPnpDriver
Definition: wdfdriver.h:51
@ WdfDriverInitNoDispatchOverride
Definition: wdfdriver.h:52
#define IRP_MN_REMOVE_DEVICE
#define IRP_MJ_MAXIMUM_FUNCTION
#define KD_DEBUGGER_ENABLED
Definition: kdfuncs.h:130
#define KD_DEBUGGER_NOT_PRESENT
Definition: kdfuncs.h:133
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by if().

◆ InitializeInternal()

VOID FxDriver::InitializeInternal ( VOID  )

◆ IsDriverObjectFlagSet()

BOOLEAN FxDriver::IsDriverObjectFlagSet ( _In_ FxDriverObjectUmFlags  Flag)
inline

Definition at line 411 of file fxdriver.hpp.

414 {
416 }
BOOLEAN IsDriverObjectFlagSet(_In_ FxDriverObjectUmFlags Flag)
Definition: xml2sdb.h:80

◆ QueryInterface()

virtual NTSTATUS FxDriver::QueryInterface ( __inout FxQueryInterfaceParams Params)
inlinevirtual

Definition at line 314 of file fxdriver.hpp.

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 }
virtual _Must_inspect_result_ NTSTATUS QueryInterface(__in FxQueryInterfaceParams *Params)
Definition: fxobject.cpp:255
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:308

◆ SetDriverObjectFlag()

VOID FxDriver::SetDriverObjectFlag ( _In_ FxDriverObjectUmFlags  Flag)
inline

Definition at line 403 of file fxdriver.hpp.

406 {
408 }
VOID SetDriverObjectFlag(_In_ FxDriverObjectUmFlags Flag)

Friends And Related Function Documentation

◆ FxDevice

friend class FxDevice
friend

Definition at line 56 of file fxdriver.hpp.

◆ FxPackage

friend class FxPackage
friend

Definition at line 57 of file fxdriver.hpp.

◆ FxWmiIrpHandler

friend class FxWmiIrpHandler
friend

Definition at line 58 of file fxdriver.hpp.

Member Data Documentation

◆ AddDevice

_Must_inspect_result_ NTSTATUS FxDriver::AddDevice
staticprivate

Definition at line 125 of file fxdriver.hpp.

Referenced by Initialize().

◆ m_CallbackLockObjectPtr

FxObject* FxDriver::m_CallbackLockObjectPtr
private

Definition at line 101 of file fxdriver.hpp.

Referenced by ConfigureConstraints(), FxDriver(), and GetCallbackLockPtr().

◆ m_CallbackLockPtr

FxCallbackLock* FxDriver::m_CallbackLockPtr
private

Definition at line 100 of file fxdriver.hpp.

Referenced by ConfigureConstraints(), FxDriver(), and GetCallbackLockPtr().

◆ m_CallbackMutexLock

FxCallbackMutexLock FxDriver::m_CallbackMutexLock
private

Definition at line 93 of file fxdriver.hpp.

Referenced by ConfigureConstraints().

◆ m_Config

WDF_DRIVER_CONFIG FxDriver::m_Config
private

Definition at line 106 of file fxdriver.hpp.

Referenced by FxDriver().

◆ m_DebuggerConnected

BOOLEAN FxDriver::m_DebuggerConnected
private

Definition at line 65 of file fxdriver.hpp.

Referenced by FxDriver(), and Initialize().

◆ m_DisposeList

FxDisposeList* FxDriver::m_DisposeList
private

Definition at line 111 of file fxdriver.hpp.

Referenced by Dispose(), FxDriver(), GetDisposeList(), Initialize(), and ~FxDriver().

◆ m_DriverDeviceAdd

FxDriverDeviceAdd FxDriver::m_DriverDeviceAdd
private

Definition at line 70 of file fxdriver.hpp.

Referenced by ConfigureConstraints(), GetDriverDeviceAddMethod(), and Initialize().

◆ m_DriverObject

◆ m_DriverUnload

FxDriverUnload FxDriver::m_DriverUnload

Definition at line 130 of file fxdriver.hpp.

Referenced by Initialize().

◆ m_ExecutionLevel

WDF_EXECUTION_LEVEL FxDriver::m_ExecutionLevel
private

Definition at line 77 of file fxdriver.hpp.

Referenced by ConfigureConstraints(), FxDriver(), and GetConstraints().

◆ m_RegistryPath

UNICODE_STRING FxDriver::m_RegistryPath
private

◆ m_SynchronizationScope

WDF_SYNCHRONIZATION_SCOPE FxDriver::m_SynchronizationScope
private

Definition at line 78 of file fxdriver.hpp.

Referenced by ConfigureConstraints(), FxDriver(), and GetConstraints().

◆ Unload

VOID FxDriver::Unload
static

Definition at line 369 of file fxdriver.hpp.

Referenced by Initialize(), and WdfDriverMiniportUnload().


The documentation for this class was generated from the following files: