1 /*++
2
3 Copyright (c) Microsoft. All rights reserved.
4
5 Module Name:
6
7 FxIoTargetUm.hpp
8
9 Abstract:
10
11 Author:
12
13
14
15 Environment:
16
17
18 Revision History:
19
20 --*/
21
22 #ifndef _FXIOTARGETUM_H_
23 #define _FXIOTARGETUM_H_
24
25 __inline
FxIoContext(VOID)26 FxIoContext::FxIoContext(
27 VOID
28 ) :
29 FxRequestContext(FX_RCT_IO),
30 m_OtherMemory(NULL),
31 m_RestoreState(FALSE)
32 {
33 ZeroMemory(&m_OriginalBufferInfo, sizeof(m_OriginalBufferInfo));
34 }
35
36 __inline
~FxIoContext(VOID)37 FxIoContext::~FxIoContext(
38 VOID
39 )
40 {
41 }
42
43 __inline
44 VOID
ReleaseAndRestore(__in FxRequestBase * Request)45 FxIoContext::ReleaseAndRestore(
46 __in FxRequestBase* Request
47 )
48 {
49 FxIrp* irp = NULL;
50
51 irp = Request->GetSubmitFxIrp();
52
53 if (m_RestoreState) {
54 irp->GetIoIrp()->RestoreCurrentBuffer(&m_OriginalBufferInfo);
55 m_RestoreState = FALSE;
56 }
57
58 //
59 // Release the 2ndary buffer if we have an outstanding reference
60 //
61 if (m_OtherMemory != NULL) {
62 m_OtherMemory->RELEASE(this);
63 m_OtherMemory = NULL;
64 }
65
66 //
67 // Release the other buffer and all __super related fields
68 //
69 FxRequestContext::ReleaseAndRestore(Request); // __super call
70 }
71
72 __inline
73 VOID
CopyParameters(__in FxRequestBase * Request)74 FxIoContext::CopyParameters(
75 __in FxRequestBase* Request
76 )
77 {
78 switch (m_MajorFunction) {
79 case IRP_MJ_WRITE:
80 m_CompletionParams.Parameters.Write.Length =
81 m_CompletionParams.IoStatus.Information;
82 break;
83
84 case IRP_MJ_READ:
85 m_CompletionParams.Parameters.Read.Length =
86 m_CompletionParams.IoStatus.Information;
87 break;
88
89 case IRP_MJ_DEVICE_CONTROL:
90 case UMINT::WdfRequestInternalIoctl:
91 m_CompletionParams.Parameters.Ioctl.Output.Length =
92 m_CompletionParams.IoStatus.Information;
93 break;
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108 default:
109 FX_VERIFY(INTERNAL, CHECK("Non Io Irp passed to CopyParameters", FALSE));
110 }
111 }
112
113 __inline
114 VOID
SwapIrpBuffer(_In_ FxRequestBase * Request,_In_ ULONG NewInputBufferCb,_In_reads_bytes_opt_ (NewInputBufferCb)PVOID NewInputBuffer,_In_ ULONG NewOutputBufferCb,_In_reads_bytes_opt_ (NewOutputBufferCb)PVOID NewOutputBuffer)115 FxIoContext::SwapIrpBuffer(
116 _In_ FxRequestBase* Request,
117 _In_ ULONG NewInputBufferCb,
118 _In_reads_bytes_opt_(NewInputBufferCb) PVOID NewInputBuffer,
119 _In_ ULONG NewOutputBufferCb,
120 _In_reads_bytes_opt_(NewOutputBufferCb) PVOID NewOutputBuffer
121 )
122 {
123 FxIrp* irp = NULL;
124
125 irp = Request->GetSubmitFxIrp();
126
127 m_RestoreState = TRUE;
128 irp->GetIoIrp()->SwapCurrentBuffer(
129 true,
130 NewInputBufferCb,
131 NewInputBuffer,
132 NewOutputBufferCb,
133 NewOutputBuffer,
134 &m_OriginalBufferInfo
135 );
136 }
137
138 __inline
139 BOOLEAN
HasValidStackSize(VOID)140 FxIoTarget::HasValidStackSize(
141 VOID
142 )
143 {
144
145
146
147
148
149
150 return TRUE;
151 }
152
153 __inline
154 VOID
Send(_In_ MdIrp Irp)155 FxIoTarget::Send(
156 _In_ MdIrp Irp
157 )
158 {
159 Forward(Irp);
160 }
161
162 #endif // _FXIOTARGETUM_H_
163