ReactOS 0.4.15-dev-7942-gd23573b
fxmemorybufferapi.cpp File Reference
#include "coreprivshared.hpp"
#include "fxmemorybuffer.hpp"
Include dependency graph for fxmemorybufferapi.cpp:

Go to the source code of this file.

Functions

_Must_inspect_result_ __drv_when (PoolType==1||PoolType==257, __drv_maxIRQL(APC_LEVEL)) __drv_when(PoolType
 
_Must_inspect_result_ __drv_maxIRQL (DISPATCH_LEVEL)) WDFAPI NTSTATUS STDCALL WDFEXPORT(WdfMemoryCreate)(__in PWDF_DRIVER_GLOBALS DriverGlobals
 
_Must_inspect_result_ __in_opt PWDF_OBJECT_ATTRIBUTES __in __drv_strictTypeMatch (__drv_typeExpr) POOL_TYPE PoolType
 
_Must_inspect_result_ __in_opt PWDF_OBJECT_ATTRIBUTES __in __in_opt ULONG __in __drv_when (BufferSize==0, __drv_reportError(BufferSize cannot be zero)) size_t BufferSize
 
 if (NT_SUCCESS(FxValidateObjectAttributesForParentHandle(pFxDriverGlobals, Attributes)))
 
 FxPointerNotNull (pFxDriverGlobals, Memory)
 
 if (FxIsPagedPoolType(PoolType))
 
 if (BufferSize==0)
 
 if (!NT_SUCCESS(status))
 
 if (PoolTag==0)
 
 FxVerifierCheckNxPoolType (pFxDriverGlobals, PoolType, PoolTag)
 
 if (NT_SUCCESS(status))
 
 FxObjectHandleGetPtr (GetFxDriverGlobals(DriverGlobals), Memory, IFX_TYPE_MEMORY,(PVOID *)&pMemory)
 
 if (BufferSize !=NULL)
 
return pMemory GetBuffer ()
 
_Must_inspect_result_ __in WDFMEMORY __in size_t __out_bcount (NumBytesToCopyTo) PVOID Buffer
 
_Must_inspect_result_ __in WDFMEMORY __in size_t __in __drv_when (NumBytesToCopyTo==0, __drv_reportError(NumBytesToCopyTo cannot be zero)) size_t NumBytesToCopyTo)
 
_Must_inspect_result_ __in WDFMEMORY __in size_t __in PVOID __in __drv_when (NumBytesToCopyFrom==0, __drv_reportError(NumBytesToCopyFrom cannot be zero)) size_t NumBytesToCopyFrom)
 

Variables

_Must_inspect_result_ __in_opt PWDF_OBJECT_ATTRIBUTES Attributes
 
_Must_inspect_result_ __in_opt PWDF_OBJECT_ATTRIBUTES __in __in_opt ULONG PoolTag
 
_Must_inspect_result_ __in_opt PWDF_OBJECT_ATTRIBUTES __in __in_opt ULONG __in __out WDFMEMORY * Memory = NULL
 
_Must_inspect_result_ __in_opt PWDF_OBJECT_ATTRIBUTES __in __in_opt ULONG __in __out WDFMEMORY __out_opt PVOIDBuffer
 
PFX_DRIVER_GLOBALS pFxDriverGlobals = GetFxDriverGlobals(DriverGlobals)
 
FxMemoryObjectpBuffer
 
WDFMEMORY hMemory
 
NTSTATUS status = FxValidateObjectAttributes(pFxDriverGlobals, Attributes)
 
 else
 
__in WDFMEMORY __out_opt size_tBufferSize
 
IFxMemorypMemory
 
_Must_inspect_result_ __in WDFMEMORY SourceMemory
 
_Must_inspect_result_ __in WDFMEMORY __in size_t SourceOffset
 
_Must_inspect_result_ __in WDFMEMORY DestinationMemory
 
_Must_inspect_result_ __in WDFMEMORY __in size_t DestinationOffset
 

Function Documentation

◆ __drv_maxIRQL()

◆ __drv_strictTypeMatch()

_Must_inspect_result_ __in_opt PWDF_OBJECT_ATTRIBUTES __in __drv_strictTypeMatch ( __drv_typeExpr  )

◆ __drv_when() [1/4]

◆ __drv_when() [2/4]

_Must_inspect_result_ __in WDFMEMORY __in size_t __in PVOID __in __drv_when ( NumBytesToCopyFrom  = = 0,
__drv_reportError(NumBytesToCopyFrom cannot be zero  
)

Definition at line 302 of file fxmemorybufferapi.cpp.

329{
330 DDI_ENTRY();
331
333 WDFMEMORY_OFFSET srcOffsets;
334 WDFMEMORY_OFFSET dstOffsets;
335 IFxMemory* pDest;
337
341 (PVOID*) &pDest);
342
344
346
347 if (NumBytesToCopyFrom == 0) {
350 "Zero bytes to copy not allowed, %!STATUS!", status);
351 return status;
352 }
353
354 RtlZeroMemory(&srcOffsets, sizeof(srcOffsets));
355 srcOffsets.BufferLength = NumBytesToCopyFrom;
356 srcOffsets.BufferOffset = 0;
357
358 RtlZeroMemory(&dstOffsets, sizeof(dstOffsets));
359 dstOffsets.BufferLength = NumBytesToCopyFrom;
360 dstOffsets.BufferOffset = DestinationOffset;
361
362 return pDest->CopyFromPtr(&dstOffsets,
363 Buffer,
364 NumBytesToCopyFrom,
365 &srcOffsets);
366}
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
virtual PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)=0
_Must_inspect_result_ NTSTATUS CopyFromPtr(__in_opt PWDFMEMORY_OFFSET DestinationOffsets, __in_bcount(SourceBufferLength) PVOID SourceBuffer, __in size_t SourceBufferLength, __in_opt PWDFMEMORY_OFFSET SourceOffsets)
#define TRACINGDEVICE
Definition: dbgtrace.h:58
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
DriverGlobals
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
#define FxPointerNotNull(FxDriverGlobals, Ptr)
Definition: fxmacros.hpp:253
NTSTATUS status
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), Memory, IFX_TYPE_MEMORY,(PVOID *)&pMemory)
_Must_inspect_result_ __in WDFMEMORY __in size_t DestinationOffset
PFX_DRIVER_GLOBALS pFxDriverGlobals
@ IFX_TYPE_MEMORY
Definition: fxtypes.h:55
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
size_t BufferOffset
Definition: wdfmemory.h:65
size_t BufferLength
Definition: wdfmemory.h:72
Definition: ps.c:97
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ WDFMEMORY DestinationMemory
Definition: wdfmemory.h:359

◆ __drv_when() [3/4]

_Must_inspect_result_ __in WDFMEMORY __in size_t __in __drv_when ( NumBytesToCopyTo  = = 0,
__drv_reportError(NumBytesToCopyTo cannot be zero  
)

Definition at line 223 of file fxmemorybufferapi.cpp.

248{
249 DDI_ENTRY();
250
252 IFxMemory* pSource;
253 WDFMEMORY_OFFSET srcOffsets;
254 WDFMEMORY_OFFSET dstOffsets;
256
260 (PVOID*) &pSource);
261
263
265
266 if (NumBytesToCopyTo == 0) {
269 "Zero bytes to copy not allowed, %!STATUS!", status);
270 return status;
271 }
272
273 RtlZeroMemory(&srcOffsets, sizeof(srcOffsets));
274 srcOffsets.BufferLength = NumBytesToCopyTo;
275 srcOffsets.BufferOffset = SourceOffset;
276
277 RtlZeroMemory(&dstOffsets, sizeof(dstOffsets));
278 dstOffsets.BufferLength = NumBytesToCopyTo;
279 dstOffsets.BufferOffset = 0;
280
281 return pSource->CopyToPtr(&srcOffsets,
282 Buffer,
283 NumBytesToCopyTo,
284 &dstOffsets);
285}
_Must_inspect_result_ NTSTATUS CopyToPtr(__in_opt PWDFMEMORY_OFFSET SourceOffsets, __out_bcount(DestinationBufferLength) PVOID DestinationBuffer, __in size_t DestinationBufferLength, __in_opt PWDFMEMORY_OFFSET DestinationOffsets)
_Must_inspect_result_ __in WDFMEMORY __in size_t SourceOffset
_Must_inspect_result_ _In_ WDFMEMORY SourceMemory
Definition: wdfmemory.h:318

◆ __drv_when() [4/4]

_Must_inspect_result_ __drv_when ( PoolType  = = 1 || PoolType == 257,
__drv_maxIRQL(APC_LEVEL  
)

◆ __out_bcount()

_Must_inspect_result_ __in WDFMEMORY __in size_t __out_bcount ( NumBytesToCopyTo  )

◆ FxObjectHandleGetPtr()

FxObjectHandleGetPtr ( GetFxDriverGlobals(DriverGlobals ,
Memory  ,
IFX_TYPE_MEMORY  ,
(PVOID *)&  pMemory 
)

Referenced by __drv_when().

◆ FxPointerNotNull()

FxPointerNotNull ( pFxDriverGlobals  ,
Memory   
)

◆ FxVerifierCheckNxPoolType()

FxVerifierCheckNxPoolType ( pFxDriverGlobals  ,
PoolType  ,
PoolTag   
)

◆ GetBuffer()

◆ if() [1/7]

if ( NT_SUCCESSstatus)

Definition at line 128 of file fxmemorybufferapi.cpp.

128 {
129 return status;
130 }

◆ if() [2/7]

if ( BufferSize = NULL)

Definition at line 201 of file fxmemorybufferapi.cpp.

201 {
203 }
virtual size_t GetBufferSize(VOID)=0
IFxMemory * pMemory
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

◆ if() [3/7]

if ( BufferSize  = = 0)

Definition at line 118 of file fxmemorybufferapi.cpp.

118 {
121 "BufferSize == 0 not allowed, %!STATUS!", status);
122 return status;
123 }

◆ if() [4/7]

Definition at line 111 of file fxmemorybufferapi.cpp.

111 {
113 if (!NT_SUCCESS(status)) {
114 return status;
115 }
116 }
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158

◆ if() [5/7]

Definition at line 98 of file fxmemorybufferapi.cpp.

99 {
101
103 Attributes->ParentObject,
105 (PVOID*)&pParent,
107 }
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), Device, FX_TYPE_DEVICE,(PVOID *)&pDevice, &pFxDriverGlobals)
FxObject * pParent
Definition: fxdpcapi.cpp:86
@ FX_TYPE_OBJECT
Definition: fxtypes.h:45
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes

◆ if() [6/7]

if ( NT_SUCCESS(status )

Definition at line 152 of file fxmemorybufferapi.cpp.

152 {
153 *Memory = hMemory;
154 if (Buffer != NULL) {
156 }
157 }
virtual PVOID GetBuffer(VOID)=0
#define NULL
Definition: types.h:112
WDFMEMORY hMemory
FxMemoryObject * pBuffer
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG _In_ _Out_ WDFMEMORY * Memory
Definition: wdfmemory.h:169

◆ if() [7/7]

if ( PoolTag  = = 0)

Definition at line 132 of file fxmemorybufferapi.cpp.

132 {
134 }
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG PoolTag
Definition: wdfmemory.h:164

Variable Documentation

◆ Attributes

◆ Buffer

Initial value:

Definition at line 55 of file fxmemorybufferapi.cpp.

◆ BufferSize

Initial value:

Definition at line 175 of file fxmemorybufferapi.cpp.

◆ DestinationMemory

Definition at line 296 of file fxmemorybufferapi.cpp.

◆ DestinationOffset

Definition at line 298 of file fxmemorybufferapi.cpp.

Referenced by __drv_when().

◆ else

else
Initial value:
{
VOID DeleteFromFailedCreate(VOID)
Definition: fxobject.cpp:391

Definition at line 158 of file fxmemorybufferapi.cpp.

◆ hMemory

WDFMEMORY hMemory

Definition at line 90 of file fxmemorybufferapi.cpp.

Referenced by if().

◆ Memory

__in WDFMEMORY Memory = NULL

Definition at line 53 of file fxmemorybufferapi.cpp.

◆ pBuffer

FxMemoryObject* pBuffer

Definition at line 89 of file fxmemorybufferapi.cpp.

Referenced by if().

◆ pFxDriverGlobals

pFxDriverGlobals = GetFxDriverGlobals(DriverGlobals)

Definition at line 88 of file fxmemorybufferapi.cpp.

Referenced by __drv_when(), and if().

◆ pMemory

IFxMemory* pMemory

Definition at line 194 of file fxmemorybufferapi.cpp.

Referenced by if().

◆ PoolTag

◆ SourceMemory

Definition at line 217 of file fxmemorybufferapi.cpp.

◆ SourceOffset

Definition at line 219 of file fxmemorybufferapi.cpp.

Referenced by __drv_when().

◆ status