ReactOS  0.4.15-dev-3163-gf17c2c0
fxiotargetremote.hpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation. All rights reserved.
4 
5 Module Name:
6 
7  FxIoTargetRemote.hpp
8 
9 Abstract:
10 
11  Derivation of FxIoTarget specializing in targets remote to this device
12  stack.
13 
14 Author:
15 
16 
17 
18 Environment:
19 
20  Both kernel and user mode
21 
22 Revision History:
23 
24 --*/
25 
26 #ifndef _FXIOTARGETREMOTE_H_
27 #define _FXIOTARGETREMOTE_H_
28 
33 };
34 
35 #if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
37 #else
38 typedef WUDF_TARGET_CONTEXT MdTargetNotifyHandle;
39 #endif
40 
42 
44 
46  __in PFX_DRIVER_GLOBALS FxDriverGlobals
47  ) :
48  FxCallback(FxDriverGlobals),
49  m_Method(NULL)
50  {
51  }
52 
54  NTSTATUS
56  __in WDFIOTARGET IoTarget
57  )
58  {
60 
61  CallbackStart();
63  CallbackEnd();
64 
65  return status;
66  }
67 
69 };
70 
72 
74  __in PFX_DRIVER_GLOBALS FxDriverGlobals
75  ) :
76  FxCallback(FxDriverGlobals),
77  m_Method(NULL)
78  {
79  }
80 
81  VOID
83  __in WDFIOTARGET Target
84  )
85  {
86  CallbackStart();
88  CallbackEnd();
89  }
90 
92 };
93 
95 
97  __in PFX_DRIVER_GLOBALS FxDriverGlobals
98  ) :
99  FxCallback(FxDriverGlobals),
100  m_Method(NULL)
101  {
102  }
103 
104  VOID
106  __in WDFIOTARGET Target
107  )
108  {
109  CallbackStart();
110  m_Method(Target);
111  CallbackEnd();
112  }
113 
115 };
116 
121 };
122 
124 
126  {
128  }
129 
130  VOID
131  Set(
134  __in PVOID Ea,
136  );
137 
138  VOID
139  Clear(
140  VOID
141  );
142 
144 
146 
148 
150 
152 
154 
156 
158 
160 
162 
164 
165 };
166 
171 };
172 
173 class FxIoTargetRemote : public FxIoTarget {
174 
175 public:
176 
177  static
179  NTSTATUS
180  _Create(
181  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
185  );
186 
188 
189  NTSTATUS
190  InitRemote(
192  );
193 
194  NTSTATUS
197  );
198 
200  NTSTATUS
201  Open(
203  );
204 
205  VOID
206  Close(
208  );
209 
210  NTSTATUS
213  );
214 
215  BOOLEAN
217  VOID
218  )
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  }
233 
234  VOID
236  VOID
237  )
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  }
245 
246  NTSTATUS
250  );
251 
252  VOID
254  VOID
255  );
256 
257  HANDLE
259  VOID
260  );
261 
262  NTSTATUS
264  VOID
265  );
266 
267  VOID
270  );
271 
272  __inline
273  WDFIOTARGET
275  VOID
276  )
277  {
278  return (WDFIOTARGET) GetObjectHandle();
279  }
280 
281  virtual
282  VOID
283  Remove(
284  VOID
285  );
286 
287  VOID
289  VOID
290  );
291 
292 protected:
294  __in PFX_DRIVER_GLOBALS FxDriverGlobals
295  );
296 
297  virtual
298  VOID
300  VOID
301  );
302 
304  NTSTATUS
307  )
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  }
317 
319  NTSTATUS
322  );
323 
324 #if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
325  static
326  DRIVER_NOTIFICATION_CALLBACK_ROUTINE
328 
329 #else // FX_CORE_USER_MODE
330  //
331  // I/O dispatcher to be used for IRPs forwarded to this remote target. It is
332  // created when the CWdfRemoteTarget is created. The win32 handle is
333  // associated with it via a call to m_pRemoteDispatcher->BindToHandle()
334  // right after we call CreateFile(...). We must call
335  // m_pRemoteDispatcher->CloseHandle() to close the handle.
336  //
337  // Because of the plug-in pattern of the IoDispatcher, we need two
338  // interface pointers (one to the outer object, and one to the plug-in.
339  //
340  IWudfIoDispatcher * m_pIoDispatcher;
341  IWudfRemoteDispatcher * m_pRemoteDispatcher;
342 
343  //
344  // Implements host's callback interface for pnp notification
345  //
346  FxIoTargetRemoteNotificationCallback* m_NotificationCallback;
347 
348  VOID
349  Forward(
350  _In_ MdIrp Irp
351  )
352  {
354  //
355  // Ignore the return value because once we have sent the request, we
356  // want all processing to be done in the completion routine.
357  //
358  (void) Irp->Forward();
359  }
360  else {
361  IWudfIoIrp* pSubmitIrp = FxIrp(Irp).GetIoIrp();
362 
363  //
364  // Move the stack location to the next location
365  //
366  pSubmitIrp->SetNextIrpStackLocation();
367 
368  //
369  // Route it using Remote dispatcher
370  //
371  m_pIoDispatcher->Dispatch(pSubmitIrp, NULL);
372  }
373  }
374 
375 private:
376 
377  NTSTATUS
378  BindToHandle(
379  VOID
380  );
381 
382  VOID
383  UnbindHandle(
384  _In_ FxIoTargetClearedPointers* TargetPointers
385  );
386 
387  NTSTATUS
388  CreateWdfFileObject(
391  );
392 
393  VOID
394  CloseWdfFileObject(
396  );
397 
398 #endif // FX_CORE_USER-MODE)
399 
400 public:
401  //
402  // File handle for m_TargetHandle
403  //
405 
406  //
407  // Notification handle returned by IoRegisterPlugPlayNotification for KMDF,
408  // or host's notification registartion interface for UMDf. Note that host
409  // uses the term RegistrationId for the same (with WUDF_CONTEXT_TYPE which
410  // is UINT64).
411  //
413 
414  //
415  // Driver writer callbacks to indicate state changes
416  //
420 
422 
424 
425  //
426  // Value from FxIoTargetRemoteOpenState
427  //
429 
430 protected:
432 };
433 
434 #if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
435 #include "fxiotargetremotekm.hpp"
436 #else
437 #include "fxiotargetremoteum.hpp"
438 #endif
439 
440 #endif // _FXIOTARGETREMOTE_H_
_Must_inspect_result_ NTSTATUS QueryInterface(__in FxQueryInterfaceParams *Params)
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
VOID UnregisterForPnpNotification(_In_ MdTargetNotifyHandle Handle)
FxIoTargetRemoteCloseReason
#define _In_opt_
Definition: ms_sal.h:309
#define _Inout_
Definition: ms_sal.h:378
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:306
#define _Out_
Definition: ms_sal.h:345
#define TRUE
Definition: types.h:120
VOID Invoke(__in WDFIOTARGET Target)
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Out_ PIO_STATUS_BLOCK _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ ULONG _In_ ULONG _In_ ULONG _In_opt_ PVOID EaBuffer
Definition: iofuncs.h:837
LONG NTSTATUS
Definition: precomp.h:26
virtual VOID Forward(__in MdIrp Irp)
Definition: fxiotarget.hpp:699
Definition: fxirp.hpp:28
PFN_WDF_IO_TARGET_QUERY_REMOVE m_Method
PFILE_OBJECT MdFileObject
Definition: mxgeneralkm.h:32
virtual VOID ClearTargetPointers(VOID)
VOID ResetTargetNotifyHandle(VOID)
enum _WDF_IO_TARGET_OPEN_TYPE WDF_IO_TARGET_OPEN_TYPE
_Must_inspect_result_ NTSTATUS OpenLocalTargetByFile(_In_ PWDF_IO_TARGET_OPEN_PARAMS OpenParams)
FxIoTargetRemoveComplete m_EvtRemoveComplete
EVT_WDF_IO_TARGET_REMOVE_CANCELED * PFN_WDF_IO_TARGET_REMOVE_CANCELED
Definition: wdfiotarget.h:108
FxIoTargetQueryRemove m_EvtQueryRemove
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
#define __out
Definition: dbghelp.h:62
unsigned char BOOLEAN
MdFileObject m_TargetFileObject
Definition: fxiotarget.hpp:923
#define _In_
Definition: ms_sal.h:308
IWudfIrp * MdIrp
Definition: mxum.h:103
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
virtual VOID Remove(VOID)
NTSTATUS GetTargetDeviceRelations(_Out_ BOOLEAN *Close)
VOID RemoveModeSpecific(VOID)
IN PVCB IN PDIRENT OUT PULONG EaLength
Definition: fatprocs.h:875
HANDLE GetTargetHandle(VOID)
EVT_WDF_IO_TARGET_REMOVE_COMPLETE * PFN_WDF_IO_TARGET_REMOVE_COMPLETE
Definition: wdfiotarget.h:121
FxIoTargetClearedPointers * m_ClearedPointers
VOID CloseTargetHandle(VOID)
_Must_inspect_result_ NTSTATUS Invoke(__in WDFIOTARGET IoTarget)
VOID Close(__in FxIoTargetRemoteCloseReason Reason)
_Must_inspect_result_ _In_ WDFIOTARGET _In_ PWDF_IO_TARGET_OPEN_PARAMS OpenParams
Definition: wdfiotarget.h:398
PVOID MdTargetNotifyHandle
unsigned char UCHAR
Definition: xmlstorage.h:181
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in FxDeviceBase *Device, __out FxIoTargetRemote **Target)
IWudfIoIrp * GetIoIrp(VOID)
Definition: fxirpum.cpp:1777
__field_bcount(EaBufferLength) PVOID EaBuffer
#define _Must_inspect_result_
Definition: ms_sal.h:558
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
NTSTATUS _Must_inspect_result_ QueryInterface(__inout FxQueryInterfaceParams *Params)
FxIoTargetRemote(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
FxIoTargetRemoveOpenParams m_OpenParams
MdTargetNotifyHandle m_TargetNotifyHandle
PFN_WDF_IO_TARGET_REMOVE_CANCELED m_Method
FxIoTargetRemoveCanceled m_EvtRemoveCanceled
FxIoTargetRemoteOpenState
_Must_inspect_result_ NTSTATUS Open(__in PWDF_IO_TARGET_OPEN_PARAMS OpenParams)
FxIoTargetRemoveCanceled(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
NTSTATUS InitRemote(__in FxDeviceBase *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)
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
_In_ HANDLE Handle
Definition: extypes.h:390
VOID Invoke(__in WDFIOTARGET Target)
unsigned int ULONG
Definition: retypes.h:1
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIOTARGET * IoTarget
Definition: wdfiotarget.h:363
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
BOOLEAN CanRegisterForPnpNotification(VOID)
FxIoTargetQueryRemove(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
NTSTATUS RegisterForPnpNotification(VOID)
void __inline CallbackStart(VOID)
Definition: fxcallback.hpp:64
#define STATUS_SUCCESS
Definition: shellext.h:65
NTSTATUS InitRemoteModeSpecific(__in FxDeviceBase *Device)
EVT_WDF_IO_TARGET_QUERY_REMOVE * PFN_WDF_IO_TARGET_QUERY_REMOVE
Definition: wdfiotarget.h:95
WDF_IO_TARGET_OPEN_TYPE OpenType
PVOID PVOID PWCHAR PVOID USHORT PULONG Reason
Definition: env.c:47
#define __in
Definition: dbghelp.h:35
static SERVICE_STATUS status
Definition: service.c:31
FxIoTargetRemoveComplete(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
__inline WDFIOTARGET GetHandle(VOID)
void __inline CallbackEnd(VOID)
Definition: fxcallback.hpp:74
ULONG ACCESS_MASK
Definition: nt_native.h:40
NTSTATUS OpenTargetHandle(_In_ PWDF_IO_TARGET_OPEN_PARAMS OpenParams, _Inout_ FxIoTargetRemoveOpenParams *pParams)
PFN_WDF_IO_TARGET_REMOVE_COMPLETE m_Method
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
static DRIVER_NOTIFICATION_CALLBACK_ROUTINE _PlugPlayNotification
Definition: ps.c:97