ReactOS 0.4.16-dev-340-g0540c21
IFxMemory Class Referenceabstract

#include <ifxmemory.hpp>

Inheritance diagram for IFxMemory:

Public Member Functions

virtual PVOID GetBuffer (VOID)=0
 
virtual size_t GetBufferSize (VOID)=0
 
virtual PMDL GetMdl (VOID)=0
 
virtual WDFMEMORY GetHandle (VOID)=0
 
virtual USHORT GetFlags (VOID)=0
 
virtual PFX_DRIVER_GLOBALS GetDriverGlobals (VOID)=0
 
virtual ULONG AddRef (__in PVOID Tag, __in LONG Line, __in_opt PSTR File)=0
 
virtual ULONG Release (__in PVOID Tag, __in LONG Line, __in_opt PSTR File)=0
 
virtual VOID Delete (VOID)=0
 
_Must_inspect_result_ NTSTATUS ValidateMemoryOffsets (__in_opt PWDFMEMORY_OFFSET Offsets)
 
_Must_inspect_result_ NTSTATUS CopyFromPtr (__in_opt PWDFMEMORY_OFFSET DestinationOffsets, __in_bcount(SourceBufferLength) PVOID SourceBuffer, __in size_t SourceBufferLength, __in_opt PWDFMEMORY_OFFSET SourceOffsets)
 
_Must_inspect_result_ NTSTATUS CopyToPtr (__in_opt PWDFMEMORY_OFFSET SourceOffsets, __out_bcount(DestinationBufferLength) PVOID DestinationBuffer, __in size_t DestinationBufferLength, __in_opt PWDFMEMORY_OFFSET DestinationOffsets)
 
virtual PVOID GetBuffer (VOID)=0
 
virtual size_t GetBufferSize (VOID)=0
 
virtual PMDL GetMdl (VOID)=0
 
virtual WDFMEMORY GetHandle (VOID)=0
 
virtual USHORT GetFlags (VOID)=0
 
virtual PFX_DRIVER_GLOBALS GetDriverGlobals (VOID)=0
 
virtual ULONG AddRef (__in PVOID Tag, __in LONG Line, __in_opt PSTR File)=0
 
virtual ULONG Release (__in PVOID Tag, __in LONG Line, __in_opt PSTR File)=0
 
virtual VOID Delete (VOID)=0
 
_Must_inspect_result_ NTSTATUS ValidateMemoryOffsets (__in_opt PWDFMEMORY_OFFSET Offsets)
 
_Must_inspect_result_ NTSTATUS CopyFromPtr (__in_opt PWDFMEMORY_OFFSET DestinationOffsets, __in_bcount(SourceBufferLength) PVOID SourceBuffer, __in size_t SourceBufferLength, __in_opt PWDFMEMORY_OFFSET SourceOffsets)
 
_Must_inspect_result_ NTSTATUS CopyToPtr (__in_opt PWDFMEMORY_OFFSET SourceOffsets, __out_bcount(DestinationBufferLength) PVOID DestinationBuffer, __in size_t DestinationBufferLength, __in_opt PWDFMEMORY_OFFSET DestinationOffsets)
 

Static Protected Member Functions

static _Must_inspect_result_ NTSTATUS _CopyPtrToPtr (__in_bcount(SourceBufferLength) PVOID SourceBuffer, __in size_t SourceBufferLength, __in_opt PWDFMEMORY_OFFSET SourceOffsets, __out_bcount(DestinationBufferLength) PVOID DestinationBuffer, __in size_t DestinationBufferLength, __in_opt PWDFMEMORY_OFFSET DestinationOffsets)
 
static _Must_inspect_result_ NTSTATUS _CopyPtrToPtr (__in_bcount(SourceBufferLength) PVOID SourceBuffer, __in size_t SourceBufferLength, __in_opt PWDFMEMORY_OFFSET SourceOffsets, __out_bcount(DestinationBufferLength) PVOID DestinationBuffer, __in size_t DestinationBufferLength, __in_opt PWDFMEMORY_OFFSET DestinationOffsets)
 

Detailed Description

Definition at line 40 of file ifxmemory.hpp.

Member Function Documentation

◆ _CopyPtrToPtr() [1/2]

_Must_inspect_result_ NTSTATUS IFxMemory::_CopyPtrToPtr ( __in_bcount(SourceBufferLength) PVOID  SourceBuffer,
__in size_t  SourceBufferLength,
__in_opt PWDFMEMORY_OFFSET  SourceOffsets,
__out_bcount(DestinationBufferLength) PVOID  DestinationBuffer,
__in size_t  DestinationBufferLength,
__in_opt PWDFMEMORY_OFFSET  DestinationOffsets 
)
staticprotected

Definition at line 205 of file fxmemoryobject.cpp.

243{
244 size_t srcSize, copyLength;
245 PUCHAR pSrcBuf, pDstBuf;
246
247 if (SourceBuffer == NULL) {
249 }
250
251 pSrcBuf = (PUCHAR) SourceBuffer;
252 srcSize = SourceBufferLength;
253
254 pDstBuf = (PUCHAR) DestinationBuffer;
255 copyLength = DestinationBufferLength;
256
257 if (SourceOffsets != NULL) {
258 if (SourceOffsets->BufferOffset != 0) {
259 if (SourceOffsets->BufferOffset >= srcSize) {
260 //
261 // Offset is beyond end of buffer
262 //
264 }
265
266 //
267 // Adjust the start and source size to reflect the offset info the
268 // source
269 //
270 pSrcBuf += SourceOffsets->BufferOffset;
271 srcSize -= SourceOffsets->BufferOffset;
272 }
273 }
274
275 if (DestinationOffsets != NULL) {
276 if (DestinationOffsets->BufferOffset != 0) {
277 if (DestinationOffsets->BufferOffset >= copyLength) {
278 //
279 // Offset is beyond end of buffer
280 //
282 }
283
284 //
285 // Adjust the start and copy length to reflect the offset info the
286 // destination
287 //
288 pDstBuf += DestinationOffsets->BufferOffset;
289 copyLength -= DestinationOffsets->BufferOffset;
290 }
291
292 //
293 // Non zero buffer length overrides previously calculated copy length
294 //
295 if (DestinationOffsets->BufferLength != 0) {
296 //
297 // Is the desired buffer length greater than the amount of buffer
298 // available?
299 //
300 if (DestinationOffsets->BufferLength > copyLength) {
302 }
303
304 copyLength = DestinationOffsets->BufferLength;
305 }
306 }
307
308 //
309 // Compare the final computed copy length against the length of the source
310 // buffer.
311 //
312 if (copyLength > srcSize) {
314 }
315
316 RtlCopyMemory(pDstBuf, pSrcBuf, copyLength);
317
318 return STATUS_SUCCESS;
319}
#define NULL
Definition: types.h:112
#define STATUS_INVALID_BUFFER_SIZE
Definition: ntstatus.h:650
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
unsigned char * PUCHAR
Definition: typedefs.h:53
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

Referenced by CopyFromPtr(), and CopyToPtr().

◆ _CopyPtrToPtr() [2/2]

static _Must_inspect_result_ NTSTATUS IFxMemory::_CopyPtrToPtr ( __in_bcount(SourceBufferLength) PVOID  SourceBuffer,
__in size_t  SourceBufferLength,
__in_opt PWDFMEMORY_OFFSET  SourceOffsets,
__out_bcount(DestinationBufferLength) PVOID  DestinationBuffer,
__in size_t  DestinationBufferLength,
__in_opt PWDFMEMORY_OFFSET  DestinationOffsets 
)
staticprotected

◆ AddRef() [1/2]

virtual ULONG IFxMemory::AddRef ( __in PVOID  Tag,
__in LONG  Line,
__in_opt PSTR  File 
)
pure virtual

◆ AddRef() [2/2]

virtual ULONG IFxMemory::AddRef ( __in PVOID  Tag,
__in LONG  Line,
__in_opt PSTR  File 
)
pure virtual

◆ CopyFromPtr() [1/2]

_Must_inspect_result_ NTSTATUS IFxMemory::CopyFromPtr ( __in_opt PWDFMEMORY_OFFSET  DestinationOffsets,
__in_bcount(SourceBufferLength) PVOID  SourceBuffer,
__in size_t  SourceBufferLength,
__in_opt PWDFMEMORY_OFFSET  SourceOffsets 
)

Definition at line 118 of file fxmemoryobject.cpp.

124{
126
128
129 //
130 // We read from the supplied buffer writing to the current FxMemoryBuffer
131 //
133 //
134 // FxMemoryBuffer is not writeable
135 //
137 "Target WDFMEMORY 0x%p is ReadOnly", GetHandle());
139
141 }
142
143 return _CopyPtrToPtr(
144 SourceBuffer,
145 SourceBufferLength,
146 SourceOffsets,
147 GetBuffer(),
149 DestinationOffsets
150 );
151}
virtual size_t GetBufferSize(VOID)=0
virtual USHORT GetFlags(VOID)=0
virtual PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)=0
static _Must_inspect_result_ NTSTATUS _CopyPtrToPtr(__in_bcount(SourceBufferLength) PVOID SourceBuffer, __in size_t SourceBufferLength, __in_opt PWDFMEMORY_OFFSET SourceOffsets, __out_bcount(DestinationBufferLength) PVOID DestinationBuffer, __in size_t DestinationBufferLength, __in_opt PWDFMEMORY_OFFSET DestinationOffsets)
#define TRACINGDEVICE
Definition: dbgtrace.h:58
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
PFX_DRIVER_GLOBALS pFxDriverGlobals
FxVerifierDbgBreakPoint(pFxDriverGlobals)
return pMemory GetBuffer()
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
@ IFxMemoryFlagReadOnly
Definition: ifxmemory.hpp:35
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define GetHandle(h)
Definition: treelist.c:116

Referenced by __drv_when().

◆ CopyFromPtr() [2/2]

_Must_inspect_result_ NTSTATUS IFxMemory::CopyFromPtr ( __in_opt PWDFMEMORY_OFFSET  DestinationOffsets,
__in_bcount(SourceBufferLength) PVOID  SourceBuffer,
__in size_t  SourceBufferLength,
__in_opt PWDFMEMORY_OFFSET  SourceOffsets 
)

◆ CopyToPtr() [1/2]

_Must_inspect_result_ NTSTATUS IFxMemory::CopyToPtr ( __in_opt PWDFMEMORY_OFFSET  SourceOffsets,
__out_bcount(DestinationBufferLength) PVOID  DestinationBuffer,
__in size_t  DestinationBufferLength,
__in_opt PWDFMEMORY_OFFSET  DestinationOffsets 
)

Definition at line 155 of file fxmemoryobject.cpp.

189{
190 //
191 // We are reading from the FxMemoryBuffer, so no need to check for ReadOnly
192 //
193 return _CopyPtrToPtr(
194 GetBuffer(),
196 SourceOffsets,
197 DestinationBuffer,
198 DestinationBufferLength,
199 DestinationOffsets
200 );
201}

Referenced by __drv_when().

◆ CopyToPtr() [2/2]

_Must_inspect_result_ NTSTATUS IFxMemory::CopyToPtr ( __in_opt PWDFMEMORY_OFFSET  SourceOffsets,
__out_bcount(DestinationBufferLength) PVOID  DestinationBuffer,
__in size_t  DestinationBufferLength,
__in_opt PWDFMEMORY_OFFSET  DestinationOffsets 
)

◆ Delete() [1/2]

virtual VOID IFxMemory::Delete ( VOID  )
pure virtual

◆ Delete() [2/2]

virtual VOID IFxMemory::Delete ( VOID  )
pure virtual

◆ GetBuffer() [1/2]

◆ GetBuffer() [2/2]

◆ GetBufferSize() [1/2]

virtual size_t IFxMemory::GetBufferSize ( VOID  )
pure virtual

◆ GetBufferSize() [2/2]

virtual size_t IFxMemory::GetBufferSize ( VOID  )
pure virtual

◆ GetDriverGlobals() [1/2]

virtual PFX_DRIVER_GLOBALS IFxMemory::GetDriverGlobals ( VOID  )
pure virtual

◆ GetDriverGlobals() [2/2]

virtual PFX_DRIVER_GLOBALS IFxMemory::GetDriverGlobals ( VOID  )
pure virtual

◆ GetFlags() [1/2]

virtual USHORT IFxMemory::GetFlags ( VOID  )
pure virtual

◆ GetFlags() [2/2]

virtual USHORT IFxMemory::GetFlags ( VOID  )
pure virtual

◆ GetHandle() [1/2]

virtual WDFMEMORY IFxMemory::GetHandle ( VOID  )
pure virtual

◆ GetHandle() [2/2]

virtual WDFMEMORY IFxMemory::GetHandle ( VOID  )
pure virtual

◆ GetMdl() [1/2]

virtual PMDL IFxMemory::GetMdl ( VOID  )
pure virtual

◆ GetMdl() [2/2]

virtual PMDL IFxMemory::GetMdl ( VOID  )
pure virtual

◆ Release() [1/2]

virtual ULONG IFxMemory::Release ( __in PVOID  Tag,
__in LONG  Line,
__in_opt PSTR  File 
)
pure virtual

◆ Release() [2/2]

virtual ULONG IFxMemory::Release ( __in PVOID  Tag,
__in LONG  Line,
__in_opt PSTR  File 
)
pure virtual

◆ ValidateMemoryOffsets() [1/2]

_Must_inspect_result_ NTSTATUS IFxMemory::ValidateMemoryOffsets ( __in_opt PWDFMEMORY_OFFSET  Offsets)
inline

Definition at line 105 of file ifxmemory.hpp.

108 {
110 size_t total;
111
112 if (Offsets == NULL) {
113 return STATUS_SUCCESS;
114 }
115
116 status = RtlSizeTAdd(Offsets->BufferLength, Offsets->BufferOffset, &total);
117
118 if (!NT_SUCCESS(status)) {
119 return status;
120 }
121
122 if (total > GetBufferSize()) {
124 }
125
126 return STATUS_SUCCESS;
127 }
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
size_t total
#define STATUS_INTEGER_OVERFLOW
Definition: ntstatus.h:385
Definition: ps.c:97

Referenced by FxUsbPipe::_FormatTransfer(), for(), if(), and FxRequestBuffer::ValidateMemoryDescriptor().

◆ ValidateMemoryOffsets() [2/2]

_Must_inspect_result_ NTSTATUS IFxMemory::ValidateMemoryOffsets ( __in_opt PWDFMEMORY_OFFSET  Offsets)
inline

Definition at line 105 of file ifxmemory.hpp.

108 {
110 size_t total;
111
112 if (Offsets == NULL) {
113 return STATUS_SUCCESS;
114 }
115
116 status = RtlSizeTAdd(Offsets->BufferLength, Offsets->BufferOffset, &total);
117
118 if (!NT_SUCCESS(status)) {
119 return status;
120 }
121
122 if (total > GetBufferSize()) {
124 }
125
126 return STATUS_SUCCESS;
127 }

The documentation for this class was generated from the following files: