ReactOS 0.4.16-dev-197-g92996da
fxmemorybufferfrompool.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxMemoryBufferFromPool.cpp
8
9Abstract:
10
11 This module implements a frameworks managed FxMemoryBufferFromPool
12
13Author:
14
15
16Environment:
17
18 kernel mode only
19
20Revision History:
21
22--*/
23
24#include "coreprivshared.hpp"
25
27 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
28 __in size_t BufferSize
29 ) :
30 FxMemoryObject(FxDriverGlobals, sizeof(*this), BufferSize)
31/*++
32
33Routine Description:
34 Constructor for this object.
35
36Arguments:
37 BufferSize - The buffer size associated with this object
38
39Return Value:
40 None
41
42 --*/
43{
44 m_Pool = NULL;
45}
46
48 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
49 __in size_t BufferSize,
50 __in USHORT ObjectSize
51 ) :
52 FxMemoryObject(FxDriverGlobals, ObjectSize, BufferSize)
53/*++
54
55Routine Description:
56 Constructor for this object.
57
58Arguments:
59 BufferSize - The buffer size associated with this object
60
61 ObjectSize - size of the derived object
62
63Return Value:
64 None
65
66 --*/
67{
68 m_Pool = NULL;
69}
70
72/*++
73
74Routine Description:
75 Destructor for this object. This function does nothing, it lets
76 SelfDestruct do all the work.
77
78Arguments:
79 None
80
81Return Value:
82 None
83
84 --*/
85{
86 if (m_Pool != NULL) {
88 }
89}
90
94 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
98 __in size_t BufferSize,
100 )
101{
105 BOOLEAN isPaged;
106
107 isPaged = FxIsPagedPoolType(PoolType);
108
109 if (isPaged) {
111 Attributes);
112 }
113 else {
115 }
116
117 //
118 // FxMemoryBufferFromPool can handle paged allocation as well. We only
119 // use FxMemoryPagedBufferFromPool if we have an FxDeviceBase that we can use
120 // in the dispose path, otherwise these 2 classes are the same.
121 //
122 if (pDeviceBase != NULL) {
123 ASSERT(isPaged);
124 pBuffer = new(FxDriverGlobals, Attributes)
126 }
127 else {
128 pBuffer = new(FxDriverGlobals, Attributes)
129 FxMemoryBufferFromPool(FxDriverGlobals, BufferSize);
130 }
131
132 if (pBuffer == NULL) {
134 }
135
137
138 if (pBuffer->AllocateBuffer(PoolType, PoolTag) == FALSE) {
140 }
141
142 if (!NT_SUCCESS(status)) {
143 pBuffer->DeleteFromFailedCreate();
144 return status;
145 }
146
147 if (isPaged) {
148 //
149 // Callbacks might be a bit excessive (passive dispose is what we are
150 // really after) because this object has no callbacks, but this is being
151 // proactive in case any callbacks are added. If they are added, this
152 // will take care of them w/out additional changes to object setup.
153 //
154 pBuffer->MarkPassiveCallbacks(ObjectDoNotLock);
155 }
156
157 *Buffer = pBuffer;
158
159 return STATUS_SUCCESS;
160}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
static FxDeviceBase * _SearchForDevice(__in FxObject *Object, __out_opt IFxHasCallbacks **Callbacks)
FxMemoryBufferFromPool(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in size_t BufferSize)
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)
static __inline VOID MxFreePool(__in PVOID Ptr)
Definition: mxmemorykm.h:41
#define __in
Definition: dbghelp.h:35
#define __in_opt
Definition: dbghelp.h:38
#define __out
Definition: dbghelp.h:62
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
FxDeviceBase * pDeviceBase
@ ObjectDoNotLock
Definition: fxobject.hpp:128
BOOLEAN FxIsPagedPoolType(__in POOL_TYPE Type)
Definition: wdfpool.cpp:43
#define ASSERT(a)
Definition: mode.c:44
#define _Must_inspect_result_
Definition: ms_sal.h:558
unsigned short USHORT
Definition: pedump.c:61
PVOID pBuffer
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: ps.c:97
INT POOL_TYPE
Definition: typedefs.h:78
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_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
_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
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList