ReactOS 0.4.15-dev-7842-g558ab78
FxMemoryBuffer Class Reference

#include <fxmemorybuffer.hpp>

Inheritance diagram for FxMemoryBuffer:
Collaboration diagram for FxMemoryBuffer:

Public Member Functions

 FxMemoryBuffer (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in size_t BufferSize)
 
PVOID GetBuffer (VOID)
 
PVOID __inline operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in USHORT ExtraSize, __in ULONG Tag, __in POOL_TYPE PoolType)
 
- Public Member Functions inherited from FxMemoryObject
virtual size_t GetBufferSize (VOID)
 
virtual PMDL GetMdl (VOID)
 
virtual WDFMEMORY GetHandle (VOID)
 
virtual PFX_DRIVER_GLOBALS GetDriverGlobals (VOID)
 
virtual ULONG AddRef (__in PVOID Tag, __in LONG Line, __in_opt PSTR File)
 
virtual ULONG Release (__in PVOID Tag, __in LONG Line, __in_opt PSTR File)
 
virtual VOID Delete (VOID)
 
virtual USHORT GetFlags (VOID)
 
- Public Member Functions inherited from FxObject
PVOID GetCOMWrapper ()
 
void SetCOMWrapper (__drv_aliasesMem PVOID Wrapper)
 
 FxObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
virtual ~FxObject (VOID)
 
PVOID __inline operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType Type)
 
PVOID __inline operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in USHORT ExtraSize=0)
 
VOID operator delete (__in PVOID Memory)
 
VOID SetNoContextHeader (VOID)
 
PVOID __inline GetObjectHandle (VOID)
 
__inline FxContextHeaderGetContextHeader (VOID)
 
__inline PFX_DRIVER_GLOBALS GetDriverGlobals (VOID)
 
WDFTYPE GetType (VOID)
 
USHORT GetObjectSize (VOID)
 
LONG GetRefCnt (VOID)
 
FxTagTrackerGetTagTracker (VOID)
 
CfxDeviceGetDevice (VOID)
 
CfxDeviceBaseGetDeviceBase (VOID)
 
VOID SetDeviceBase (__in CfxDeviceBase *DeviceBase)
 
__inline VOID CallCleanup (VOID)
 
ULONG __inline AddRef (__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG Release (__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG AddRefOverride (__in WDFOBJECT_OFFSET Offset, __in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG ReleaseOverride (__in WDFOBJECT_OFFSET Offset, __in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual _Must_inspect_result_ NTSTATUS QueryInterface (__in FxQueryInterfaceParams *Params)
 
VOID MarkTraceState (VOID)
 
BOOLEAN __inline IsTraceState (VOID)
 
VOID __inline TraceDroppedEvent (__in FxObjectDroppedEvent Event)
 
VOID MarkPassiveDispose (__in FxObjectLockState State=ObjectLock)
 
VOID MarkPassiveCallbacks (__in FxObjectLockState State=ObjectLock)
 
VOID MarkForceDisposeThread (__in FxObjectLockState State=ObjectLock)
 
BOOLEAN IsPassiveCallbacks (__in BOOLEAN AcquireLock=TRUE)
 
BOOLEAN IsPassiveDispose (__in BOOLEAN AcquireLock=TRUE)
 
BOOLEAN IsForceDisposeThread (__in BOOLEAN AcquireLock=TRUE)
 
VOID MarkCommitted (VOID)
 
BOOLEAN IsCommitted (VOID)
 
VOID MarkDisposeOverride (__in FxObjectLockState State=ObjectLock)
 
VOID MarkNoDeleteDDI (__in FxObjectLockState State=ObjectLock)
 
BOOLEAN IsNoDeleteDDI (VOID)
 
_Must_inspect_result_ NTSTATUS Commit (__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
 
VOID DeleteFromFailedCreate (VOID)
 
VOID ClearEvtCallbacks (VOID)
 
BOOLEAN EarlyDispose (VOID)
 
virtual VOID DeleteObject (VOID)
 
virtual BOOLEAN Dispose (VOID)
 
_Must_inspect_result_ NTSTATUS AssignParentObject (__in FxObject *ParentObject)
 
_Must_inspect_result_ NTSTATUS AddContext (__in FxContextHeader *Header, __in PVOID *Context, __in PWDF_OBJECT_ATTRIBUTES Attributes)
 
_Must_inspect_result_ NTSTATUS RemoveParentAssignment (VOID)
 
_Must_inspect_result_ FxObjectGetParentObjectReferenced (__in PVOID Tag)
 
BOOLEAN IsDisposed (VOID)
 
- Public Member Functions inherited from IFxMemory
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 Public Member Functions

static _Must_inspect_result_ NTSTATUS _Create (__in PFX_DRIVER_GLOBALS DriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG PoolTag, __in size_t BufferSize, __in POOL_TYPE PoolType, __out FxMemoryObject **Object)
 
- Static Public Member Functions inherited from FxMemoryObject
static _Must_inspect_result_ NTSTATUS _Create (__in PFX_DRIVER_GLOBALS DriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in POOL_TYPE PoolType, __in ULONG PoolTag, __in size_t BufferSize, __out FxMemoryObject **Object)
 
- Static Public Member Functions inherited from FxObject
static FxObject_FromDisposeEntry (__in PSINGLE_LIST_ENTRY Entry)
 
static FxObject_GetObjectFromHandle (__in WDFOBJECT Handle, __inout PWDFOBJECT_OFFSET ObjectOffset)
 
static PVOID __inline _ToHandle (__in FxObject *Object)
 
static VOID __inline _ReferenceActual (__in WDFOBJECT Object, __in_opt PVOID Tag, __in LONG Line, __in PSTR File)
 
static VOID __inline _DereferenceActual (__in WDFOBJECT Object, __in_opt PVOID Tag, __in LONG Line, __in PSTR File)
 
static PVOID _GetDebugBase (__in FxObject *Object)
 
static PFX_POOL_HEADER _CleanupPointer (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *Object)
 
static _Must_inspect_result_ NTSTATUS _GetEffectiveLock (__in FxObject *Object, __in_opt IFxHasCallbacks *Callbacks, __in BOOLEAN AutomaticLocking, __in BOOLEAN PassiveCallbacks, __out FxCallbackLock **CallbackLock, __out_opt FxObject **CallbackLockObject)
 
static _Must_inspect_result_ NTSTATUS _ObjectQuery (_In_ FxObject *Object, _In_ CONST GUID *Guid, _In_ ULONG QueryBufferLength, _Out_writes_bytes_(QueryBufferLength) PVOID QueryBuffer)
 

Protected Member Functions

 FxMemoryBuffer (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in USHORT ObjectSize, __in size_t BufferSize)
 
 ~FxMemoryBuffer ()
 
- Protected Member Functions inherited from FxMemoryObject
 FxMemoryObject (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in USHORT ObjectSize, __in size_t BufferSize)
 
virtual _Must_inspect_result_ NTSTATUS QueryInterface (__inout FxQueryInterfaceParams *Params)
 
- Protected Member Functions inherited from FxObject
 FxObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType ObjectType)
 
FxObjectDebugExtensionGetDebugExtension (VOID)
 
BOOLEAN IsDebug (VOID)
 
VOID AllocateTagTracker (__in WDFTYPE Type)
 
virtual VOID SelfDestruct (VOID)
 
PVOID __inline GetObjectHandleUnchecked (VOID)
 
VOID __inline DestroyChildren (VOID)
 
VOID DeleteEarlyDisposedObject (VOID)
 

Additional Inherited Members

- Static Protected Member Functions inherited from FxObject
static PVOID _GetBase (__in FxObject *Object)
 
- Static Protected Member Functions inherited from IFxMemory
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)
 
- Protected Attributes inherited from FxMemoryObject
size_t m_BufferSize
 
- Protected Attributes inherited from FxObject
union {
   CfxDeviceBase *   m_DeviceBase
 
   CfxDevice *   m_Device
 
}; 
 

Detailed Description

Definition at line 25 of file fxmemorybuffer.hpp.

Constructor & Destructor Documentation

◆ FxMemoryBuffer() [1/2]

FxMemoryBuffer::FxMemoryBuffer ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in size_t  BufferSize 
)

Definition at line 55 of file fxmemorybuffer.cpp.

58 :
59 FxMemoryObject(FxDriverGlobals,
60 (USHORT) COMPUTE_OBJECT_SIZE(sizeof(*this), (ULONG) BufferSize),
62/*++
63
64Routine Description:
65 Constructor for FxMemoryBuffer. Initializes the entire data structure.
66
67Arguments:
68 BufferSize - Size of the buffer represented by this object
69
70 We round up the object size (via COMPUTE_OBJECT_SIZE) because the object,
71 the context and the memory it returns via GetBuffer() are all in one allocation
72 and the returned memory needs to match the alignment that raw pool follows.
73
74 Note on downcasting to USHORT
75 ==============================
76 Note that FxMemoryBuffer is used for buffer less than a page size, and
77 object-size and buffer-size are added and allocated together.
78 Downcasting to USHORT is safe because size of object plus buffer (<page size)
79 would be smaller than 64K that could fit in USHORT.
80
81 For buffer larger than 1 page size, object memory is allocated separately
82 from buffer memory and the object used is FxMemoryBufferFromPool.
83 There is no downcasting done in that case.
84
85 See comments in FxMemoryObject.hpp for info on various fx memory objects.
86
87Assumes:
88 FxMemoryBuffer::operator new has already initialized the entire allocation
89
90Return Value:
91 None
92
93 --*/
94{
96}
#define COMPUTE_OBJECT_SIZE(_rawObjectSize, _extraSize)
Definition: fxhandle.h:107
#define USHORT_MAX
Definition: intsafe.h:147
#define ASSERT(a)
Definition: mode.c:44
unsigned short USHORT
Definition: pedump.c:61
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

◆ FxMemoryBuffer() [2/2]

FxMemoryBuffer::FxMemoryBuffer ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in USHORT  ObjectSize,
__in size_t  BufferSize 
)
protected

Definition at line 98 of file fxmemorybuffer.cpp.

102 :
103 FxMemoryObject(FxDriverGlobals,
106
107/*++
108
109Routine Description:
110 Constructor for derivations FxMemoryBuffer. Initializes the entire data
111 structure.
112
113 We round up the object size (via COMPUTE_OBJECT_SIZE) because the object,
114 the context and the memory it returns via GetBuffer() are all in one allocation
115 and the returned memory needs to match the alignment that raw pool follows.
116
117 Note on downcasting to USHORT
118 ==============================
119 Note that FxMemoryBuffer is used for buffer less than a page size, and
120 object-size and buffer-size are added and allocated together.
121 Downcasting to USHORT is safe because size of object plus buffer (<page size)
122 would be smaller than 64K that could fit in USHORT.
123
124 For buffer larger than 1 page size, object memory is allocated separately
125 from buffer memory and the object used is FxMemoryBufferFromPool.
126 There is no downcasting done in that case.
127
128 See comments in FxMemoryObject.hpp for info on various fx memory objects.
129
130Arguments:
131 ObjectSize - Size of the derived object
132
133 BufferSize - Size of the buffer represented by this object
134
135Return Value:
136 None
137
138 --*/
139{
141}

◆ ~FxMemoryBuffer()

FxMemoryBuffer::~FxMemoryBuffer ( )
protected

Definition at line 143 of file fxmemorybuffer.cpp.

157{
158}

Member Function Documentation

◆ _Create()

_Must_inspect_result_ NTSTATUS FxMemoryBuffer::_Create ( __in PFX_DRIVER_GLOBALS  DriverGlobals,
__in_opt PWDF_OBJECT_ATTRIBUTES  Attributes,
__in ULONG  PoolTag,
__in size_t  BufferSize,
__in POOL_TYPE  PoolType,
__out FxMemoryObject **  Object 
)
static

Definition at line 32 of file fxmemorybuffer.cpp.

40{
42
45
46 if (pBuffer == NULL) {
48 }
49
50 *Object = pBuffer;
51
52 return STATUS_SUCCESS;
53}
#define NULL
Definition: types.h:112
DriverGlobals
PVOID pBuffer
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG PoolTag
Definition: wdfmemory.h:164

Referenced by FxMemoryObject::_Create().

◆ GetBuffer()

PVOID FxMemoryBuffer::GetBuffer ( VOID  )
virtual

Implements IFxMemory.

Definition at line 161 of file fxmemorybuffer.cpp.

176{
177 //
178 // The buffer follows the struct itself
179 //
180 return ((PUCHAR) this) + COMPUTE_RAW_OBJECT_SIZE(sizeof(*this));
181}
#define COMPUTE_RAW_OBJECT_SIZE(_rawObjectSize)
Definition: fxhandle.h:100
unsigned char * PUCHAR
Definition: typedefs.h:53

◆ operator new()

PVOID __inline FxMemoryBuffer::operator new ( __in size_t  Size,
__in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in_opt PWDF_OBJECT_ATTRIBUTES  Attributes,
__in USHORT  ExtraSize,
__in ULONG  Tag,
__in POOL_TYPE  PoolType 
)
inline

Definition at line 54 of file fxmemorybuffer.hpp.

62 {
63 //
64 // PoolType must be non paged pool but it can be NonPagedPool
65 // or NonPagedPoolNx or their variants
66 //
68
69 //
70 // Specialize operator new so that we can use the caller's tag when
71 // making the object allocation vs using the default driver-wide tag.
72 //
73 return FxObjectHandleAlloc(FxDriverGlobals,
75 Size,
76 Tag,
78 ExtraSize,
80 }
PVOID FxObjectHandleAlloc(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in POOL_TYPE PoolType, __in size_t Size, __in ULONG Tag, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in USHORT ExtraSize, __in FxObjectType ObjectType)
Definition: handleapi.cpp:163
@ FxObjectTypeExternal
Definition: fxobject.hpp:120
BOOLEAN FxIsPagedPoolType(__in POOL_TYPE Type)
Definition: wdfpool.cpp:43
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

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