ReactOS 0.4.15-dev-8058-ga7cbb60
fxrequestoutputbuffer.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxRequestOutputBuffer.cpp
8
9Abstract:
10
11 This module implements class representing the output buffer in an FxRequest
12
13Author:
14
15
16
17Environment:
18
19 Both kernel and user mode
20
21Revision History:
22
23
24
25
26--*/
27
28#include "coreprivshared.hpp"
29
30// Tracing support
31extern "C" {
32// #include "FxRequestOutputBuffer.tmh"
33}
34
37 VOID
38 )
39/*++
40
41Routine Description:
42 Returns the output buffer that has been cached away by the call to SetBuffer()
43
44Arguments:
45 None
46
47Return Value:
48 Valid memory or NULL on error
49
50 --*/
51{
53
56
58 case METHOD_BUFFERED:
59 //
60 // For buffered ioctls, input and output buffer pointers are same.
61 //
62 return m_Buffer;
63
66 //
67 // FxRequest::GetDeviceControlOutputMemoryObject has already called
68 // MmGetSystemAddressForMdlSafe and returned success, so we know that
69 // we can safely call MmGetSystemAddressForMdlSafe again to get a
70 // valid VA pointer.
71 //
73
74 case METHOD_NEITHER:
75 return m_Buffer;
76
77 default:
79 return NULL;
80 }
81}
82
83size_t
85 VOID
86 )
87/*++
88
89Routine Description:
90 Returns the size of the buffer returned by GetBuffer()
91
92Arguments:
93 None
94
95Return Value:
96 Buffer length or 0 on error
97
98 --*/
99{
101
104
106}
107
109PMDL
111 VOID
112 )
113/*++
114
115Routine Description:
116 Returns the PMDL from the irp if one exists, otherwise NULL
117
118Arguments:
119 None
120
121Return Value:
122 a valid PMDL or NULL (not an error condition)
123
124 --*/
125{
127
130
132 case METHOD_IN_DIRECT:
134 return m_Mdl;
135
136 default:
137 return NULL;
138 }
139}
140
141WDFMEMORY
143 VOID
144 )
145/*++
146
147Routine Description:
148 Returns the handle that will represent this object to the driver writer.
149
150Arguments:
151 None
152
153Return Value:
154 Valid WDF handle
155
156 --*/
157{
158 return GetRequest()->GetMemoryHandle(
159 FIELD_OFFSET(FxRequest, m_OutputBufferOffset));
160}
161
162USHORT
164 VOID
165 )
166/*++
167
168Routine Description:
169 Returns the flags associated with this buffer. This currently only includes
170 whether the buffer is read only or not
171
172Arguments:
173 None
174
175Return Value:
176 flags from IFxMemoryFlags
177
178 --*/
179{
181
184
186 case METHOD_IN_DIRECT:
188
189 case METHOD_BUFFERED:
191 case METHOD_NEITHER: // since it is neither, we can't tell, so leave it as 0
192 default:
193 return 0;
194 }
195}
196
199 VOID
200 )
201/*++
202
203Routine Description:
204 Returns the driver globals
205
206Arguments:
207 none
208
209Return Value:
210 Driver globals pointer
211
212 --*/
213{
214 return GetRequest()->GetDriverGlobals();
215}
216
217ULONG
219 __in PVOID Tag,
220 __in LONG Line,
222 )
223/*++
224
225Routine Description:
226 Adds an irp reference to the owning FxRequest. This object does not maintain
227 its own reference count. A request cannot be completed with outstanding
228 irp references.
229
230Arguments:
231 Tag - the tag to use to track the reference
232
233 Line - The line number of the caller
234
235 File - the file name of the caller
236
237Return Value:
238 current reference count
239
240 --*/
241{
245
247
248 return 2;
249}
250
251ULONG
253 __in PVOID Tag,
254 __in LONG Line,
256 )
257/*++
258
259Routine Description:
260 Removes an irp reference to the owning FxRequest. This object does not maintain
261 its own reference count. A request cannot be completed with outstanding
262 irp references.
263
264Arguments:
265 Tag - the tag to use to track the release
266
267 Line - The line number of the caller
268
269 File - the file name of the caller
270
271Return Value:
272 current reference count
273
274 --*/
275{
279
281
282 return 1;
283}
284
287 VOID
288 )
289/*++
290
291Routine Description:
292 Return the owning FxRequest based on this object's address
293
294Arguments:
295 None
296
297Return Value:
298 owning FxRequest
299
300 --*/
301{
302 return CONTAINING_RECORD(this, FxRequest, m_OutputBuffer);
303}
304
305VOID
307 VOID
308 )
309/*++
310
311Routine Description:
312 Attempt to delete this interface. Since this is an embedded object, it
313 cannot be deleted. Since this function is only called internally, the
314 internal caller knows if the IFxMemory is deletable because the internal
315 caller allocated the IFxMemory to begin with.
316
317Arguments:
318 None
319
320Return Value:
321 None
322
323 --*/
324{
325 // this function should never be called
326 ASSERT(FALSE);
327}
Definition: File.h:16
Definition: fxirp.hpp:28
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
ULONG GetParameterIoctlCodeBufferMethod(VOID)
Definition: fxirpum.cpp:1490
ULONG GetParameterIoctlOutputBufferLength(VOID)
Definition: fxirpum.cpp:1504
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
FxIrp * GetFxIrp(VOID)
Definition: fxrequest.hpp:957
WDFMEMORY GetMemoryHandle(__in USHORT Offset)
Definition: fxrequest.hpp:658
VOID ReleaseIrpReference(VOID)
Definition: fxrequest.cpp:2512
VOID AddIrpReference(VOID)
Definition: fxrequest.cpp:2470
static __inline PVOID MxGetSystemAddressForMdlSafe(__inout PMDL Mdl, __in ULONG Priority)
Definition: mxgeneralkm.h:366
#define __in
Definition: dbghelp.h:35
#define __in_opt
Definition: dbghelp.h:38
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
FxIrp * irp
@ IFxMemoryFlagReadOnly
Definition: ifxmemory.hpp:35
#define ASSERT(a)
Definition: mode.c:44
@ NormalPagePriority
Definition: imports.h:56
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define METHOD_NEITHER
Definition: nt_native.h:597
#define METHOD_OUT_DIRECT
Definition: nt_native.h:596
#define METHOD_BUFFERED
Definition: nt_native.h:594
#define METHOD_IN_DIRECT
Definition: nt_native.h:595
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
virtual ULONG Release(__in PVOID Tag, __in LONG Line, __in_opt PSTR File)
virtual _Must_inspect_result_ PMDL GetMdl(VOID)
virtual USHORT GetFlags(VOID)
virtual ULONG AddRef(__in PVOID Tag, __in LONG Line, __in_opt PSTR File)
virtual PVOID GetBuffer(VOID)
virtual size_t GetBufferSize(VOID)
virtual WDFMEMORY GetHandle(VOID)
virtual PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: ncftp.h:79
char * PSTR
Definition: typedefs.h:51
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
#define IRP_MJ_INTERNAL_DEVICE_CONTROL