ReactOS  0.4.15-dev-2487-g7b27e7c
FxMemoryObject Class Reference

#include <fxmemoryobject.hpp>

Inheritance diagram for FxMemoryObject:
Collaboration diagram for FxMemoryObject:

Public Member Functions

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
 
_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
 
_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 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

 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)
 

Protected Attributes

size_t m_BufferSize
 
- Protected Attributes inherited from FxObject
union {
   CfxDeviceBase *   m_DeviceBase
 
   CfxDevice *   m_Device
 
}; 
 

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)
 

Detailed Description

Definition at line 72 of file fxmemoryobject.hpp.

Constructor & Destructor Documentation

◆ FxMemoryObject()

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

Definition at line 29 of file fxmemoryobject.cpp.

33  :
34  // intentionally do not pass IFX_TYPE_MEMORY to the base constructor
35  // because we need to pass the interface back when converting from
36  // handle to object and that will require a different this pointer offset
37  // which will be handled by QueryInterface
38  FxObject(FX_TYPE_OBJECT, ObjectSize, FxDriverGlobals),
40 {
41  //
42  // Since we are passing the generic object type FX_TYPE_OBJECT to FxObject,
43  // we need to figure out on our own if need to allocate a tag tracker or not.
44  //
45  if (IsDebug()) {
47  }
48 }
VOID AllocateTagTracker(__in WDFTYPE Type)
Definition: fxobject.cpp:273
FxObject(VOID)
Definition: fxobject.hpp:333
BOOLEAN IsDebug(VOID)
Definition: fxobject.hpp:409
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251

Member Function Documentation

◆ _Create()

_Must_inspect_result_ NTSTATUS FxMemoryObject::_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

Definition at line 52 of file fxmemoryobject.cpp.

60 {
61  //
62  // If the buffer is
63  // a) a PAGE or larger
64  // b) we are debugging allocations
65  // c) less then a page and pageable
66  //
67  // separate the object from its memory so that we can assure
68  //
69  // 1) the buffer pointer is PAGE aligned
70  // 2) the kernel's buffer overrun/underrun checking can be used
71  // 3) for case c), that the object is non pageable while the memory pointer
72  // it returns to the driver is pageable
73  //
74 
75  //
76  // By placing FxIsPagedPool last in the list, BufferSize < PAGE_SIZE
77  //
78  if (BufferSize >= PAGE_SIZE ||
79  (FxDriverGlobals->FxVerifierOn && FxDriverGlobals->FxPoolTrackingOn) ||
82  FxDriverGlobals,
83  Attributes,
84  PoolType,
85  PoolTag,
86  BufferSize,
87  Object);
88  }
89  else {
90 
91  //
92  // Before the changes for NxPool this code path assumed NonPagedPool
93  //
94  // To maintain compatibility with existing behavior (and add on NxPool
95  // options we pass in PoolType to FxMemoryBuffer::_Create but
96  // normalize NonPagedPool variants to NonPagedPool.
97  //
98  switch(PoolType)
99  {
104  }
105 
107  FxDriverGlobals,
108  Attributes,
109  PoolTag,
110  BufferSize,
111  PoolType,
112  Object);
113  }
114 }
BOOLEAN FxIsPagedPoolType(__in POOL_TYPE Type)
Definition: wdfpool.cpp:43
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in POOL_TYPE PoolType, __in ULONG PoolTag, __in size_t BufferSize, __out FxMemoryObject **Buffer)
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG PoolTag
Definition: wdfmemory.h:159
#define PAGE_SIZE
Definition: env_spec_w32.h:49
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810
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)
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes

Referenced by FxDevice::_AllocAndQueryProperty(), FxDevice::_AllocAndQueryPropertyEx(), and if().

◆ AddRef()

virtual ULONG FxMemoryObject::AddRef ( __in PVOID  Tag,
__in LONG  Line,
__in_opt PSTR  File 
)
inlinevirtual

Implements IFxMemory.

Definition at line 129 of file fxmemoryobject.hpp.

134  {
135  return FxObject::AddRef(Tag, Line, File);
136  }
Definition: ncftp.h:79
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
ULONG __inline AddRef(__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxobject.hpp:826
Definition: File.h:15

◆ Delete()

virtual VOID FxMemoryObject::Delete ( VOID  )
inlinevirtual

Implements IFxMemory.

Definition at line 151 of file fxmemoryobject.hpp.

154  {
155  DeleteObject();
156  }
virtual VOID DeleteObject(VOID)

◆ GetBufferSize()

virtual size_t FxMemoryObject::GetBufferSize ( VOID  )
inlinevirtual

Implements IFxMemory.

Definition at line 89 of file fxmemoryobject.hpp.

92  {
93  return m_BufferSize;
94  }

Referenced by FxMemoryBufferFromPool::AllocateBuffer(), and FxUsbPipeContinuousReader::FormatRepeater().

◆ GetDriverGlobals()

virtual PFX_DRIVER_GLOBALS FxMemoryObject::GetDriverGlobals ( VOID  )
inlinevirtual

Implements IFxMemory.

Definition at line 120 of file fxmemoryobject.hpp.

123  {
125  }
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734

Referenced by FxRequestMemory::~FxRequestMemory().

◆ GetFlags()

virtual USHORT FxMemoryObject::GetFlags ( VOID  )
inlinevirtual

Implements IFxMemory.

Reimplemented in FxRequestMemory.

Definition at line 160 of file fxmemoryobject.hpp.

163  {
164  //
165  // By default, memory is readable and writable
166  return 0;
167  }

◆ GetHandle()

virtual WDFMEMORY FxMemoryObject::GetHandle ( VOID  )
inlinevirtual

Implements IFxMemory.

Definition at line 111 of file fxmemoryobject.hpp.

114  {
115  return (WDFMEMORY) GetObjectHandle();
116  }
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603

Referenced by FxDevice::_AllocAndQueryPropertyEx().

◆ GetMdl()

virtual PMDL FxMemoryObject::GetMdl ( VOID  )
inlinevirtual

Implements IFxMemory.

Reimplemented in FxRequestMemory.

Definition at line 98 of file fxmemoryobject.hpp.

101  {
102  //
103  // This function or its derivatives do not allocate the PMDL, they just
104  // return one if there is one in the object already.
105  //
106  return NULL;
107  }
#define NULL
Definition: types.h:112

◆ QueryInterface()

virtual _Must_inspect_result_ NTSTATUS FxMemoryObject::QueryInterface ( __inout FxQueryInterfaceParams Params)
inlineprotectedvirtual

Reimplemented in FxMemoryBufferPreallocated.

Definition at line 181 of file fxmemoryobject.hpp.

184  {
185  switch (Params->Type) {
186  case IFX_TYPE_MEMORY:
187  // cast is necessary for necessary this pointer offset to be computed
188  *Params->Object = (IFxMemory*) this;
189  return STATUS_SUCCESS;
190 
191  default:
192  return FxObject::QueryInterface(Params); // __super call
193  }
194  }
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:306
virtual _Must_inspect_result_ NTSTATUS QueryInterface(__in FxQueryInterfaceParams *Params)
Definition: fxobject.cpp:255
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by FxMemoryBufferPreallocated::QueryInterface().

◆ Release()

virtual ULONG FxMemoryObject::Release ( __in PVOID  Tag,
__in LONG  Line,
__in_opt PSTR  File 
)
inlinevirtual

Implements IFxMemory.

Definition at line 140 of file fxmemoryobject.hpp.

145  {
146  return FxObject::Release(Tag, Line, File);
147  }
virtual ULONG Release(__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxobject.hpp:853
Definition: ncftp.h:79
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
Definition: File.h:15

Member Data Documentation

◆ m_BufferSize

size_t FxMemoryObject::m_BufferSize
protected

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