ReactOS 0.4.15-dev-5863-g1fe3ab7
fxrequestsystembuffer.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxRequestSystemBuffer.cpp
8
9Abstract:
10
11 This module implements class representing the system buffer in an FxRequest
12
13Author:
14
15
16
17
18Environment:
19
20 Both kernel and user mode
21
22Revision History:
23
24
25
26
27--*/
28
29#include "coreprivshared.hpp"
30
31// Tracing support
32extern "C" {
33// #include "FxRequestSystemBuffer.tmh"
34}
35
36size_t
38 VOID
39 )
40/*++
41
42Routine Description:
43 Returns the size of the buffer returned by GetBuffer()
44
45Arguments:
46 None
47
48Return Value:
49 Buffer length or 0 on error
50
51 --*/
52{
54
55 switch (irp->GetMajorFunction()) {
56 case IRP_MJ_READ:
58
59 case IRP_MJ_WRITE:
61
65
66 default:
67 // should not get here
69 return 0;
70 }
71}
72
74PMDL
76 VOID
77 )
78/*++
79
80Routine Description:
81 Returns the PMDL from the irp if one exists, otherwise NULL
82
83Arguments:
84 None
85
86Return Value:
87 a valid PMDL or NULL (not an error condition)
88
89 --*/
90{
93
94 switch (irp->GetMajorFunction()) {
95 case IRP_MJ_READ:
96 case IRP_MJ_WRITE:
98
100 return m_Mdl;
101 }
102 // || || Fall through || ||
103 // \/ \/ \/ \/
104
107 //
108 // For IOCLs, the outbuffer will return the PMDL
109 //
110 // || || Fall through || ||
111 // \/ \/ \/ \/
112
113 default:
114 return NULL;
115 }
116}
117
118WDFMEMORY
120 VOID
121 )
122/*++
123
124Routine Description:
125 Returns the handle that will represent this object to the driver writer.
126
127Arguments:
128 None
129
130Return Value:
131 Valid WDF handle
132
133 --*/
134{
135 return GetRequest()->GetMemoryHandle(
136 FIELD_OFFSET(FxRequest, m_SystemBufferOffset));
137}
138
139USHORT
141 VOID
142 )
143/*++
144
145Routine Description:
146 Returns the flags associated with this buffer. This currently only includes
147 whether the buffer is read only or not
148
149Arguments:
150 None
151
152Return Value:
153 flags from IFxMemoryFlags
154
155 --*/
156{
158
159 switch (irp->GetMajorFunction()) {
163 case METHOD_BUFFERED:
164 case METHOD_NEITHER:
165 return 0;
166
167 case METHOD_IN_DIRECT:
170 }
171
172 case IRP_MJ_READ:
173 return 0;
174
175 case IRP_MJ_WRITE:
177
178 default:
179 ASSERT(FALSE);
180 return 0;
181 }
182}
183
186 VOID
187 )
188/*++
189
190Routine Description:
191 Returns the driver globals
192
193Arguments:
194 none
195
196Return Value:
197 Driver globals pointer
198
199 --*/
200{
201 return GetRequest()->GetDriverGlobals();
202}
203
204ULONG
206 __in PVOID Tag,
207 __in LONG Line,
209 )
210/*++
211
212Routine Description:
213 Adds an irp reference to the owning FxRequest. This object does not maintain
214 its own reference count. A request cannot be completed with outstanding
215 irp references.
216
217Arguments:
218 Tag - the tag to use to track the reference
219
220 Line - The line number of the caller
221
222 File - the file name of the caller
223
224Return Value:
225 current reference count
226
227 --*/
228{
232
234
235 //
236 // This value should never be used by the caller
237 //
238 return 2;
239}
240
241ULONG
243 __in PVOID Tag,
244 __in LONG Line,
246 )
247/*++
248
249Routine Description:
250 Removes an irp reference to the owning FxRequest. This object does not maintain
251 its own reference count. A request cannot be completed with outstanding
252 irp references.
253
254Arguments:
255 Tag - the tag to use to track the release
256
257 Line - The line number of the caller
258
259 File - the file name of the caller
260
261Return Value:
262 current reference count
263
264 --*/
265{
269
271
272 return 1;
273}
274
277 VOID
278 )
279/*++
280
281Routine Description:
282 Return the owning FxRequest based on this object's address
283
284Arguments:
285 None
286
287Return Value:
288 owning FxRequest
289
290 --*/
291{
292 return CONTAINING_RECORD(this, FxRequest, m_SystemBuffer);
293}
294
295VOID
297 VOID
298 )
299/*++
300
301Routine Description:
302 Attempt to delete this interface. Since this is an embedded object, it
303 cannot be deleted. Since this function is only called internally, the
304 internal caller knows if the IFxMemory is deletable because the internal
305 caller allocated the IFxMemory to begin with.
306
307Arguments:
308 None
309
310Return Value:
311 None
312
313 --*/
314{
315 // this function should never be called
316 ASSERT(FALSE);
317}
Definition: File.h:16
__inline WDF_DEVICE_IO_TYPE GetIoType(VOID)
Definition: fxdevice.hpp:1084
static FxDevice * GetFxDevice(__in MdDeviceObject DeviceObject)
Definition: fxdeviceum.cpp:60
Definition: fxirp.hpp:28
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
ULONG GetParameterWriteLength(VOID)
Definition: fxirpum.cpp:1601
MdDeviceObject GetDeviceObject(VOID)
Definition: fxirpum.cpp:1352
ULONG GetParameterIoctlCodeBufferMethod(VOID)
Definition: fxirpum.cpp:1490
ULONG GetParameterIoctlInputBufferLength(VOID)
Definition: fxirpum.cpp:1518
ULONG GetParameterReadLength(VOID)
Definition: fxirpum.cpp:1589
__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
#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
FxDevice * pDevice
FxIrp * irp
@ IFxMemoryFlagReadOnly
Definition: ifxmemory.hpp:35
#define ASSERT(a)
Definition: mode.c:44
#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_READ
Definition: rdpdr.c:46
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
virtual ULONG Release(__in PVOID Tag, __in LONG Line, __in_opt PSTR File)
virtual size_t GetBufferSize(VOID)
virtual PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
virtual USHORT GetFlags(VOID)
virtual WDFMEMORY GetHandle(VOID)
virtual ULONG AddRef(__in PVOID Tag, __in LONG Line, __in_opt PSTR File)
virtual _Must_inspect_result_ PMDL GetMdl(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
@ WdfDeviceIoDirect
Definition: wdfdevice.h:453
#define IRP_MJ_INTERNAL_DEVICE_CONTROL