ReactOS  0.4.15-dev-2355-gaf9df93
FxDevice Class Reference

#include <fxdevice.hpp>

Inheritance diagram for FxDevice:
Collaboration diagram for FxDevice:

Public Member Functions

 FxDevice (__in FxDriver *ArgDriver)
 
 ~FxDevice (VOID)
 
_Must_inspect_result_ NTSTATUS DeleteDeviceFromFailedCreate (__in NTSTATUS FailedStatus, __in BOOLEAN UseStateMachine)
 
__inline FxPackageGetDispatchPackage (__in UCHAR MajorFunction)
 
MdRemoveLock GetRemoveLock (VOID)
 
MdDeviceObject __inline GetSafePhysicalDevice (VOID)
 
VOID SetInterruptThreadpool (_In_ FxInterruptThreadpool *Pool)
 
FxInterruptThreadpoolGetInterruptThreadpool (VOID)
 
_Must_inspect_result_ NTSTATUS DispatchPreprocessedIrp (__in MdIrp Irp, __in PVOID DispatchContext)
 
__inline WDF_DEVICE_IO_TYPE GetIoType (VOID)
 
__inline WDF_DEVICE_IO_TYPE GetIoTypeForReadWriteBufferAccess (VOID)
 
__inline CHAR GetDefaultPriorityBoost (VOID)
 
__inline WDF_FILEOBJECT_CLASS GetFileObjectClass (VOID)
 
__inline VOID SetFileObjectClass (__in WDF_FILEOBJECT_CLASS FileObjectClass)
 
VOID InstallPackage (__inout FxPackage *Package)
 
__inline WDF_DEVICE_PNP_STATE GetDevicePnpState ()
 
__inline WDF_DEVICE_POWER_STATE GetDevicePowerState ()
 
__inline WDF_DEVICE_POWER_POLICY_STATE GetDevicePowerPolicyState ()
 
__inline VOID SetDevicePnpState (__in WDF_DEVICE_PNP_STATE DeviceState)
 
__inline VOID SetDevicePowerState (__in WDF_DEVICE_POWER_STATE DeviceState)
 
__inline VOID SetDevicePowerPolicyState (__in WDF_DEVICE_POWER_POLICY_STATE DeviceState)
 
__inline BOOLEAN IsPnp (VOID)
 
__inline BOOLEAN IsLegacy (VOID)
 
__inline BOOLEAN IsExclusive (VOID)
 
__inline BOOLEAN IsFdo (VOID)
 
__inline FxPkgFdoGetFdoPkg (VOID)
 
__inline BOOLEAN IsPdo (VOID)
 
__inline FxPkgPdoGetPdoPkg (VOID)
 
_Must_inspect_result_ NTSTATUS CreateDevice (__in PWDFDEVICE_INIT DeviceInit)
 
__inline VOID SetParentWaitingOnRemoval (VOID)
 
VOID FinishInitializing (VOID)
 
VOID Destroy (VOID)
 
virtual VOID DeleteObject (VOID)
 
virtual BOOLEAN Dispose (VOID)
 
__inline PWDF_OBJECT_ATTRIBUTES GetRequestAttributes (VOID)
 
PVOID AllocateRequestMemory (__in_opt PWDF_OBJECT_ATTRIBUTES Attributes)
 
VOID FreeRequestMemory (__in FxRequest *Request)
 
virtual _Must_inspect_result_ NTSTATUS AddIoTarget (__inout FxIoTarget *IoTarget)
 
virtual VOID RemoveIoTarget (__inout FxIoTarget *IoTarget)
 
virtual _Must_inspect_result_ NTSTATUS AllocateEnumInfo (VOID)
 
virtual VOID AddChildList (__inout FxChildList *List)
 
virtual VOID RemoveChildList (__inout FxChildList *List)
 
virtual _Must_inspect_result_ NTSTATUS AllocateDmaEnablerList (VOID)
 
virtual VOID AddDmaEnabler (__inout FxDmaEnabler *Enabler)
 
virtual VOID RemoveDmaEnabler (__inout FxDmaEnabler *Enabler)
 
virtual FxIoTargetGetDefaultIoTarget (VOID)
 
FxIoTargetSelfGetSelfIoTarget (VOID)
 
virtual _Must_inspect_result_ NTSTATUS QueryInterface (__inout FxQueryInterfaceParams *Params)
 
__inline BOOLEAN IsFilter ()
 
_Must_inspect_result_ NTSTATUS SetFilter (__in BOOLEAN Value)
 
__inline BOOLEAN IsPowerPageableCapable (VOID)
 
_Must_inspect_result_ NTSTATUS Initialize (__in PWDFDEVICE_INIT DeviceInit, __in_opt PWDF_OBJECT_ATTRIBUTES DeviceAttributes)
 
VOID ConfigureAutoForwardCleanupClose (__in PWDFDEVICE_INIT DeviceInit)
 
_Must_inspect_result_ NTSTATUS PostInitialize (VOID)
 
_Must_inspect_result_ NTSTATUS PdoInitialize (__in PWDFDEVICE_INIT DeviceInit)
 
_Must_inspect_result_ NTSTATUS FdoInitialize (__in PWDFDEVICE_INIT DeviceInit)
 
_Must_inspect_result_ NTSTATUS ControlDeviceInitialize (__in PWDFDEVICE_INIT DeviceInit)
 
VOID ControlDeviceDelete (VOID)
 
_Must_inspect_result_ NTSTATUS OpenSettingsKey (__out HANDLE *Key, __in ACCESS_MASK DesiredAccess=STANDARD_RIGHTS_ALL)
 
VOID DeleteSymbolicLink (VOID)
 
__inline BYTE GetCallbackFlagsLocked (VOID)
 
__inline BYTE GetCallbackFlags (VOID)
 
__inline VOID SetCallbackFlagsLocked (__in BYTE Flags)
 
__inline VOID SetCallbackFlags (__in BYTE Flags)
 
__inline VOID ClearCallbackFlagsLocked (__in BYTE Flags)
 
__inline VOID ClearCallbackFlags (__in BYTE Flags)
 
FxCxDeviceInfoGetCxDeviceInfo (__in FxDriver *CxDriver)
 
__inline BOOLEAN IsCxDriverInIoPath (__in FxDriver *CxDriver)
 
__inline BOOLEAN IsCxInIoPath (VOID)
 
__inline FxDriverGetCxDriver (__in FxCxDeviceInfo *CxDeviceInfo)
 
BOOLEAN IsRemoveLockEnabledForIo (VOID)
 
VOID FxLogDeviceStartTelemetryEvent (VOID)
 
virtual VOID SetDeviceTelemetryInfoFlags (_In_ FxDeviceInfoFlags Flag)
 
USHORT GetDeviceTelemetryInfoFlags (VOID)
 
__inline CHAR GetStackSize (VOID)
 
__inline VOID SetStackSize (_In_ CHAR Size)
 
NTSTATUS UpdateInterruptThreadpoolLimits (VOID)
 
FxCmResListGetTranslatedResources ()
 
VOID DetachDevice (VOID)
 
VOID InvalidateDeviceState (VOID)
 
NTSTATUS CreateSymbolicLink (_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_ PCUNICODE_STRING SymbolicLinkName)
 
VOID SetCleanupFromFailedCreate (BOOLEAN Value)
 
BOOLEAN IsInterfaceRegistered (_In_ const GUID *InterfaceClassGUID, _In_opt_ PCUNICODE_STRING RefString)
 
_Must_inspect_result_ NTSTATUS OpenDevicemapKeyWorker (_In_ PFX_DRIVER_GLOBALS pFxDriverGlobals, _In_ PCUNICODE_STRING KeyName, _In_ ACCESS_MASK DesiredAccess, _In_ FxRegKey *pKey)
 
_Must_inspect_result_ NTSTATUS AssignProperty (_In_ PVOID PropertyData, _In_ FxPropertyType FxPropertyType, _In_ DEVPROPTYPE Type, _In_ ULONG BufferLength, _In_opt_ PVOID PropertyBuffer)
 
_Must_inspect_result_ NTSTATUS FxValidateInterfacePropertyData (_In_ PWDF_DEVICE_INTERFACE_PROPERTY_DATA PropertyData)
 
VOID GetDeviceStackIoType (_Out_ WDF_DEVICE_IO_TYPE *ReadWriteIoType, _Out_ WDF_DEVICE_IO_TYPE *IoControlIoType)
 
__inline UMINT::WDF_DEVICE_IO_BUFFER_RETRIEVAL GetRetrievalMode (VOID)
 
__inline WDF_DEVICE_IO_TYPE GetPreferredRWTransferMode (VOID)
 
__inline WDF_DEVICE_IO_TYPE GetPreferredIoctlTransferMode (VOID)
 
__inline ULONG GetDirectTransferThreshold (VOID)
 
NTSTATUS ProcessWmiPowerQueryOrSetData (_In_ RdWmiPowerAction Action, _Out_ BOOLEAN *QueryResult)
 
NTSTATUS NtStatusFromHr (_In_ HRESULT Hr)
 
IWudfDeviceStack * GetDeviceStack (VOID)
 
IWudfDeviceStack2 * GetDeviceStack2 (VOID)
 
VOID RetrieveDeviceRegistrySettings (VOID)
 
BOOLEAN IsDirectHardwareAccessAllowed ()
 
BOOLEAN IsInterruptAccessAllowed (VOID)
 
BOOLEAN AreRegistersMappedToUsermode (VOID)
 
PVOID GetPseudoAddressFromSystemAddress (__in PVOID SystemAddress)
 
PVOID GetSystemAddressFromPseudoAddress (__in PVOID PseudoAddress)
 
BOOL IsRegister (__in WDF_DEVICE_HWACCESS_TARGET_TYPE Type)
 
BOOL IsPort (__in WDF_DEVICE_HWACCESS_TARGET_TYPE Type)
 
BOOL IsBufferType (__in WDF_DEVICE_HWACCESS_TARGET_TYPE Type)
 
SIZE_T ReadRegister (__in WDF_DEVICE_HWACCESS_TARGET_SIZE Size, __in PVOID Register)
 
VOID ReadRegisterBuffer (__in WDF_DEVICE_HWACCESS_TARGET_SIZE Size, __in PVOID Register, __out_ecount_full(Count) PVOID Buffer, __in ULONG Count)
 
VOID WriteRegister (__in WDF_DEVICE_HWACCESS_TARGET_SIZE Size, __in PVOID Register, __in SIZE_T Value)
 
VOID WriteRegisterBuffer (__in WDF_DEVICE_HWACCESS_TARGET_SIZE Size, __in PVOID Register, __in_ecount(Count) PVOID Buffer, __in ULONG Count)
 
VOID RetrieveDeviceInfoRegistrySettings (_Out_ PCWSTR *GroupId, _Out_ PUMDF_DRIVER_REGSITRY_INFO DeviceRegInfo)
 
- Public Member Functions inherited from FxDeviceBase
NTSTATUS ConfigureConstraints (__in_opt PWDF_OBJECT_ATTRIBUTES ObjectAttributes)
 
VOID GetConstraints (__out_opt WDF_EXECUTION_LEVEL *ExecutionLevel, __out_opt WDF_SYNCHRONIZATION_SCOPE *SynchronizationScope)
 
FxCallbackLockGetCallbackLockPtr (__out_opt FxObject **LockObject)
 
__inline FxDriverGetDriver (VOID)
 
MdDeviceObject __inline GetDeviceObject (VOID)
 
__inline MxDeviceObjectGetMxDeviceObject (VOID)
 
ULONG __inline GetDeviceObjectFlags (VOID)
 
VOID __inline SetDeviceObjectFlags (_In_ ULONG Flags)
 
MdDeviceObject __inline GetAttachedDevice (VOID)
 
ULONG __inline GetAttachedDeviceObjectFlags (VOID)
 
MdDeviceObject __inline GetPhysicalDevice (VOID)
 
WDFDEVICE __inline GetHandle (VOID)
 
__inline _Must_inspect_result_ NTSTATUS AcquireDmaPacketTransaction (VOID)
 
__inline VOID ReleaseDmaPacketTransaction (VOID)
 
VOID AddToDisposeList (__inout FxObject *Object)
 
_Must_inspect_result_ NTSTATUS QueryInterface (__inout FxQueryInterfaceParams *Params)
 
_Must_inspect_result_ NTSTATUS QueryForInterface (__in const GUID *InterfaceType, __out PINTERFACE Interface, __in USHORT Size, __in USHORT Version, __in PVOID InterfaceSpecificData, __in_opt MdDeviceObject TargetDevice=NULL)
 
__inline MdDeviceObject GetAttachedDeviceReference (VOID)
 
_Must_inspect_result_ NTSTATUS AllocateTarget (_Out_ FxIoTarget **Target, _In_ BOOLEAN SelfTarget)
 
- 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)
 
_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
 

Static Public Member Functions

static _Must_inspect_result_ NTSTATUS _Create (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDFDEVICE_INIT *DeviceInit, __in_opt PWDF_OBJECT_ATTRIBUTES DeviceAttributes, __out FxDevice **Device)
 
static FxDeviceRemLockAction __inline _RequiresRemLock (__in UCHAR MajorCode, __in UCHAR MinorCode)
 
static FxDeviceGetFxDevice (__in MdDeviceObject DeviceObject)
 
static _Must_inspect_result_ NTSTATUS STDCALL Dispatch (__in MdDeviceObject DeviceObject, __in MdIrp OriginalIrp)
 
static VOID DispatchUm (_In_ MdDeviceObject DeviceObject, _In_ MdIrp Irp, _In_opt_ IUnknown *Context)
 
static VOID DispatchWithLockUm (_In_ MdDeviceObject DeviceObject, _In_ MdIrp Irp, _In_opt_ IUnknown *Context)
 
static _Must_inspect_result_ NTSTATUS STDCALL DispatchWithLock (__in MdDeviceObject DeviceObject, __in MdIrp OriginalIrp)
 
static __inline CCHAR GetCxDriverIndex (__in FxCxDeviceInfo *CxDeviceInfo)
 
static __inline NTSTATUS _OpenDeviceRegistryKey (_In_ MdDeviceObject DeviceObject, _In_ ULONG DevInstKeyType, _In_ ACCESS_MASK DesiredAccess, _Out_ PHANDLE DevInstRegKey)
 
static __inline NTSTATUS _GetDeviceProperty (_In_ MdDeviceObject DeviceObject, _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty, _In_ ULONG BufferLength, _Out_opt_ PVOID PropertyBuffer, _Out_ PULONG ResultLength)
 
static _Must_inspect_result_ NTSTATUS _ValidateOpenKeyParams (_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device)
 
static _Must_inspect_result_ NTSTATUS _OpenKey (_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device, _In_ ULONG DeviceInstanceKeyType, _In_ ACCESS_MASK DesiredAccess, _In_opt_ PWDF_OBJECT_ATTRIBUTES KeyAttributes, _Out_ WDFKEY *Key)
 
static _Must_inspect_result_ NTSTATUS _AllocAndQueryProperty (_In_ PFX_DRIVER_GLOBALS Globals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device, _In_opt_ MdDeviceObject RemotePdo, _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty, _In_ POOL_TYPE PoolType, _In_opt_ PWDF_OBJECT_ATTRIBUTES PropertyMemoryAttributes, _Out_ WDFMEMORY *PropertyMemory)
 
static _Must_inspect_result_ NTSTATUS _QueryProperty (_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device, _In_opt_ MdDeviceObject RemotePdo, _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty, _In_ ULONG BufferLength, _Out_opt_ PVOID PropertyBuffer, _Out_opt_ PULONG ResultLength)
 
static VOID STDCALL _InterfaceReferenceNoOp (__in_opt PVOID Context)
 
static VOID STDCALL _InterfaceDereferenceNoOp (__in_opt PVOID Context)
 
static FxWdmDeviceExtension_GetFxWdmExtension (__in MdDeviceObject DeviceObject)
 
static _Must_inspect_result_ NTSTATUS _AllocAndQueryPropertyEx (_In_ PFX_DRIVER_GLOBALS DriverGlobals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device, _In_ PVOID PropertyData, _In_ FxPropertyType FxPropertyType, _In_ POOL_TYPE PoolType, _In_opt_ PWDF_OBJECT_ATTRIBUTES PropertyMemoryAttributes, _Out_ WDFMEMORY *PropertyMemory, _Out_ PDEVPROPTYPE PropertyType)
 
static _Must_inspect_result_ NTSTATUS _QueryPropertyEx (_In_ PFX_DRIVER_GLOBALS DriverGlobals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device, _In_ PVOID PropertyData, _In_ FxPropertyType FxPropertyType, _In_ ULONG BufferLength, _Out_ PVOID PropertyBuffer, _Out_ PULONG ResultLength, _Out_ PDEVPROPTYPE PropertyType)
 
static VOID GetPreferredTransferMode (_In_ MdDeviceObject DeviceObject, _Out_ UMINT::WDF_DEVICE_IO_BUFFER_RETRIEVAL *RetrievalMode, _Out_ WDF_DEVICE_IO_TYPE *RWPreference, _Out_ WDF_DEVICE_IO_TYPE *IoctlPreference)
 
static WUDF_INTERFACE_CONTEXT RemoteInterfaceArrival (_In_ IWudfDevice *DeviceObject, _In_ LPCGUID DeviceInterfaceGuid, _In_ PCWSTR SymbolicLink)
 
static void RemoteInterfaceRemoval (_In_ IWudfDevice *DeviceObject, _In_ WUDF_INTERFACE_CONTEXT RemoteInterfaceID)
 
static void PoFxDevicePowerRequired (_In_ MdDeviceObject DeviceObject)
 
static void PoFxDevicePowerNotRequired (_In_ MdDeviceObject DeviceObject)
 
static BOOL TransportQueryId (_In_ IWudfDevice *DeviceObject, _In_ DWORD Id, _In_ PVOID DataBuffer, _In_ SIZE_T cbDataBufferSize)
 
static NTSTATUS NtStatusFromHr (_In_ IWudfDeviceStack *DevStack, _In_ HRESULT Hr)
 
static ULONG __inline GetLength (__in WDF_DEVICE_HWACCESS_TARGET_SIZE Size)
 
- Static Public Member Functions inherited from FxDeviceBase
static FxDeviceBase_SearchForDevice (__in FxObject *Object, __out_opt IFxHasCallbacks **Callbacks)
 
static FxDeviceBase_SearchForDevice (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes)
 
- 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

CfxDevicem_ParentDevice
 
UNICODE_STRING m_DeviceName
 
UNICODE_STRING m_SymbolicLinkName
 
UNICODE_STRING m_MofResourceName
 
BOOLEAN m_PdoKnown
 
BOOLEAN m_AutoForwardCleanupClose
 
BOOLEAN m_SelfIoTargetNeeded
 
WDF_FILEOBJECT_CLASS m_FileObjectClass
 
FxSpinLockTransactionedList m_IoTargetsList
 
LIST_ENTRY m_PreprocessInfoListHead
 
LIST_ENTRY m_CxDeviceInfoListHead
 
FxPkgIom_PkgIo
 
FxPkgPnpm_PkgPnp
 
FxPkgGeneralm_PkgGeneral
 
FxWmiIrpHandlerm_PkgWmi
 
FxDefaultIrpHandlerm_PkgDefault
 
BOOLEAN m_CleanupFromFailedCreate
 
FxMessageDispatchm_Dispatcher
 
IWudfDeviceStack * m_DevStack
 
HKEY m_PdoDevKey
 
PWSTR m_DeviceKeyPath
 
PWSTR m_KernelDeviceName
 
PWSTR m_DeviceInstanceId
 
UMINT::WDF_DEVICE_IO_BUFFER_RETRIEVAL m_RetrievalMode
 
WDF_DEVICE_IO_TYPE m_IoctlIoType
 
ULONG m_DirectTransferThreshold
 
WDF_DIRECT_HARDWARE_ACCESS_TYPE m_DirectHardwareAccess
 
WDF_REGISTER_ACCESS_MODE_TYPE m_RegisterAccessMode
 
WDF_FILE_OBJECT_POLICY_TYPE m_FileObjectPolicy
 
WDF_FS_CONTEXT_USE_POLICY_TYPE m_FsContextUsePolicy
 
FxInterruptThreadpoolm_InteruptThreadpool
 
- Public Attributes inherited from FxDeviceBase
FxDisposeListm_DisposeList
 

Protected Attributes

LIST_ENTRY m_FileObjectListHead
 
NPAGED_LOOKASIDE_LIST m_RequestLookasideList
 
size_t m_RequestLookasideListElementSize
 
WDF_OBJECT_ATTRIBUTES m_RequestAttributes
 
- Protected Attributes inherited from FxDeviceBase
FxDriverm_Driver
 
MxDeviceObject m_DeviceObject
 
MxDeviceObject m_AttachedDevice
 
MxDeviceObject m_PhysicalDevice
 
FxCallbackLockm_CallbackLockPtr
 
FxObjectm_CallbackLockObjectPtr
 
WDF_EXECUTION_LEVEL m_ExecutionLevel
 
WDF_SYNCHRONIZATION_SCOPE m_SynchronizationScope
 
LONG m_DmaPacketTransactionStatus
 
- Protected Attributes inherited from FxObject
union {
   CfxDeviceBase *   m_DeviceBase
 
   CfxDevice *   m_Device
 
}; 
 

Private Member Functions

VOID SetInitialState (VOID)
 
_Must_inspect_result_ NTSTATUS PreprocessIrp (__in MdIrp Irp)
 
_Must_inspect_result_ NTSTATUS DeleteDeviceFromFailedCreateNoDelete (__in NTSTATUS FailedStatus, __in BOOLEAN UseStateMachine)
 
VOID SetFilterIoType (VOID)
 
VOID DestructorInternal (VOID)
 
NTSTATUS WmiPkgRegister (VOID)
 
VOID WmiPkgDeregister (VOID)
 
VOID WmiPkgCleanup (VOID)
 

Static Private Member Functions

static _Must_inspect_result_ NTSTATUS _AcquireOptinRemoveLock (__in MdDeviceObject DeviceObject, __in MdIrp Irp)
 

Private Attributes

WDF_DEVICE_PNP_STATE m_CurrentPnpState
 
WDF_DEVICE_POWER_STATE m_CurrentPowerState
 
WDF_DEVICE_POWER_POLICY_STATE m_CurrentPowerPolicyState
 
WDF_DEVICE_IO_TYPE m_ReadWriteIoType
 
BYTE m_CallbackFlags
 
BOOLEAN m_Filter
 
BOOLEAN m_PowerPageableCapable
 
BOOLEAN m_ParentWaitingOnChild
 
BOOLEAN m_Exclusive
 
BOOLEAN m_Legacy
 
BOOLEAN m_DeviceObjectDeleted
 
CHAR m_DefaultPriorityBoost
 
USHORT m_DeviceTelemetryInfoFlags
 

Static Private Attributes

static const CHAR m_PriorityBoosts []
 
static MdCompletionRoutineType _CompletionRoutineForRemlockMaintenance
 

Friends

class FxDriver
 
class FxIrp
 
class FxFileObject
 
class FxPkgPnp
 
VOID GetTriageInfo (VOID)
 

Additional Inherited Members

- Protected Member Functions inherited from FxDeviceBase
 FxDeviceBase (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxDriver *Driver, __in WDFTYPE Type, __in USHORT Size)
 
 ~FxDeviceBase (VOID)
 
VOID Init (__in MdDeviceObject DeviceObject, __in MdDeviceObject AttachedDevice, __in MdDeviceObject PhysicalDevice)
 
- 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)
 

Detailed Description

Definition at line 487 of file fxdevice.hpp.

Constructor & Destructor Documentation

◆ FxDevice()

FxDevice::FxDevice ( __in FxDriver ArgDriver)

Definition at line 143 of file fxdevice.cpp.

145  :
146  FxDeviceBase(ArgDriver->GetDriverGlobals(), ArgDriver, FX_TYPE_DEVICE, sizeof(FxDevice)),
148 {
149  SetInitialState();
150 }
VOID SetInitialState(VOID)
Definition: fxdevice.cpp:153
CfxDevice * m_ParentDevice
Definition: fxdevice.hpp:569
FxDeviceBase(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxDriver *Driver, __in WDFTYPE Type, __in USHORT Size)
FxDevice(__in FxDriver *ArgDriver)
Definition: fxdevice.cpp:143
#define NULL
Definition: types.h:112

Referenced by _Create().

◆ ~FxDevice()

FxDevice::~FxDevice ( VOID  )

Definition at line 239 of file fxdevice.cpp.

240 {
242 
243  // Make it always present right now even on free builds
244  if (IsDisposed() == FALSE) {
247  "FxDevice 0x%p not disposed: this maybe a driver reference count "
248  "problem with WDFDEVICE %p", this, GetObjectHandleUnchecked());
249 
253  (ULONG_PTR) this);
254  }
255 
256  //
257  // Execute mode-specific destructor. Noop for KMDF, but does
258  // does detach and delete of UM device object for UMDF. Therefore
259  // can be done before other cleanup.
260  //
262 
263  //
264  // If the device has been initialized but hasn't yet been
265  // destroyed, destroy it now.
266  //
267 
268 
269 
270 
271 
272 
273 
275 
277 
278 #if FX_CORE_MODE == FX_CORE_KERNEL_MODE
279  //
280  // Assert only applicable to KM because FxDevice can get destroyed in UMDF
281  // without going through normal pnp remove path, for example, when an
282  // AddDevice failure is done in reflector, after all um drivers have
283  // succeeded AddDevice. KMDF and host use fake remove irp to handle
284  // AddDevice failure in KMDF and host respectively, but reflector does not
285  // do that for AddDevice failure that happens in reflector.
286  // Note that symbolicName buffer will anyway be deleted in this destructor
287  // later on so the symbolic link buffer doesn't leak out.
288  //
290 #endif
291 
293 
294  if (m_PkgIo != NULL) {
295  m_PkgIo->RELEASE(NULL);
296  m_PkgIo = NULL;
297  }
298 
299  if (m_PkgPnp != NULL) {
300  m_PkgPnp->RELEASE(NULL);
301  m_PkgPnp = NULL;
302  }
303 
304  if (m_PkgGeneral != NULL) {
305  m_PkgGeneral->RELEASE(NULL);
306  m_PkgGeneral = NULL;
307  }
308 
309  if (m_PkgWmi != NULL) {
310  m_PkgWmi->RELEASE(NULL);
311  m_PkgWmi = NULL;
312  }
313 
314  if (m_PkgDefault != NULL) {
315  m_PkgDefault->RELEASE(NULL);
316  m_PkgDefault = NULL;
317  }
318 
324  delete info;
325  }
326 
330  info = CONTAINING_RECORD(next, FxCxDeviceInfo, ListEntry);
332  delete info;
333  }
334 
335  //
336  // Clean up any referenced objects
337  //
338  if (m_DeviceName.Buffer != NULL) {
341  }
342 
344 
345  if (m_MofResourceName.Buffer != NULL) {
348  }
349 
350  //
351  // m_RequestLookasideListElementSize will be set to non zero if we have
352  // initialized the request lookaside list.
353  //
357  }
358 
359  if (m_ParentDevice != NULL) {
360  m_ParentDevice->RELEASE(this);
361  }
362 }
VOID DestructorInternal(VOID)
Definition: fxdevicekm.cpp:390
NPAGED_LOOKASIDE_LIST m_RequestLookasideList
Definition: fxdevice.hpp:648
CfxDevice * m_ParentDevice
Definition: fxdevice.hpp:569
UNICODE_STRING m_SymbolicLinkName
Definition: fxdevice.hpp:580
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define FxVerifierBugCheck(FxDriverGlobals, Error,...)
Definition: fxverifier.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
FxDefaultIrpHandler * m_PkgDefault
Definition: fxdevice.hpp:673
FxWmiIrpHandler * m_PkgWmi
Definition: fxdevice.hpp:672
#define FALSE
Definition: types.h:117
UNICODE_STRING m_MofResourceName
Definition: fxdevice.hpp:585
#define TRACE_LEVEL_FATAL
Definition: storswtr.h:26
size_t m_RequestLookasideListElementSize
Definition: fxdevice.hpp:653
UNICODE_STRING m_DeviceName
Definition: fxdevice.hpp:578
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
LIST_ENTRY m_CxDeviceInfoListHead
Definition: fxdevice.hpp:635
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define ASSERT(a)
Definition: mode.c:45
BOOLEAN IsDisposed(VOID)
Definition: fxobject.hpp:1241
LIST_ENTRY m_PreprocessInfoListHead
Definition: fxdevice.hpp:630
struct _test_info info[]
Definition: SetCursorPos.c:19
PVOID __inline GetObjectHandleUnchecked(VOID)
Definition: fxobject.hpp:446
FxPkgIo * m_PkgIo
Definition: fxdevice.hpp:669
Definition: typedefs.h:119
FxPkgGeneral * m_PkgGeneral
Definition: fxdevice.hpp:671
FxPkgPnp * m_PkgPnp
Definition: fxdevice.hpp:670
static __inline VOID MxDeleteNPagedLookasideList(_In_ PNPAGED_LOOKASIDE_LIST LookasideList)
Definition: mxgeneralkm.h:433
__inline MdDeviceObject GetObject(VOID)
VOID DeleteSymbolicLink(VOID)
static unsigned __int64 next
Definition: rand_nt.c:6
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
Definition: wdfpool.cpp:361
MxDeviceObject m_DeviceObject
Definition: fxdevice.hpp:471

Member Function Documentation

◆ _AcquireOptinRemoveLock()

_Must_inspect_result_ NTSTATUS FxDevice::_AcquireOptinRemoveLock ( __in MdDeviceObject  DeviceObject,
__in MdIrp  Irp 
)
staticprivate

Definition at line 1296 of file fxdevice.cpp.

1300 {
1301  NTSTATUS status;
1302  FxIrp irp(Irp);
1303 
1304  FxWdmDeviceExtension * wdmDeviceExtension =
1306 
1307  if (wdmDeviceExtension->RemoveLockOptionFlags &
1309 
1310  status = Mx::MxAcquireRemoveLock(&(wdmDeviceExtension->IoRemoveLock), Irp);
1311 
1312  if (!NT_SUCCESS(status)) {
1313  return status;
1314  }
1315 
1317 
1319  DeviceObject,
1321  DeviceObject,
1322  TRUE,
1323  TRUE,
1324  TRUE
1325  );
1326 
1328  }
1329 
1330  return STATUS_SUCCESS;
1331 }
static __inline NTSTATUS MxAcquireRemoveLock(__in MdRemoveLock RemoveLock, __in_opt PVOID Tag)
Definition: mxgeneralkm.h:268
#define TRUE
Definition: types.h:120
static MdCompletionRoutineType _CompletionRoutineForRemlockMaintenance
Definition: fxdevice.hpp:831
LONG NTSTATUS
Definition: precomp.h:26
Definition: fxirp.hpp:28
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
VOID SetNextIrpStackLocation(VOID)
Definition: fxirpum.cpp:1235
_In_ PIRP Irp
Definition: csq.h:116
VOID SetCompletionRoutineEx(__in MdDeviceObject DeviceObject, __in MdCompletionRoutine CompletionRoutine, __in PVOID Context, __in BOOLEAN InvokeOnSuccess=TRUE, __in BOOLEAN InvokeOnError=TRUE, __in BOOLEAN InvokeOnCancel=TRUE)
Definition: fxirpum.cpp:104
WUDF_IO_REMOVE_LOCK IoRemoveLock
Definition: fxdevice.hpp:34
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static FxWdmDeviceExtension * _GetFxWdmExtension(__in MdDeviceObject DeviceObject)
Definition: fxdevicekm.hpp:30
ULONG RemoveLockOptionFlags
Definition: fxdevice.hpp:38
#define STATUS_SUCCESS
Definition: shellext.h:65
VOID CopyCurrentIrpStackLocationToNext(VOID)
Definition: fxirpum.cpp:209
static SERVICE_STATUS status
Definition: service.c:31
FxIrp * irp
Definition: ps.c:97

Referenced by DispatchWithLock().

◆ _AllocAndQueryProperty()

_Must_inspect_result_ NTSTATUS FxDevice::_AllocAndQueryProperty ( _In_ PFX_DRIVER_GLOBALS  Globals,
_In_opt_ PWDFDEVICE_INIT  DeviceInit,
_In_opt_ FxDevice Device,
_In_opt_ MdDeviceObject  RemotePdo,
_In_ DEVICE_REGISTRY_PROPERTY  DeviceProperty,
_In_ POOL_TYPE  PoolType,
_In_opt_ PWDF_OBJECT_ATTRIBUTES  PropertyMemoryAttributes,
_Out_ WDFMEMORY *  PropertyMemory 
)
static

Definition at line 1986 of file fxdevice.cpp.

1996 {
1998  NTSTATUS status;
1999  ULONG length = 0;
2000 
2002  DeviceInit,
2003  Device,
2004  RemotePdo,
2006  0,
2007  NULL,
2008  &length);
2011  "Could not retrieve property %d length, %!STATUS!",
2014  return status;
2015  }
2016 
2019  PoolType,
2020  Globals->Tag,
2021  length,
2022  &pMemory);
2023  if (!NT_SUCCESS(status)) {
2025  "Could not allocate WDFMEMORY, %!STATUS!", status);
2026  return status;
2027  }
2028 
2030  DeviceInit,
2031  Device,
2032  RemotePdo,
2034  length,
2035  pMemory->GetBuffer(),
2036  &length);
2037  if (!NT_SUCCESS(status)) {
2039  "Could not query for full buffer, size %d, for "
2040  "property %d, %!STATUS!",
2042  pMemory->DeleteObject();
2043  return status;
2044  }
2045 
2048 
2049  if (!NT_SUCCESS(status)) {
2051  "Could not commit memory object, %!STATUS!",
2052  status);
2053  pMemory->DeleteObject();
2054  }
2055 
2056  return status;
2057 }
virtual VOID DeleteObject(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)
Definition: fxobject.cpp:904
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty
Definition: wdfdevice.h:3767
LONG NTSTATUS
Definition: precomp.h:26
FxMemoryObject * pMemory
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFMEMORY * PropertyMemory
Definition: wdfdevice.h:3810
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE _In_opt_ PWDF_OBJECT_ATTRIBUTES PropertyMemoryAttributes
Definition: wdfdevice.h:3810
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define _Analysis_assume_
Definition: no_sal2.h:388
#define NULL
Definition: types.h:112
static _Must_inspect_result_ NTSTATUS _QueryProperty(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device, _In_opt_ MdDeviceObject RemotePdo, _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty, _In_ ULONG BufferLength, _Out_opt_ PVOID PropertyBuffer, _Out_opt_ PULONG ResultLength)
Definition: fxdevicekm.cpp:939
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810
unsigned int ULONG
Definition: retypes.h:1
_In_ PWDFDEVICE_INIT DeviceInit
Definition: wdfcontrol.h:113
static SERVICE_STATUS status
Definition: service.c:31
virtual PVOID GetBuffer(VOID)=0
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS DriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in POOL_TYPE PoolType, __in ULONG PoolTag, __in size_t BufferSize, __out FxMemoryObject **Object)
Definition: ps.c:97

◆ _AllocAndQueryPropertyEx()

_Must_inspect_result_ NTSTATUS FxDevice::_AllocAndQueryPropertyEx ( _In_ PFX_DRIVER_GLOBALS  DriverGlobals,
_In_opt_ PWDFDEVICE_INIT  DeviceInit,
_In_opt_ FxDevice Device,
_In_ PVOID  PropertyData,
_In_ FxPropertyType FxPropertyType  ,
_In_ POOL_TYPE  PoolType,
_In_opt_ PWDF_OBJECT_ATTRIBUTES  PropertyMemoryAttributes,
_Out_ WDFMEMORY *  PropertyMemory,
_Out_ PDEVPROPTYPE  PropertyType 
)
static

Definition at line 2061 of file fxdevice.cpp.

2072 {
2074  NTSTATUS status;
2075  ULONG length = 0;
2076  DEVPROPTYPE propType;
2077  ULONG requiredLength;
2078 
2080  DeviceInit,
2081  Device,
2082  PropertyData,
2084  0,
2085  NULL,
2086  &requiredLength,
2087  &propType);
2090  "Could not retrieve property, %!STATUS!",
2091  status);
2093  return status;
2094  }
2095 
2096  *PropertyMemory = NULL;
2097  *PropertyType = 0;
2098 
2099  length = requiredLength;
2102  PoolType,
2103  DriverGlobals->Tag,
2104  length,
2105  &pMemory);
2106  if (!NT_SUCCESS(status)) {
2108  "Could not allocate WDFMEMORY, %!STATUS!", status);
2109  return status;
2110  }
2111 
2113  DeviceInit,
2114  Device,
2115  PropertyData,
2117  length,
2118  pMemory->GetBuffer(),
2119  &requiredLength,
2120  &propType);
2121  if (!NT_SUCCESS(status)) {
2123  "Could not query for full buffer, size %d, for "
2124  "property, %!STATUS!",
2125  length, status);
2126  pMemory->DeleteObject();
2127  return status;
2128  }
2129 
2132 
2133  if (!NT_SUCCESS(status)) {
2135  "Could not commit memory object, %!STATUS!",
2136  status);
2137  pMemory->DeleteObject();
2138  }
2139  else {
2141  *PropertyType = propType;
2142  }
2143 
2144  return status;
2145 }
virtual VOID DeleteObject(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)
Definition: fxobject.cpp:904
LONG NTSTATUS
Definition: precomp.h:26
FxMemoryObject * pMemory
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFMEMORY * PropertyMemory
Definition: wdfdevice.h:3810
DriverGlobals
_In_ WDFDEVICE _In_ PWDF_DEVICE_INTERFACE_PROPERTY_DATA PropertyData
ULONG DEVPROPTYPE
Definition: devpropdef.h:24
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
static _Must_inspect_result_ NTSTATUS _QueryPropertyEx(_In_ PFX_DRIVER_GLOBALS DriverGlobals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device, _In_ PVOID PropertyData, _In_ FxPropertyType FxPropertyType, _In_ ULONG BufferLength, _Out_ PVOID PropertyBuffer, _Out_ PULONG ResultLength, _Out_ PDEVPROPTYPE PropertyType)
Definition: fxdevicekm.cpp:859
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
_In_ WDFDEVICE _In_ PWDF_DEVICE_INTERFACE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG _Out_ PDEVPROPTYPE PropertyType
FxPropertyType
Definition: fxdevice.hpp:85
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE _In_opt_ PWDF_OBJECT_ATTRIBUTES PropertyMemoryAttributes
Definition: wdfdevice.h:3810
virtual WDFMEMORY GetHandle(VOID)
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define TRACINGPNP
Definition: dbgtrace.h:67
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define _Analysis_assume_
Definition: no_sal2.h:388
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810
unsigned int ULONG
Definition: retypes.h:1
_In_ PWDFDEVICE_INIT DeviceInit
Definition: wdfcontrol.h:113
static SERVICE_STATUS status
Definition: service.c:31
virtual PVOID GetBuffer(VOID)=0
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS DriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in POOL_TYPE PoolType, __in ULONG PoolTag, __in size_t BufferSize, __out FxMemoryObject **Object)
Definition: ps.c:97

◆ _Create()

_Must_inspect_result_ NTSTATUS FxDevice::_Create ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in PWDFDEVICE_INIT DeviceInit,
__in_opt PWDF_OBJECT_ATTRIBUTES  DeviceAttributes,
__out FxDevice **  Device 
)
static

Definition at line 366 of file fxdevice.cpp.

372 {
374  FxDevice* pDevice;
377  PLIST_ENTRY pNext;
378  PWDFCXDEVICE_INIT pCxInit;
379  FxWdmDeviceExtension* wdmDeviceExtension;
380 
381  *Device = NULL;
382  pInit = *DeviceInit;
383 
384  pDevice = new (FxDriverGlobals, DeviceAttributes)
386 
387  if (pDevice == NULL) {
389  goto Done;
390  }
391 
393  if (!NT_SUCCESS(status)) {
394  goto Done;
395  }
396 
397  switch (pInit->InitType) {
398  case FxDeviceInitTypeFdo:
400  break;
401 
402  case FxDeviceInitTypePdo:
404  break;
405 
408  break;
409 
410  default:
411  //
412  // Should not drop here
413  //
414  ASSERT(FALSE);
415  break;
416  }
417  if (!NT_SUCCESS(status)) {
418  goto Done;
419  }
420 
421  //
422  // Ok, we have created the device. Now lets create a handle for it.
423  //
425  if (!NT_SUCCESS(status)) {
426  goto Done;
427  }
428 
429  //
430  // Can't use the PDO's FxDevice m_Parent as the object hierarchy parent
431  // because the Fx object hierarchy lifetime rules do not match the
432  // rules for a pnp PDO lifetime vs its FDO.
433  //
435  &object,
436  pDevice->GetDriver());
437  if (!NT_SUCCESS(status)) {
438  goto Done;
439  }
440 
441  //
442  // NOTE: ---> DO NOT FAIL FROM HERE FORWARD <---
443  //
444 
445  //
446  // Up until now we have not reassigned any of the allocations in pInit
447  // and assigned them to the underlying objects. We are now at the point
448  // of "no return", ie we cannot fail. If we reassigned the allocations
449  // before this point and the driver retried to create the device (let's
450  // say with a different name), we would have freed those allocations
451  // and the driver writer would have thought that particular settings
452  // we valid, but were not b/c we freed them on error. So, to avoid a
453  // huge tracking mess, we only grab the allocations once we know for
454  // *sure* we are going to return success.
455  //
456  if (pInit->DeviceName != NULL) {
458  }
459 
460  //
461  // Check for driver preprocess requirements.
462  //
463  if (pInit->PreprocessInfo != NULL) {
469 
470  //
471  // If the driver is preprocessing requests on this device, they need
472  // their own stack location so that they can set their own completion
473  // routine.
474  //
476  }
477 
478 #if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
479  wdmDeviceExtension = _GetFxWdmExtension(pDevice->GetDeviceObject());
480  if (wdmDeviceExtension->RemoveLockOptionFlags &
482  //
483  // We will use a completion routine for remlock maintenance
484  //
486  }
487 
488  //
489  // Note: In case of UMDF StackSize is incremented prior to attaching
490  // the device to stack. See the comment in FxDeviceUm.cpp
491  //
494  }
495 
496 #else
497  UNREFERENCED_PARAMETER(wdmDeviceExtension);
498 #endif
499 
500  //
501  // Check for any class-extensions' preprocess requirements.
502  //
503  for (pNext = pInit->CxDeviceInitListHead.Flink;
504  pNext != &pInit->CxDeviceInitListHead;
505  pNext = pNext->Flink) {
506 
507  pCxInit = CONTAINING_RECORD(pNext, WDFCXDEVICE_INIT, ListEntry);
508 
509  if (pCxInit->PreprocessInfo != NULL) {
512  &pCxInit->PreprocessInfo->ListEntry);
513  pCxInit->PreprocessInfo = NULL;
514 
515  //
516  // If the class extension is preprocessing requests on this
517  // device, it needs its own stack location so that it can
518  // set its own completion routine.
519  //
521  }
522  }
523 
524  if (pDevice->IsPnp()) {
525  //
526  // Take all of the allocations out of pInit related to pnp. This
527  // will also transition the pnp state machine into the added state.
528  //
530  }
531 
533 
534  //
535  // Clear out the pointer, we freed it on behalf of the caller
536  //
537  *DeviceInit = NULL;
538 
539  if (pInit->CreatedOnStack == FALSE) {
540  delete pInit;
541  }
542 
543 Done:
544  if (!NT_SUCCESS(status) && pDevice != NULL) {
545  //
546  // We want to propagate the original error code
547  //
549  pDevice = NULL;
550  }
551 
552  *Device = pDevice;
553 
554  return status;
555 }
_Must_inspect_result_ NTSTATUS Initialize(__in PWDFDEVICE_INIT DeviceInit, __in_opt PWDF_OBJECT_ATTRIBUTES DeviceAttributes)
Definition: fxdevice.cpp:663
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
coclass MSXML2::XSLTemplate40 object
_Must_inspect_result_ NTSTATUS Commit(__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
Definition: fxobject.cpp:904
VOID __inline ReleaseString(__out PUNICODE_STRING ReleaseTo)
Definition: fxstring.hpp:47
_Must_inspect_result_ NTSTATUS ControlDeviceInitialize(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxdevicekm.cpp:399
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
virtual VOID FinishInitialize(__inout PWDFDEVICE_INIT DeviceInit)
Definition: fxpkgpnp.cpp:1240
LONG NTSTATUS
Definition: precomp.h:26
__inline BOOLEAN IsPnp(VOID)
Definition: fxdevice.hpp:1200
#define InsertTailList(ListHead, Entry)
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
FxDevice * CreatedDevice
#define FALSE
Definition: types.h:117
_Must_inspect_result_ _Inout_ PWDFDEVICE_INIT _In_opt_ PWDF_OBJECT_ATTRIBUTES DeviceAttributes
Definition: wdfdevice.h:3561
FxDeviceInitType InitType
UNICODE_STRING m_DeviceName
Definition: fxdevice.hpp:578
_Must_inspect_result_ NTSTATUS PdoInitialize(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxdevicekm.cpp:221
FxIrpPreprocessInfo * PreprocessInfo
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
FxIrpPreprocessInfo * PreprocessInfo
FxDevice * pDevice
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define ASSERT(a)
Definition: mode.c:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
FxDevice(__in FxDriver *ArgDriver)
Definition: fxdevice.cpp:143
LIST_ENTRY m_PreprocessInfoListHead
Definition: fxdevice.hpp:630
__inline CHAR GetStackSize(VOID)
Definition: fxdevice.hpp:1824
FxDriver * Driver
_Must_inspect_result_ NTSTATUS FdoInitialize(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxdevicekm.cpp:33
__inline FxDriver * GetDriver(VOID)
Definition: fxdevice.hpp:164
BOOLEAN CreatedOnStack
FxString * DeviceName
BOOLEAN m_SelfIoTargetNeeded
Definition: fxdevice.hpp:611
Definition: typedefs.h:119
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
LIST_ENTRY CxDeviceInitListHead
FxPkgPnp * m_PkgPnp
Definition: fxdevice.hpp:670
static FxWdmDeviceExtension * _GetFxWdmExtension(__in MdDeviceObject DeviceObject)
Definition: fxdevicekm.hpp:30
PWDFDEVICE_INIT pInit
__inline VOID SetStackSize(_In_ CHAR Size)
Definition: fxdevice.hpp:1833
ULONG RemoveLockOptionFlags
Definition: fxdevice.hpp:38
#define NULL
Definition: types.h:112
_Must_inspect_result_ NTSTATUS PostInitialize(VOID)
Definition: fxdevice.cpp:940
_In_ PWDFDEVICE_INIT DeviceInit
Definition: wdfcontrol.h:113
_Must_inspect_result_ NTSTATUS DeleteDeviceFromFailedCreate(__in NTSTATUS FailedStatus, __in BOOLEAN UseStateMachine)
Definition: fxdevice.cpp:644
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ _GetDeviceProperty()

__inline NTSTATUS FxDevice::_GetDeviceProperty ( _In_ MdDeviceObject  DeviceObject,
_In_ DEVICE_REGISTRY_PROPERTY  DeviceProperty,
_In_ ULONG  BufferLength,
_Out_opt_ PVOID  PropertyBuffer,
_Out_ PULONG  ResultLength 
)
static

Definition at line 1093 of file fxdeviceum.cpp.

1100 {
1101  HRESULT hr;
1102  NTSTATUS status;
1103 
1104  DEVPROPTYPE propType;
1105  const DEVPROPKEY *propKey = NULL;
1106 
1107  //
1108  // {cccccccc-cccc-cccc-cccc-cccccccccccc}
1109  // 2 brackets + 4 dashes + 32 characters + UNICODE_NULL
1110  //
1111  GUID guidBuffer = {0};
1112  ULONG guidChLen = 2 + 4 + 32 + 1;
1113  ULONG guidCbLen = guidChLen * sizeof(WCHAR);
1114  BOOLEAN convertGuidToString = FALSE;
1115 
1117  ULONG bufferLen = BufferLength;
1118  ULONG resultLen = 0;
1119 
1120  UMINT::WDF_PROPERTY_STORE_ROOT rootSpecifier;
1121  rootSpecifier.LengthCb = sizeof(UMINT::WDF_PROPERTY_STORE_ROOT);
1122  rootSpecifier.RootClass = UMINT::WdfPropertyStoreRootClassHardwareKey;
1123  rootSpecifier.Qualifier.HardwareKey.ServiceName = NULL;
1124 
1125  //
1126  // Map DEVICE_REGISTRY_PROPERTY enums to DEVPROPKEYs
1127  //
1128  switch (DeviceProperty)
1129  {
1131  propKey = &DEVPKEY_Device_DeviceDesc;
1132  break;
1134  propKey = &DEVPKEY_Device_HardwareIds;
1135  break;
1137  propKey = &DEVPKEY_Device_CompatibleIds;
1138  break;
1140  ASSERTMSG("Not available in UMDF\n", FALSE);
1141  break;
1143  ASSERTMSG("Not available in UMDF\n", FALSE);
1144  break;
1146  propKey = &DEVPKEY_Device_Class;
1147  break;
1149  propKey = &DEVPKEY_Device_ClassGuid;
1150  convertGuidToString = TRUE;
1151  break;
1153  propKey = &DEVPKEY_NAME;
1154  break;
1156  propKey = &DEVPKEY_Device_Manufacturer;
1157  break;
1159  propKey = &DEVPKEY_Device_FriendlyName;
1160  break;
1162  propKey = &DEVPKEY_Device_LocationInfo;
1163  break;
1165  propKey = &DEVPKEY_Device_PDOName;
1166  break;
1168  propKey = &DEVPKEY_Device_BusTypeGuid;
1169  break;
1171  propKey = &DEVPKEY_Device_LegacyBusType;
1172  break;
1174  propKey = &DEVPKEY_Device_BusNumber;
1175  break;
1177  propKey = &DEVPKEY_Device_EnumeratorName;
1178  break;
1179  case DevicePropertyAddress:
1180  propKey = &DEVPKEY_Device_Address;
1181  break;
1183  propKey = &DEVPKEY_Device_UINumber;
1184  break;
1186  propKey = &DEVPKEY_Device_InstallState;
1187  break;
1189  propKey = &DEVPKEY_Device_RemovalPolicy;
1190  break;
1192  ASSERTMSG("Not available in UMDF\n", FALSE);
1193  break;
1195  ASSERTMSG("Not available in UMDF\n", FALSE);
1196  break;
1198  propKey = &DEVPKEY_Device_ContainerId;
1199  convertGuidToString = TRUE;
1200  break;
1201  }
1202 
1203  FX_VERIFY(DRIVER(BadArgument, TODO), CHECK_NOT_NULL(propKey));
1204 
1205  if (convertGuidToString)
1206  {
1207  buffer = &guidBuffer;
1208  bufferLen = sizeof(GUID);
1209  }
1210 
1211  hr = ((IWudfDeviceStack*)DeviceStack)->GetUnifiedPropertyData(&rootSpecifier,
1212  propKey,
1213  0,
1214  0,
1215  bufferLen,
1216  &propType,
1217  &resultLen,
1218  buffer);
1219  if (S_OK == hr)
1220  {
1222 
1223  //
1224  // Some DEVICE_REGISTRY_PROPERTY values are GUID strings,
1225  // while their DEVPROPKEY equivalents are GUID structs. To preserve
1226  // KMDF-UMDF DDI parity, we convert select GUID structs to wchar strings.
1227  //
1228  if (convertGuidToString)
1229  {
1230  if (PropertyBuffer == NULL || BufferLength < guidCbLen)
1231  {
1233  }
1234  else
1235  {
1237  guidChLen,
1238  L"{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
1239  guidBuffer.Data1, guidBuffer.Data2, guidBuffer.Data3,
1240  guidBuffer.Data4[0], guidBuffer.Data4[1],
1241  guidBuffer.Data4[2], guidBuffer.Data4[3],
1242  guidBuffer.Data4[4], guidBuffer.Data4[5],
1243  guidBuffer.Data4[6], guidBuffer.Data4[7]);
1244  if (hr != S_OK)
1245  {
1247  }
1248  }
1249  }
1250  }
1252  {
1254  }
1255  else
1256  {
1258  }
1259 
1260  if (ResultLength)
1261  {
1262  *ResultLength = convertGuidToString ? guidCbLen : resultLen;
1263  }
1264 
1265  return status;
1266 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty
Definition: wdfdevice.h:3767
LONG NTSTATUS
Definition: precomp.h:26
GLuint buffer
Definition: glext.h:5915
ULONG DEVPROPTYPE
Definition: devpropdef.h:24
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define StringCchPrintf
Definition: strsafe.h:517
#define TODO
Definition: SAX2.c:49
#define FALSE
Definition: types.h:117
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
unsigned char BOOLEAN
FX_VERIFY(INTERNAL, CHECK_NOT_NULL(LoaderInterface->pIWudfHost))
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
static const WCHAR L[]
Definition: oid.c:1250
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID PropertyBuffer
Definition: wdfdevice.h:4431
struct _GUID GUID
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
Definition: ps.c:97

Referenced by __deref_out_range(), _QueryProperty(), CreateSymbolicLink(), and FxGetDevicePropertyString().

◆ _GetFxWdmExtension()

__inline FxWdmDeviceExtension * FxDevice::_GetFxWdmExtension ( __in MdDeviceObject  DeviceObject)
static

Definition at line 30 of file fxdevicekm.hpp.

33 {
34  //
35  // DeviceObject->DeviceExtension points to our FxDevice allocation. We
36  // get the underlying DeviceExtension allocated as part of the
37  // PDEVICE_OBJECT by adding the sizeof(DEVICE_OBJECT) to get the start
38  // of the DeviceExtension. This is documented behavior on how the
39  // DeviceExtension can be found.
40  //
42  sizeof(*DeviceObject));
43 }
#define WDF_PTR_ADD_OFFSET(_ptr, _offset)
Definition: wdfcore.h:144
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055

Referenced by _AcquireOptinRemoveLock(), _Create(), FxPkgGeneral::AcquireRemoveLockForClose(), CreateDevice(), FxWmiIrpHandler::Dispatch(), DispatchWithLock(), GetRemoveLock(), and IsRemoveLockEnabledForIo().

◆ _InterfaceDereferenceNoOp()

static VOID STDCALL FxDevice::_InterfaceDereferenceNoOp ( __in_opt PVOID  Context)
inlinestatic

Definition at line 1778 of file fxdevice.hpp.

1781  {
1782  // NoOp dereference stub for query interface
1784  }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317

Referenced by FxPkgPdo::HandleQueryInterfaceForReenumerate().

◆ _InterfaceReferenceNoOp()

static VOID STDCALL FxDevice::_InterfaceReferenceNoOp ( __in_opt PVOID  Context)
inlinestatic

Definition at line 1767 of file fxdevice.hpp.

1770  {
1771  // NoOp reference stub for query interface
1773  }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317

Referenced by FxPkgPdo::HandleQueryInterfaceForReenumerate().

◆ _OpenDeviceRegistryKey()

__inline NTSTATUS FxDevice::_OpenDeviceRegistryKey ( _In_ MdDeviceObject  DeviceObject,
_In_ ULONG  DevInstKeyType,
_In_ ACCESS_MASK  DesiredAccess,
_Out_ PHANDLE  DevInstRegKey 
)
static

Definition at line 1012 of file fxdeviceum.cpp.

1020 {
1021  NTSTATUS status;
1022  HRESULT hr;
1023 
1024  UMINT::WDF_PROPERTY_STORE_ROOT root;
1025  UMINT::WDF_PROPERTY_STORE_RETRIEVE_FLAGS flags = UMINT::WdfPropertyStoreNormal;
1026  PWSTR subpath = NULL;
1027 
1028 
1029 
1030 
1031  #define WDF_REGKEY_DEVICE_SUBKEY 256
1032  #define WDF_REGKEY_DRIVER_SUBKEY 256
1033 
1034  root.LengthCb = sizeof(UMINT::WDF_PROPERTY_STORE_ROOT);
1035 
1037  {
1038  ASSERTMSG("Not available in UMDF\n", FALSE);
1039  }
1041  {
1042  root.RootClass = UMINT::WdfPropertyStoreRootClassHardwareKey;
1043 
1045  {
1046  root.Qualifier.HardwareKey.ServiceName = DriverName;
1047  flags = UMINT::WdfPropertyStoreCreateIfMissing;
1048  }
1049  else
1050  {
1051  root.Qualifier.HardwareKey.ServiceName = WDF_PROPERTY_STORE_HARDWARE_KEY_ROOT;
1052  }
1053  }
1055  {
1056  root.RootClass = UMINT::WdfPropertyStoreRootClassSoftwareKey;
1057 
1059  {
1060  subpath = DriverName;
1061  flags = UMINT::WdfPropertyStoreCreateIfMissing;
1062  }
1063  else
1064  {
1065  subpath = L"\\";
1066  }
1067  }
1069  {
1070  root.RootClass = UMINT::WdfPropertyStoreRootClassLegacyHardwareKey;
1071 
1072  //
1073  // Legacy keys must always be opened volatile for UMDF
1074  //
1075  flags = UMINT::WdfPropertyStoreCreateVolatile;
1076 
1077  subpath = NULL;
1078  root.Qualifier.LegacyHardwareKey.LegacyMapName = DriverName;
1079  }
1080 
1081  hr = ((IWudfDeviceStack*)DeviceStack)->CreateRegistryEntry(&root,
1082  flags,
1083  DesiredAccess,
1084  subpath,
1086  NULL);
1087  status = FxDevice::NtStatusFromHr(DeviceStack, hr);
1088 
1089  return status;
1090 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
#define WDF_REGKEY_DRIVER_SUBKEY
#define FX_PLUGPLAY_REGKEY_DEVICEMAP
Definition: mxum.h:48
HRESULT hr
Definition: shlfolder.c:183
#define PLUGPLAY_REGKEY_DEVICE
Definition: iofuncs.h:2782
uint16_t * PWSTR
Definition: typedefs.h:56
_In_ ULONG DevInstKeyType
Definition: iofuncs.h:1123
struct _root root
LONG NTSTATUS
Definition: precomp.h:26
#define FALSE
Definition: types.h:117
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
static NTSTATUS NtStatusFromHr(_In_ IWudfDeviceStack *DevStack, _In_ HRESULT Hr)
Definition: fxdeviceum.cpp:826
LONG HRESULT
Definition: typedefs.h:79
GLbitfield flags
Definition: glext.h:7161
static const WCHAR L[]
Definition: oid.c:1250
#define PLUGPLAY_REGKEY_DRIVER
Definition: usbd.c:42
_In_ ULONG _In_ ACCESS_MASK _Out_ PHANDLE DevInstRegKey
Definition: iofuncs.h:1123
#define NULL
Definition: types.h:112
#define WDF_REGKEY_DEVICE_SUBKEY
static SERVICE_STATUS status
Definition: service.c:31
#define PLUGPLAY_REGKEY_CURRENT_HWPROFILE
Definition: iofuncs.h:2784
Definition: ps.c:97

Referenced by _OpenKey(), and OpenSettingsKey().

◆ _OpenKey()

_Must_inspect_result_ NTSTATUS FxDevice::_OpenKey ( _In_ PFX_DRIVER_GLOBALS  FxDriverGlobals,
_In_opt_ PWDFDEVICE_INIT  DeviceInit,
_In_opt_ FxDevice Device,
_In_ ULONG  DeviceInstanceKeyType,
_In_ ACCESS_MASK  DesiredAccess,
_In_opt_ PWDF_OBJECT_ATTRIBUTES  KeyAttributes,
_Out_ WDFKEY *  Key 
)
static

Definition at line 731 of file fxdevicekm.cpp.

740 {
741  FxRegKey* pKey;
742  WDFKEY keyHandle;
743  HANDLE hKey = NULL;
745  MdDeviceObject pdo;
746 
747  status = FxValidateObjectAttributes(FxDriverGlobals, KeyAttributes);
748  if (!NT_SUCCESS(status)) {
749  return status;
750  }
751 
752  status = FxVerifierCheckIrqlLevel(FxDriverGlobals, PASSIVE_LEVEL);
753  if (!NT_SUCCESS(status)) {
754  return status;
755  }
756 
757  status = _ValidateOpenKeyParams(FxDriverGlobals, DeviceInit, Device);
758  if (!NT_SUCCESS(status)) {
759  return status;
760  }
761 
763 
764  if (DeviceInit != NULL) {
765  pdo = DeviceInit->Fdo.PhysicalDevice;
766  }
767  else {
768  pdo = Device->GetSafePhysicalDevice();
769  if (pdo == NULL) {
770  //
771  // Pnp doesn't know about the PDO yet.
772  //
775  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
776  "WDFDEVICE %p is not yet known to PnP manager, cannot open "
777  "PNP registry keys in this state, %!STATUS!", Device->GetHandle(), status);
778  return status;
779  }
780  }
781 
782  pKey = new(FxDriverGlobals, KeyAttributes) FxRegKey(FxDriverGlobals);
783 
784  if (pKey == NULL) {
786  }
787 
788  if (Device != NULL) {
790  }
791 
793 
794  if (NT_SUCCESS(status)) {
798  &hKey);
799  if (NT_SUCCESS(status)) {
800  pKey->SetHandle(hKey);
801  *Key = keyHandle;
802  }
803  }
804 
805  if (!NT_SUCCESS(status)) {
806  //
807  // No object is being returned, make sure the destroy callback will not
808  // be called.
809  //
811  }
812 
813  return status;
814 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
static _Must_inspect_result_ NTSTATUS _ValidateOpenKeyParams(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device)
Definition: fxdevice.cpp:2149
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ NTSTATUS Commit(__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
Definition: fxobject.cpp:904
static __inline NTSTATUS _OpenDeviceRegistryKey(_In_ MdDeviceObject DeviceObject, _In_ ULONG DevInstKeyType, _In_ ACCESS_MASK DesiredAccess, _Out_ PHANDLE DevInstRegKey)
LONG NTSTATUS
Definition: precomp.h:26
VOID SetDeviceBase(__in CfxDeviceBase *DeviceBase)
Definition: fxobject.hpp:797
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK _In_opt_ PWDF_OBJECT_ATTRIBUTES KeyAttributes
Definition: wdfdevice.h:2654
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG DeviceInstanceKeyType
Definition: wdfdevice.h:2654
_Must_inspect_result_ NTSTATUS FxValidateObjectAttributes(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
__inline VOID SetHandle(__in HANDLE Key)
Definition: fxregkey.hpp:94
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
FxRegKey * pKey
FxAutoRegKey hKey
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define _Analysis_assume_
Definition: no_sal2.h:388
#define NULL
Definition: types.h:112
VOID DeleteFromFailedCreate(VOID)
Definition: fxobject.cpp:391
_In_ PWDFDEVICE_INIT DeviceInit
Definition: wdfcontrol.h:113
static SERVICE_STATUS status
Definition: service.c:31
WDFKEY keyHandle
Definition: ps.c:97

◆ _QueryProperty()

_Must_inspect_result_ NTSTATUS FxDevice::_QueryProperty ( _In_ PFX_DRIVER_GLOBALS  FxDriverGlobals,
_In_opt_ PWDFDEVICE_INIT  DeviceInit,
_In_opt_ FxDevice Device,
_In_opt_ MdDeviceObject  RemotePdo,
_In_ DEVICE_REGISTRY_PROPERTY  DeviceProperty,
_In_ ULONG  BufferLength,
_Out_opt_ PVOID  PropertyBuffer,
_Out_opt_ PULONG  ResultLength 
)
static

Definition at line 939 of file fxdevicekm.cpp.

949 {
951  MdDeviceObject pdo;
952 
953  ASSERT(DeviceInit != NULL || Device != NULL || RemotePdo != NULL);
954 
955  if (RemotePdo != NULL) {
956  pdo = RemotePdo;
957  }
958  else {
959  status = FxDevice::_ValidateOpenKeyParams(FxDriverGlobals,
960  DeviceInit,
961  Device);
962  if (!NT_SUCCESS(status)) {
963  return status;
964  }
965 
966  if (DeviceInit != NULL) {
967  pdo = DeviceInit->Fdo.PhysicalDevice;
968  }
969  else {
970  pdo = Device->GetSafePhysicalDevice();
971  if (pdo == NULL) {
972  //
973  // Pnp doesn't know about the PDO yet.
974  //
977  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
978  "WDFDEVICE %p is not yet known to PnP manager, cannot query "
979  "device properties in this state, %!STATUS!", Device->GetHandle(), status);
980  return status;
981  }
982  }
983  }
984 
987  BufferLength,
989  ResultLength);
990  return status;
991 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
static _Must_inspect_result_ NTSTATUS _ValidateOpenKeyParams(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device)
Definition: fxdevice.cpp:2149
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty
Definition: wdfdevice.h:3767
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define ASSERT(a)
Definition: mode.c:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID PropertyBuffer
Definition: wdfdevice.h:4431
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
static __inline NTSTATUS _GetDeviceProperty(_In_ MdDeviceObject DeviceObject, _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty, _In_ ULONG BufferLength, _Out_opt_ PVOID PropertyBuffer, _Out_ PULONG ResultLength)
_In_ PWDFDEVICE_INIT DeviceInit
Definition: wdfcontrol.h:113
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by _AllocAndQueryProperty().

◆ _QueryPropertyEx()

_Must_inspect_result_ NTSTATUS FxDevice::_QueryPropertyEx ( _In_ PFX_DRIVER_GLOBALS  DriverGlobals,
_In_opt_ PWDFDEVICE_INIT  DeviceInit,
_In_opt_ FxDevice Device,
_In_ PVOID  PropertyData,
_In_ FxPropertyType FxPropertyType  ,
_In_ ULONG  BufferLength,
_Out_ PVOID  PropertyBuffer,
_Out_ PULONG  ResultLength,
_Out_ PDEVPROPTYPE  PropertyType 
)
static

Definition at line 859 of file fxdevicekm.cpp.

870 {
872  DEVPROPTYPE propType;
873  ULONG requiredLength = 0;
874  const DEVPROPKEY * propertyKey;
875  LCID lcid;
876  PWDF_DEVICE_PROPERTY_DATA deviceData;
877  MdDeviceObject pdo;
878 
881 
882  *ResultLength = 0;
883  *PropertyType = 0;
884 
886  DeviceInit,
887  Device);
888  if (!NT_SUCCESS(status)) {
889  return status;
890  }
891 
893 
894  if (DeviceInit != NULL) {
895  pdo = DeviceInit->Fdo.PhysicalDevice;
896  }
897  else {
898  pdo = Device->GetSafePhysicalDevice();
899  if (pdo == NULL) {
900  //
901  // Pnp doesn't know about the PDO yet.
902  //
906  "WDFDEVICE %p is not yet known to PnP manager, cannot query "
907  "device properties in this state, %!STATUS!", Device->GetHandle(), status);
908  return status;
909  }
910  }
911 
913  propertyKey = deviceData->PropertyKey;
914  lcid = deviceData->Lcid;
915 
916  status = IoGetDevicePropertyData(pdo,
917  propertyKey,
918  lcid,
919  0,
920  BufferLength,
922  &requiredLength,
923  &propType);
925  *ResultLength = requiredLength;
926  *PropertyType = propType;
927  }
928  else {
930  "Query for property buffer failed, %!STATUS!",
931  status);
932  }
933 
934  return status;
935 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
static _Must_inspect_result_ NTSTATUS _ValidateOpenKeyParams(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device)
Definition: fxdevice.cpp:2149
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
DWORD LCID
Definition: nls.h:13
DriverGlobals
_In_ WDFDEVICE _In_ PWDF_DEVICE_INTERFACE_PROPERTY_DATA PropertyData
ULONG DEVPROPTYPE
Definition: devpropdef.h:24
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
_In_ const DEVPROPKEY * PropertyKey
Definition: wdfdevice.h:1912
_In_ WDFDEVICE _In_ PWDF_DEVICE_INTERFACE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG _Out_ PDEVPROPTYPE PropertyType
#define TRACINGDEVICE
Definition: dbgtrace.h:58
FxPropertyType
Definition: fxdevice.hpp:85
#define ASSERT(a)
Definition: mode.c:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _WDF_DEVICE_PROPERTY_DATA * PWDF_DEVICE_PROPERTY_DATA
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID PropertyBuffer
Definition: wdfdevice.h:4431
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define TRACINGPNP
Definition: dbgtrace.h:67
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define _Analysis_assume_
Definition: no_sal2.h:388
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
_In_ PWDFDEVICE_INIT DeviceInit
Definition: wdfcontrol.h:113
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by _AllocAndQueryPropertyEx().

◆ _RequiresRemLock()

static FxDeviceRemLockAction __inline FxDevice::_RequiresRemLock ( __in UCHAR  MajorCode,
__in UCHAR  MinorCode 
)
inlinestatic

Definition at line 933 of file fxdevice.hpp.

937  {
938  switch (MajorCode) {
939  //
940  // We require remove locks for power irps because they can show
941  // up after the device has been removed if the Power subysystem has
942  // taken a reference on the device object that raced with the
943  // remove irp (or if we are attached above the power policy owner
944  // and the power policy owner requests a power irp during remove
945  // processing.
946  //
947  // What it boils down to is that we do it for power because
948  // that is the only valid irp which can be sent with an outstanding
949  // reference w/out coordination to the device's pnp state. We
950  // assume that for all other irps, the sender has synchronized with
951  // the pnp state of the device.
952  //
953  // We also acquire the remove lock for WMI IRPs because they can
954  // come into the stack while we are processing a remove. For
955  // instance, a WMI irp can come into the stack to the attached
956  // device before it has a change to process the remove device and
957  // unregister with WMI.
958  //
959  // PNP irps can come in at any time as well. For instance, query
960  // device relations for removal or ejection relations can be sent
961  // at any time (and there are pnp stress tests which send them
962  // during remove).
963  //
964  case IRP_MJ_PNP:
965  //
966  // We special case remove device and only acquire the remove lock
967  // in the minor code handler itself. If handled remove device in
968  // the normal way and there was a preprocess routine for it, then
969  // we could deadlock if the irp was dispatched back to KMDF in the
970  // preprocess routine with an extra outstandling remlock acquire
971  // (which won't be released until the preprocess routine returns,
972  // which will be too late).
973  //
974  if (MinorCode == IRP_MN_REMOVE_DEVICE) {
976  }
977  case IRP_MJ_POWER:
980 
981  default:
982 #if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
983  return FxDeviceRemLockOptIn;
984 #else
985  //
986  // There is no forseeable scenario where a UMDF driver would need to
987  // need to support remove lock for IO IRPs. While this ifdef can be safely
988  // removed and UMDF can also return FxDeviceRemLockOptIn, that is
989  // being avoided here so that the caller does not need to test the
990  // remove lock flags for IO which would never be set.
991  //
993 #endif
994  }
995  }
#define IRP_MN_REMOVE_DEVICE
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
#define IRP_MJ_POWER
#define IRP_MJ_SYSTEM_CONTROL

Referenced by FxDefaultIrpHandler::Dispatch(), DispatchPreprocessedIrp(), DispatchWithLock(), FxDriver::Initialize(), and PreprocessIrp().

◆ _ValidateOpenKeyParams()

_Must_inspect_result_ NTSTATUS FxDevice::_ValidateOpenKeyParams ( _In_ PFX_DRIVER_GLOBALS  FxDriverGlobals,
_In_opt_ PWDFDEVICE_INIT  DeviceInit,
_In_opt_ FxDevice Device 
)
static

Definition at line 2149 of file fxdevice.cpp.

2154 {
2156 
2157  //
2158  // This function should be called with exactly one valid WDFDEVICE_INIT
2159  // or one valid FxDevice object. Supplying neither or both is an error.
2160  //
2161  if ((DeviceInit == NULL && Device == NULL) ||
2162  (DeviceInit != NULL && Device != NULL)) {
2163 
2166  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
2167  "Device OpenKey/QueryProperty was called with invalid "
2168  "DeviceInit and Device parameters, %!STATUS!", status);
2169  FxVerifierDbgBreakPoint(FxDriverGlobals);
2170  }
2171 
2172  return status;
2173 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define TRACINGDEVICE
Definition: dbgtrace.h:58
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
_In_ PWDFDEVICE_INIT DeviceInit
Definition: wdfcontrol.h:113
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
FxVerifierDbgBreakPoint(pFxDriverGlobals)
Definition: ps.c:97

Referenced by _OpenKey(), _QueryProperty(), and _QueryPropertyEx().

◆ AddChildList()

VOID FxDevice::AddChildList ( __inout FxChildList List)
virtual

Reimplemented from FxDeviceBase.

Definition at line 431 of file fxdevicekm.cpp.

434 {
435  if (IsPnp()) {
437  }
438 }
__inline BOOLEAN IsPnp(VOID)
Definition: fxdevice.hpp:1200
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
FxPkgPnp * m_PkgPnp
Definition: fxdevice.hpp:670
VOID AddChildList(__in FxChildList *List)
Definition: fxpkgpnp.cpp:4970

Referenced by FxChildList::Initialize().

◆ AddDmaEnabler()

VOID FxDevice::AddDmaEnabler ( __inout FxDmaEnabler Enabler)
virtual

Reimplemented from FxDeviceBase.

Definition at line 465 of file fxdevicekm.cpp.

468 {
469  if (IsPnp()) {
470  m_PkgPnp->AddDmaEnabler(Enabler);
471  }
472 }
__inline BOOLEAN IsPnp(VOID)
Definition: fxdevice.hpp:1200
VOID AddDmaEnabler(__in FxDmaEnabler *Enabler)
Definition: fxpkgpnpkm.cpp:277
FxPkgPnp * m_PkgPnp
Definition: fxdevice.hpp:670

◆ AddIoTarget()

_Must_inspect_result_ NTSTATUS FxDevice::AddIoTarget ( __inout FxIoTarget IoTarget)
virtual

Reimplemented from FxDeviceBase.

Definition at line 1770 of file fxdevice.cpp.

1773 {
1774  NTSTATUS status;
1775 
1777  &IoTarget->m_TransactionedEntry);
1778 
1779  if (NT_SUCCESS(status)) {
1780  IoTarget->m_AddedToDeviceList = TRUE;
1781  IoTarget->ADDREF(this);
1782  }
1783 
1784  return status;
1785 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS Add(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxTransactionedEntry *Entry)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
FxSpinLockTransactionedList m_IoTargetsList
Definition: fxdevice.hpp:623
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIOTARGET * IoTarget
Definition: wdfiotarget.h:363
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ AllocateDmaEnablerList()

_Must_inspect_result_ NTSTATUS FxDevice::AllocateDmaEnablerList ( VOID  )
virtual

Reimplemented from FxDeviceBase.

Definition at line 452 of file fxdevicekm.cpp.

455 {
456  if (IsPnp()) {
458  }
459  else {
460  return STATUS_SUCCESS;
461  }
462 }
__inline BOOLEAN IsPnp(VOID)
Definition: fxdevice.hpp:1200
FxPkgPnp * m_PkgPnp
Definition: fxdevice.hpp:670
#define STATUS_SUCCESS
Definition: shellext.h:65
_Must_inspect_result_ NTSTATUS AllocateDmaEnablerList(VOID)
Definition: fxpkgpnpkm.cpp:241

◆ AllocateEnumInfo()

_Must_inspect_result_ NTSTATUS FxDevice::AllocateEnumInfo ( VOID  )
virtual

Reimplemented from FxDeviceBase.

Definition at line 1803 of file fxdevice.cpp.

1806 {
1807  if (IsPnp()) {
1808  return m_PkgPnp->AllocateEnumInfo();
1809  }
1810  else {
1811  return STATUS_SUCCESS;
1812  }
1813 }
__inline BOOLEAN IsPnp(VOID)
Definition: fxdevice.hpp:1200
_Must_inspect_result_ NTSTATUS AllocateEnumInfo(VOID)
Definition: fxpkgpnp.cpp:4920
FxPkgPnp * m_PkgPnp
Definition: fxdevice.hpp:670
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ AllocateRequestMemory()

PVOID FxDevice::AllocateRequestMemory ( __in_opt PWDF_OBJECT_ATTRIBUTES  Attributes)

Definition at line 1628 of file fxdevice.cpp.

1657 {
1659  PFX_POOL_TRACKER pTracker;
1661  PVOID ptr, pTrueBase;
1662 
1664  ptr = NULL;
1665 
1666  if (IsPdo() && GetPdoPkg()->IsForwardRequestToParentEnabled()) {
1668  }
1669  else {
1672  }
1673 
1674  if (pTrueBase != NULL) {
1675  if (pGlobals->IsPoolTrackingOn()) {
1676  pTracker = (PFX_POOL_TRACKER) pTrueBase;
1677  pHeader = WDF_PTR_ADD_OFFSET_TYPE(pTrueBase,
1678  sizeof(FX_POOL_TRACKER),
1679  PFX_POOL_HEADER);
1680 
1681  //
1682  // Format and insert the Tracker in the NonPagedHeader list.
1683  //
1685  pTracker,
1687  pGlobals->Tag,
1688  _ReturnAddress());
1689  }
1690  else {
1691  pHeader = (PFX_POOL_HEADER) pTrueBase;
1692  }
1693 
1694  //
1695  // Common init
1696  //
1697  pHeader->Base = pTrueBase;
1698  pHeader->FxDriverGlobals = pGlobals;
1699 
1700  ptr = &pHeader->AllocationStart[0];
1701 
1702  if (RequestAttributes == NULL) {
1704  }
1705 
1707  pGlobals,
1708  ptr,
1709  COMPUTE_OBJECT_SIZE(sizeof(FxRequest), 0),
1712  );
1713 
1714 #if FX_VERBOSE_TRACE
1716  "Allocating FxRequest* %p, WDFREQUEST %p",
1717  ptr, _ToHandle((FxObject*) ptr));
1718 #endif
1719  return ptr;
1720  }
1721 
1722  return NULL;
1723 }
NPAGED_LOOKASIDE_LIST m_RequestLookasideList
Definition: fxdevice.hpp:648
#define TRACINGREQUEST
Definition: dbgtrace.h:65
VOID __inline FxPoolInsertNonPagedAllocateTracker(__in PFX_POOL Pool, __in PFX_POOL_TRACKER Tracker, __in SIZE_T Size, __in ULONG Tag, __in PVOID Caller)
__inline PVOID FxAllocateFromNPagedLookasideList(_In_ PNPAGED_LOOKASIDE_LIST Lookaside, _In_opt_ size_t ElementSize=0)
Definition: fxglobalskm.h:565
FX_POOL FxPoolFrameworks
Definition: fxglobals.h:388
BOOLEAN IsPoolTrackingOn(VOID)
Definition: fxglobals.h:215
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
_In_ PWDFDEVICE_INIT _In_ PWDF_OBJECT_ATTRIBUTES RequestAttributes
Definition: wdfdevice.h:3428
static PVOID ptr
Definition: dispmode.c:27
size_t m_RequestLookasideListElementSize
Definition: fxdevice.hpp:653
FxContextHeader * pHeader
Definition: handleapi.cpp:604
#define COMPUTE_OBJECT_SIZE(_rawObjectSize, _extraSize)
Definition: fxhandle.h:107
FX_POOL_HEADER * PFX_POOL_HEADER
Definition: fxpool.h:51
__inline FxPkgPdo * GetPdoPkg(VOID)
Definition: fxdevice.hpp:1254
PFX_DRIVER_GLOBALS pGlobals
WDF_OBJECT_ATTRIBUTES m_RequestAttributes
Definition: fxdevice.hpp:659
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
static PVOID __inline _ToHandle(__in FxObject *Object)
Definition: fxobject.hpp:659
void * _ReturnAddress(void)
__inline BOOLEAN IsPdo(VOID)
Definition: fxdevice.hpp:1245
_Must_inspect_result_ __inline PVOID FxAllocateFromNPagedLookasideListNoTracking(__in PNPAGED_LOOKASIDE_LIST Lookaside)
Definition: fxglobalskm.h:487
PVOID FxObjectAndHandleHeaderInit(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PVOID AllocationStart, __in USHORT ObjectSize, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in FxObjectType ObjectType)
Definition: handleapi.cpp:292
FX_POOL_TRACKER * PFX_POOL_TRACKER
Definition: fxpool.h:107
#define WDF_PTR_ADD_OFFSET_TYPE(_ptr, _offset, _type)
Definition: wdfcore.h:141

◆ AreRegistersMappedToUsermode()

BOOLEAN FxDevice::AreRegistersMappedToUsermode ( VOID  )
inline

Definition at line 2092 of file fxdevice.hpp.

2095  {
2096  return (m_RegisterAccessMode == WdfRegisterAccessUsingUserModeMapping);
2097  }
WDF_REGISTER_ACCESS_MODE_TYPE m_RegisterAccessMode
Definition: fxdevice.hpp:783

◆ AssignProperty()

NTSTATUS FxDevice::AssignProperty ( _In_ PVOID  PropertyData,
_In_ FxPropertyType FxPropertyType  ,
_In_ DEVPROPTYPE  Type,
_In_ ULONG  BufferLength,
_In_opt_ PVOID  PropertyBuffer 
)

Definition at line 668 of file fxdevicekm.cpp.

675 {
677  const DEVPROPKEY * propertyKey;
678  LCID lcid;
679  ULONG flags;
680  PWDF_DEVICE_PROPERTY_DATA deviceData;
681  PDEVICE_OBJECT pdo;
682 
684 
686 
688 
689  propertyKey = deviceData->PropertyKey;
690  lcid = deviceData->Lcid;
691  flags = deviceData->Flags;
692 
693  pdo = GetSafePhysicalDevice();
694 
695  if (pdo == NULL) {
696  //
697  // Pnp doesn't know about the PDO yet.
698  //
702  "WDFDEVICE %p is not yet known to PnP manager, cannot call "
703  "WdfDeviceAssignPropertyEx in this state, %!STATUS!",
704  GetHandle(), status);
705 
706  return status;
707  }
708 
709  status = IoSetDevicePropertyData(
710  pdo,
711  propertyKey,
712  lcid,
713  flags,
714  Type,
715  BufferLength,
717  );
718 
719  if (!NT_SUCCESS(status)) {
722  "WDFDEVICE %p failed to assign device property, %!STATUS!",
723  GetHandle(), status);
724  }
725 
726  return status;
727 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
LONG NTSTATUS
Definition: precomp.h:26
DWORD LCID
Definition: nls.h:13
_In_ WDFDEVICE _In_ PWDF_DEVICE_INTERFACE_PROPERTY_DATA PropertyData
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
_In_ const DEVPROPKEY * PropertyKey
Definition: wdfdevice.h:1912
#define TRACINGDEVICE
Definition: dbgtrace.h:58
FxPropertyType
Definition: fxdevice.hpp:85
#define ASSERT(a)
Definition: mode.c:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Type
Definition: Type.h:6
struct _WDF_DEVICE_PROPERTY_DATA * PWDF_DEVICE_PROPERTY_DATA
GLbitfield flags
Definition: glext.h:7161
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID PropertyBuffer
Definition: wdfdevice.h:4431
MdDeviceObject __inline GetSafePhysicalDevice(VOID)
Definition: fxdevice.hpp:1005
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define TRACINGPNP
Definition: dbgtrace.h:67
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ ClearCallbackFlags()

__inline VOID FxDevice::ClearCallbackFlags ( __in BYTE  Flags)
inline

Definition at line 1548 of file fxdevice.hpp.

1551  {
1552  KIRQL irql;
1553 
1554  Lock(&irql);
1556  Unlock(irql);
1557  }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__inline VOID ClearCallbackFlagsLocked(__in BYTE Flags)
Definition: fxdevice.hpp:1539
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124

Referenced by __drv_when().

◆ ClearCallbackFlagsLocked()

__inline VOID FxDevice::ClearCallbackFlagsLocked ( __in BYTE  Flags)
inline

Definition at line 1539 of file fxdevice.hpp.

1542  {
1543  m_CallbackFlags &= ~Flags;
1544  }
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
BYTE m_CallbackFlags
Definition: fxdevice.hpp:519

Referenced by ClearCallbackFlags().

◆ ConfigureAutoForwardCleanupClose()

VOID FxDevice::ConfigureAutoForwardCleanupClose ( __in PWDFDEVICE_INIT  DeviceInit)

Definition at line 864 of file fxdevice.cpp.

867 {
868  WDF_TRI_STATE autoForwardCleanupClose;
870  BOOLEAN checkClientDriver;
871 
872  autoForwardCleanupClose = WdfUseDefault;
873  checkClientDriver = TRUE;
874 
875  //
876  // Device-wide configuration for auto forwarding cleanup and close requests:
877  // . Use WdfFalse if one of the devices in the chain use this setting with a create
878  // callback (this means it will complete all create IRPs).
879  // . Else use lowest driver's setting in the chain (order of cx chain: lower to higher).
880  // . If no settings are present, use default.
881  //
882  for (next = DeviceInit->CxDeviceInitListHead.Blink;
883  next != &DeviceInit->CxDeviceInitListHead;
884  next = next->Blink) {
885 
886  PWDFCXDEVICE_INIT cxInit;
887 
888  cxInit = CONTAINING_RECORD(next, WDFCXDEVICE_INIT, ListEntry);
889 
890  if (cxInit->FileObject.Set) {
891  autoForwardCleanupClose = cxInit->FileObject.AutoForwardCleanupClose;
892 
893  if (autoForwardCleanupClose == WdfFalse &&
895 
896  checkClientDriver = FALSE;
897  break;
898  }
899  }
900  }
901 
902  if (checkClientDriver && DeviceInit->FileObject.Set) {
903  autoForwardCleanupClose = DeviceInit->FileObject.AutoForwardCleanupClose;
904  }
905 
906  switch (autoForwardCleanupClose) {
907  case WdfTrue:
908 
910  //
911  // If the device is legacy then set it to false because you can't forward
912  // requests.
913  //
914  if(m_Legacy) {
916  }
917  break;
918 
919  case WdfFalse:
921  break;
922 
923  case WdfUseDefault:
924  //
925  // For filters (which must be FDOs), we default to TRUE. All other
926  // device roles (FDO, PDO, control) default to FALSE. We cannot check
927  // m_Filter yet because it is set in FdoInitialize which occurs later.
928  //
929  if (DeviceInit->IsFdoInit() && DeviceInit->Fdo.Filter) {
931  }
932  else {
934  }
935  }
936 }
BOOLEAN m_Legacy
Definition: fxdevice.hpp:547
#define TRUE
Definition: types.h:120
enum _WDF_TRI_STATE WDF_TRI_STATE
WDFCX_FILEOBJECT_CONFIG Callbacks
CxFileObjectInit FileObject
PFN_WDFCX_DEVICE_FILE_CREATE EvtCxDeviceFileCreate
Definition: wdfcx.h:28
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
BOOLEAN m_AutoForwardCleanupClose
Definition: fxdevice.hpp:605
Definition: typedefs.h:119
WDF_TRI_STATE AutoForwardCleanupClose
static unsigned __int64 next
Definition: rand_nt.c:6
#define NULL
Definition: types.h:112
_In_ PWDFDEVICE_INIT DeviceInit
Definition: wdfcontrol.h:113

Referenced by Initialize().

◆ ControlDeviceDelete()

VOID FxDevice::ControlDeviceDelete ( VOID  )
inline

Definition at line 1465 of file fxdevice.hpp.

1468  {
1469  //
1470  // FxDevice::DeleteObject() has already run, so we must call the super
1471  // class's version of DeleteObject();
1472  //
1474 
1475  FxDeviceBase::DeleteObject(); // __super call
1476  }
virtual VOID DeleteObject(VOID)
#define ASSERT(a)
Definition: mode.c:45
BOOLEAN m_DeviceObjectDeleted
Definition: fxdevice.hpp:553

Referenced by FxPkgGeneral::DecrementOpenHandleCount().

◆ ControlDeviceInitialize()

_Must_inspect_result_ NTSTATUS FxDevice::ControlDeviceInitialize ( __in PWDFDEVICE_INIT  DeviceInit)

Definition at line 399 of file fxdevicekm.cpp.

402 {
404 
405  m_Legacy = TRUE;
406 
408 
409  if (!NT_SUCCESS(status)) {
410  return status;
411  }
412 
413  // status = m_PkgWmi->PostCreateDeviceInitialize(); __REACTOS__
414  // if (!NT_SUCCESS(status)) {
415  // return status;
416  // }
417 
419  if (!NT_SUCCESS(status)) {
420  return status;
421  }
422 
423  //
424  // NOTE: The driver writer must clear the DO_DEVICE_INITIALIZING bit
425  // via WdfControlFinishInitializing
426  //
427  return status;
428 }
BOOLEAN m_Legacy
Definition: fxdevice.hpp:547
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ NTSTATUS PostCreateDeviceInitialize(__in PWDFDEVICE_INIT Init)
_Must_inspect_result_ NTSTATUS CreateDevice(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxdevice.cpp:964
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
FxPkgGeneral * m_PkgGeneral
Definition: fxdevice.hpp:671
_In_ PWDFDEVICE_INIT DeviceInit
Definition: wdfcontrol.h:113
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by _Create().

◆ CreateDevice()

_Must_inspect_result_ NTSTATUS FxDevice::CreateDevice ( __in PWDFDEVICE_INIT  DeviceInit)

Definition at line 964 of file fxdevice.cpp.

967 {
968  MdDeviceObject pNewDeviceObject;
969  ULONG characteristics;
971  DEVICE_TYPE devType;
972 
974  if (!NT_SUCCESS(status)) {
975  return status;
976  }
977 
978  devType = DeviceInit->DeviceType;
979  if (devType < ARRAY_SIZE(m_PriorityBoosts)) {
981  }
982 
983  characteristics = DeviceInit->Characteristics;
984 
985  //
986  // You can only create secure device objects which have a name. All other
987  // device objects rely on the PDO's security
988  //
989  if (DeviceInit->ShouldCreateSecure()) {
990  PUNICODE_STRING pName, pSddl;
991  LPGUID pGuid;
992 
993  if (DeviceInit->DeviceName != NULL) {
994  pName = DeviceInit->DeviceName->GetUnicodeString();
995  }
996  else {
997  pName = NULL;
998  }
999 
1000  if (DeviceInit->Security.DeviceClassSet) {
1001  pGuid = &DeviceInit->Security.DeviceClass;
1002  }
1003  else {
1004  pGuid = NULL;
1005  }
1006 
1007  if (DeviceInit->Security.Sddl != NULL) {
1008  pSddl = DeviceInit->Security.Sddl->GetUnicodeString();
1009  }
1010  else {
1011  //
1012  // Always provide an SDDL if one is not supplied.
1013  //
1014  // SDDL_DEVOBJ_SYS_ALL_ADM_ALL = "D:P(A;;GA;;;SY)(A;;GA;;;BA)"
1015  //
1016  // SDDL_DEVOBJ_SYS_ALL_ADM_ALL allows the kernel, system, and
1017  // administrator complete control over the device. No other users
1018  // may access the device.
1019  //
1020  // pSddl = (PUNICODE_STRING) &SDDL_DEVOBJ_SYS_ALL_ADM_ALL;
1021  pSddl = NULL; // __REACTOS__ : wdmsec.lib is not supported
1022  }
1023 
1026  sizeof(FxWdmDeviceExtension),
1027  pName,
1028  devType,
1029  characteristics,
1030  m_Exclusive,
1031  pSddl,
1032  pGuid,
1033  &pNewDeviceObject);
1034  }
1035  else {
1038  sizeof(FxWdmDeviceExtension),
1039  NULL,
1040  devType,
1041  characteristics,
1042  m_Exclusive,
1043  &pNewDeviceObject);
1044  }
1045 
1046  if (NT_SUCCESS(status)) {
1047  FxWdmDeviceExtension* pWdmExt;
1048 
1049  pWdmExt = _GetFxWdmExtension(pNewDeviceObject);
1050 
1051  //
1052  // We reassign DeviceExtension below and then use the knowledge that
1053  // we can always retrieve DeviceExtension by adding sizeof(DEVICE_OBJECT)
1054  // to pNewDeviceObject. ASSERT that this assumption is correct.
1055  //
1056  MxDeviceObject newDeviceObject(pNewDeviceObject);
1057  ASSERT(pWdmExt == newDeviceObject.GetDeviceExtension());
1058 
1060  GetDriverGlobals()->Tag,
1061  0, // max min
1062  0 // highwater mark
1063  );
1064 
1065  //
1066  // Option for remove lock is stored in device extension
1067  // since this option may be examined after FxDevice is destroyed
1068  // (if an Irp is sent after removal of device).
1069  // We combine the flags from DeviceInit with what's set through registry
1070  //
1071  pWdmExt->RemoveLockOptionFlags = DeviceInit->RemoveLockOptionFlags |
1073 
1074  //
1075  // We assign the first context assigned to this object as the
1076  // DeviceExtension for compatibility reasons. This allows existing
1077  // WDM extensions to work as well as any stack which exports a known
1078  // structure for the extension (ie the FDO knows the extension of its
1079  // PDO and casts it and accesses it directly).
1080  //
1081  newDeviceObject.SetDeviceExtension(&GetContextHeader()->Context[0]);
1082  m_DeviceObject.SetObject(pNewDeviceObject);
1083 
1084  //
1085  // Set some device object flags based on properties of DeviceInit.
1086  //
1087  // If we are a filter, we will set these flags later
1088  // (in FxDevice::FdoInitialize) based on the device we are attached to.
1089  //
1090  if (m_Filter == FALSE) {
1091  if (DeviceInit->ReadWriteIoType == WdfDeviceIoBuffered) {
1093  }
1094  else if (DeviceInit->ReadWriteIoType == WdfDeviceIoDirect) {
1096  }
1097 
1098  m_ReadWriteIoType = DeviceInit->ReadWriteIoType;
1099  m_PowerPageableCapable = DeviceInit->PowerPageable;
1100  }
1101  }
1102 
1103  return status;
1104 }
VOID SetFlags(ULONG Flags)
static const CHAR m_PriorityBoosts[]
Definition: fxdevice.hpp:563
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ NTSTATUS Initialize(__in PWDFDEVICE_INIT DeviceInit)
static __inline NTSTATUS MxCreateDevice(_In_ MdDriverObject DriverObject, _In_ ULONG DeviceExtensionSize, _In_opt_ PUNICODE_STRING DeviceName, _In_ DEVICE_TYPE DeviceType, _In_ ULONG DeviceCharacteristics, _In_ BOOLEAN Exclusive, _Out_ MdDeviceObject *DeviceObject)
Definition: mxgeneralkm.h:557
BOOLEAN m_Exclusive
Definition: fxdevice.hpp:540
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
#define FALSE
Definition: types.h:117
WDF_DEVICE_IO_TYPE m_ReadWriteIoType
Definition: fxdevice.hpp:514
BOOLEAN m_Filter
Definition: fxdevice.hpp:522
static LPSTR pName
Definition: security.c:75
WUDF_IO_REMOVE_LOCK IoRemoveLock
Definition: fxdevice.hpp:34
#define ASSERT(a)
Definition: mode.c:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
ULONG RemoveLockOptionFlags
Definition: fxglobals.h:494
CHAR m_DefaultPriorityBoost
Definition: fxdevice.hpp:561
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
FxPkgGeneral * m_PkgGeneral
Definition: fxdevice.hpp:671
__inline MdDriverObject GetObject(VOID)
static __inline NTSTATUS MxCreateDeviceSecure(_In_ MdDriverObject DriverObject, _In_ ULONG DeviceExtensionSize, _In_opt_ PUNICODE_STRING DeviceName, _In_ DEVICE_TYPE DeviceType, _In_ ULONG DeviceCharacteristics, _In_ BOOLEAN Exclusive, _In_ PCUNICODE_STRING DefaultSDDLString, _In_opt_ LPCGUID DeviceClassGuid, _Out_ MdDeviceObject *DeviceObject)
Definition: mxgeneralkm.h:521
__inline FxContextHeader * GetContextHeader(VOID)
Definition: fxobject.hpp:720
static FxWdmDeviceExtension * _GetFxWdmExtension(__in MdDeviceObject DeviceObject)
Definition: fxdevicekm.hpp:30
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
static __inline VOID MxInitializeRemoveLock(__in MdRemoveLock Lock, __in ULONG AllocateTag, __in ULONG MaxLockedMinutes, __in ULONG HighWatermark)
Definition: mxgeneralkm.h:256
BOOLEAN m_PowerPageableCapable
Definition: fxdevice.hpp:530
#define ARRAY_SIZE(a)
Definition: main.h:24
__inline VOID SetObject(__in_opt MdDeviceObject DeviceObject)
#define DEVICE_TYPE
Definition: guid.c:10
ULONG RemoveLockOptionFlags
Definition: fxdevice.hpp:38
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
FxDriver * m_Driver
Definition: fxdevice.hpp:469
_In_ PWDFDEVICE_INIT DeviceInit
Definition: wdfcontrol.h:113
ULONG GetFlags(VOID)
static SERVICE_STATUS status
Definition: service.c:31
MxDeviceObject m_DeviceObject
Definition: fxdevice.hpp:471
MxDriverObject m_DriverObject
Definition: fxdriver.hpp:62
Definition: ps.c:97

Referenced by ControlDeviceInitialize(), FdoInitialize(), and PdoInitialize().

◆ CreateSymbolicLink()

NTSTATUS FxDevice::CreateSymbolicLink ( _In_ PFX_DRIVER_GLOBALS  FxDriverGlobals,
_In_ PCUNICODE_STRING  SymbolicLinkName 
)

Definition at line 513 of file fxdevicekm.cpp.

517 {
521 
522  //
523  // Ensure m_DeviceName has been set or we can get the PDO's name
524  //
525  if (m_DeviceName.Buffer == NULL) {
527  PWSTR pBuffer;
528  ULONG length;
529 
530  if (IsLegacy()) {
531  //
532  // No PDO on a legacy stack, can't call IoGetDeviceProperty
533  //
535 
537  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
538  "WDFDEVICE %p has no device name (use WdfDeviceInitAssignName), "
539  "%!STATUS!", GetHandle(), status);
540 
541  return status;
542  }
543 
545  if (pPdo == NULL) {
546  //
547  // No PDO yet for this device, pnp doesn't know about it.
548  //
550 
552  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
553  "WDFDEVICE %p has not yet been reported to pnp, cannot call "
554  "IoGetDeviceProperty in this state, %!STATUS!", GetHandle(), status);
555 
556  return status;
557  }
558 
559  length = 0;
560 
563  0,
564  NULL,
565  &length);
566 
569  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
570  "WDFDEVICE %p IoGetDeviceProperty failed %!STATUS!",
571  GetHandle(), status);
572  return status;
573  }
574  else if (length > USHORT_MAX) {
576 
578  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
579  "WDFDEVICE %p PDO name too long (%d, max is %d), %!STATUS!",
581 
582  return status;
583  }
584  else if (length == 0) {
585  //
586  // We can get zero back if the PDO is being deleted.
587  //
589 
591  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
592  "WDFDEVICE %p PDO name length is zero, %!STATUS!",
593  GetHandle(), status);
594 
595  return status;
596  }
597 
598  pBuffer = (PWSTR) FxPoolAllocate(FxDriverGlobals, PagedPool, length);
599  if (pBuffer == NULL) {
601 
603  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
604  "WDFDEVICE %p could not allocate buffer for PDO name, %!STATUS!",
605  GetHandle(), status);
606 
607  return status;
608  }
609 
610  //
611  // pdoName will free pBuffer when it is destructed
612  //
614 
617  length,
618  pBuffer,
619  &length);
620 
621  if (!NT_SUCCESS(status)) {
623  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
624  "WDFDEVICE %p IoGetDeviceProperty failed second time, %!STATUS!",
625  GetHandle(), status);
626  return status;
627  }
628 
631 
633  }
634  else {
635  pName = &m_DeviceName;
636  }
637 
638  status = FxDuplicateUnicodeString(FxDriverGlobals,
641 
642  if (!NT_SUCCESS(status)) {
644  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
645  "WDFDEVICE %p allocate buffer for symbolic name failed, %!STATUS!",
646  GetHandle(), status);
647 
648  return status;
649  }
650 
652 
653  if (!NT_SUCCESS(status)) {
655 
657  sizeof(m_SymbolicLinkName));
658 
660  "WDFDEVICE %p create sybolic link failed, %!STATUS!",
661  GetHandle(), status);
662  }
663 
664  return status;
665 }
#define USHORT_MAX
Definition: intsafe.h:145
static __inline NTSTATUS MxCreateSymbolicLink(_In_ PUNICODE_STRING SymbolicLinkName, _In_ PUNICODE_STRING DeviceName)
Definition: mxgeneralkm.h:579
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
USHORT MaximumLength
Definition: env_spec_w32.h:370
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
uint16_t * PWSTR
Definition: typedefs.h:56
LONG NTSTATUS
Definition: precomp.h:26
FxAutoString pdoName
FxDevice * pPdo
UNICODE_STRING m_SymbolicLinkName
Definition: fxdevice.hpp:580
__inline BOOLEAN IsLegacy(VOID)
Definition: fxdevice.hpp:1209
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
#define UNICODE_NULL
#define STATUS_INTEGER_OVERFLOW
Definition: ntstatus.h:385
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
PVOID pBuffer
UNICODE_STRING m_DeviceName
Definition: fxdevice.hpp:578
#define TRACINGDEVICE
Definition: dbgtrace.h:58
static LPSTR pName
Definition: security.c:75
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ NTSTATUS FxDuplicateUnicodeString(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in const UNICODE_STRING *Source, __out PUNICODE_STRING Destination)
Definition: stringutil.cpp:180
MdDeviceObject __inline GetSafePhysicalDevice(VOID)
Definition: fxdevice.hpp:1005
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
unsigned short USHORT
Definition: pedump.c:61
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
static __inline NTSTATUS _GetDeviceProperty(_In_ MdDeviceObject DeviceObject, _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty, _In_ ULONG BufferLength, _Out_opt_ PVOID PropertyBuffer, _Out_ PULONG ResultLength)
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
UNICODE_STRING m_UnicodeString
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
Definition: wdfpool.cpp:361
static SERVICE_STATUS status
Definition: service.c:31
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING SymbolicLinkName
Definition: wdfdevice.h:3736
Definition: ps.c:97

◆ DeleteDeviceFromFailedCreate()

_Must_inspect_result_ NTSTATUS FxDevice::DeleteDeviceFromFailedCreate ( __in NTSTATUS  FailedStatus,
__in BOOLEAN  UseStateMachine 
)

Definition at line 644 of file fxdevice.cpp.

648 {
650 
651  status = DeleteDeviceFromFailedCreateNoDelete(FailedStatus, UseStateMachine);
652 
653  //
654  // Delete the Fx object now
655  //
656  DeleteObject();
657 
658  return status;
659 }
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ NTSTATUS DeleteDeviceFromFailedCreateNoDelete(__in NTSTATUS FailedStatus, __in BOOLEAN UseStateMachine)
Definition: fxdevice.cpp:559
static SERVICE_STATUS status
Definition: service.c:31
virtual VOID DeleteObject(VOID)
Definition: fxdevice.cpp:1135
Definition: ps.c:97

Referenced by _Create().

◆ DeleteDeviceFromFailedCreateNoDelete()

_Must_inspect_result_ NTSTATUS FxDevice::DeleteDeviceFromFailedCreateNoDelete ( __in NTSTATUS  FailedStatus,
__in BOOLEAN  UseStateMachine 
)
private

Definition at line 559 of file fxdevice.cpp.

563 {
564  //
565  // Cleanup the device, the driver may have allocated resources
566  // associated with the WDFDEVICE
567  //
570  "WDFDEVICE %p !devobj %p created, but EvtDriverDeviceAdd returned "
571  "status %!STATUS! or failure in creation",
572  GetObjectHandleUnchecked(), GetDeviceObject(), FailedStatus);
573 
574  //
575  // We do not let filters affect the building of the rest of the stack.
576  // If they return error, we convert it to STATUS_SUCCESS, remove the
577  // attached device from the stack, and cleanup.
578  //
579  if (IsFilter()) {
582  "WDFDEVICE %p, !devobj %p is a filter, converting %!STATUS! to"
583  " STATUS_SUCCESS", GetObjectHandleUnchecked(), GetDeviceObject(),
584  FailedStatus);
585  FailedStatus = STATUS_SUCCESS;
586  }
587 
588  if (UseStateMachine) {
589  MxEvent waitEvent;
590 
591  //
592  // See comments for m_CleanupFromFailedCreate in class definition file
593  // for use of this statement.
594  //
596 
597 
598 
599 
600 
603  }
604  else {
605  //
606  // Upon certain types of failure, like STATUS_OBJECT_NAME_COLLISION, we
607  // could keep the pDevice around and the caller retry after changing
608  // a property, but the simpler route for now is to just recreate
609  // everything from scratch on the retry.
610  //
611  // Usually the pnp state machine will do this and the FxDevice destructor
612  // relies on it running b/c it does some cleanup.
613  //
614  EarlyDispose();
615  DestroyChildren();
616 
617  //
618  // Wait for all children to drain out and cleanup.
619  //
620  if (m_DisposeList != NULL) {
622  }
623 
624  //
625  // We keep a reference on m_PkgPnp which is released in the destructor
626  // so we can safely touch m_PkgPnp after destroying all of the child
627  // objects.
628  //
629  if (m_PkgPnp != NULL) {
631  }
632  }
633 
634  //
635  // This will detach and delete the device object
636  //
637  Destroy();
638 
639  return FailedStatus;
640 }
VOID CleanupDeviceFromFailedCreate(__in MxEvent *WaitEvent)
Definition: fxpkgpnp.cpp:2190
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
#define TRUE
Definition: types.h:120
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
MxEvent * GetSelfPointer(VOID)
Definition: mxevent.h:110
BOOLEAN EarlyDispose(VOID)
CHECK_RETURN_IF_USER_MODE __inline NTSTATUS Initialize(__in EVENT_TYPE Type, __in BOOLEAN InitialState)
Definition: mxeventkm.h:55
#define FALSE
Definition: types.h:117
VOID Destroy(VOID)
Definition: fxdevicekm.cpp:329
FxDisposeList * m_DisposeList
Definition: fxdevice.hpp:466
__inline BOOLEAN IsFilter()
Definition: fxdevice.hpp:1408
VOID SetCleanupFromFailedCreate(BOOLEAN Value)
Definition: fxdevice.hpp:1877
PVOID __inline GetObjectHandleUnchecked(VOID)
Definition: fxobject.hpp:446
FxPkgPnp * m_PkgPnp
Definition: fxdevice.hpp:670
VOID __inline DestroyChildren(VOID)
Definition: fxobject.hpp:464
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define TRACINGPNP
Definition: dbgtrace.h:67
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
VOID WaitForEmpty(VOID)
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
VOID CleanupStateMachines(__in BOOLEAN ClenaupPnp)
Definition: fxpkgpnp.cpp:2066
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by DeleteDeviceFromFailedCreate(), and DeleteObject().

◆ DeleteObject()

VOID FxDevice::DeleteObject ( VOID  )
virtual

Reimplemented from FxObject.

Definition at line 1135 of file fxdevice.cpp.

1152 {
1153  if (IsPnp() && IsPdo()) {
1154  FxPkgPdo* pPkgPdo;
1155  KIRQL irql;
1156  BOOLEAN remove;
1157 
1158  remove = FALSE;
1159 
1160  pPkgPdo = GetPdoPkg();
1161 
1162  pPkgPdo->Lock(&irql);
1163 
1165  //
1166  // Since no pnp action has been taken since the child was created, we
1167  // should be in the initial state.
1168  //
1170  //
1171  // A PDO in this state should be deletable
1172  //
1173  ASSERT(IsNoDeleteDDI() == FALSE);
1174 
1175  remove = TRUE;
1176  }
1177  else {
1178  //
1179  // If we are not in the init state, we should be in the created
1180  // state. This means we are failing from FxDevice::CreateDevice.
1181  //
1183  }
1184  }
1185 
1186  pPkgPdo->Unlock(irql);
1187 
1188  if (remove) {
1189  //
1190  // Cleanup the device and then let the super class delete the object.
1191  //
1194  }
1195  }
1196  else if (IsLegacy() && m_PkgGeneral != NULL && m_DeviceObject.GetObject() != NULL) {
1197  //
1198  // We allow tracing devices to go through a normal DeleteObject() path
1199  // where we do not prematurely delete the device object.
1200  //
1202 
1204 
1205  //
1206  // This reference will be released in Destroy().
1207  //
1209 
1210  if (m_PkgWmi != NULL) {
1211  //
1212  // Since a legacy NT4 driver does not have an explicit WMI
1213  // deregistration DDI, we do it for them on deletion.
1214  //
1215  // This is done in DeleteObject because we need to deregister before
1216  // we delete the device object, otherwise we can bugcheck when
1217  // running under driver verifier.
1218  //
1219  // m_PkgWmi->Deregister(); __REACTOS__
1220  }
1221 
1222  //
1223  // By deleting the device object now, we prevent any new creates from
1224  // being sent to the device (the io manager enforces this).
1225  //
1227 
1229  //
1230  // Delay the actual destruction of the device until the last open
1231  // handle has been closed. ControlDeviceDelete() will perform the
1232  // destruction later.
1233  //
1234  return;
1235  }
1236  }
1237 
1238  FxDeviceBase::DeleteObject(); // __super call
1239 }
virtual VOID DeleteObject(VOID)
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define TRUE
Definition: types.h:120
__inline BOOLEAN IsPnp(VOID)
Definition: fxdevice.hpp:1200
KIRQL irql
Definition: wave.h:1
BOOLEAN m_AddedToStaticList
Definition: fxpkgpdo.hpp:63
__inline BOOLEAN IsLegacy(VOID)
Definition: fxdevice.hpp:1209
UCHAR KIRQL
Definition: env_spec_w32.h:591
FxWmiIrpHandler * m_PkgWmi
Definition: fxdevice.hpp:672
#define FALSE
Definition: types.h:117
static __inline VOID MxReferenceObject(__in PVOID Object)
Definition: mxgeneralkm.h:238
unsigned char BOOLEAN
_Must_inspect_result_ NTSTATUS DeleteDeviceFromFailedCreateNoDelete(__in NTSTATUS FailedStatus, __in BOOLEAN UseStateMachine)
Definition: fxdevice.cpp:559
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
#define ASSERT(a)
Definition: mode.c:45
BOOLEAN IsNoDeleteDDI(VOID)
Definition: fxobject.hpp:1135
__inline FxPkgPdo * GetPdoPkg(VOID)
Definition: fxdevice.hpp:1254
FxPkgPdo * pPkgPdo
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
BOOLEAN m_Static
Definition: fxpkgpdo.hpp:61
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
FxPkgGeneral * m_PkgGeneral
Definition: fxdevice.hpp:671
__inline MdDeviceObject GetObject(VOID)
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
WDF_DEVICE_PNP_STATE m_CurrentPnpState
Definition: fxdevice.hpp:507
#define NULL
Definition: types.h:112
static __inline VOID MxDeleteDevice(_In_ MdDeviceObject Device)
Definition: mxgeneralkm.h:493
__inline BOOLEAN IsPdo(VOID)
Definition: fxdevice.hpp:1245
int remove
Definition: msacm.c:1365
BOOLEAN CanDestroyControlDevice(VOID)
MxDeviceObject m_DeviceObject
Definition: fxdevice.hpp:471
BOOLEAN m_DeviceObjectDeleted
Definition: fxdevice.hpp:553

Referenced by FxFileObject::_DestroyFileObject(), FxPkgPnp::DeleteDevice(), and DeleteDeviceFromFailedCreate().

◆ DeleteSymbolicLink()

VOID __inline FxDevice::DeleteSymbolicLink ( VOID  )

Definition at line 1342 of file fxdeviceum.cpp.

1345 {
1346  if (m_SymbolicLinkName.Buffer != NULL) {
1347  //
1348  // There is no IoDeleteSymbolicLink equivalent exposed by UMDF host.
1349  // Reflector takes care of deleteing the symbolic link on removal.
1350  // So just free the string now.
1351  //
1354  }
1355 }
UNICODE_STRING m_SymbolicLinkName
Definition: fxdevice.hpp:580
#define NULL
Definition: types.h:112
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
Definition: wdfpool.cpp:361

Referenced by FxPkgFdo::DeleteSymbolicLinkOverload(), FxPkgPdo::DeleteSymbolicLinkOverload(), Destroy(), FxPkgPdo::PnpEventPdoRemovedOverload(), and ~FxDevice().

◆ Destroy()

VOID FxDevice::Destroy ( VOID  )

Definition at line 329 of file fxdevicekm.cpp.

332 {
333  //
334  // We must be at passive for IoDeleteDevice
335  //
337 
338  if (m_DeviceObject.GetObject() != NULL) {
339  //
340  // The device object may not go away right away if there are pending
341  // references on it. But we can't look up our FxDevice anymore, so
342  // lets clear the DeviceExtension pointer.
343  //
345  }
346 
347  //
348  // Since this can be called in the context of the destructor when the ref
349  // count is zero, use GetObjectHandleUnchecked() to get the handle value.
350  //
353  "Deleting !devobj %p, WDFDEVICE %p, attached to !devobj %p",
355 
356  DetachDevice();
357 
358  if (m_DeviceObject.GetObject() != NULL) {
360 
361  if (m_DeviceObjectDeleted) {
362  //
363  // The device already deleted previously, release the reference we
364  // took at the time of delete.
365  //
367  }
368  else {
370  }
371 
373  }
374 
375  //
376  // Clean up any referenced objects
377  //
378  if (m_DeviceName.Buffer != NULL) {
381  }
382 
383  if (m_MofResourceName.Buffer != NULL) {
386  }
387 }
MxDeviceObject m_AttachedDevice
Definition: fxdevice.hpp:472
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
VOID DetachDevice(VOID)
UNICODE_STRING m_MofResourceName
Definition: fxdevice.hpp:585
UNICODE_STRING m_DeviceName
Definition: fxdevice.hpp:578
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define ASSERT(a)
Definition: mode.c:45
static __inline KIRQL MxGetCurrentIrql()
Definition: mxgeneralkm.h:86
PVOID __inline GetObjectHandleUnchecked(VOID)
Definition: fxobject.hpp:446
VOID SetDeviceExtension(PVOID Value)
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
__inline MdDeviceObject GetObject(VOID)
VOID DeleteSymbolicLink(VOID)
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
__inline VOID SetObject(__in_opt MdDeviceObject DeviceObject)
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
static __inline VOID MxDeleteDevice(_In_ MdDeviceObject Device)
Definition: mxgeneralkm.h:493
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
Definition: wdfpool.cpp:361
static __inline VOID MxDereferenceObject(__in PVOID Object)
Definition: mxgeneralkm.h:247
MxDeviceObject m_DeviceObject
Definition: fxdevice.hpp:471
BOOLEAN m_DeviceObjectDeleted
Definition: fxdevice.hpp:553

Referenced by FxPkgPnp::DeleteDevice(), DeleteDeviceFromFailedCreateNoDelete(), and Dispose().

◆ DestructorInternal()

VOID FxDevice::DestructorInternal ( VOID  )
private

Definition at line 390 of file fxdevicekm.cpp.

393 {
394  // NOTHING TO DO
395 }

Referenced by ~FxDevice().

◆ DetachDevice()

__inline VOID FxDevice::DetachDevice ( VOID  )

Definition at line 1269 of file fxdeviceum.cpp.

1272 {
1273  //
1274  // Note that UMDF host's DetachDevice has a different interface than
1275  // IoDetachDevice. DetachDevice takes the current device object as parameter
1276  // instead of target device.
1277  //
1278  if (m_DevStack != NULL && m_DeviceObject.GetObject() != NULL) {
1281 
1282  //
1283  // This was a weak ref. Set it to NULL. m_DeviceObject (IWudfDevice)'s
1284  // lifetime is managed by host through a ref taken during Attach.
1285  //
1287  }
1288 }
MxDeviceObject m_AttachedDevice
Definition: fxdevice.hpp:472
IWudfDeviceStack * m_DevStack
Definition: fxdevice.hpp:743
static VOID MxDetachDevice(_Inout_ MdDeviceObject Device)
Definition: mxgeneralkm.h:502
__inline MdDeviceObject GetObject(VOID)
__inline VOID SetObject(__in_opt MdDeviceObject DeviceObject)
#define NULL
Definition: types.h:112
MxDeviceObject m_DeviceObject
Definition: fxdevice.hpp:471

Referenced by Destroy().

◆ Dispatch()

_Must_inspect_result_ NTSTATUS FxDevice::Dispatch ( __in MdDeviceObject  DeviceObject,
__in MdIrp  OriginalIrp 
)
static

Definition at line 1549 of file fxdevice.cpp.

1553 {
1555  return DispatchWorker(device,
1556  Irp,
1557  device->m_PreprocessInfoListHead.Flink);
1558 }
static FxDevice * GetFxDevice(__in MdDeviceObject DeviceObject)
Definition: fxdeviceum.cpp:60
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
Definition: devices.h:37
_Must_inspect_result_ __inline NTSTATUS DispatchWorker(__in FxDevice *Device, __in MdIrp Irp, __in WDFCONTEXT DispatchContext)
Definition: fxdevice.cpp:1506

Referenced by DispatchUm(), DispatchWithLock(), and FxDriver::Initialize().

◆ DispatchPreprocessedIrp()

_Must_inspect_result_ NTSTATUS FxDevice::DispatchPreprocessedIrp ( __in MdIrp  Irp,
__in PVOID  DispatchContext 
)

Definition at line 1562 of file fxdevice.cpp.

1566 {
1567  NTSTATUS status;
1568  UCHAR major, minor;
1569  FxIrp irp(Irp);
1570 
1571  //
1572  // The contract for this DDI is just like IoCallDriver. The caller sets up
1573  // their stack location and then the DDI advances to the next stack location.
1574  // This means that the caller either has to call IoSkipCurrentIrpStackLocation
1575  // or IoCopyCurrentIrpStackLocationToNext before calling this DDI.
1576  //
1578 
1581 
1582  //
1583  // FxPkgPnp and FxWmiIrpHandler expect that there will be a remove lock
1584  // acquired for all power irps. We release the remlock when we called
1585  // Evt(Ext)DevicePreprocessIrp.
1586  //
1589  GetRemoveLock(),
1590  Irp
1591  );
1592 
1593  if (!NT_SUCCESS(status)) {
1594  goto Done;
1595  }
1596  }
1597 
1598  return DispatchWorker(this, Irp, DispatchContext);
1599 
1600 Done:
1601  irp.SetStatus(status);
1602  irp.SetInformation(0);
1604 
1605  return status;
1606 }
static __inline NTSTATUS MxAcquireRemoveLock(__in MdRemoveLock RemoveLock, __in_opt PVOID Tag)
Definition: mxgeneralkm.h:268
_In_ UCHAR _In_ UCHAR _In_ ULONG _In_ WDFCONTEXT _Inout_ PIRP _In_ WDFCONTEXT DispatchContext
Definition: wdfdevice.h:1697
MdRemoveLock GetRemoveLock(VOID)
Definition: fxdevicekm.hpp:47
VOID SetStatus(__in NTSTATUS Status)
Definition: fxirpum.cpp:457
LONG NTSTATUS
Definition: precomp.h:26
Definition: fxirp.hpp:28
VOID SetNextIrpStackLocation(VOID)
Definition: fxirpum.cpp:1235
_In_ PIRP Irp
Definition: csq.h:116
ULONG major
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID CompleteRequest(__in_opt CCHAR PriorityBoost=IO_NO_INCREMENT)
Definition: fxirpum.cpp:24
VOID SetInformation(__in ULONG_PTR Information)
Definition: fxirpum.cpp:504
unsigned char UCHAR
Definition: xmlstorage.h:181
_Must_inspect_result_ __inline NTSTATUS DispatchWorker(__in FxDevice *Device, __in MdIrp Irp, __in WDFCONTEXT DispatchContext)
Definition: fxdevice.cpp:1506
static FxDeviceRemLockAction __inline _RequiresRemLock(__in UCHAR MajorCode, __in UCHAR MinorCode)
Definition: fxdevice.hpp:933
UCHAR GetMinorFunction(VOID)
Definition: fxirpum.cpp:297
#define IO_NO_INCREMENT
Definition: iotypes.h:598
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
static SERVICE_STATUS status
Definition: service.c:31
ULONG minor
FxIrp * irp
Definition: ps.c:97

◆ DispatchUm()

VOID FxDevice::DispatchUm ( _In_ MdDeviceObject  DeviceObject,
_In_ MdIrp  Irp,
_In_opt_ IUnknown Context 
)
static

Definition at line 32 of file fxdeviceum.cpp.

37 {
39 
40 
41 
42 
43 
45 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
static _Must_inspect_result_ NTSTATUS STDCALL Dispatch(__in MdDeviceObject DeviceObject, __in MdIrp OriginalIrp)
Definition: fxdevice.cpp:1549

Referenced by FxDriver::Initialize().

◆ DispatchWithLock()

_Must_inspect_result_ NTSTATUS FxDevice::DispatchWithLock ( __in MdDeviceObject  DeviceObject,
__in MdIrp  OriginalIrp 
)
static

Definition at line 1335 of file fxdevice.cpp.

1339 {
1340  NTSTATUS status;
1341  FxIrp irp(Irp);
1342 
1344  irp.GetMinorFunction())) {
1345 
1348  &_GetFxWdmExtension(DeviceObject)->IoRemoveLock,
1349  Irp
1350  );
1351 
1352  if (!NT_SUCCESS(status)) {
1353  irp.SetStatus(status);
1355 
1356  return status;
1357  }
1358 
1359  break;
1360 
1361  case FxDeviceRemLockOptIn:
1363  DeviceObject,
1364  Irp
1365  );
1366 
1367  if (!NT_SUCCESS(status)) {
1368  irp.SetStatus(status);
1370 
1371  return status;
1372  }
1373 
1374  break;
1375 
1377  //
1378  // Try to Acquire and Release the RemLock. If acquiring the lock
1379  // fails then it is not safe to process the IRP and the IRP should
1380  // be completed immediately.
1381  //
1383  &_GetFxWdmExtension(DeviceObject)->IoRemoveLock,
1384  Irp
1385  );
1386 
1387  if (!NT_SUCCESS(status)) {
1388  irp.SetStatus(status);
1390 
1391  return status;
1392  }
1393 
1395  &_GetFxWdmExtension(DeviceObject)->IoRemoveLock,
1396  Irp
1397  );
1398  break;
1399  }
1400 
1401  return Dispatch(DeviceObject, Irp);
1402 }
static __inline NTSTATUS MxAcquireRemoveLock(__in MdRemoveLock RemoveLock, __in_opt PVOID Tag)
Definition: mxgeneralkm.h:268
VOID SetStatus(__in NTSTATUS Status)
Definition: fxirpum.cpp:457
LONG NTSTATUS
Definition: precomp.h:26
Definition: fxirp.hpp:28
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
static _Must_inspect_result_ NTSTATUS _AcquireOptinRemoveLock(__in MdDeviceObject DeviceObject, __in MdIrp Irp)
Definition: fxdevice.cpp:1296
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID CompleteRequest(__in_opt CCHAR PriorityBoost=IO_NO_INCREMENT)
Definition:</