ReactOS 0.4.16-dev-338-g34e76ad
fxiotargetremote.hpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation. All rights reserved.
4
5Module Name:
6
7 FxIoTargetRemote.hpp
8
9Abstract:
10
11 Derivation of FxIoTarget specializing in targets remote to this device
12 stack.
13
14Author:
15
16
17
18Environment:
19
20 Both kernel and user mode
21
22Revision 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
38typedef WUDF_TARGET_CONTEXT MdTargetNotifyHandle;
39#endif
40
42
44
46 __in PFX_DRIVER_GLOBALS FxDriverGlobals
47 ) :
48 FxCallback(FxDriverGlobals),
50 {
51 }
52
56 __in WDFIOTARGET IoTarget
57 )
58 {
60
64
65 return status;
66 }
67
69};
70
72
74 __in PFX_DRIVER_GLOBALS FxDriverGlobals
75 ) :
76 FxCallback(FxDriverGlobals),
78 {
79 }
80
81 VOID
83 __in WDFIOTARGET Target
84 )
85 {
89 }
90
92};
93
95
97 __in PFX_DRIVER_GLOBALS FxDriverGlobals
98 ) :
99 FxCallback(FxDriverGlobals),
101 {
102 }
103
104 VOID
106 __in WDFIOTARGET Target
107 )
108 {
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
174
175public:
176
177 static
180 _Create(
181 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
185 );
186
188
192 );
193
197 );
198
201 Open(
203 );
204
205 VOID
206 Close(
208 );
209
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
250 );
251
252 VOID
254 VOID
255 );
256
257 HANDLE
259 VOID
260 );
261
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
292protected:
294 __in PFX_DRIVER_GLOBALS FxDriverGlobals
295 );
296
297 virtual
298 VOID
300 VOID
301 );
302
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
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(
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
375private:
376
378 BindToHandle(
379 VOID
380 );
381
382 VOID
383 UnbindHandle(
384 _In_ FxIoTargetClearedPointers* TargetPointers
385 );
386
388 CreateWdfFileObject(
391 );
392
393 VOID
394 CloseWdfFileObject(
396 );
397
398#endif // FX_CORE_USER-MODE)
399
400public:
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
430protected:
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_
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
void __inline CallbackStart(VOID)
Definition: fxcallback.hpp:64
void __inline CallbackEnd(VOID)
Definition: fxcallback.hpp:74
FxIoTargetClearedPointers * m_ClearedPointers
FxIoTargetRemoveComplete m_EvtRemoveComplete
_Must_inspect_result_ NTSTATUS OpenLocalTargetByFile(_In_ PWDF_IO_TARGET_OPEN_PARAMS OpenParams)
HANDLE GetTargetHandle(VOID)
__inline WDFIOTARGET GetHandle(VOID)
FxIoTargetQueryRemove m_EvtQueryRemove
virtual VOID ClearTargetPointers(VOID)
BOOLEAN CanRegisterForPnpNotification(VOID)
VOID ResetTargetNotifyHandle(VOID)
FxIoTargetRemoveOpenParams m_OpenParams
NTSTATUS InitRemote(__in FxDeviceBase *Device)
NTSTATUS GetTargetDeviceRelations(_Out_ BOOLEAN *Close)
VOID UnregisterForPnpNotification(_In_ MdTargetNotifyHandle Handle)
MdTargetNotifyHandle m_TargetNotifyHandle
NTSTATUS RegisterForPnpNotification(VOID)
NTSTATUS InitRemoteModeSpecific(__in FxDeviceBase *Device)
VOID RemoveModeSpecific(VOID)
FxIoTargetRemoveCanceled m_EvtRemoveCanceled
NTSTATUS OpenTargetHandle(_In_ PWDF_IO_TARGET_OPEN_PARAMS OpenParams, _Inout_ FxIoTargetRemoveOpenParams *pParams)
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in FxDeviceBase *Device, __out FxIoTargetRemote **Target)
VOID CloseTargetHandle(VOID)
_Must_inspect_result_ NTSTATUS QueryInterface(__in FxQueryInterfaceParams *Params)
static DRIVER_NOTIFICATION_CALLBACK_ROUTINE _PlugPlayNotification
NTSTATUS _Must_inspect_result_ QueryInterface(__inout FxQueryInterfaceParams *Params)
virtual VOID Forward(__in MdIrp Irp)
Definition: fxiotarget.hpp:699
MdFileObject m_TargetFileObject
Definition: fxiotarget.hpp:923
Definition: fxirp.hpp:28
IWudfIoIrp * GetIoIrp(VOID)
Definition: fxirpum.cpp:1777
_In_ PIRP Irp
Definition: csq.h:116
#define __in
Definition: dbghelp.h:35
#define __out
Definition: dbghelp.h:62
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
IN PVCB IN PDIRENT OUT PULONG EaLength
Definition: fatprocs.h:879
return pObject GetObjectHandle()
FxIoTargetRemoteCloseReason
@ FxIoTargetRemoteCloseReasonPlainClose
@ FxIoTargetRemoteCloseReasonQueryRemove
@ FxIoTargetRemoteCloseReasonDelete
PVOID MdTargetNotifyHandle
FxIoTargetRemoteOpenState
@ FxIoTargetRemoteOpenStateClosed
@ FxIoTargetRemoteOpenStateOpening
@ FxIoTargetRemoteOpenStateOpen
@ FX_TYPE_IO_TARGET_REMOTE
Definition: fxtypes.h:101
ULONG Handle
Definition: gdb_input.c:15
#define Open
Definition: syshdrs.h:62
PVOID PVOID PWCHAR PVOID USHORT PULONG Reason
Definition: env.c:47
static void Clear(void)
Definition: treeview.c:388
PFILE_OBJECT MdFileObject
Definition: mxgeneralkm.h:32
IWudfIrp * MdIrp
Definition: mxum.h:103
#define _Inout_
Definition: no_sal2.h:162
#define _Must_inspect_result_
Definition: no_sal2.h:62
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
ULONG ACCESS_MASK
Definition: nt_native.h:40
static BOOL Set
Definition: pageheap.c:10
@ Close
Definition: sacdrv.h:268
#define STATUS_SUCCESS
Definition: shellext.h:65
PFN_WDF_IO_TARGET_QUERY_REMOVE m_Method
_Must_inspect_result_ NTSTATUS Invoke(__in WDFIOTARGET IoTarget)
FxIoTargetQueryRemove(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
VOID Invoke(__in WDFIOTARGET Target)
PFN_WDF_IO_TARGET_REMOVE_CANCELED m_Method
FxIoTargetRemoveCanceled(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
FxIoTargetRemoveComplete(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
PFN_WDF_IO_TARGET_REMOVE_COMPLETE m_Method
VOID Invoke(__in WDFIOTARGET Target)
WDF_IO_TARGET_OPEN_TYPE OpenType
__field_bcount(EaBufferLength) PVOID EaBuffer
Definition: ps.c:97
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
enum _WDF_IO_TARGET_OPEN_TYPE WDF_IO_TARGET_OPEN_TYPE
EVT_WDF_IO_TARGET_REMOVE_CANCELED * PFN_WDF_IO_TARGET_REMOVE_CANCELED
Definition: wdfiotarget.h:108
@ WdfIoTargetOpenLocalTargetByFile
Definition: wdfiotarget.h:66
_Must_inspect_result_ _In_ WDFIOTARGET _In_ PWDF_IO_TARGET_OPEN_PARAMS OpenParams
Definition: wdfiotarget.h:401
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIOTARGET * IoTarget
Definition: wdfiotarget.h:368
EVT_WDF_IO_TARGET_REMOVE_COMPLETE * PFN_WDF_IO_TARGET_REMOVE_COMPLETE
Definition: wdfiotarget.h:121
EVT_WDF_IO_TARGET_QUERY_REMOVE * PFN_WDF_IO_TARGET_QUERY_REMOVE
Definition: wdfiotarget.h:95
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:308
_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:845
_In_ BOOLEAN Remove
Definition: psfuncs.h:110
unsigned char UCHAR
Definition: xmlstorage.h:181