ReactOS 0.4.16-dev-329-g9223134
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)
 
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 VOID SetDeviceTelemetryInfoFlags (_In_ FxDeviceInfoFlags Flag)
 
__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)
 
virtual FxIoTargetGetDefaultIoTarget (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)
 
virtual VOID DeleteObject (VOID)
 
virtual BOOLEAN Dispose (VOID)
 
_Must_inspect_result_ NTSTATUS AssignParentObject (__in FxObject *ParentObject)
 
_Must_inspect_result_ NTSTATUS AddContext (__in FxContextHeader *Header, __in PVOID *Context, __in PWDF_OBJECT_ATTRIBUTES Attributes)
 
_Must_inspect_result_ NTSTATUS RemoveParentAssignment (VOID)
 
_Must_inspect_result_ FxObjectGetParentObjectReferenced (__in PVOID Tag)
 
BOOLEAN IsDisposed (VOID)
 
- Public Member Functions inherited from IFxHasCallbacks
virtual VOID GetConstraints (__out WDF_EXECUTION_LEVEL *ExecutionLevel, __out WDF_SYNCHRONIZATION_SCOPE *SynchronizationScope)=0
 
virtual _Must_inspect_result_ FxCallbackLockGetCallbackLockPtr (__out_opt FxObject **LockObject)=0
 

Static Public Member Functions

static _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{
150}
CfxDevice * m_ParentDevice
Definition: fxdevice.hpp:569
VOID SetInitialState(VOID)
Definition: fxdevice.cpp:153
#define NULL
Definition: types.h:112
@ FX_TYPE_DEVICE
Definition: fxtypes.h:47

◆ ~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);
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);
317 }
318
324 delete info;
325 }
326
332 delete info;
333 }
334
335 //
336 // Clean up any referenced objects
337 //
338 if (m_DeviceName.Buffer != NULL) {
341 }
342
344
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}
MxDeviceObject m_DeviceObject
Definition: fxdevice.hpp:471
size_t m_RequestLookasideListElementSize
Definition: fxdevice.hpp:653
FxWmiIrpHandler * m_PkgWmi
Definition: fxdevice.hpp:672
UNICODE_STRING m_DeviceName
Definition: fxdevice.hpp:578
VOID DeleteSymbolicLink(VOID)
VOID DestructorInternal(VOID)
Definition: fxdevicekm.cpp:390
FxDefaultIrpHandler * m_PkgDefault
Definition: fxdevice.hpp:673
NPAGED_LOOKASIDE_LIST m_RequestLookasideList
Definition: fxdevice.hpp:648
FxPkgPnp * m_PkgPnp
Definition: fxdevice.hpp:670
UNICODE_STRING m_MofResourceName
Definition: fxdevice.hpp:585
FxPkgGeneral * m_PkgGeneral
Definition: fxdevice.hpp:671
LIST_ENTRY m_PreprocessInfoListHead
Definition: fxdevice.hpp:630
FxPkgIo * m_PkgIo
Definition: fxdevice.hpp:669
UNICODE_STRING m_SymbolicLinkName
Definition: fxdevice.hpp:580
LIST_ENTRY m_CxDeviceInfoListHead
Definition: fxdevice.hpp:635
BOOLEAN IsDisposed(VOID)
Definition: fxobject.hpp:1241
PVOID __inline GetObjectHandleUnchecked(VOID)
Definition: fxobject.hpp:446
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
__inline MdDeviceObject GetObject(VOID)
static __inline VOID MxDeleteNPagedLookasideList(_In_ PNPAGED_LOOKASIDE_LIST LookasideList)
Definition: mxgeneralkm.h:433
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define FALSE
Definition: types.h:117
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
Definition: wdfpool.cpp:361
#define FxVerifierBugCheck(FxDriverGlobals, Error,...)
Definition: fxverifier.h:58
#define ASSERT(a)
Definition: mode.c:44
static unsigned __int64 next
Definition: rand_nt.c:6
#define TRACE_LEVEL_FATAL
Definition: storswtr.h:26
Definition: typedefs.h:120
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
@ WDF_OBJECT_ERROR
Definition: wdfbugcodes.h:64

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{
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
1322 TRUE,
1323 TRUE,
1324 TRUE
1325 );
1326
1328 }
1329
1330 return STATUS_SUCCESS;
1331}
LONG NTSTATUS
Definition: precomp.h:26
static MdCompletionRoutineType _CompletionRoutineForRemlockMaintenance
Definition: fxdevice.hpp:831
static FxWdmDeviceExtension * _GetFxWdmExtension(__in MdDeviceObject DeviceObject)
Definition: fxdevicekm.hpp:30
Definition: fxirp.hpp:28
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
VOID SetNextIrpStackLocation(VOID)
Definition: fxirpum.cpp:1235
VOID CopyCurrentIrpStackLocationToNext(VOID)
Definition: fxirpum.cpp:209
static __inline NTSTATUS MxAcquireRemoveLock(__in MdRemoveLock RemoveLock, __in_opt PVOID Tag)
Definition: mxgeneralkm.h:268
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
FxIrp * irp
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG RemoveLockOptionFlags
Definition: fxdevice.hpp:38
WUDF_IO_REMOVE_LOCK IoRemoveLock
Definition: fxdevice.hpp:34
Definition: ps.c:97
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
@ WDF_REMOVE_LOCK_OPTION_ACQUIRE_FOR_IO
Definition: wdfdevice.h:1639

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 1988 of file fxdevice.cpp.

1998{
2001 ULONG length = 0;
2002
2004 DeviceInit,
2005 Device,
2006 RemotePdo,
2008 0,
2009 NULL,
2010 &length);
2013 "Could not retrieve property %d length, %!STATUS!",
2016 return status;
2017 }
2018
2021 PoolType,
2022 Globals->Tag,
2023 length,
2024 &pMemory);
2025 if (!NT_SUCCESS(status)) {
2027 "Could not allocate WDFMEMORY, %!STATUS!", status);
2028 return status;
2029 }
2030
2032 DeviceInit,
2033 Device,
2034 RemotePdo,
2036 length,
2037 pMemory->GetBuffer(),
2038 &length);
2039 if (!NT_SUCCESS(status)) {
2041 "Could not query for full buffer, size %d, for "
2042 "property %d, %!STATUS!",
2045 return status;
2046 }
2047
2050
2051 if (!NT_SUCCESS(status)) {
2053 "Could not commit memory object, %!STATUS!",
2054 status);
2056 }
2057
2058 return status;
2059}
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
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)
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
virtual PVOID GetBuffer(VOID)=0
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
FxMemoryObject * pMemory
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define _Analysis_assume_
Definition: no_sal2.h:388
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_In_ PWDFDEVICE_INIT DeviceInit
Definition: wdfcontrol.h:113
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE _In_opt_ PWDF_OBJECT_ATTRIBUTES PropertyMemoryAttributes
Definition: wdfdevice.h:3817
_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:3820
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty
Definition: wdfdevice.h:3769

◆ _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 2063 of file fxdevice.cpp.

2074{
2077 ULONG length = 0;
2078 DEVPROPTYPE propType;
2079 ULONG requiredLength;
2080
2082 DeviceInit,
2083 Device,
2086 0,
2087 NULL,
2088 &requiredLength,
2089 &propType);
2092 "Could not retrieve property, %!STATUS!",
2093 status);
2095 return status;
2096 }
2097
2099 *PropertyType = 0;
2100
2101 length = requiredLength;
2104 PoolType,
2105 DriverGlobals->Tag,
2106 length,
2107 &pMemory);
2108 if (!NT_SUCCESS(status)) {
2110 "Could not allocate WDFMEMORY, %!STATUS!", status);
2111 return status;
2112 }
2113
2115 DeviceInit,
2116 Device,
2119 length,
2120 pMemory->GetBuffer(),
2121 &requiredLength,
2122 &propType);
2123 if (!NT_SUCCESS(status)) {
2125 "Could not query for full buffer, size %d, for "
2126 "property, %!STATUS!",
2127 length, status);
2129 return status;
2130 }
2131
2134
2135 if (!NT_SUCCESS(status)) {
2137 "Could not commit memory object, %!STATUS!",
2138 status);
2140 }
2141 else {
2143 *PropertyType = propType;
2144 }
2145
2146 return status;
2147}
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
virtual WDFMEMORY GetHandle(VOID)
#define TRACINGPNP
Definition: dbgtrace.h:67
ULONG DEVPROPTYPE
Definition: devpropdef.h:24
FxPropertyType
Definition: fxdevice.hpp:85
_In_ WDFDEVICE _In_ PWDF_DEVICE_INTERFACE_PROPERTY_DATA PropertyData
_In_ WDFDEVICE _In_ PWDF_DEVICE_INTERFACE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG _Out_ PDEVPROPTYPE PropertyType
DriverGlobals

◆ _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{
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) {
400 break;
401
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
543Done:
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}
__inline FxDriver * GetDriver(VOID)
Definition: fxdevice.hpp:164
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
__inline BOOLEAN IsPnp(VOID)
Definition: fxdevice.hpp:1200
__inline CHAR GetStackSize(VOID)
Definition: fxdevice.hpp:1824
_Must_inspect_result_ NTSTATUS Initialize(__in PWDFDEVICE_INIT DeviceInit, __in_opt PWDF_OBJECT_ATTRIBUTES DeviceAttributes)
Definition: fxdevice.cpp:663
_Must_inspect_result_ NTSTATUS PdoInitialize(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxdevicekm.cpp:221
_Must_inspect_result_ NTSTATUS PostInitialize(VOID)
Definition: fxdevice.cpp:940
BOOLEAN m_SelfIoTargetNeeded
Definition: fxdevice.hpp:611
_Must_inspect_result_ NTSTATUS FdoInitialize(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxdevicekm.cpp:33
__inline VOID SetStackSize(_In_ CHAR Size)
Definition: fxdevice.hpp:1833
_Must_inspect_result_ NTSTATUS DeleteDeviceFromFailedCreate(__in NTSTATUS FailedStatus, __in BOOLEAN UseStateMachine)
Definition: fxdevice.cpp:644
_Must_inspect_result_ NTSTATUS ControlDeviceInitialize(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxdevicekm.cpp:399
virtual VOID FinishInitialize(__inout PWDFDEVICE_INIT DeviceInit)
Definition: fxpkgpnp.cpp:1240
VOID __inline ReleaseString(__out PUNICODE_STRING ReleaseTo)
Definition: fxstring.hpp:47
#define InsertTailList(ListHead, Entry)
FxDevice * pDevice
@ FxDeviceInitTypeControlDevice
@ FxDeviceInitTypeFdo
@ FxDeviceInitTypePdo
PWDFDEVICE_INIT pInit
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
FxIrpPreprocessInfo * PreprocessInfo
FxString * DeviceName
FxDeviceInitType InitType
LIST_ENTRY CxDeviceInitListHead
FxDriver * Driver
BOOLEAN CreatedOnStack
FxIrpPreprocessInfo * PreprocessInfo
FxDevice * CreatedDevice
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _Inout_ PWDFDEVICE_INIT _In_opt_ PWDF_OBJECT_ATTRIBUTES DeviceAttributes
Definition: wdfdevice.h:3563

◆ _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;
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;
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}
unsigned char BOOLEAN
#define TODO
Definition: SAX2.c:44
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
FX_VERIFY(INTERNAL, CHECK_NOT_NULL(LoaderInterface->pIWudfHost))
GLuint buffer
Definition: glext.h:5915
#define S_OK
Definition: intsafe.h:52
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
#define L(x)
Definition: ntvdm.h:50
HRESULT hr
Definition: shlfolder.c:183
#define StringCchPrintf
Definition: strsafe.h:517
uint16_t * PWSTR
Definition: typedefs.h:56
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID PropertyBuffer
Definition: wdfdevice.h:4437
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
@ DevicePropertyCompatibleIDs
Definition: iotypes.h:1197
@ DevicePropertyAddress
Definition: iotypes.h:1211
@ DevicePropertyEnumeratorName
Definition: iotypes.h:1210
@ DevicePropertyBootConfiguration
Definition: iotypes.h:1198
@ DevicePropertyResourceRequirements
Definition: iotypes.h:1215
@ DevicePropertyDriverKeyName
Definition: iotypes.h:1202
@ DevicePropertyInstallState
Definition: iotypes.h:1213
@ DevicePropertyClassGuid
Definition: iotypes.h:1201
@ DevicePropertyUINumber
Definition: iotypes.h:1212
@ DevicePropertyBusNumber
Definition: iotypes.h:1209
@ DevicePropertyBootConfigurationTranslated
Definition: iotypes.h:1199
@ DevicePropertyRemovalPolicy
Definition: iotypes.h:1214
@ DevicePropertyPhysicalDeviceObjectName
Definition: iotypes.h:1206
@ DevicePropertyLegacyBusType
Definition: iotypes.h:1208
@ DevicePropertyAllocatedResources
Definition: iotypes.h:1216
@ DevicePropertyManufacturer
Definition: iotypes.h:1203
@ DevicePropertyClassName
Definition: iotypes.h:1200
@ DevicePropertyFriendlyName
Definition: iotypes.h:1204
@ DevicePropertyContainerID
Definition: iotypes.h:1217
@ DevicePropertyLocationInformation
Definition: iotypes.h:1205
@ DevicePropertyHardwareID
Definition: iotypes.h:1196
@ DevicePropertyBusTypeGuid
Definition: iotypes.h:1207
@ DevicePropertyDeviceDescription
Definition: iotypes.h:1195
__wchar_t WCHAR
Definition: xmlstorage.h:180

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

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 }

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 }

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{
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,
1084 subpath,
1086 NULL);
1087 status = FxDevice::NtStatusFromHr(DeviceStack, hr);
1088
1089 return status;
1090}
struct _root root
static NTSTATUS NtStatusFromHr(_In_ IWudfDeviceStack *DevStack, _In_ HRESULT Hr)
Definition: fxdeviceum.cpp:826
GLbitfield flags
Definition: glext.h:7161
#define FX_PLUGPLAY_REGKEY_DEVICEMAP
Definition: mxum.h:48
#define PLUGPLAY_REGKEY_DRIVER
Definition: usbd.c:42
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
#define WDF_REGKEY_DRIVER_SUBKEY
Definition: wdfregistry.h:51
#define WDF_REGKEY_DEVICE_SUBKEY
Definition: wdfregistry.h:50
#define PLUGPLAY_REGKEY_CURRENT_HWPROFILE
Definition: iofuncs.h:2788
_In_ ULONG _In_ ACCESS_MASK _Out_ PHANDLE DevInstRegKey
Definition: iofuncs.h:1127
_In_ ULONG DevInstKeyType
Definition: iofuncs.h:1125
#define PLUGPLAY_REGKEY_DEVICE
Definition: iofuncs.h:2786

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
748 if (!NT_SUCCESS(status)) {
749 return status;
750 }
751
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)) {
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}
static _Must_inspect_result_ NTSTATUS _ValidateOpenKeyParams(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device)
Definition: fxdevice.cpp:2151
static __inline NTSTATUS _OpenDeviceRegistryKey(_In_ MdDeviceObject DeviceObject, _In_ ULONG DevInstKeyType, _In_ ACCESS_MASK DesiredAccess, _Out_ PHANDLE DevInstRegKey)
VOID SetDeviceBase(__in CfxDeviceBase *DeviceBase)
Definition: fxobject.hpp:797
VOID DeleteFromFailedCreate(VOID)
Definition: fxobject.cpp:391
__inline VOID SetHandle(__in HANDLE Key)
Definition: fxregkey.hpp:94
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
FxRegKey * pKey
WDFKEY keyHandle
FxAutoRegKey hKey
_Must_inspect_result_ NTSTATUS FxValidateObjectAttributes(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
#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:2660
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG DeviceInstanceKeyType
Definition: wdfdevice.h:2656

◆ _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 {
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
990 return status;
991}
static __inline NTSTATUS _GetDeviceProperty(_In_ MdDeviceObject DeviceObject, _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty, _In_ ULONG BufferLength, _Out_opt_ PVOID PropertyBuffer, _Out_ PULONG ResultLength)

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
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,
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}
@ FxDeviceProperty
Definition: fxdevice.hpp:86
DWORD LCID
Definition: nls.h:13
_In_ const DEVPROPKEY * PropertyKey
Definition: wdfdevice.h:1912
struct _WDF_DEVICE_PROPERTY_DATA * PWDF_DEVICE_PROPERTY_DATA

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)
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_MJ_PNP
Definition: cdrw_usr.h:52
@ FxDeviceRemLockRequired
Definition: fxdevice.hpp:80
@ FxDeviceRemLockTestValid
Definition: fxdevice.hpp:81
@ FxDeviceRemLockNotRequired
Definition: fxdevice.hpp:79
@ FxDeviceRemLockOptIn
Definition: fxdevice.hpp:82
#define IRP_MN_REMOVE_DEVICE
#define IRP_MJ_SYSTEM_CONTROL
#define IRP_MJ_POWER

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 2151 of file fxdevice.cpp.

2156{
2158
2159 //
2160 // This function should be called with exactly one valid WDFDEVICE_INIT
2161 // or one valid FxDevice object. Supplying neither or both is an error.
2162 //
2163 if ((DeviceInit == NULL && Device == NULL) ||
2164 (DeviceInit != NULL && Device != NULL)) {
2165
2168 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
2169 "Device OpenKey/QueryProperty was called with invalid "
2170 "DeviceInit and Device parameters, %!STATUS!", status);
2171 FxVerifierDbgBreakPoint(FxDriverGlobals);
2172 }
2173
2174 return status;
2175}
FxVerifierDbgBreakPoint(pFxDriverGlobals)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

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}
VOID AddChildList(__in FxChildList *List)
Definition: fxpkgpnp.cpp:4970
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550

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}
VOID AddDmaEnabler(__in FxDmaEnabler *Enabler)
Definition: fxpkgpnpkm.cpp:277

◆ AddIoTarget()

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

Reimplemented from FxDeviceBase.

Definition at line 1772 of file fxdevice.cpp.

1775{
1777
1779 &IoTarget->m_TransactionedEntry);
1780
1781 if (NT_SUCCESS(status)) {
1782 IoTarget->m_AddedToDeviceList = TRUE;
1783 IoTarget->ADDREF(this);
1784 }
1785
1786 return status;
1787}
FxSpinLockTransactionedList m_IoTargetsList
Definition: fxdevice.hpp:623
NTSTATUS Add(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxTransactionedEntry *Entry)
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIOTARGET * IoTarget
Definition: wdfiotarget.h:368

◆ 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}
_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 1805 of file fxdevice.cpp.

1808{
1809 if (IsPnp()) {
1810 return m_PkgPnp->AllocateEnumInfo();
1811 }
1812 else {
1813 return STATUS_SUCCESS;
1814 }
1815}
_Must_inspect_result_ NTSTATUS AllocateEnumInfo(VOID)
Definition: fxpkgpnp.cpp:4920

◆ AllocateRequestMemory()

PVOID FxDevice::AllocateRequestMemory ( __in_opt PWDF_OBJECT_ATTRIBUTES  Attributes)

Definition at line 1630 of file fxdevice.cpp.

1659{
1661 PFX_POOL_TRACKER pTracker;
1663 PVOID ptr, pTrueBase;
1664
1666 ptr = NULL;
1667
1668 if (IsPdo() && GetPdoPkg()->IsForwardRequestToParentEnabled()) {
1670 }
1671 else {
1674 }
1675
1676 if (pTrueBase != NULL) {
1677 if (pGlobals->IsPoolTrackingOn()) {
1678 pTracker = (PFX_POOL_TRACKER) pTrueBase;
1679 pHeader = WDF_PTR_ADD_OFFSET_TYPE(pTrueBase,
1680 sizeof(FX_POOL_TRACKER),
1682
1683 //
1684 // Format and insert the Tracker in the NonPagedHeader list.
1685 //
1687 pTracker,
1689 pGlobals->Tag,
1690 _ReturnAddress());
1691 }
1692 else {
1693 pHeader = (PFX_POOL_HEADER) pTrueBase;
1694 }
1695
1696 //
1697 // Common init
1698 //
1699 pHeader->Base = pTrueBase;
1700 pHeader->FxDriverGlobals = pGlobals;
1701
1702 ptr = &pHeader->AllocationStart[0];
1703
1704 if (RequestAttributes == NULL) {
1706 }
1707
1709 pGlobals,
1710 ptr,
1711 COMPUTE_OBJECT_SIZE(sizeof(FxRequest), 0),
1714 );
1715
1716#if FX_VERBOSE_TRACE
1718 "Allocating FxRequest* %p, WDFREQUEST %p",
1719 ptr, _ToHandle((FxObject*) ptr));
1720#endif
1721 return ptr;
1722 }
1723
1724 return NULL;
1725}
WDF_OBJECT_ATTRIBUTES m_RequestAttributes
Definition: fxdevice.hpp:659
__inline BOOLEAN IsPdo(VOID)
Definition: fxdevice.hpp:1245
__inline FxPkgPdo * GetPdoPkg(VOID)
Definition: fxdevice.hpp:1254
static PVOID __inline _ToHandle(__in FxObject *Object)
Definition: fxobject.hpp:659
#define TRACINGREQUEST
Definition: dbgtrace.h:65
__inline PVOID FxAllocateFromNPagedLookasideList(_In_ PNPAGED_LOOKASIDE_LIST Lookaside, _In_opt_ size_t ElementSize=0)
Definition: fxglobalskm.h:565
_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
#define COMPUTE_OBJECT_SIZE(_rawObjectSize, _extraSize)
Definition: fxhandle.h:107
PFX_DRIVER_GLOBALS pGlobals
@ FxObjectTypeExternal
Definition: fxobject.hpp:120
FX_POOL_TRACKER * PFX_POOL_TRACKER
Definition: fxpool.h:109
FX_POOL_HEADER * PFX_POOL_HEADER
Definition: fxpool.h:51
VOID __inline FxPoolInsertNonPagedAllocateTracker(__in PFX_POOL Pool, __in PFX_POOL_TRACKER Tracker, __in SIZE_T Size, __in ULONG Tag, __in PVOID Caller)
FxContextHeader * pHeader
Definition: handleapi.cpp:604
#define _ReturnAddress()
Definition: intrin_arm.h:35
static PVOID ptr
Definition: dispmode.c:27
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
FX_POOL FxPoolFrameworks
Definition: fxglobals.h:388
BOOLEAN IsPoolTrackingOn(VOID)
Definition: fxglobals.h:215
#define WDF_PTR_ADD_OFFSET_TYPE(_ptr, _offset, _type)
Definition: wdfcore.h:141
_In_ PWDFDEVICE_INIT _In_ PWDF_OBJECT_ATTRIBUTES RequestAttributes
Definition: wdfdevice.h:3431

◆ 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,
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}
Type
Definition: Type.h:7
MdDeviceObject __inline GetSafePhysicalDevice(VOID)
Definition: fxdevice.hpp:1005
#define GetHandle(h)
Definition: treelist.c:116

◆ 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 }
__inline VOID ClearCallbackFlagsLocked(__in BYTE Flags)
Definition: fxdevice.hpp:1539
__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_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:127
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by __drv_when().

◆ ClearCallbackFlagsLocked()

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

Definition at line 1539 of file fxdevice.hpp.

1542 {
1544 }
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
BOOLEAN m_AutoForwardCleanupClose
Definition: fxdevice.hpp:605
WDFCX_FILEOBJECT_CONFIG Callbacks
WDF_TRI_STATE AutoForwardCleanupClose
CxFileObjectInit FileObject
PFN_WDFCX_DEVICE_FILE_CREATE EvtCxDeviceFileCreate
Definition: wdfcx.h:28
@ WdfTrue
Definition: wdftypes.h:88
@ WdfUseDefault
Definition: wdftypes.h:89
@ WdfFalse
Definition: wdftypes.h:87
enum _WDF_TRI_STATE WDF_TRI_STATE

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 }
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}
_Must_inspect_result_ NTSTATUS CreateDevice(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxdevice.cpp:964
_Must_inspect_result_ NTSTATUS PostCreateDeviceInitialize(__in PWDFDEVICE_INIT Init)

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,
1031 pSddl,
1032 pGuid,
1033 &pNewDeviceObject);
1034 }
1035 else {
1038 sizeof(FxWdmDeviceExtension),
1039 NULL,
1040 devType,
1041 characteristics,
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
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}
#define ARRAY_SIZE(A)
Definition: main.h:20
FxDriver * m_Driver
Definition: fxdevice.hpp:469
BOOLEAN m_Exclusive
Definition: fxdevice.hpp:540
CHAR m_DefaultPriorityBoost
Definition: fxdevice.hpp:561
WDF_DEVICE_IO_TYPE m_ReadWriteIoType
Definition: fxdevice.hpp:514
BOOLEAN m_Filter
Definition: fxdevice.hpp:522
BOOLEAN m_PowerPageableCapable
Definition: fxdevice.hpp:530
static const CHAR m_PriorityBoosts[]
Definition: fxdevice.hpp:563
MxDriverObject m_DriverObject
Definition: fxdriver.hpp:62
__inline FxContextHeader * GetContextHeader(VOID)
Definition: fxobject.hpp:720
_Must_inspect_result_ NTSTATUS Initialize(__in PWDFDEVICE_INIT DeviceInit)
__inline VOID SetObject(__in_opt MdDeviceObject DeviceObject)
ULONG GetFlags(VOID)
VOID SetFlags(ULONG Flags)
__inline MdDriverObject GetObject(VOID)
static __inline VOID MxInitializeRemoveLock(__in MdRemoveLock Lock, __in ULONG AllocateTag, __in ULONG MaxLockedMinutes, __in ULONG HighWatermark)
Definition: mxgeneralkm.h:256
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
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
#define DEVICE_TYPE
Definition: guid.c:10
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
static LPSTR pName
Definition: security.c:75
ULONG RemoveLockOptionFlags
Definition: fxglobals.h:494
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
@ WdfDeviceIoBuffered
Definition: wdfdevice.h:452
@ WdfDeviceIoDirect
Definition: wdfdevice.h:453

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) {
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 {
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}
__inline BOOLEAN IsLegacy(VOID)
Definition: fxdevice.hpp:1209
static __inline NTSTATUS MxCreateSymbolicLink(_In_ PUNICODE_STRING SymbolicLinkName, _In_ PUNICODE_STRING DeviceName)
Definition: mxgeneralkm.h:579
#define PagedPool
Definition: env_spec_w32.h:308
FxAutoString pdoName
FxDevice * pPdo
#define USHORT_MAX
Definition: intsafe.h:147
#define UNICODE_NULL
#define STATUS_INTEGER_OVERFLOW
Definition: ntstatus.h:385
unsigned short USHORT
Definition: pedump.c:61
PVOID pBuffer
_Must_inspect_result_ NTSTATUS FxDuplicateUnicodeString(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in const UNICODE_STRING *Source, __out PUNICODE_STRING Destination)
Definition: stringutil.cpp:180
UNICODE_STRING m_UnicodeString
USHORT MaximumLength
Definition: env_spec_w32.h:370
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING SymbolicLinkName
Definition: wdfdevice.h:3739

◆ 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}
_Must_inspect_result_ NTSTATUS DeleteDeviceFromFailedCreateNoDelete(__in NTSTATUS FailedStatus, __in BOOLEAN UseStateMachine)
Definition: fxdevice.cpp:559
pKey DeleteObject()

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();
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}
FxDisposeList * m_DisposeList
Definition: fxdevice.hpp:466
VOID Destroy(VOID)
Definition: fxdevicekm.cpp:329
VOID SetCleanupFromFailedCreate(BOOLEAN Value)
Definition: fxdevice.hpp:1877
__inline BOOLEAN IsFilter()
Definition: fxdevice.hpp:1408
VOID WaitForEmpty(VOID)
VOID __inline DestroyChildren(VOID)
Definition: fxobject.hpp:464
BOOLEAN EarlyDispose(VOID)
VOID CleanupStateMachines(__in BOOLEAN ClenaupPnp)
Definition: fxpkgpnp.cpp:2066
VOID CleanupDeviceFromFailedCreate(__in MxEvent *WaitEvent)
Definition: fxpkgpnp.cpp:2190
CHECK_RETURN_IF_USER_MODE __inline NTSTATUS Initialize(__in EVENT_TYPE Type, __in BOOLEAN InitialState)
Definition: mxeventkm.h:55
MxEvent * GetSelfPointer(VOID)
Definition: mxevent.h:110
return pDevice GetDeviceObject()
@ SynchronizationEvent
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29

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()) {
1155 KIRQL irql;
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 //
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
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}
WDF_DEVICE_PNP_STATE m_CurrentPnpState
Definition: fxdevice.hpp:507
BOOLEAN IsNoDeleteDDI(VOID)
Definition: fxobject.hpp:1135
BOOLEAN CanDestroyControlDevice(VOID)
BOOLEAN m_AddedToStaticList
Definition: fxpkgpdo.hpp:63
BOOLEAN m_Static
Definition: fxpkgpdo.hpp:61
static __inline VOID MxDeleteDevice(_In_ MdDeviceObject Device)
Definition: mxgeneralkm.h:493
static __inline VOID MxReferenceObject(__in PVOID Object)
Definition: mxgeneralkm.h:238
FxPkgPdo * pPkgPdo
int remove
Definition: msacm.c:1366
@ WdfDevStatePnpInit
Definition: wdfdevice.h:69
@ WdfDevStatePnpObjectCreated
Definition: wdfdevice.h:64

Referenced by FxPkgPnp::DeleteDevice().

◆ DeleteSymbolicLink()

VOID __inline FxDevice::DeleteSymbolicLink ( VOID  )

Definition at line 1342 of file fxdeviceum.cpp.

1345{
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}

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
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
386 }
387}
MxDeviceObject m_AttachedDevice
Definition: fxdevice.hpp:472
VOID DetachDevice(VOID)
VOID SetDeviceExtension(PVOID Value)
static __inline VOID MxDereferenceObject(__in PVOID Object)
Definition: mxgeneralkm.h:247
static __inline KIRQL MxGetCurrentIrql()
Definition: mxgeneralkm.h:86

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}
IWudfDeviceStack * m_DevStack
Definition: fxdevice.hpp:743
static VOID MxDetachDevice(_Inout_ MdDeviceObject Device)
Definition: mxgeneralkm.h:502

Referenced by Destroy().

◆ Dispatch()

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

Definition at line 1551 of file fxdevice.cpp.

1555{
1557 return DispatchWorker(device,
1558 Irp,
1559 device->m_PreprocessInfoListHead.Flink);
1560}
static FxDevice * GetFxDevice(__in MdDeviceObject DeviceObject)
Definition: fxdeviceum.cpp:60
_Must_inspect_result_ __inline NTSTATUS DispatchWorker(__in FxDevice *Device, __in MdIrp Irp, __in WDFCONTEXT DispatchContext)
Definition: fxdevice.cpp:1507
Definition: devices.h:37

Referenced by FxDriver::Initialize().

◆ DispatchPreprocessedIrp()

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

Definition at line 1564 of file fxdevice.cpp.

1568{
1570 UCHAR major, minor;
1571 FxIrp irp(Irp);
1572
1573 //
1574 // The contract for this DDI is just like IoCallDriver. The caller sets up
1575 // their stack location and then the DDI advances to the next stack location.
1576 // This means that the caller either has to call IoSkipCurrentIrpStackLocation
1577 // or IoCopyCurrentIrpStackLocationToNext before calling this DDI.
1578 //
1580
1583
1584 //
1585 // FxPkgPnp and FxWmiIrpHandler expect that there will be a remove lock
1586 // acquired for all power irps. We release the remlock when we called
1587 // Evt(Ext)DevicePreprocessIrp.
1588 //
1591 GetRemoveLock(),
1592 Irp
1593 );
1594
1595 if (!NT_SUCCESS(status)) {
1596 goto Done;
1597 }
1598 }
1599
1600 return DispatchWorker(this, Irp, DispatchContext);
1601
1602Done:
1606
1607 return status;
1608}
static FxDeviceRemLockAction __inline _RequiresRemLock(__in UCHAR MajorCode, __in UCHAR MinorCode)
Definition: fxdevice.hpp:933
MdRemoveLock GetRemoveLock(VOID)
Definition: fxdevicekm.hpp:47
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
VOID CompleteRequest(__in_opt CCHAR PriorityBoost=IO_NO_INCREMENT)
Definition: fxirpum.cpp:24
VOID SetStatus(__in NTSTATUS Status)
Definition: fxirpum.cpp:457
VOID SetInformation(__in ULONG_PTR Information)
Definition: fxirpum.cpp:504
UCHAR GetMinorFunction(VOID)
Definition: fxirpum.cpp:297
#define minor(rdev)
Definition: propsheet.cpp:929
#define major(rdev)
Definition: propsheet.cpp:928
_In_ UCHAR _In_ UCHAR _In_ ULONG _In_ WDFCONTEXT _Inout_ PIRP _In_ WDFCONTEXT DispatchContext
Definition: wdfdevice.h:1708
#define IO_NO_INCREMENT
Definition: iotypes.h:598
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ 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}
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH * Dispatch
Definition: wsk.h:188

Referenced by FxDriver::Initialize().

◆ DispatchWithLock()

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

Definition at line 1336 of file fxdevice.cpp.

1340{
1342 FxIrp irp(Irp);
1343
1345 irp.GetMinorFunction())) {
1346
1349 &_GetFxWdmExtension(DeviceObject)->IoRemoveLock,
1350 Irp
1351 );
1352
1353 if (!NT_SUCCESS(status)) {
1356
1357 return status;
1358 }
1359
1360 break;
1361
1365 Irp
1366 );
1367
1368 if (!NT_SUCCESS(status)) {
1371
1372 return status;
1373 }
1374
1375 break;
1376
1378 //
1379 // Try to Acquire and Release the RemLock. If acquiring the lock
1380 // fails then it is not safe to process the IRP and the IRP should
1381 // be completed immediately.
1382 //
1384 &_GetFxWdmExtension(DeviceObject)->IoRemoveLock,
1385 Irp
1386 );
1387
1388 if (!NT_SUCCESS(status)) {
1391
1392 return status;
1393 }
1394
1396 &_GetFxWdmExtension(DeviceObject)->IoRemoveLock,
1397 Irp
1398 );
1399 break;
1400 }
1401
1402 return Dispatch(DeviceObject, Irp);
1403}
static _Must_inspect_result_ NTSTATUS _AcquireOptinRemoveLock(__in MdDeviceObject DeviceObject, __in MdIrp Irp)
Definition: fxdevice.cpp:1296
static __inline VOID MxReleaseRemoveLock(__in MdRemoveLock RemoveLock, __in PVOID Tag)
Definition: mxgeneralkm.h:278

Referenced by DispatchWithLockUm(), and FxDriver::Initialize().

◆ DispatchWithLockUm()

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

Definition at line 48 of file fxdeviceum.cpp.

53{
55
57}
static _Must_inspect_result_ NTSTATUS STDCALL DispatchWithLock(__in MdDeviceObject DeviceObject, __in MdIrp OriginalIrp)
Definition: fxdevice.cpp:1336

Referenced by FxDriver::Initialize().

◆ Dispose()

BOOLEAN FxDevice::Dispose ( VOID  )
virtual

Reimplemented from FxObject.

Definition at line 1242 of file fxdevice.cpp.

1245{
1247
1248 if (m_Legacy) {
1249 if (m_PkgWmi != NULL) {
1250 //
1251 // We deregister in Dispose() (as well as DeleteObject()) for
1252 // control devices which are implicitly destroyed when the driver
1253 // unloads and FxDriver is being deleted.
1254 //
1255 // Since a legacy NT4 driver does not have an explicit WMI
1256 // deregistration DDI, we do it for them on destruction.
1257 //
1258 // This is done in Dispose because we are guaranteed to be at
1259 // passive level here. Even though m_PkgWmi was already
1260 // Dispose()'ed (because it is a child of this object), it is still
1261 // valid to reference the pointer because there is an explicit
1262 // reference on the object that was taken when we created this object.
1263 //
1264 // m_PkgWmi->Deregister(); __REACTOS__
1265 }
1266
1267 //
1268 // Important that the cleanup routine be called while the PDEVICE_OBJECT
1269 // is valid!
1270 //
1271 CallCleanup();
1272
1273 //
1274 // Manually destroy the children now so that by the time we wait on the
1275 // dispose empty out, all of the children will have been added to it.
1276 //
1278
1279 if (m_DisposeList != NULL) {
1281 }
1282
1283 //
1284 // Now delete the device object
1285 //
1286 Destroy();
1287
1288 return FALSE;
1289 }
1290
1291 return FxDeviceBase::Dispose(); // __super call
1292}
virtual BOOLEAN Dispose(VOID)
__inline VOID CallCleanup(VOID)
Definition: fxobject.hpp:815

◆ FdoInitialize()

_Must_inspect_result_ NTSTATUS FxDevice::FdoInitialize ( __in PWDFDEVICE_INIT  DeviceInit)

Definition at line 33 of file fxdevicekm.cpp.

36{
39 FxPkgFdo * pkgFdo;
40
42
43 if (DeviceInit->Fdo.EventCallbacks.EvtDeviceFilterAddResourceRequirements != NULL &&
44 DeviceInit->Fdo.EventCallbacks.EvtDeviceRemoveAddedResources == NULL) {
45 //
46 // Not allowed to add resources without filtering them out later
47 //
50 "Must set EvtDeviceRemoveAddedResources if "
51 "EvtDeviceFilterAddResourceRequirements (%p) is set",
52 DeviceInit->Fdo.EventCallbacks.EvtDeviceFilterAddResourceRequirements);
53
55
57 }
58
59 //
60 // All FDOs cannot be deleted through the driver calling WdfObjectDelete
61 //
63
65
66 //
67 // The PDO is known because it was used to bring up this FDO.
68 //
70
71 //
72 // Try to create and install the default packages that an FDO contains.
73 //
74
75 // PnP
76 status = FxPkgFdo::_Create(pGlobals, (CfxDevice*)this, &pkgFdo);
77
78 if (!NT_SUCCESS(status)) {
79 return status;
80 }
81 else {
82 m_PkgPnp = pkgFdo;
83 }
84
86
87 status = SetFilter(DeviceInit->Fdo.Filter);
88 if (!NT_SUCCESS(status)) {
89 return status;
90 }
91
93 if (!NT_SUCCESS(status)) {
94 return status;
95 }
96
97
98 //
99 // Should be done after invoking Initialize so that FxPkgFdo::m_EnumInfo is
100 // already allocated.
101 //
102 if (DeviceInit->Fdo.ListConfig.Size > 0) {
104 &DeviceInit->Fdo.ListConfig,
105 DeviceInit->Fdo.ListConfigAttributes.Size > 0
106 ? &DeviceInit->Fdo.ListConfigAttributes
107 : NULL);
108
109 if (!NT_SUCCESS(status)) {
110 return status;
111 }
112
114 }
115
116 //
117 // If the Size is zero then the driver writer never set any callbacks so we
118 // can skip this call.
119 //
120 if (DeviceInit->Fdo.EventCallbacks.Size != 0) {
121 status = GetFdoPkg()->RegisterCallbacks(&DeviceInit->Fdo.EventCallbacks);
122 if (!NT_SUCCESS(status)) {
123 return status;
124 }
125 }
126
128 if (NT_SUCCESS(status)) {
129 //
130 // If this is an FDO then the PhysicalDevice field will be initialized,
131 // and we need to attach to the device stack.
132 //
135
137 //
138 // We couldn't attach the device for some reason.
139 //
142
144 }
145 else {
146 //
147 // If we are a filter device, inherit some state from the
148 // attached device.
149 //
150 if (m_Filter) {
151 //
152 // Set the IO type and power pageable status on our device based
153 // on the attached device's settings.
154 //
156
159
162
163 //
164 // For devices other then filters, m_PowerPageableCapable gets
165 // set in CreateDevice, but since this is determined for filters
166 // by the device they have attached to, we must set this value
167 // later as a special case only for filters.
168 //
171 }
172 }
173 else {
174 //
175 // We are not a filter, we dictate our own DO flags
176 //
177
178 //
179 // Power pageable and inrush are mutually exclusive
180 //
181 if (DeviceInit->PowerPageable) {
183 }
184 else if (DeviceInit->Inrush) {
186 }
187 }
188 }
189 }
190
191 if (!NT_SUCCESS(status)) {
192 return status;
193 }
194
195 // status = m_PkgWmi->PostCreateDeviceInitialize(); __REACTOS__
196 // if (!NT_SUCCESS(status)) {
197 // return status;
198 // }
199
201 if (!NT_SUCCESS(status)) {
202 return status;
203 }
204
206
207 if (NT_SUCCESS(status)) {
208 //
209 // Do not clear the DO_DEVICE_INITIALIZING bit here. Instead, either
210 // let the caller do it in their AddDevice or do it after the AddDevice
211 // callback returns.
212 //
213 // FinishInitializing();
214 }
215
216 return status;
217}
MxDeviceObject m_PhysicalDevice
Definition: fxdevice.hpp:473
BOOLEAN m_PdoKnown
Definition: fxdevice.hpp:599
_Must_inspect_result_ NTSTATUS SetFilter(__in BOOLEAN Value)
Definition: fxdevice.cpp:1851
__inline FxPkgFdo * GetFdoPkg(VOID)
Definition: fxdevice.hpp:1236
VOID InstallPackage(__inout FxPackage *Package)
Definition: fxdevice.cpp:1611
VOID SetFilterIoType(VOID)
Definition: fxdevice.cpp:1873
virtual VOID SetDeviceTelemetryInfoFlags(_In_ FxDeviceInfoFlags Flag)
Definition: fxdevice.hpp:1807
VOID MarkNoDeleteDDI(__in FxObjectLockState State=ObjectLock)
Definition: fxobject.hpp:1118
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS pGlobals, __in CfxDevice *Device, __deref_out FxPkgFdo **PkgFdo)
Definition: fxpkgfdo.cpp:195
virtual _Must_inspect_result_ NTSTATUS Initialize(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxpkgfdokm.cpp:361
_Must_inspect_result_ NTSTATUS CreateDefaultDeviceList(__in PWDF_CHILD_LIST_CONFIG ListConfig, __in PWDF_OBJECT_ATTRIBUTES ListAttributes)
Definition: fxpkgfdo.cpp:816
_Must_inspect_result_ NTSTATUS RegisterCallbacks(__in PWDF_FDO_EVENT_CALLBACKS DispatchTable)
Definition: fxpkgfdo.cpp:796
_Must_inspect_result_ NTSTATUS PostCreateDeviceInitialize(VOID)
Definition: fxpkgfdo.cpp:1524
VOID SetDeviceType(DEVICE_TYPE Value)
VOID SetCharacteristics(ULONG Characteristics)
DEVICE_TYPE GetDeviceType(VOID)
ULONG GetCharacteristics(VOID)
static __inline MdDeviceObject MxAttachDeviceToDeviceStack(_In_ MdDeviceObject SourceDevice, _In_ MdDeviceObject TargetDevice)
Definition: mxgeneralkm.h:511
@ DeviceInfoHasDynamicChildren
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define DO_POWER_PAGABLE
#define DO_POWER_INRUSH

Referenced by _Create().

◆ FinishInitializing()

VOID FxDevice::FinishInitializing ( VOID  )

Definition at line 1109 of file fxdevice.cpp.

1129{
1130
1132}
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399

Referenced by PdoInitialize().

◆ FreeRequestMemory()

VOID FxDevice::FreeRequestMemory ( __in FxRequest Request)

Definition at line 1728 of file fxdevice.cpp.

1731{
1733
1734#if FX_VERBOSE_TRACE
1736 "Free FxRequest* %p memory", Request);
1737#endif
1738
1739 //
1740 // Remove the request from the list of outstanding requests against this
1741 // driver.
1742 //
1744 if (IsPdo() && GetPdoPkg()->IsForwardRequestToParentEnabled()) {
1746 }
1747 else {
1749 }
1750}
static PFX_POOL_HEADER _CleanupPointer(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *Object)
Definition: fxobject.hpp:1273
__inline VOID FxFreeToNPagedLookasideList(__in PNPAGED_LOOKASIDE_LIST Lookaside, __in PVOID Entry)
Definition: fxglobalskm.h:611
__inline VOID FxFreeToNPagedLookasideListNoTracking(__in PNPAGED_LOOKASIDE_LIST Lookaside, __in PVOID Entry)
Definition: fxglobalskm.h:528
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547

Referenced by FxRequestFromLookaside::SelfDestruct().

◆ FxLogDeviceStartTelemetryEvent()

VOID FxDevice::FxLogDeviceStartTelemetryEvent ( VOID  )
inline

Definition at line 1798 of file fxdevice.hpp.

1801 {
1802 // LogDeviceStartTelemetryEvent(GetDriverGlobals(), this); __REACTOS__ : no-op
1803 }

◆ FxValidateInterfacePropertyData()

_Must_inspect_result_ NTSTATUS FxDevice::FxValidateInterfacePropertyData ( _In_ PWDF_DEVICE_INTERFACE_PROPERTY_DATA  PropertyData)

Definition at line 1693 of file fxdeviceum.cpp.

1696{
1699
1700 if (PropertyData->Size != sizeof(WDF_DEVICE_INTERFACE_PROPERTY_DATA)) {
1703 "PropertyData size (%d) incorrect, expected %d, %!STATUS!",
1704 PropertyData->Size,
1705 sizeof(WDF_DEVICE_INTERFACE_PROPERTY_DATA), status);
1706 return status;
1707 }
1708
1709 FxPointerNotNull(pFxDriverGlobals, PropertyData->InterfaceClassGUID);
1710
1712 if (!NT_SUCCESS(status)) {
1714 return status;
1715 }
1716
1717 if (PropertyData->ReferenceString != NULL) {
1719 PropertyData->ReferenceString);
1720 if (!NT_SUCCESS(status)) {
1722 return status;
1723 }
1724 }
1725
1726 //
1727 // check if the interface has been registered with WDF
1728 //
1729 if (IsInterfaceRegistered(PropertyData->InterfaceClassGUID,
1730 PropertyData->ReferenceString) == FALSE) {
1734 "WDFDEVICE %p cannot assign interface property for an interface not"
1735 " yet registered with WDF, %!STATUS!",
1736 GetHandle(), status);
1737 return status;
1738 }
1739
1740 return status;
1741}
BOOLEAN IsInterfaceRegistered(_In_ const GUID *InterfaceClassGUID, _In_opt_ PCUNICODE_STRING RefString)
Definition: fxdevice.cpp:1926
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define FxPointerNotNull(FxDriverGlobals, Ptr)
Definition: fxmacros.hpp:253
_Must_inspect_result_ NTSTATUS __inline FxValidateUnicodeString(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PCUNICODE_STRING String)
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133

◆ GetCallbackFlags()

__inline BYTE FxDevice::GetCallbackFlags ( VOID  )
inline

Definition at line 1501 of file fxdevice.hpp.

1504 {
1505 BYTE flags;
1506 KIRQL irql;
1507
1508 Lock(&irql);
1510 Unlock(irql);
1511
1512 return flags;
1513 }
__inline BYTE GetCallbackFlagsLocked(VOID)
Definition: fxdevice.hpp:1492
unsigned char BYTE
Definition: xxhash.c:193

◆ GetCallbackFlagsLocked()

__inline BYTE FxDevice::GetCallbackFlagsLocked ( VOID  )
inline

Definition at line 1492 of file fxdevice.hpp.

1495 {
1496 return m_CallbackFlags;
1497 }

Referenced by GetCallbackFlags().

◆ GetCxDeviceInfo()

FxCxDeviceInfo * FxDevice::GetCxDeviceInfo ( __in FxDriver CxDriver)
inline

Definition at line 1560 of file fxdevice.hpp.

1563 {
1564 FxCxDeviceInfo* cxDeviceInfo;
1566
1567 //
1568 // Check if we are using I/O class extensions.
1569 //
1572 next = next->Flink) {
1573
1574 cxDeviceInfo = CONTAINING_RECORD(next, FxCxDeviceInfo, ListEntry);
1575 if (cxDeviceInfo->Driver == CxDriver) {
1576 return cxDeviceInfo;
1577 }
1578 }
1579
1580 return NULL;
1581 }
FxDriver * Driver

Referenced by FxPkgIo::CreateQueue(), if(), and IsCxDriverInIoPath().

◆ GetCxDriver()

__inline FxDriver * FxDevice::GetCxDriver ( __in FxCxDeviceInfo CxDeviceInfo)
inline

Definition at line 1654 of file fxdevice.hpp.

1657 {
1658 if (CxDeviceInfo != NULL) {
1659 return CxDeviceInfo->Driver;
1660 }
1661 else {
1662 return GetDriver();
1663 }
1664 }
return pDevice GetDriver() -> GetHandle()

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

◆ GetCxDriverIndex()

static __inline CCHAR FxDevice::GetCxDriverIndex ( __in FxCxDeviceInfo CxDeviceInfo)
inlinestatic

Definition at line 1640 of file fxdevice.hpp.

1643 {
1644 if (CxDeviceInfo != NULL) {
1645 return CxDeviceInfo->Index;
1646 }
1647 else {
1648 return 0;
1649 }
1650 }

Referenced by FxPkgIo::AddIoQueue(), and FxPkgIo::ConfigureDynamicDispatching().

◆ GetDefaultIoTarget()

FxIoTarget * FxDevice::GetDefaultIoTarget ( VOID  )
virtual

Reimplemented from FxDeviceBase.

Definition at line 1818 of file fxdevice.cpp.

1821{
1822 if (IsPnp() && IsFdo()) {
1823 return GetFdoPkg()->m_DefaultTarget;
1824 }
1825 else {
1826 return NULL;
1827 }
1828}
FxIoTarget * m_DefaultTarget
Definition: fxpkgfdo.hpp:47
_In_z_ PCCHAR _In_ PDEVICE_OBJECT _In_ BOOLEAN IsFdo
Definition: classpnp.h:984

◆ GetDefaultPriorityBoost()

__inline CHAR FxDevice::GetDefaultPriorityBoost ( VOID  )
inline

Definition at line 1111 of file fxdevice.hpp.

1114 {
1116 }

Referenced by FxRequest::Complete().

◆ GetDevicePnpState()

◆ GetDevicePowerPolicyState()

__inline WDF_DEVICE_POWER_POLICY_STATE FxDevice::GetDevicePowerPolicyState ( )
inline

◆ GetDevicePowerState()

__inline WDF_DEVICE_POWER_STATE FxDevice::GetDevicePowerState ( )
inline

Definition at line 1157 of file fxdevice.hpp.

1159 {
1160 return m_CurrentPowerState;
1161 }
WDF_DEVICE_POWER_STATE m_CurrentPowerState
Definition: fxdevice.hpp:508

Referenced by __drv_maxIRQL(), FxPkgPnp::PowerEnterNewState(), FxPkgPnp::PowerProcessEvent(), and FxPkgPnp::PowerProcessEventInner().

◆ GetDeviceStack()

__inline IWudfDeviceStack * FxDevice::GetDeviceStack ( VOID  )

◆ GetDeviceStack2()

__inline IWudfDeviceStack2 * FxDevice::GetDeviceStack2 ( VOID  )

Definition at line 444 of file fxdeviceum.hpp.

446{
447 IWudfDeviceStack2 *pDeviceStack2;
449
450 hrQI = m_DevStack->QueryInterface(IID_IWudfDeviceStack2,
451 (PVOID*)&pDeviceStack2);
452 FX_VERIFY(INTERNAL, CHECK_QI(hrQI, pDeviceStack2));
453
454 m_DevStack->Release();
455
456 return pDeviceStack2;
457}
HRESULT hrQI
Definition: framework.cpp:106

Referenced by FxPoxInterface::PowerNotRequiredCallbackInvoked().

◆ GetDeviceStackIoType()

VOID FxDevice::GetDeviceStackIoType ( _Out_ WDF_DEVICE_IO_TYPE ReadWriteIoType,
_Out_ WDF_DEVICE_IO_TYPE IoControlIoType 
)

Definition at line 1744 of file fxdeviceum.cpp.

1748{
1749 UMINT::WDF_DEVICE_IO_BUFFER_RETRIEVAL retrievalMode;
1750
1751 GetDeviceStack()->GetDeviceStackPreferredTransferMode(
1752 &retrievalMode,
1753 (UMINT::WDF_DEVICE_IO_TYPE*)ReadWriteIoType,
1754 (UMINT::WDF_DEVICE_IO_TYPE*)IoControlIoType
1755 );
1756}
IWudfDeviceStack * GetDeviceStack(VOID)
Definition: fxdeviceum.hpp:435
_In_ WDFDEVICE _Out_ WDF_DEVICE_IO_TYPE _Out_ WDF_DEVICE_IO_TYPE * IoControlIoType
ioTypeConfig ReadWriteIoType

◆ GetDeviceTelemetryInfoFlags()

USHORT FxDevice::GetDeviceTelemetryInfoFlags ( VOID  )
inline

Definition at line 1815 of file fxdevice.hpp.

1818 {
1820 }
USHORT m_DeviceTelemetryInfoFlags
Definition: fxdevice.hpp:617

◆ GetDirectTransferThreshold()

__inline ULONG FxDevice::GetDirectTransferThreshold ( VOID  )
inline

Definition at line 1986 of file fxdevice.hpp.

1989 {
1991 }
ULONG m_DirectTransferThreshold
Definition: fxdevice.hpp:772

Referenced by FxMessageDispatch::GetDirectTransferThreshold().

◆ GetDispatchPackage()

__inline FxPackage * FxDevice::GetDispatchPackage ( __in UCHAR  MajorFunction)
inline

Definition at line 890 of file fxdevice.hpp.

893 {
894 switch (MajorFunction) {
895 case IRP_MJ_CREATE:
896 case IRP_MJ_CLOSE:
897 case IRP_MJ_CLEANUP:
898 case IRP_MJ_SHUTDOWN:
899 return (FxPackage*) m_PkgGeneral;
900
901 case IRP_MJ_READ:
902 case IRP_MJ_WRITE:
905 return (FxPackage*) m_PkgIo;
906
908 return (FxPackage*) m_PkgWmi;
909
910 case IRP_MJ_PNP:
911 case IRP_MJ_POWER:
912 if (m_PkgPnp != NULL) {
913 return (FxPackage*) m_PkgPnp;
914 }
915 else {
916 return (FxPackage*) m_PkgDefault;
917 }
918 break;
919
920 default:
921 return (FxPackage*) m_PkgDefault;
922 }
923 }
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
_In_ UCHAR MajorFunction
Definition: wdfdevice.h:1697
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
#define IRP_MJ_SHUTDOWN
#define IRP_MJ_CLEANUP

Referenced by FxIoTargetSelf::Send().

◆ GetFdoPkg()

__inline FxPkgFdo * FxDevice::GetFdoPkg ( VOID  )
inline

Definition at line 1236 of file fxdevice.hpp.

1239 {
1240 return (FxPkgFdo*) m_PkgPnp;
1241 }

Referenced by FdoInitialize(), GetDefaultIoTarget(), GetSelfIoTarget(), FxPkgPdo::Initialize(), and SetFilter().

◆ GetFileObjectClass()

__inline WDF_FILEOBJECT_CLASS FxDevice::GetFileObjectClass ( VOID  )
inline

Definition at line 1123 of file fxdevice.hpp.

1126 {
1127 return m_FileObjectClass;
1128 }
WDF_FILEOBJECT_CLASS m_FileObjectClass
Definition: fxdevice.hpp:621

Referenced by FxPkgGeneral::CreateCompleted(), FxRequest::GetFileObject(), FxPkgGeneral::OnCleanup(), FxPkgGeneral::OnClose(), and FxPkgGeneral::OnCreate().

◆ GetFxDevice()

__inline FxDevice * FxDevice::GetFxDevice ( __in MdDeviceObject  DeviceObject)
static

Definition at line 60 of file fxdeviceum.cpp.

63{
64 IWudfDevice2* device2;
65
66
67
68
69 device2 = static_cast<IWudfDevice2*> (DeviceObject);
70
71 return (FxDevice *)device2->GetContext();
72}

Referenced by FxPkgPdo::_QueryCapsWorkItem(), Dispatch(), FxRequestSystemBuffer::GetBuffer(), FxRequestSystemBuffer::GetMdl(), GetPreferredTransferMode(), PoFxDevicePowerNotRequired(), and PoFxDevicePowerRequired().

◆ GetInterruptThreadpool()

FxInterruptThreadpool * FxDevice::GetInterruptThreadpool ( VOID  )
inline

Definition at line 1057 of file fxdevice.hpp.

1060 {
1061 return m_InteruptThreadpool;
1062 }
FxInterruptThreadpool * m_InteruptThreadpool
Definition: fxdevice.hpp:798

◆ GetIoType()

__inline WDF_DEVICE_IO_TYPE FxDevice::GetIoType ( VOID  )
inline

Definition at line 1084 of file fxdevice.hpp.

1087 {
1088 return m_ReadWriteIoType;
1089 }

Referenced by FxRequestSystemBuffer::GetBuffer(), and FxRequestSystemBuffer::GetMdl().

◆ GetIoTypeForReadWriteBufferAccess()

__inline WDF_DEVICE_IO_TYPE FxDevice::GetIoTypeForReadWriteBufferAccess ( VOID  )
inline

Definition at line 1093 of file fxdevice.hpp.

1096 {
1097#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
1098 return m_ReadWriteIoType;
1099#else
1100 //
1101 // For UM, both buffer-copy and direct-access i/o buffer access types
1102 // follow the same storage and retrieval model in internal structures
1103 // as in buffered I/O so always return WdfDeviceIoBuffered.
1104 //
1105 return WdfDeviceIoBuffered;
1106#endif
1107 }

◆ GetLength()

static ULONG __inline FxDevice::GetLength ( __in WDF_DEVICE_HWACCESS_TARGET_SIZE  Size)
inlinestatic

Definition at line 2118 of file fxdevice.hpp.

2121 {
2122 ULONG length = 0;
2123
2124 switch(Size) {
2125 case WdfDeviceHwAccessTargetSizeUchar:
2126 length = sizeof(UCHAR);
2127 break;
2128 case WdfDeviceHwAccessTargetSizeUshort:
2129 length = sizeof(USHORT);
2130 break;
2131 case WdfDeviceHwAccessTargetSizeUlong:
2132 length = sizeof(ULONG);
2133 break;
2134 case WdfDeviceHwAccessTargetSizeUlong64:
2135 length = sizeof(ULONG64);
2136 break;
2137 default:
2138 ASSERT(FALSE);
2139 }
2140
2141 return length;
2142 }
unsigned __int64 ULONG64
Definition: imports.h:198
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

◆ GetPdoPkg()

◆ GetPreferredIoctlTransferMode()

__inline WDF_DEVICE_IO_TYPE FxDevice::GetPreferredIoctlTransferMode ( VOID  )
inline

Definition at line 1977 of file fxdevice.hpp.

1980 {
1981 return m_IoctlIoType;
1982 }
WDF_DEVICE_IO_TYPE m_IoctlIoType
Definition: fxdevice.hpp:771

◆ GetPreferredRWTransferMode()

__inline WDF_DEVICE_IO_TYPE FxDevice::GetPreferredRWTransferMode ( VOID  )
inline

Definition at line 1968 of file fxdevice.hpp.

1971 {
1972 return m_ReadWriteIoType;
1973 }

◆ GetPreferredTransferMode()

VOID FxDevice::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

Definition at line 593 of file fxdeviceum.cpp.

619{
621
623
624 *RetrievalMode = device->GetRetrievalMode();
625 *RWPreference =