ReactOS 0.4.15-dev-7842-g558ab78
fxmemoryobject.hpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxMemoryObject.hpp
8
9Abstract:
10 This is the base class for a whole host of memory objects which serve
11 different purposes: The hierarchy is this
12
13 FxMemoryObject : public FxObject, public IFxMemory
14 FxMemoryBuffer
15 FxMemoryBufferFromPool
16 FxMemoryPagedBufferFromPool
17 FxMemoryBufferFromLookaside
18 FxMemoryBufferFromPoolLookaside
19 FxMemoryPagedBufferFromPoolLookaside
20 FxMemoryBufferPreallocated
21 FxRequestMemory
22
23 Here is quick overview of what each object does/brings to the table:
24
25 FxMemoryObject: provides an implementation for almost all of IFxMemory's
26 abstract functions. It also provides a static _Create function which
27 can create non lookaside based memory objects
28
29 FxMemoryBuffer: memory object which can hold the external buffer within its
30 own object allocation. This means that the sizeof(FxMemoryBuffer) +
31 external bufer size + extra computations < PAGE_SIZE
32
33 FxMemoryBufferFromPool: memory object whose external buffer is a separate
34 allocation. The external buffer can be either paged or non paged.
35
36 FxMemoryPagedBufferFromPool: same as FxMemoryBufferFromPool. In addition,
37 it has a back pointer to the owning FxDeviceBase so that the object
38 can be disposed on the correct dispose list.
39
40 FxMemoryBufferFromLookaside: same as FxMemoryBuffer. In addition, the
41 object knows how to return itself to the lookaside which created it.
42
43 FxMemoryBufferFromPoolLookaside: same as FxMemoryBufferFromPool. In
44 addtion, the object knows how to return itself to the lookaside which
45 created it.
46
47 FxMemoryPagedBufferFromPoolLookaside: same as
48 FxMemoryBufferFromPoolLookaside. In addtion, it has a back pointer to
49 the owning FxDeviceBase so that the object can be disposed on the
50 correct dispose list.
51
52 FxMemoryBufferPreallocated: a memory object which does not own the external
53 buffer's lifetime. It is a wrapper object to allow existing buffers to
54 be used as a WDFMEMORY.
55
56 FxRequestMemory: same as FxMemoryBufferPreallocated. In addtion, it knows
57 about PMDLs and is tied to the lifetime of a WDFREQUEST.
58
59Author:
60
61Environment:
62
63 kernel mode only
64
65Revision History:
66
67--*/
68
69#ifndef _FXMEMORYOBJECT_H_
70#define _FXMEMORYOBJECT_H_
71
72class FxMemoryObject : public FxObject, public IFxMemory {
73public:
74 static
77 _Create(
82 __in size_t BufferSize,
84 );
85
86 // begin IFxMemory derivations
87 virtual
88 size_t
90 VOID
91 )
92 {
93 return m_BufferSize;
94 }
95
96 virtual
97 PMDL
99 VOID
100 )
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 }
108
109 virtual
110 WDFMEMORY
112 VOID
113 )
114 {
115 return (WDFMEMORY) GetObjectHandle();
116 }
117
118 virtual
121 VOID
122 )
123 {
125 }
126
127 virtual
128 ULONG
130 __in PVOID Tag,
131 __in LONG Line,
133 )
134 {
135 return FxObject::AddRef(Tag, Line, File);
136 }
137
138 virtual
139 ULONG
141 __in PVOID Tag,
142 __in LONG Line,
144 )
145 {
146 return FxObject::Release(Tag, Line, File);
147 }
148
149 virtual
150 VOID
152 VOID
153 )
154 {
155 DeleteObject();
156 }
157
158 virtual
159 USHORT
161 VOID
162 )
163 {
164 //
165 // By default, memory is readable and writable
166 return 0;
167 }
168 // end IFxMemory derivations
169
170protected:
171
173 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
174 __in USHORT ObjectSize,
175 __in size_t BufferSize
176 );
177
178 virtual
183 )
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 }
195
197};
198
199#endif // _FXMEMORYOBJECT_H_
LONG NTSTATUS
Definition: precomp.h:26
Definition: File.h:16
virtual USHORT GetFlags(VOID)
virtual PMDL GetMdl(VOID)
virtual VOID Delete(VOID)
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)
virtual ULONG AddRef(__in PVOID Tag, __in LONG Line, __in_opt PSTR File)
virtual WDFMEMORY GetHandle(VOID)
virtual PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
virtual ULONG Release(__in PVOID Tag, __in LONG Line, __in_opt PSTR File)
virtual _Must_inspect_result_ NTSTATUS QueryInterface(__inout FxQueryInterfaceParams *Params)
virtual size_t GetBufferSize(VOID)
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
ULONG __inline AddRef(__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxobject.hpp:826
virtual ULONG Release(__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxobject.hpp:853
virtual _Must_inspect_result_ NTSTATUS QueryInterface(__in FxQueryInterfaceParams *Params)
Definition: fxobject.cpp:255
#define __in
Definition: dbghelp.h:35
#define __inout
Definition: dbghelp.h:50
#define __in_opt
Definition: dbghelp.h:38
#define __out
Definition: dbghelp.h:62
#define NULL
Definition: types.h:112
return pObject GetObjectHandle()
DriverGlobals
pKey DeleteObject()
@ IFX_TYPE_MEMORY
Definition: fxtypes.h:55
#define _Must_inspect_result_
Definition: ms_sal.h:558
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: ncftp.h:79
char * PSTR
Definition: typedefs.h:51
INT POOL_TYPE
Definition: typedefs.h:78
uint32_t ULONG
Definition: typedefs.h:59
_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_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG PoolTag
Definition: wdfmemory.h:164
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:308