ReactOS  0.4.15-dev-3163-gf17c2c0
FxIoTargetRemote Class Reference

#include <fxiotargetremote.hpp>

Inheritance diagram for FxIoTargetRemote:
Collaboration diagram for FxIoTargetRemote:

Public Member Functions

 ~FxIoTargetRemote ()
 
NTSTATUS InitRemote (__in FxDeviceBase *Device)
 
NTSTATUS InitRemoteModeSpecific (__in FxDeviceBase *Device)
 
_Must_inspect_result_ NTSTATUS Open (__in PWDF_IO_TARGET_OPEN_PARAMS OpenParams)
 
VOID Close (__in FxIoTargetRemoteCloseReason Reason)
 
NTSTATUS GetTargetDeviceRelations (_Out_ BOOLEAN *Close)
 
BOOLEAN CanRegisterForPnpNotification (VOID)
 
VOID ResetTargetNotifyHandle (VOID)
 
NTSTATUS OpenTargetHandle (_In_ PWDF_IO_TARGET_OPEN_PARAMS OpenParams, _Inout_ FxIoTargetRemoveOpenParams *pParams)
 
VOID CloseTargetHandle (VOID)
 
HANDLE GetTargetHandle (VOID)
 
NTSTATUS RegisterForPnpNotification (VOID)
 
VOID UnregisterForPnpNotification (_In_ MdTargetNotifyHandle Handle)
 
__inline WDFIOTARGET GetHandle (VOID)
 
virtual VOID Remove (VOID)
 
VOID RemoveModeSpecific (VOID)
 
- Public Member Functions inherited from FxIoTarget
 FxIoTarget (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in USHORT ObjectSize)
 
 FxIoTarget (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in USHORT ObjectSize, __in WDFTYPE WdfType)
 
virtual _Must_inspect_result_ NTSTATUS Start (VOID)
 
virtual VOID Stop (__in WDF_IO_TARGET_SENT_IO_ACTION Action)
 
virtual VOID Purge (__in WDF_IO_TARGET_PURGE_IO_ACTION Action)
 
NTSTATUS _Must_inspect_result_ QueryInterface (__inout FxQueryInterfaceParams *Params)
 
__inline WDF_IO_TARGET_STATE GetState (VOID)
 
__inline MdDeviceObject GetTargetDevice (VOID)
 
__inline MdDeviceObject GetTargetPDO (VOID)
 
__inline MdFileObject GetTargetFileObject (VOID)
 
__inline WDFDEVICE GetDeviceHandle (VOID)
 
WDFIOTARGET GetHandle (VOID)
 
__inline FxDriverGetDriver (VOID)
 
virtual _Must_inspect_result_ MdDeviceObject GetTargetDeviceObject (_In_ CfxDeviceBase *Device)
 
_Must_inspect_result_ NTSTATUS Init (__in CfxDeviceBase *Device)
 
ULONG Submit (__in FxRequestBase *Request, __in_opt PWDF_REQUEST_SEND_OPTIONS Options, __in_opt ULONG Flags)
 
 FX_DECLARE_VF_FUNCTION_P1 (NTSTATUS, VerifySubmitLocked, _In_ FxRequestBase *)
 
ULONG SubmitLocked (__in FxRequestBase *Request, __in_opt PWDF_REQUEST_SEND_OPTIONS Options, __in ULONG Flags)
 
_Must_inspect_result_ NTSTATUS SubmitSync (__in FxRequestBase *Request, __in_opt PWDF_REQUEST_SEND_OPTIONS Options=NULL, __out_opt PULONG Action=NULL)
 
VOID TimerCallback (__in FxRequestBase *Request)
 
VOID CompleteCanceledRequest (__in FxRequestBase *Request)
 
VOID SubmitPendedRequest (__in FxRequestBase *Request)
 
VOID CompletePendedRequest (__in FxRequestBase *Request)
 
BOOLEAN __inline HasEnoughStackLocations (__in FxIrp *Irp)
 
_Must_inspect_result_ NTSTATUS FormatIoRequest (__inout FxRequestBase *Request, __in UCHAR MajorCode, __in FxRequestBuffer *IoBuffer, __in_opt PLONGLONG StartingOffset, __in_opt FxFileObject *FileObject=NULL)
 
_Must_inspect_result_ NTSTATUS FormatIoctlRequest (__in FxRequestBase *Request, __in ULONG Ioctl, __in BOOLEAN Internal, __in FxRequestBuffer *InputBuffer, __in FxRequestBuffer *OutputBuffer, __in_opt FxFileObject *FileObject=NULL)
 
_Must_inspect_result_ NTSTATUS FormatInternalIoctlOthersRequest (__in FxRequestBase *Request, __in ULONG Ioctl, __in FxRequestBuffer *Buffers)
 
VOID CancelSentIo (VOID)
 
_Must_inspect_result_ NTSTATUS SubmitSyncRequestIgnoreTargetState (__in FxRequestBase *Request, __in_opt PWDF_REQUEST_SEND_OPTIONS RequestOptions)
 
VOID UpdateTargetIoType (VOID)
 
BOOLEAN HasValidStackSize (VOID)
 
virtual VOID Send (_In_ MdIrp Irp)
 
- 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)
 
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)
 
_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)
 

Static Public Member Functions

static _Must_inspect_result_ NTSTATUS _Create (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in FxDeviceBase *Device, __out FxIoTargetRemote **Target)
 
- Static Public Member Functions inherited from FxIoTarget
static VOID _CancelSentRequest (__in FxRequestBase *Request)
 
static FxIoTarget_FromEntry (__in FxTransactionedEntry *Entry)
 
- 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

HANDLE m_TargetHandle
 
MdTargetNotifyHandle m_TargetNotifyHandle
 
FxIoTargetQueryRemove m_EvtQueryRemove
 
FxIoTargetRemoveCanceled m_EvtRemoveCanceled
 
FxIoTargetRemoveComplete m_EvtRemoveComplete
 
FxCREvent m_OpenedEvent
 
FxIoTargetClearedPointersm_ClearedPointers
 
UCHAR m_OpenState
 
- Public Attributes inherited from FxIoTarget
FxTransactionedEntry m_TransactionedEntry
 
BOOLEAN m_InStack
 
BOOLEAN m_AddedToDeviceList
 

Protected Member Functions

 FxIoTargetRemote (__in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
virtual VOID ClearTargetPointers (VOID)
 
_Must_inspect_result_ NTSTATUS QueryInterface (__in FxQueryInterfaceParams *Params)
 
_Must_inspect_result_ NTSTATUS OpenLocalTargetByFile (_In_ PWDF_IO_TARGET_OPEN_PARAMS OpenParams)
 
- Protected Member Functions inherited from FxIoTarget
 ~FxIoTarget ()
 
_Must_inspect_result_ NTSTATUS InitModeSpecific (__in CfxDeviceBase *Device)
 
virtual BOOLEAN Dispose (VOID)
 
VOID FailPendedRequest (__in FxRequestBase *Request, __in NTSTATUS Status)
 
VOID DrainPendedRequestsLocked (__in PLIST_ENTRY RequestListHead, __in BOOLEAN RequestWillBeResent)
 
VOID CompletePendedRequestList (__in PLIST_ENTRY RequestListHead)
 
VOID SubmitPendedRequests (__in PLIST_ENTRY RequestListHeadHead)
 
VOID GetSentRequestsListLocked (__in PSINGLE_LIST_ENTRY RequestListHead, __in PLIST_ENTRY SendList, __out PBOOLEAN AddedToList)
 
virtual _Must_inspect_result_ NTSTATUS GotoStartState (__in PLIST_ENTRY RequestListHead, __in BOOLEAN Lock=TRUE)
 
virtual VOID GotoStopState (__in WDF_IO_TARGET_SENT_IO_ACTION Action, __in PSINGLE_LIST_ENTRY SentRequestListHead, __out PBOOLEAN Wait, __in BOOLEAN LockSelf)
 
virtual VOID GotoPurgeState (__in WDF_IO_TARGET_PURGE_IO_ACTION Action, __in PLIST_ENTRY PendedRequestListHead, __in PSINGLE_LIST_ENTRY SentRequestListHead, __out PBOOLEAN Wait, __in BOOLEAN LockSelf)
 
_Must_inspect_result_ NTSTATUS PendRequestLocked (__in FxRequestBase *Request)
 
__inline VOID CompleteRequest (__in FxRequestBase *Request)
 
VOID HandleFailedResubmit (__in FxRequestBase *Request)
 
VOID RequestCompletionRoutine (__in FxRequestBase *Request)
 
BOOLEAN RemoveCompletedRequestLocked (__in FxRequestBase *Request)
 
UCHAR GetTargetIoType (VOID)
 
virtual VOID GotoRemoveState (__in WDF_IO_TARGET_STATE NewState, __in PLIST_ENTRY PendedRequestListHead, __in PSINGLE_LIST_ENTRY SentRequestListHead, __in BOOLEAN Lock, __out PBOOLEAN Wait)
 
virtual VOID WaitForSentIoToComplete (VOID)
 
virtual VOID WaitForDisposeEvent (VOID)
 
virtual VOID Forward (__in MdIrp Irp)
 
__inline VOID CopyFileObjectAndFlags (__in FxRequestBase *Request)
 
__inline VOID IncrementIoCount (VOID)
 
__inline VOID DecrementIoCount (VOID)
 
VOID PrintDisposeMessage (VOID)
 
- 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)
 

Protected Attributes

FxIoTargetRemoveOpenParams m_OpenParams
 
- Protected Attributes inherited from FxIoTarget
LIST_ENTRY m_SentIoListHead
 
LIST_ENTRY m_IgnoredIoListHead
 
FxCREvent m_SentIoEvent
 
FxCREventm_DisposeEvent
 
FxCREvent m_DisposeEventUm
 
FxIrpQueue m_PendedQueue
 
FxDriverm_Driver
 
MdDeviceObject m_InStackDevice
 
MdDeviceObject m_TargetDevice
 
MdDeviceObject m_TargetPdo
 
MdFileObject m_TargetFileObject
 
WDF_IO_TARGET_STATE m_State
 
LONG m_IoCount
 
CCHAR m_TargetStackSize
 
UCHAR m_TargetIoType
 
BOOLEAN m_WaitingForSentIo
 
BOOLEAN m_Removing
 
- Protected Attributes inherited from FxObject
union {
   CfxDeviceBase *   m_DeviceBase
 
   CfxDevice *   m_Device
 
}; 
 

Static Protected Attributes

static DRIVER_NOTIFICATION_CALLBACK_ROUTINE _PlugPlayNotification
 
- Static Protected Attributes inherited from FxIoTarget
static MdCompletionRoutineType _RequestCompletionRoutine
 
static EVT_WDF_REQUEST_COMPLETION_ROUTINE _SyncCompletionRoutine
 

Additional Inherited Members

- Static Public Attributes inherited from FxIoTarget
static const PVOID m_SentRequestTag = (PVOID) 'lcnC'
 
- Static Protected Member Functions inherited from FxIoTarget
static VOID _CancelSentRequests (__in PSINGLE_LIST_ENTRY RequestListHead)
 
static VOID _RequestCancelled (__in FxIrpQueue *Queue, __in MdIrp Irp, __in PMdIoCsqIrpContext pCsqContext, __in KIRQL CallerIrql)
 
- Static Protected Member Functions inherited from FxObject
static PVOID _GetBase (__in FxObject *Object)
 

Detailed Description

Definition at line 173 of file fxiotargetremote.hpp.

Constructor & Destructor Documentation

◆ ~FxIoTargetRemote()

FxIoTargetRemote::~FxIoTargetRemote ( )

Definition at line 67 of file fxiotargetremote.cpp.

68 {
69 }

◆ FxIoTargetRemote()

FxIoTargetRemote::FxIoTargetRemote ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals)
protected

Definition at line 31 of file fxiotargetremote.cpp.

33  :
34  FxIoTarget(FxDriverGlobals, sizeof(FxIoTargetRemote)),
35  m_EvtQueryRemove(FxDriverGlobals),
36  m_EvtRemoveCanceled(FxDriverGlobals),
37  m_EvtRemoveComplete(FxDriverGlobals)
38 {
39 
40  //
41  // No automatic state changes based on the pnp state changes of our own
42  // device stack. The one exception is remove where we need to shut
43  // everything down.
44  //
45  m_InStack = FALSE;
46 
49 
51 
55 
56 #if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
58 #elif (FX_CORE_MODE == FX_CORE_USER_MODE)
59  m_TargetNotifyHandle = WUDF_TARGET_CONTEXT_INVALID;
60 
61  m_pIoDispatcher = NULL;
62  m_pRemoteDispatcher = NULL;
63  m_NotificationCallback = NULL;
64 #endif
65 }
PFN_WDF_IO_TARGET_QUERY_REMOVE m_Method
FxIoTargetRemoveComplete m_EvtRemoveComplete
FxIoTargetQueryRemove m_EvtQueryRemove
#define FALSE
Definition: types.h:117
FxIoTarget(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in USHORT ObjectSize)
Definition: fxiotarget.cpp:34
BOOLEAN m_InStack
Definition: fxiotarget.hpp:855
FxIoTargetClearedPointers * m_ClearedPointers
MdTargetNotifyHandle m_TargetNotifyHandle
PFN_WDF_IO_TARGET_REMOVE_CANCELED m_Method
FxIoTargetRemoveCanceled m_EvtRemoveCanceled
#define NULL
Definition: types.h:112
PFN_WDF_IO_TARGET_REMOVE_COMPLETE m_Method

Referenced by _Create().

Member Function Documentation

◆ _Create()

_Must_inspect_result_ NTSTATUS FxIoTargetRemote::_Create ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in PWDF_OBJECT_ATTRIBUTES  Attributes,
__in FxDeviceBase Device,
__out FxIoTargetRemote **  Target 
)
static

Definition at line 73 of file fxiotargetremote.cpp.

79 {
82  WDFOBJECT hTarget;
84 
85  *Target = NULL;
86 
87  if (Attributes == NULL || Attributes->ParentObject == NULL) {
88  pParent = Device;
89  }
90  else {
91  CfxDeviceBase* pSearchDevice;
92 
93  FxObjectHandleGetPtr(FxDriverGlobals,
94  Attributes->ParentObject,
96  (PVOID*) &pParent);
97 
99 
100  if (pSearchDevice == NULL) {
102 
104  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
105  "Attributes->ParentObject 0x%p must have WDFDEVICE as an "
106  "eventual ancestor, %!STATUS!",
107  Attributes->ParentObject, status);
108 
109  return status;
110  }
111  else if (pSearchDevice != Device) {
113 
115  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
116  "Attributes->ParentObject 0x%p ancestor is WDFDEVICE %p, but "
117  "not the same WDFDEVICE 0x%p passed to WdfIoTargetCreate, "
118  "%!STATUS!",
119  Attributes->ParentObject, pSearchDevice->GetHandle(),
120  Device->GetHandle(), status);
121 
122  return status;
123  }
124  }
125 
126  pTarget = new (FxDriverGlobals, Attributes)
127  FxIoTargetRemote(FxDriverGlobals);
128 
129  if (pTarget == NULL) {
132  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
133  "Could not allocate memory for target, %!STATUS!", status);
134  return status;
135  }
136 
137  //
138  // initialize the new target
139  //
140  status = pTarget->InitRemote(Device);
141  if (!NT_SUCCESS(status)) {
142  return status;
143  }
144 
145  //
146  // Commit and apply the attributes
147  //
148  status = pTarget->Commit(Attributes, &hTarget, pParent);
149 
150  if (NT_SUCCESS(status)) {
151  *Target = pTarget;
152  }
153  else {
154  //
155  // This will properly clean up the target's state and free it
156  //
158  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
159  "Commit failed for target, %!STATUS!", status);
161  }
162 
163  return status;
164 }
FxIoTarget * pTarget
Definition: fxdeviceapi.cpp:97
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ NTSTATUS Commit(__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
Definition: fxobject.cpp:904
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), Fdo, FX_TYPE_DEVICE,(PVOID *)&pFdo)
static FxDeviceBase * _SearchForDevice(__in FxObject *Object, __out_opt IFxHasCallbacks **Callbacks)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
FxIoTargetRemote(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
VOID DeleteFromFailedCreate(VOID)
Definition: fxobject.cpp:391
FxObject * pParent
Definition: fxdpcapi.cpp:86
static SERVICE_STATUS status
Definition: service.c:31
#define TRACINGIOTARGET
Definition: dbgtrace.h:72
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
Definition: ps.c:97

◆ CanRegisterForPnpNotification()

BOOLEAN FxIoTargetRemote::CanRegisterForPnpNotification ( VOID  )
inline

Definition at line 216 of file fxiotargetremote.hpp.

219  {
220  BOOLEAN canRegister = FALSE;
221 
222 #if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
223  if (m_TargetFileObject != NULL) {
224  canRegister = TRUE;
225  }
226 #else // FX_CORE_USER_MODE
227  if (m_TargetHandle != NULL) {
228  canRegister = TRUE;
229  }
230 #endif
231  return canRegister;
232  }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
MdFileObject m_TargetFileObject
Definition: fxiotarget.hpp:923
#define NULL
Definition: types.h:112

Referenced by Open().

◆ ClearTargetPointers()

VOID FxIoTargetRemote::ClearTargetPointers ( VOID  )
protectedvirtual

Reimplemented from FxIoTarget.

Definition at line 725 of file fxiotargetremote.cpp.

728 {
731  "WDFIOTARGET %p cleared pointers %p state %!WDF_IO_TARGET_STATE!,"
732  " open state %d, pdo %p, fileobj %p, handle %p",
735 
736  //
737  // Check to see if the caller who is changing state wants these pointer
738  // values before they being cleared out.
739  //
740  if (m_ClearedPointers != NULL) {
745  }
746 
747  //
748  // m_TargetHandle is only an FxIoTargetRemote field, clear it now
749  //
751 
752  //
753  // m_TargetPdo and m_TargetFileObject will be cleared in the following call.
754  //
755  // m_TargetNotifyHandle is not cleared in the following call and is left
756  // valid because we want to receive the notification about query remove being
757  // canceled or completing. When we receive either of those notifications,
758  // m_TargetNotifyHandle will be freed then.
759  //
760  FxIoTarget::ClearTargetPointers(); // __super call
761 }
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
WDF_IO_TARGET_STATE m_State
Definition: fxiotarget.hpp:928
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
MdFileObject m_TargetFileObject
Definition: fxiotarget.hpp:923
MdDeviceObject m_TargetPdo
Definition: fxiotarget.hpp:918
FxIoTargetClearedPointers * m_ClearedPointers
virtual VOID ClearTargetPointers(VOID)
Definition: fxiotarget.hpp:618
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
#define TRACINGIOTARGET
Definition: dbgtrace.h:72

◆ Close()

VOID FxIoTargetRemote::Close ( __in FxIoTargetRemoteCloseReason  Reason)

Definition at line 519 of file fxiotargetremote.cpp.

522 {
523  FxIoTargetClearedPointers pointers;
524  MdTargetNotifyHandle pNotifyHandle;
526  LIST_ENTRY pended;
527  WDF_IO_TARGET_STATE removeState;
528  KIRQL irql;
529  BOOLEAN wait;
531 
534  "enter: WDFIOTARGET %p, reason %d", GetObjectHandle(), Reason);
535 
536  RtlZeroMemory(&pointers, sizeof(pointers));
537  pNotifyHandle = NULL;
538 
539  sent.Next = NULL;
540  InitializeListHead(&pended);
541 
542  wait = FALSE;
543 
544  //
545  // Pick a value that is not used anywhere in the function and make sure that
546  // we have changed it, before we go to the Remove state
547  //
548 #pragma prefast(suppress: __WARNING_UNUSED_SCALAR_ASSIGNMENT, "PFD is warning that the following assignement is unused. Suppress it to prevent changing any logic.")
549  removeState = WdfIoTargetStarted;
550 
551 CheckState:
552  Lock(&irql);
553 
554  //
555  // If we are in the process of opening the target, wait for that to finish.
556  //
558  Unlock(irql);
559 
562  "Closing WDFIOTARGET %p which is opening, waiting on event %p",
564 
566 
567  //
568  // Jump back to the top and recheck
569  //
570  goto CheckState;
571  }
572 
576  "Closing WDFIOTARGET %p, reason: delete", GetObjectHandle());
577 
578  removeState = WdfIoTargetDeleted;
579  }
584  "Closing WDFIOTARGET %p, reason: query remove",
585  GetObjectHandle());
586  //
587  // Not really being removed, but that is what the API name is...
588  //
589  removeState = WdfIoTargetClosedForQueryRemove;
590  }
591  else {
592 
595  "Closing WDFIOTARGET %p, reason: close", GetObjectHandle());
596 
598  removeState = WdfIoTargetClosed;
599  }
600  else {
601  removeState = WdfIoTargetClosedForQueryRemove;
602  }
603  }
604 
605  //
606  // Either way, we are no longer open for business
607  //
609  }
610  else {
613  "Closing WDFIOTARGET %p which is not open", GetObjectHandle());
614 
615  //
616  // We are not opened, so treat this as a cleanup
617  //
618  removeState = WdfIoTargetClosed;
619  }
620 
623  "WDFIOTARGET %p: fileobj %p, devobj %p, handle %p, notify handle %I64d",
626 
628  //
629  // If we are closing for a query remove, we want to keep the handle
630  // around so that we can be notified of the final close or if the close
631  // was canceled.
632  //
633  pNotifyHandle = m_TargetNotifyHandle;
635  }
636 
637  ASSERT(removeState != WdfIoTargetStarted);
638  m_ClearedPointers = &pointers;
639  GotoRemoveState(removeState, &pended, &sent, FALSE, &wait);
640 
641  Unlock(irql);
642 
643  UnregisterForPnpNotification(pNotifyHandle);
644 
645  //
646  // Complete any requests we might have pulled off of our lists
647  //
648  CompletePendedRequestList(&pended);
650 
651  //
652  // We were just removed, wait for any I/O to complete back if necessary.
653  //
654  if (wait) {
657  "WDFIOTARGET %p, waiting for stop to complete", GetObjectHandle());
658 
660  }
661 
662  switch (Reason) {
664  //
665  // m_OpenParams is needed for reopen on canceled query remove
666  //
667  DO_NOTHING();
668  break;
669 
672  break;
673 
674  default:
675  //
676  // If this object is not about to be deleted, we need to revert some
677  // of the state that just changed.
678  //
680  break;
681  }
682 
683  if (removeState == WdfIoTargetDeleted) {
685  }
686 
687  //
688  // Finally, close down our handle and pointers
689  //
690  if (pointers.TargetPdo != NULL) {
693  "WDFIOTARGET %p derefing PDO %p on close",
694  GetObjectHandle(), pointers.TargetPdo);
695 
697  }
698 
699  if (pointers.TargetFileObject != NULL) {
702  "WDFIOTARGET %p derefing FileObj %p on close",
703  GetObjectHandle(), pointers.TargetFileObject);
705 
706 #if (FX_CORE_MODE == FX_CORE_USER_MODE)
707  CloseWdfFileObject(pointers.TargetFileObject);
708 #endif
709  }
710 
711 #if (FX_CORE_MODE == FX_CORE_USER_MODE)
712  UnbindHandle(&pointers);
713 #endif
714 
715  if (pointers.TargetHandle != NULL) {
718  "WDFIOTARGET %p closing handle %p on close",
719  GetObjectHandle(), pointers.TargetHandle);
720  Mx::MxClose(pointers.TargetHandle);
721  }
722 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
MdDeviceObject m_TargetDevice
Definition: fxiotarget.hpp:910
VOID CompletePendedRequestList(__in PLIST_ENTRY RequestListHead)
Definition: fxiotarget.cpp:520
VOID UnregisterForPnpNotification(_In_ MdTargetNotifyHandle Handle)
Definition: ntbasedef.h:628
PVOID GetEvent(VOID)
Definition: fxwaitlock.hpp:172
#define CheckState(OldState, NewState)
KIRQL irql
Definition: wave.h:1
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
VOID ResetTargetNotifyHandle(VOID)
FxCREvent m_SentIoEvent
Definition: fxiotarget.hpp:878
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
static __inline NTSTATUS MxClose(__in HANDLE Handle)
Definition: mxgeneralkm.h:758
NTSTATUS EnterCRAndWaitAndLeave(VOID)
Definition: fxwaitlock.hpp:87
unsigned char BOOLEAN
_Must_inspect_result_ BOOLEAN IsVersionGreaterThanOrEqualTo(__in ULONG Major, __in ULONG Minor)
Definition: globalskm.cpp:92
MdFileObject m_TargetFileObject
Definition: fxiotarget.hpp:923
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define ASSERT(a)
Definition: mode.c:44
FxIoTargetClearedPointers * m_ClearedPointers
WDF_EXTERN_C_START enum _WDF_IO_TARGET_STATE WDF_IO_TARGET_STATE
VOID Clear(VOID)
Definition: fxwaitlock.hpp:152
Definition: msg.h:34
Definition: typedefs.h:119
virtual VOID WaitForSentIoToComplete(VOID)
Definition: fxiotarget.hpp:676
FxIoTargetRemoveOpenParams m_OpenParams
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
MdTargetNotifyHandle m_TargetNotifyHandle
virtual VOID WaitForDisposeEvent(VOID)
Definition: fxiotarget.cpp:124
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
virtual VOID GotoRemoveState(__in WDF_IO_TARGET_STATE NewState, __in PLIST_ENTRY PendedRequestListHead, __in PSINGLE_LIST_ENTRY SentRequestListHead, __in BOOLEAN Lock, __out PBOOLEAN Wait)
Definition: fxiotarget.cpp:964
static VOID _CancelSentRequests(__in PSINGLE_LIST_ENTRY RequestListHead)
Definition: fxiotarget.cpp:550
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
unsigned long long UINT64
PVOID PVOID PWCHAR PVOID USHORT PULONG Reason
Definition: env.c:47
static __inline VOID MxDereferenceObject(__in PVOID Object)
Definition: mxgeneralkm.h:247
#define TRACINGIOTARGET
Definition: dbgtrace.h:72
#define DO_NOTHING()
Definition: mxgeneral.h:32

Referenced by GetTargetDeviceRelations(), FxIoTargetRemoteNotificationCallback::OnQueryRemove(), FxIoTargetRemoteNotificationCallback::OnRemoveComplete(), Open(), and Remove().

◆ CloseTargetHandle()

VOID FxIoTargetRemote::CloseTargetHandle ( VOID  )

◆ GetHandle()

__inline WDFIOTARGET FxIoTargetRemote::GetHandle ( VOID  )
inline

◆ GetTargetDeviceRelations()

NTSTATUS FxIoTargetRemote::GetTargetDeviceRelations ( _Out_ BOOLEAN Close)

Definition at line 281 of file fxiotargetremotekm.cpp.

284 {
286  FxAutoIrp irp(NULL);
287  PIRP pIrp;
289 
291 
293 
294  if (pIrp != NULL) {
296 
297  irp.SetIrp(pIrp);
298 
300  stack->MajorFunction = IRP_MJ_PNP;
301  stack->MinorFunction = IRP_MN_QUERY_DEVICE_RELATIONS;
302  stack->Parameters.QueryDeviceRelations.Type = TargetDeviceRelation;
303 
304  //
305  // Initialize the status to error in case the bus driver decides not
306  // to set it correctly.
307  //
309 
311 
312  if (NT_SUCCESS(status)) {
313  PDEVICE_RELATIONS pRelations;
314 
315  pRelations = (PDEVICE_RELATIONS) irp.GetInformation();
316 
317  ASSERT(pRelations != NULL);
318 
319  //
320  // m_TargetPdo was referenced by the bus driver, it will be
321  // dereferenced when the target is closed.
322  //
323  m_TargetPdo = pRelations->Objects[0];
324 
325  //
326  // We, as the caller, are responsible for freeing the relations
327  // that the bus driver allocated.
328  //
329  ExFreePool(pRelations);
330  }
331  else {
332  //
333  // Could not retrieve the PDO pointer, error handled later
334  //
335  DO_NOTHING();
336  }
337  }
338  else {
339  //
340  // Could not even allocate an irp, failure.
341  //
345  "Unable to allocate memory for IRP WDFIOTARGET %p, %!STATUS!",
347  }
348 
349  //
350  // Only fail the open if we cannot allocate an irp or if the lower
351  // driver could not allocate a relations.
352  //
354  *Close = TRUE;
355  }
356  else {
358  }
359 
360  //
361  // Remove the reference taken by IoGetAttachedDeviceReference
362  //
364 
365  return status;
366 }
MdDeviceObject m_TargetDevice
Definition: fxiotarget.hpp:910
return STATUS_NOT_SUPPORTED
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
VOID SetStatus(__in NTSTATUS Status)
Definition: fxirpum.cpp:457
#define TRUE
Definition: types.h:120
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2163
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
LONG NTSTATUS
Definition: precomp.h:26
static stack_node_t * stack
Definition: rpn_ieee.c:37
FxIrp * pIrp
PDEVICE_OBJECT pTopOfStack
#define FALSE
Definition: types.h:117
CHECK_RETURN_IF_USER_MODE NTSTATUS SendIrpSynchronously(__in MdDeviceObject DeviceObject)
Definition: fxirpum.cpp:151
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
MdDeviceObject m_TargetPdo
Definition: fxiotarget.hpp:918
PIO_STACK_LOCATION GetNextIrpStackLocation(VOID)
Definition: fxirpum.cpp:387
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1406
Definition: _stack.h:47
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ObDereferenceObject
Definition: obfuncs.h:203
VOID Close(__in FxIoTargetRemoteCloseReason Reason)
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
ULONG_PTR GetInformation()
Definition: fxirpum.cpp:513
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
#define IRP_MN_QUERY_DEVICE_RELATIONS
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615
#define STATUS_SUCCESS
Definition: shellext.h:65
MdIrp SetIrp(MdIrp irp)
Definition: fxirpkm.hpp:71
static SERVICE_STATUS status
Definition: service.c:31
#define TRACINGIOTARGET
Definition: dbgtrace.h:72
FxIrp * irp
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define DO_NOTHING()
Definition: mxgeneral.h:32
Definition: ps.c:97

Referenced by Open().

◆ GetTargetHandle()

HANDLE FxIoTargetRemote::GetTargetHandle ( VOID  )

Definition at line 74 of file fxiotargetremotekm.hpp.

77 {
78  return m_TargetHandle;
79 }

◆ InitRemote()

NTSTATUS FxIoTargetRemote::InitRemote ( __in FxDeviceBase Device)

Definition at line 167 of file fxiotargetremote.cpp.

170 {
172 
173  //
174  // do the base class mode-specific initialization
175  //
176  status = FxIoTarget::InitModeSpecific(Device); // __super call
177  if (!NT_SUCCESS(status)) {
178  return status;
179  }
180 
181  //
182  // Do mode-specific initilialization
183  //
185  if (!NT_SUCCESS(status)) {
186  return status;
187  }
188 
189  m_Driver = Device->GetDriver();
190 
192  m_InStackDevice = Device->GetDeviceObject();
193 
194  (void) Device->AddIoTarget(this);
195 
196  return STATUS_SUCCESS;
197 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
LONG NTSTATUS
Definition: precomp.h:26
VOID SetDeviceBase(__in CfxDeviceBase *DeviceBase)
Definition: fxobject.hpp:797
_Must_inspect_result_ NTSTATUS InitModeSpecific(__in CfxDeviceBase *Device)
MdDeviceObject m_InStackDevice
Definition: fxiotarget.hpp:905
FxDriver * m_Driver
Definition: fxiotarget.hpp:900
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define STATUS_SUCCESS
Definition: shellext.h:65
NTSTATUS InitRemoteModeSpecific(__in FxDeviceBase *Device)
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ InitRemoteModeSpecific()

NTSTATUS FxIoTargetRemote::InitRemoteModeSpecific ( __in FxDeviceBase Device)

Definition at line 29 of file fxiotargetremotekm.hpp.

32 {
34 
35  //
36  // Nothing mode-specific work to do for KM here.
37  //
38  DO_NOTHING();
39 
40  return STATUS_SUCCESS;
41 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DO_NOTHING()
Definition: mxgeneral.h:32

Referenced by InitRemote().

◆ Open()

_Must_inspect_result_ NTSTATUS FxIoTargetRemote::Open ( __in PWDF_IO_TARGET_OPEN_PARAMS  OpenParams)

Definition at line 201 of file fxiotargetremote.cpp.

204 {
207  LIST_ENTRY pended;
210  BOOLEAN close, reopen;
211  PVOID pEa;
212  ULONG eaLength;
213  KIRQL irql;
214 
215  RtlZeroMemory(&name, sizeof(name));
216  close = FALSE;
217  reopen = OpenParams->Type == WdfIoTargetOpenReopen ? TRUE : FALSE;
218 
219  pEa = NULL;
220  eaLength = 0;
221 
222  //
223  // We only support reopening using stored settings when we open by name
224  //
225  if (reopen && m_OpenParams.OpenType != WdfIoTargetOpenByName) {
229  "Reopen only supported if the open type is WdfIoTargetOpenByName WDFIOTARGET %p %!STATUS!",
231  return status;
232  }
233 
234  //
235  // Must preallocate all settings now
236  //
237  if (reopen) {
238  //
239  // convert the type into the type used for the previous open
240  //
242  pParams = &m_OpenParams;
243  }
244  else {
245  type = OpenParams->Type;
246  pParams = &params;
247 
248  if (OpenParams->Type == WdfIoTargetOpenByName) {
249 
251  &OpenParams->TargetDeviceName,
252  &name);
253  if (!NT_SUCCESS(status)) {
256  "Could not allocate memory for target name for WDFIOTARGET %p",
257  GetObjectHandle());
258  goto Done;
259  }
260  if (OpenParams->EaBuffer != NULL && OpenParams->EaBufferLength > 0) {
261 
262  pEa = FxPoolAllocate(GetDriverGlobals(),
263  PagedPool,
264  OpenParams->EaBufferLength);
265 
266  if (pEa == NULL) {
269  "Could not allocate memory for target name "
270  "for WDFIOTARGET %p", GetObjectHandle());
272  goto Done;
273  }
274  else {
275  eaLength = OpenParams->EaBufferLength;
276  RtlCopyMemory(pEa, OpenParams->EaBuffer, eaLength);
277  }
278  }
279  }
280  }
281 
282  Lock(&irql);
283 
284  if (m_State == WdfIoTargetDeleted) {
287  "Opening WDFIOTARGET %p which is removed, state %d",
290  }
292  //
293  // We are either open or are opening
294  //
297  "Opening an already open WDFIOTARGET %p, open state %d",
300  }
301  else {
304  "Opening WDFIOTARGET %p", GetObjectHandle());
305 
306  //
307  // Clear the event so that if something is waiting on the state
308  // transition, they will block until we are done.
309  //
311 
314  }
315  Unlock(irql);
316 
317  if (!NT_SUCCESS(status)) {
318  goto Done;
319  }
320 
323  ASSERT(m_TargetPdo == NULL);
325 
326  //
327  // m_TargetNotifyHandle can be a valid value if the caller has previously
328  // opened the target, received a query remove, then a cancel remove, and
329  // is now reopening the target.
330  //
333 
334  //
335  // Only clear the open parameters if we are not attempting a reopen.
336  //
337  if (reopen == FALSE) {
339  }
340 
341  switch (type) {
344 
345  //
346  // OpenParams must be non NULL b/c we can't reopen a target with a
347  // previous device object.
348  //
350 
351  m_TargetDevice = (MdDeviceObject) OpenParams->TargetDeviceObject;
352  m_TargetFileObject = (MdFileObject) OpenParams->TargetFileObject;
354 
355  //
356  // By taking a manual reference here, we simplify the code in
357  // FxIoTargetRemote::Close where we can assume there is an outstanding
358  // reference on the PFILE_OBJECT at all times as long as we have a non
359  // NULL pointer.
360  //
361  if (m_TargetFileObject != NULL) {
363  }
364 
366 
367  break;
368 
371 
373  break;
374 
376  //
377  // Only capture the open parameters if we are not reopening.
378  //
379  if (reopen == FALSE) {
380  pParams->Set(OpenParams, &name, pEa, eaLength);
381  }
382 
383  status = OpenTargetHandle(OpenParams, pParams);
384  if (NT_SUCCESS(status)) {
385  if (reopen == FALSE) {
386  m_OpenParams.Set(OpenParams, &name, pEa, eaLength);
387 
388  //
389  // Setting pEa to NULL stops it from being freed later.
390  // Zeroing out name stops it from being freed later.
391  //
392  pEa = NULL;
393  RtlZeroMemory(&name, sizeof(name));
394  }
395  }
396  else {
397  close = TRUE;
398  }
399  break;
400  }
401 
402  InitializeListHead(&pended);
403 
404  //
405  // Get Target file object for KMDF. Noop for UMDF.
406  //
407  if (NT_SUCCESS(status)) {
409  }
410 
412  if (reopen == FALSE) {
413  //
414  // Set the values before the register so that if a notification
415  // comes in before the register returns, we have a function to call.
416  //
417  m_EvtQueryRemove.m_Method = OpenParams->EvtIoTargetQueryRemove;
418  m_EvtRemoveCanceled.m_Method = OpenParams->EvtIoTargetRemoveCanceled;
419  m_EvtRemoveComplete.m_Method = OpenParams->EvtIoTargetRemoveComplete;
420  }
421 
423 
424  //
425  // Even if we can't register, we still are successful in opening
426  // up the device and we will proceed from there.
427  //
428  if (!NT_SUCCESS(status)) {
431  "WDFIOTARGET %p, could not register pnp notification, %!STATUS! not "
432  "treated as an error", GetObjectHandle(), status);
433 
437 
439  }
440  }
441 
442  //
443  // UMDF only. Bind handle to remote dispatcher.
444  //
445 #if (FX_CORE_MODE == FX_CORE_USER_MODE)
447  status = BindToHandle();
448  if (!NT_SUCCESS(status)) {
449  close = TRUE;
450  }
451  }
452 #endif
453 
454  Lock(&irql);
455 
456  if (NT_SUCCESS(status)) {
457 
458 #if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
461 #endif
462 
464 
465  //
466  // Set our state to started. This will also resend any pended requests
467  // due to a query remove.
468  //
469  status = GotoStartState(&pended, FALSE);
470 
471  //
472  // We could not successfully start, close back down
473  //
474  if (!NT_SUCCESS(status)) {
477  "WDFIOTARGET %p could not transition to started state, %!STATUS!",
479 
480  close = TRUE;
481  }
482  }
483  else {
485  }
486 
487  //
488  // No matter what, indicate to any waiters that our state change has
489  // completed.
490  //
491  m_OpenedEvent.Set();
492 
493  Unlock(irql);
494 
495 Done:
496  //
497  // Resubmit any reads that were pended until now.
498  //
499  if (NT_SUCCESS(status)) {
500  SubmitPendedRequests(&pended);
501  }
502  else if (close) {
504  }
505 
506  if (name.Buffer != NULL) {
507  FxPoolFree(name.Buffer);
508  }
509 
510  if (pEa != NULL) {
511  FxPoolFree(pEa);
512  }
513 
514  return status;
515 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
MdDeviceObject m_TargetDevice
Definition: fxiotarget.hpp:910
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
VOID UnregisterForPnpNotification(_In_ MdTargetNotifyHandle Handle)
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT MdDeviceObject
Definition: mxgeneralkm.h:30
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
KIRQL irql
Definition: wave.h:1
PFN_WDF_IO_TARGET_QUERY_REMOVE m_Method
PFILE_OBJECT MdFileObject
Definition: mxgeneralkm.h:32
VOID Set(VOID)
Definition: fxwaitlock.hpp:144
VOID ResetTargetNotifyHandle(VOID)
WDF_IO_TARGET_STATE m_State
Definition: fxiotarget.hpp:928
#define UMDF_ONLY_CODE_PATH_ASSERT()
Definition: fxmin.hpp:132
enum _WDF_IO_TARGET_OPEN_TYPE WDF_IO_TARGET_OPEN_TYPE
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
_Must_inspect_result_ NTSTATUS OpenLocalTargetByFile(_In_ PWDF_IO_TARGET_OPEN_PARAMS OpenParams)
UCHAR KIRQL
Definition: env_spec_w32.h:591
FxIoTargetRemoveComplete m_EvtRemoveComplete
FxIoTargetQueryRemove m_EvtQueryRemove
#define FALSE
Definition: types.h:117
GLenum const GLfloat * params
Definition: glext.h:5645
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
static __inline VOID MxReferenceObject(__in PVOID Object)
Definition: mxgeneralkm.h:238
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
unsigned char BOOLEAN
MdFileObject m_TargetFileObject
Definition: fxiotarget.hpp:923
MdDeviceObject m_TargetPdo
Definition: fxiotarget.hpp:918
NTSTATUS GetTargetDeviceRelations(_Out_ BOOLEAN *Close)
UCHAR GetTargetIoType(VOID)
Definition: fxiotarget.hpp:631
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID Clear(VOID)
Definition: fxwaitlock.hpp:152
VOID Close(__in FxIoTargetRemoteCloseReason Reason)
_Must_inspect_result_ _In_ WDFIOTARGET _In_ PWDF_IO_TARGET_OPEN_PARAMS OpenParams
Definition: wdfiotarget.h:398
_Must_inspect_result_ NTSTATUS FxDuplicateUnicodeString(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in const UNICODE_STRING *Source, __out PUNICODE_STRING Destination)
Definition: stringutil.cpp:180
UCHAR m_TargetIoType
Definition: fxiotarget.hpp:947
Definition: typedefs.h:119
#define close
Definition: acwin.h:98
#define KMDF_ONLY_CODE_PATH_ASSERT()
Definition: fx.hpp:55
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
virtual _Must_inspect_result_ NTSTATUS GotoStartState(__in PLIST_ENTRY RequestListHead, __in BOOLEAN Lock=TRUE)
Definition: fxiotarget.cpp:306
FxIoTargetRemoveOpenParams m_OpenParams
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
MdTargetNotifyHandle m_TargetNotifyHandle
PFN_WDF_IO_TARGET_REMOVE_CANCELED m_Method
CCHAR m_TargetStackSize
Definition: fxiotarget.hpp:941
FxIoTargetRemoveCanceled m_EvtRemoveCanceled
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
VOID Set(__in PWDF_IO_TARGET_OPEN_PARAMS OpenParams, __in PUNICODE_STRING Name, __in PVOID Ea, __in ULONG EaLength)
Definition: name.c:38
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
BOOLEAN CanRegisterForPnpNotification(VOID)
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
NTSTATUS RegisterForPnpNotification(VOID)
#define STATUS_SUCCESS
Definition: shellext.h:65
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
Definition: wdfpool.cpp:361
WDF_IO_TARGET_OPEN_TYPE OpenType
static SERVICE_STATUS status
Definition: service.c:31
VOID SubmitPendedRequests(__in PLIST_ENTRY RequestListHeadHead)
Definition: fxiotarget.cpp:268
#define TRACINGIOTARGET
Definition: dbgtrace.h:72
NTSTATUS OpenTargetHandle(_In_ PWDF_IO_TARGET_OPEN_PARAMS OpenParams, _Inout_ FxIoTargetRemoveOpenParams *pParams)
PFN_WDF_IO_TARGET_REMOVE_COMPLETE m_Method
Definition: ps.c:97
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by FxIoTargetRemoteNotificationCallback::OnRemoveCanceled().

◆ OpenLocalTargetByFile()

NTSTATUS FxIoTargetRemote::OpenLocalTargetByFile ( _In_ PWDF_IO_TARGET_OPEN_PARAMS  OpenParams)
protected

Definition at line 58 of file fxiotargetremotekm.hpp.

61 {
63 
64  //
65  // Nothing mode-specific work to do for KM here.
66  //
67  DO_NOTHING();
68 
69  return STATUS_SUCCESS;
70 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_Must_inspect_result_ _In_ WDFIOTARGET _In_ PWDF_IO_TARGET_OPEN_PARAMS OpenParams
Definition: wdfiotarget.h:398
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DO_NOTHING()
Definition: mxgeneral.h:32

Referenced by Open().

◆ OpenTargetHandle()

NTSTATUS FxIoTargetRemote::OpenTargetHandle ( _In_ PWDF_IO_TARGET_OPEN_PARAMS  OpenParams,
_Inout_ FxIoTargetRemoveOpenParams pParams 
)

Definition at line 203 of file fxiotargetremotekm.cpp.

207 {
209  IO_STATUS_BLOCK ioStatus;
211 
213  &pParams->TargetDeviceName,
215  NULL,
216  NULL);
217 
218  status = ZwCreateFile(&m_TargetHandle,
219  pParams->DesiredAccess,
220  &oa,
221  &ioStatus,
222  pParams->AllocationSizePointer,
223  pParams->FileAttributes,
224  pParams->ShareAccess,
225  pParams->CreateDisposition,
226  pParams->CreateOptions,
227  pParams->EaBuffer,
228  pParams->EaBufferLength);
229 
230  OpenParams->FileInformation = (ULONG)ioStatus.Information;
231 
232  if (NT_SUCCESS(status)) {
235  "ZwCreateFile for WDFIOTARGET %p returned status %!STATUS!, info 0x%x",
236  GetObjectHandle(), status, (ULONG) ioStatus.Information);
237 
238  //
239  // The open operation was successful. Dereference the file handle and
240  // obtain a pointer to the device object for the handle.
241  //
244  pParams->DesiredAccess,
246  KernelMode,
248  NULL);
249 
250  if (NT_SUCCESS(status)) {
252 
253  if (m_TargetDevice == NULL) {
256  "WDFIOTARGET %p, could not convert filobj %p to devobj",
258 
260  }
261  }
262  else {
265  "WDFIOTARGET %p, could not convert handle %p to fileobject, "
266  "status %!STATUS!",
268  }
269  }
270  else {
273  "ZwCreateFile for WDFIOTARGET %p returned status %!STATUS!, info 0x%x",
274  GetObjectHandle(), status, (ULONG) ioStatus.Information);
275  }
276 
277  return status;
278 }
MdDeviceObject m_TargetDevice
Definition: fxiotarget.hpp:910
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
MdFileObject m_TargetFileObject
Definition: fxiotarget.hpp:923
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
_Must_inspect_result_ _In_ WDFIOTARGET _In_ PWDF_IO_TARGET_OPEN_PARAMS OpenParams
Definition: wdfiotarget.h:398
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
static SERVICE_STATUS status
Definition: service.c:31
#define TRACINGIOTARGET
Definition: dbgtrace.h:72
Definition: ps.c:97

Referenced by Open().

◆ QueryInterface()

_Must_inspect_result_ NTSTATUS FxIoTargetRemote::QueryInterface ( __in FxQueryInterfaceParams Params)
inlineprotectedvirtual

Reimplemented from FxObject.

Definition at line 305 of file fxiotargetremote.hpp.

308  {
309  if (Params->Type == FX_TYPE_IO_TARGET_REMOTE) {
310  *Params->Object = (FxIoTargetRemote*) this;
311  return STATUS_SUCCESS;
312  }
313  else {
314  return FxIoTarget::QueryInterface(Params); // __super call
315  }
316  }
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:306
NTSTATUS _Must_inspect_result_ QueryInterface(__inout FxQueryInterfaceParams *Params)
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ RegisterForPnpNotification()

NTSTATUS FxIoTargetRemote::RegisterForPnpNotification ( VOID  )

Definition at line 143 of file fxiotargetremotekm.cpp.

145 {
147 
148  //
149  // Register for PNP notifications on the handle we just opened.
150  // This will notify us of pnp state changes on the handle.
151  //
154  0,
158  this,
160 
161  return status;
162 }
LONG NTSTATUS
Definition: precomp.h:26
FxDriver * m_Driver
Definition: fxiotarget.hpp:900
MdFileObject m_TargetFileObject
Definition: fxiotarget.hpp:923
__inline MdDriverObject GetDriverObject(VOID)
Definition: fxdriver.hpp:252
MdTargetNotifyHandle m_TargetNotifyHandle
NTSTATUS NTAPI IoRegisterPlugPlayNotification(_In_ IO_NOTIFICATION_EVENT_CATEGORY EventCategory, _In_ ULONG EventCategoryFlags, _In_opt_ PVOID EventCategoryData, _In_ PDRIVER_OBJECT DriverObject, _In_ PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, _Inout_opt_ PVOID Context, _Out_ PVOID *NotificationEntry)
Definition: pnpnotify.c:345
static SERVICE_STATUS status
Definition: service.c:31
static DRIVER_NOTIFICATION_CALLBACK_ROUTINE _PlugPlayNotification
Definition: ps.c:97

Referenced by Open().

◆ Remove()

VOID FxIoTargetRemote::Remove ( VOID  )
virtual

Reimplemented from FxIoTarget.

Definition at line 764 of file fxiotargetremote.cpp.

767 {
768  //
769  // Close is the same as remove in this object
770  //
772 
773  //
774  // Do mode-specific work
775  //
777 
778  return ;
779 }
return
Definition: dirsup.c:529
VOID RemoveModeSpecific(VOID)
VOID Close(__in FxIoTargetRemoteCloseReason Reason)

◆ RemoveModeSpecific()

VOID FxIoTargetRemote::RemoveModeSpecific ( VOID  )

Definition at line 45 of file fxiotargetremotekm.hpp.

48 {
49  //
50  // Nothing mode-specific work to do for KM here.
51  //
52  DO_NOTHING();
53 }
#define DO_NOTHING()
Definition: mxgeneral.h:32

Referenced by Remove().

◆ ResetTargetNotifyHandle()

VOID FxIoTargetRemote::ResetTargetNotifyHandle ( VOID  )
inline

Definition at line 235 of file fxiotargetremote.hpp.

238  {
239 #if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
241 #else // FX_CORE_USER_MODE
242  m_TargetNotifyHandle = WUDF_TARGET_CONTEXT_INVALID;
243 #endif
244  }
MdTargetNotifyHandle m_TargetNotifyHandle
#define NULL
Definition: types.h:112

Referenced by Close(), and Open().

◆ UnregisterForPnpNotification()

VOID FxIoTargetRemote::UnregisterForPnpNotification ( _In_ MdTargetNotifyHandle  Handle)

Definition at line 165 of file fxiotargetremotekm.cpp.

168 {
169  if (Handle != NULL) {
170 
171 
172 
173 
174 
175 
176 
177 
178 
179 
180 
181 
182 
183 
184 
185 
186 
187 
188 
189 
190 
191 
192 
195  }
196  else {
198  }
199  }
200 }
PFN_IO_UNREGISTER_PLUGPLAY_NOTIFICATION_EX IoUnregisterPlugPlayNotificationEx
Definition: fxglobals.h:740
NTSTATUS NTAPI IoUnregisterPlugPlayNotification(_In_ PVOID NotificationEntry)
Definition: pnpnotify.c:479
FxLibraryGlobalsType FxLibraryGlobals
Definition: globals.cpp:95
#define NULL
Definition: types.h:112
_In_ HANDLE Handle
Definition: extypes.h:390

Referenced by Close(), and Open().

Member Data Documentation

◆ _PlugPlayNotification

_Must_inspect_result_ NTSTATUS STDCALL FxIoTargetRemote::_PlugPlayNotification
staticprotected

Definition at line 327 of file fxiotargetremote.hpp.

Referenced by RegisterForPnpNotification().

◆ m_ClearedPointers

FxIoTargetClearedPointers* FxIoTargetRemote::m_ClearedPointers

Definition at line 423 of file fxiotargetremote.hpp.

Referenced by ClearTargetPointers(), Close(), and FxIoTargetRemote().

◆ m_EvtQueryRemove

FxIoTargetQueryRemove FxIoTargetRemote::m_EvtQueryRemove

◆ m_EvtRemoveCanceled

FxIoTargetRemoveCanceled FxIoTargetRemote::m_EvtRemoveCanceled

◆ m_EvtRemoveComplete

FxIoTargetRemoveComplete FxIoTargetRemote::m_EvtRemoveComplete

◆ m_OpenedEvent

FxCREvent FxIoTargetRemote::m_OpenedEvent

Definition at line 421 of file fxiotargetremote.hpp.

Referenced by Close(), and Open().

◆ m_OpenParams

FxIoTargetRemoveOpenParams FxIoTargetRemote::m_OpenParams
protected

Definition at line 431 of file fxiotargetremote.hpp.

Referenced by Close(), and Open().

◆ m_OpenState

UCHAR FxIoTargetRemote::m_OpenState

Definition at line 428 of file fxiotargetremote.hpp.

Referenced by ClearTargetPointers(), Close(), FxIoTargetRemote(), and Open().

◆ m_TargetHandle

◆ m_TargetNotifyHandle


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