ReactOS  0.4.15-dev-2961-gecb0c09
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]

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

◆ __drv_when() [2/4]

◆ __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 
258  SourceMemory,
260  (PVOID*) &pSource);
261 
262  pFxDriverGlobals = pSource->GetDriverGlobals();
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 }
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
FxPointerNotNull(pFxDriverGlobals, Memory)
virtual PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)=0
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ WDFMEMORY SourceMemory
Definition: wdfmemory.h:318
DriverGlobals
NTSTATUS status
size_t BufferOffset
Definition: wdfmemory.h:65
Definition: bufpool.h:45
#define TRACINGDEVICE
Definition: dbgtrace.h:58
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), Memory, IFX_TYPE_MEMORY,(PVOID *)&pMemory)
PFX_DRIVER_GLOBALS pFxDriverGlobals
size_t BufferLength
Definition: wdfmemory.h:72
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
_Must_inspect_result_ __in WDFMEMORY __in size_t SourceOffset
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
_Must_inspect_result_ NTSTATUS CopyToPtr(__in_opt PWDFMEMORY_OFFSET SourceOffsets, __out_bcount(DestinationBufferLength) PVOID DestinationBuffer, __in size_t DestinationBufferLength, __in_opt PWDFMEMORY_OFFSET DestinationOffsets)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
Definition: ps.c:97

◆ __drv_when() [4/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 }
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
FxPointerNotNull(pFxDriverGlobals, Memory)
virtual PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)=0
LONG NTSTATUS
Definition: precomp.h:26
DriverGlobals
NTSTATUS status
size_t BufferOffset
Definition: wdfmemory.h:65
Definition: bufpool.h:45
#define TRACINGDEVICE
Definition: dbgtrace.h:58
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), Memory, IFX_TYPE_MEMORY,(PVOID *)&pMemory)
PFX_DRIVER_GLOBALS pFxDriverGlobals
size_t BufferLength
Definition: wdfmemory.h:72
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
_Must_inspect_result_ NTSTATUS CopyFromPtr(__in_opt PWDFMEMORY_OFFSET DestinationOffsets, __in_bcount(SourceBufferLength) PVOID SourceBuffer, __in size_t SourceBufferLength, __in_opt PWDFMEMORY_OFFSET SourceOffsets)
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
_Must_inspect_result_ __in WDFMEMORY __in size_t DestinationOffset
_Must_inspect_result_ _In_ WDFMEMORY DestinationMemory
Definition: wdfmemory.h:359
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
Definition: ps.c:97

◆ __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   
)

Referenced by __drv_when().

◆ FxVerifierCheckNxPoolType()

FxVerifierCheckNxPoolType ( pFxDriverGlobals  ,
PoolType  ,
PoolTag   
)

◆ GetBuffer()

return pMemory GetBuffer ( )

◆ if() [1/7]

Definition at line 98 of file fxmemorybufferapi.cpp.

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

◆ if() [2/7]

Definition at line 111 of file fxmemorybufferapi.cpp.

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

◆ 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  }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
NTSTATUS status
#define TRACINGDEVICE
Definition: dbgtrace.h:58
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
Definition: ps.c:97

◆ if() [4/7]

if ( NT_SUCCESSstatus)

Definition at line 128 of file fxmemorybufferapi.cpp.

128  {
129  return status;
130  }
NTSTATUS status

◆ if() [5/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:159
PFX_DRIVER_GLOBALS pFxDriverGlobals

◆ if() [6/7]

if ( NT_SUCCESS(status )

Definition at line 152 of file fxmemorybufferapi.cpp.

152  {
153  *Memory = hMemory;
154  if (Buffer != NULL) {
155  *Buffer = pBuffer->GetBuffer();
156  }
157  }
FxMemoryObject * pBuffer
WDFMEMORY hMemory
Definition: bufpool.h:45
_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
#define NULL
Definition: types.h:112
virtual PVOID GetBuffer(VOID)=0

◆ if() [7/7]

if ( BufferSize = NULL)

Definition at line 201 of file fxmemorybufferapi.cpp.

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

Variable Documentation

◆ Attributes

◆ Buffer

Initial value:
{
#define DDI_ENTRY()
Definition: fxglobalskm.h:56

Definition at line 85 of file fxmemorybufferapi.cpp.

◆ BufferSize

Initial value:
{
#define DDI_ENTRY()
Definition: fxglobalskm.h:56

Definition at line 191 of file fxmemorybufferapi.cpp.

◆ DestinationMemory

Definition at line 296 of file fxmemorybufferapi.cpp.

◆ DestinationOffset

Definition at line 296 of file fxmemorybufferapi.cpp.

Referenced by __drv_when().

◆ else

else
Initial value:
{
FxMemoryObject * pBuffer
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 217 of file fxmemorybufferapi.cpp.

Referenced by __drv_when().

◆ status