ReactOS 0.4.15-dev-7924-g5949c20
fxpool.h
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxPool.h
8
9Abstract:
10
11 This module contains private Pool package definitions
12
13Author:
14
15
16
17
18Environment:
19
20 Both kernel and user mode
21
22Revision History:
23
24
25 Made it mode agnostic
26
27 New failure paths:
28 Initialization failures of paged/non-paged lock -
29
30 Upon failure we disable pool tracking, rest of the behavior
31 remains unchanged, and FxPoolInitialize not being bubbled up
32 doesn't become an issue.
33
34--*/
35
36#ifndef _FXPOOL_H_
37#define _FXPOOL_H_
38
39//
40// Common pool header for small allocations (less than PAGE_SIZE)
41//
43
45
47
49};
50
52
53#define FX_POOL_HEADER_SIZE FIELD_OFFSET(FX_POOL_HEADER, AllocationStart)
54
55
56//
57// This structure described an indivdually tracked pool.
58//
59// The frameworks tracks pool on behalf of the frameworks (global),
60// and per driver.
61//
62
63struct FX_POOL {
66
69
70 // Current Pool Usage Information
73
76
77 // Peak Pool Usage Information
80
83};
84
86
87//
88// This structure is allocated along with the pool item and
89// is used to track it.
90//
91// Note: We would be messing up cache aligned if its greater
92// than 16.
93//
94// Our struct is 7 DWORD's on an x86, and 11 DWORDS on 64 bit
95// machines.
96//
97// This rounds up to 8 or 12 DWORDS.
98//
99//
100struct DECLSPEC_ALIGN(MEMORY_ALLOCATION_ALIGNMENT) FX_POOL_TRACKER {
103 ULONG Tag;
104 SIZE_T Size;
106 PVOID CallersAddress;
107};
108
109typedef FX_POOL_TRACKER *PFX_POOL_TRACKER;
110
111/*++
112
113Routine Description:
114
115 Initialize the FX_POOL tracking object
116
117Arguments:
118
119 Pool - FX_POOL object for tracking allocations
120
121Returns:
122
123 status
124
125--*/
129 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
131 );
132
133/*++
134
135Routine Description:
136
137 Destory the FX_POOL tracking object
138
139Arguments:
140
141 Pool - FX_POOL object for tracking allocations
142
143--*/
144VOID
146 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
148 );
149
150
151extern "C"
155 VOID
156 );
157
158extern "C"
159VOID
162 );
163
167 );
168
169/*++
170
171Routine Description:
172
173 Allocates system pool tracked in a FX_POOL tracking object.
174
175Arguments:
176
177 Pool - FX_POOL object for tracking allocations
178
179 Type - POOL_TYPE from ntddk.h
180
181 Size - Size in bytes of the allocation
182
183 Tag - Caller specified additional tag value for debugging/tracing
184
185 PVOID - Caller's address, usefull for finding who allocated the memory
186
187Returns:
188
189 NULL - Could not allocate pool
190 !NULL - Pointer to pool of minimum Size bytes
191
192--*/
193PVOID
195 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
199 __in ULONG Tag,
200 __in PVOID CallersAddress
201 );
202
203/*++
204
205Routine Description:
206
207 Release tracked pool
208
209Arguments:
210
211 Pool - FX_POOL object allocation is tracked in
212
213 ptr - Pointer to pool to release
214
215Returns:
216
217--*/
218void
220 __in_xcount(ptr is at an offset from AllocationStart) PVOID ptr
221 );
222
223/*++
224
225Routine Description:
226
227 Dump the FX_POOL tracking object
228
229Arguments:
230
231 Pool - FX_POOL object for tracking allocations
232
233Returns:
234
235 STATUS_SUCCESS
236
237--*/
240 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
242 );
243
244/*++
245
246Routine Description:
247
248 Initialize the pool support package at startup time.
249
250 This must be called before the first allocation.
251
252Arguments:
253
254Returns:
255
256 STATUS_SUCCESS
257
258--*/
262 __in PFX_DRIVER_GLOBALS FxDriverGlobals
263 );
264/*++
265
266Routine Description:
267
268 Destroy the pool support package at unload time
269
270 This must be after the last free
271
272Arguments:
273
274Returns:
275
276 status
277
278--*/
279VOID
281 __in PFX_DRIVER_GLOBALS FxDriverGlobals
282 );
283
284
285
286#endif // _FXPOOL_H_
unsigned char BOOLEAN
Type
Definition: Type.h:7
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:50
#define __in
Definition: dbghelp.h:35
DriverGlobals
FX_POOL_TRACKER * PFX_POOL_TRACKER
Definition: fxpool.h:109
VOID FxFreeDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: globals.cpp:1181
NTSTATUS FxPoolDump(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PFX_POOL Pool)
Definition: wdfpool.cpp:459
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
Definition: wdfpool.cpp:361
BOOLEAN FxIsPagedPoolType(__in POOL_TYPE Type)
Definition: wdfpool.cpp:43
_Must_inspect_result_ NTSTATUS FxPoolPackageInitialize(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
Definition: wdfpool.cpp:667
_Must_inspect_result_ PWDF_DRIVER_GLOBALS FxAllocateDriverGlobals(VOID)
Definition: globals.cpp:1052
PVOID FxPoolAllocator(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PFX_POOL Pool, __in POOL_TYPE Type, __in SIZE_T Size, __in ULONG Tag, __in PVOID CallersAddress)
Definition: wdfpool.cpp:76
FX_POOL * PFX_POOL
Definition: fxpool.h:85
VOID FxPoolDestroy(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PFX_POOL Pool)
Definition: wdfpool.cpp:627
_Must_inspect_result_ NTSTATUS FxPoolInitialize(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PFX_POOL Pool)
Definition: wdfpool.cpp:554
VOID FxPoolPackageDestroy(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
Definition: wdfpool.cpp:689
FX_POOL_HEADER * PFX_POOL_HEADER
Definition: fxpool.h:51
GLintptr offset
Definition: glext.h:5920
static PVOID ptr
Definition: dispmode.c:27
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define MEMORY_ALLOCATION_ALIGNMENT
Definition: ntbasedef.h:90
#define __in_xcount(size)
Definition: specstrings.h:109
CardRegion * from
Definition: spigame.cpp:19
PFX_DRIVER_GLOBALS FxDriverGlobals
Definition: fxpool.h:46
DECLSPEC_ALIGN(MEMORY_ALLOCATION_ALIGNMENT) ULONG AllocationStart[1]
PVOID Base
Definition: fxpool.h:44
Definition: fxpool.h:63
ULONG PeakNonPagedAllocations
Definition: fxpool.h:81
LIST_ENTRY PagedHead
Definition: fxpool.h:68
ULONG PeakPagedAllocations
Definition: fxpool.h:82
SIZE_T PeakNonPagedBytes
Definition: fxpool.h:78
MxPagedLockNoDynam PagedLock
Definition: fxpool.h:67
LIST_ENTRY NonPagedHead
Definition: fxpool.h:65
MxLockNoDynam NonPagedLock
Definition: fxpool.h:64
ULONG PagedAllocations
Definition: fxpool.h:75
SIZE_T NonPagedBytes
Definition: fxpool.h:71
SIZE_T PeakPagedBytes
Definition: fxpool.h:79
ULONG NonPagedAllocations
Definition: fxpool.h:74
SIZE_T PagedBytes
Definition: fxpool.h:72
Definition: typedefs.h:120
INT POOL_TYPE
Definition: typedefs.h:78
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG
Definition: typedefs.h:59
static int Link(const char **args)
Definition: vfdcmd.c:2414
_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
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533