1 /*++
2 
3 Copyright (c) Microsoft Corporation.  All rights reserved.
4 
5 Module Name:
6 
7     FxIoTargetSelf.hpp
8 
9 Abstract:
10 
11     Encapsulation of the Self target to which FxRequest are sent to.
12     FxSelfTarget represents the client itself and is used to send IO to
13     itself.
14 
15     Unlike the the local and remote targets, the IO sent to an Self IO
16     target is routed to the sender's own top level queues. A dedicated queue
17     may also be configured as the target for requests dispatched to the Self
18     Io targets.
19 
20 Author:
21 
22 
23 
24 Environment:
25 
26     Both kernel and user mode
27 
28 Revision History:
29 
30 --*/
31 
32 #ifndef _FXIOTARGETSELF_H_
33 #define _FXIOTARGETSELF_H_
34 
35 class FxIoTargetSelf : public FxIoTarget {
36 
37 public:
38 
39     FxIoTargetSelf(
40         _In_ PFX_DRIVER_GLOBALS FxDriverGlobals,
41         _In_ USHORT ObjectSize
42         );
43 
44     virtual
45     _Must_inspect_result_
46     MdDeviceObject
GetTargetDeviceObject(_In_ CfxDeviceBase * Device)47     GetTargetDeviceObject(
48         _In_ CfxDeviceBase* Device
49         )
50     /*++
51     Routine Description:
52         Returns the target device object of the Device. In case of an Self
53         Io Target it is the device itself.
54 
55     Arguments:
56 
57         Device - Handle to the Device Object
58 
59     Returns:
60 
61         MdDeviceObject for the Device.
62 
63     --*/
64     {
65         return Device->GetDeviceObject();
66     }
67 
68     FxIoQueue*
69     GetDispatchQueue(
70         _In_ UCHAR MajorFunction
71         );
72 
73     VOID
SetDispatchQueue(_In_ FxIoQueue * DispatchQueue)74     SetDispatchQueue(
75         _In_ FxIoQueue* DispatchQueue
76         )
77     /*++
78     Routine Description:
79         Sets a disapatch queue for the IO send to the Self IO Target.
80     --*/
81     {
82         ASSERT(m_DispatchQueue == NULL);
83         m_DispatchQueue =  DispatchQueue;
84     }
85 
86     virtual
87     VOID
88     Send(
89         _In_ MdIrp Irp
90         );
91 
92 protected:
93     //
94     // Hide destructor since we are reference counted object
95     //
96     ~FxIoTargetSelf();
97 
98 private:
99 
100     //
101     // A Queue configured to dispatch IO sent to the Self IO Target.
102     //
103     FxIoQueue* m_DispatchQueue;
104 
105 };
106 
107 #endif //_FXIOTARGETSELF_H_
108