ReactOS 0.4.16-dev-306-g647d351
wdfpoolkm.cpp File Reference
#include "fxobjectpch.hpp"
Include dependency graph for wdfpoolkm.cpp:

Go to the source code of this file.

Functions

 __drv_maxIRQL (DISPATCH_LEVEL) NTKERNELAPI PMDL STDCALL IoAllocateMdl(__in_opt __drv_aliasesMem PVOID VirtualAddress
 
PMDL FxMdlAllocateDebug (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *Owner, __in PVOID VirtualAddress, __in ULONG Length, __in BOOLEAN SecondaryBuffer, __in BOOLEAN ChargeQuota, __in PVOID CallersAddress)
 
VOID FxMdlFreeDebug (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PMDL Mdl)
 
VOID FxMdlDump (__in PFX_DRIVER_GLOBALS FxDriverGlobals)
 

Variables

__in ULONG Length
 
__in ULONG __in BOOLEAN SecondaryBuffer
 
__in ULONG __in BOOLEAN __in BOOLEAN ChargeQuota
 
__in ULONG __in BOOLEAN __in BOOLEAN __inout_opt PIRP Irp
 

Function Documentation

◆ __drv_maxIRQL()

__drv_maxIRQL ( DISPATCH_LEVEL  )

◆ FxMdlAllocateDebug()

PMDL FxMdlAllocateDebug ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in FxObject Owner,
__in PVOID  VirtualAddress,
__in ULONG  Length,
__in BOOLEAN  SecondaryBuffer,
__in BOOLEAN  ChargeQuota,
__in PVOID  CallersAddress 
)

Definition at line 81 of file wdfpoolkm.cpp.

90{
92 FxAllocatedMdls* pAllocated, **ppNext;
93 ULONG i;
94 PMDL pMdl;
95 KIRQL irql;
96
97 pExtension = FxDriverGlobals->DebugExtension;
98 if (pExtension == NULL) {
100 Length,
103 NULL);
104 }
105
106 pAllocated = &pExtension->AllocatedMdls;
107 ppNext = NULL;
108 pMdl = NULL;
109
111
112 while (pAllocated != NULL && pAllocated->Count == NUM_MDLS_IN_INFO) {
113 ppNext = &pAllocated->Next;
114 pAllocated = pAllocated->Next;
115 }
116
117 if (pAllocated == NULL) {
118 //
119 // No more entries, allocate a new table
120 //
122 NonPagedPool, sizeof(FxAllocatedMdls), FxDriverGlobals->Tag);
123
124 if (pAllocated != NULL) {
125 //
126 // Zero out the new buffer and link it in to the list
127 //
128 RtlZeroMemory(pAllocated, sizeof(*pAllocated));
129 *ppNext = pAllocated;
130 }
131 else {
132 //
133 // Could not allocate a new table, return error
134 //
136
137 return NULL;
138 }
139 }
140
141 for (i = 0; i < NUM_MDLS_IN_INFO; i++) {
142 if (pAllocated->Info[i].Mdl != NULL) {
143 continue;
144 }
145
147 Length,
150 NULL);
151
152 if (pMdl != NULL) {
153 pAllocated->Info[i].Mdl = pMdl;
154 pAllocated->Info[i].Owner = Owner;
155 pAllocated->Info[i].Caller = CallersAddress;
156 pAllocated->Count++;
157 }
158 break;
159 }
160
162
163 return pMdl;
164}
#define NULL
Definition: types.h:112
KIRQL irql
Definition: wave.h:1
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define NonPagedPool
Definition: env_spec_w32.h:307
#define NUM_MDLS_IN_INFO
Definition: fxglobalskm.h:47
#define IoAllocateMdl
Definition: fxmdl.h:88
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ SaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ OwnerSize PSID Owner
Definition: rtlfuncs.h:1609
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
FxMdlDebugInfo Info[NUM_MDLS_IN_INFO]
Definition: fxglobalskm.h:50
struct FxAllocatedMdls * Next
Definition: fxglobalskm.h:52
FxAllocatedMdls AllocatedMdls
Definition: fxglobals.h:124
FxObject * Owner
Definition: fxglobalskm.h:43
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress
__in ULONG __in BOOLEAN SecondaryBuffer
Definition: wdfpoolkm.cpp:48
__in ULONG __in BOOLEAN __in BOOLEAN ChargeQuota
Definition: wdfpoolkm.cpp:49

Referenced by FxMdlAllocate().

◆ FxMdlDump()

VOID FxMdlDump ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals)

Definition at line 239 of file wdfpoolkm.cpp.

242{
244 BOOLEAN leak;
245
246 if (FxDriverGlobals->DebugExtension == NULL) {
247 return;
248 }
249
250 leak = FALSE;
251
252 for (pCur = &FxDriverGlobals->DebugExtension->AllocatedMdls;
253 pCur != NULL;
254 pCur = pCur->Next) {
255 ULONG i;
256
257 for (i = 0; i < NUM_MDLS_IN_INFO; i++) {
258 if (pCur->Info[i].Mdl != NULL) {
259 leak = TRUE;
260
262 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
263 "PMDL 0x%p leaked, FxObject owner %p, Callers Address %p",
264 pCur->Info[i].Mdl, pCur->Info[i].Owner,
265 pCur->Info[i].Caller);
266 }
267 }
268 }
269
270 if (leak) {
271 FxVerifierDbgBreakPoint(FxDriverGlobals);
272 }
273}
unsigned char BOOLEAN
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
SINGLE_LIST_ENTRY * pCur
FxVerifierDbgBreakPoint(pFxDriverGlobals)
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:637

Referenced by FxPoolDestroy().

◆ FxMdlFreeDebug()

VOID FxMdlFreeDebug ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in PMDL  Mdl 
)

Definition at line 167 of file wdfpoolkm.cpp.

171{
173 FxAllocatedMdls* pAllocated, **ppNext;
174 ULONG i;
175 KIRQL irql;
176 BOOLEAN found;
177
178 pExtension = FxDriverGlobals->DebugExtension;
179 if (pExtension == NULL) {
180 IoFreeMdl(Mdl);
181 return;
182 }
183
184 found = FALSE;
185
186 pAllocated = &pExtension->AllocatedMdls;
187 ppNext = NULL;
188
190
191 while (pAllocated != NULL) {
192 for (i = 0; i < NUM_MDLS_IN_INFO; i++) {
193 if (pAllocated->Info[i].Mdl != Mdl) {
194 continue;
195 }
196
197 RtlZeroMemory(&pAllocated->Info[i],
198 sizeof(pAllocated->Info[i]));
199
200 pAllocated->Count--;
201
202 if (pAllocated->Count == 0 &&
203 pAllocated != &pExtension->AllocatedMdls) {
204 //
205 // Remove the current table from the chain
206 //
207 *ppNext = pAllocated->Next;
208
209 //
210 // And free it
211 //
212 ExFreePool(pAllocated);
213 }
214
215 IoFreeMdl(Mdl);
216 found = TRUE;
217 break;
218 }
219
220 if (found) {
221 break;
222 }
223
224 ppNext = &pAllocated->Next;
225 pAllocated = pAllocated->Next;
226 }
227
229
230 if (found == FALSE) {
231
232
233
234 FxVerifierDbgBreakPoint(FxDriverGlobals);
235 }
236}
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define IoFreeMdl
Definition: fxmdl.h:89
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl

Referenced by FxMdlFree().

Variable Documentation

◆ ChargeQuota

Definition at line 49 of file wdfpoolkm.cpp.

Referenced by FxMdlAllocateDebug().

◆ Irp

◆ Length

Definition at line 47 of file wdfpoolkm.cpp.

◆ SecondaryBuffer

__in ULONG __in BOOLEAN SecondaryBuffer

Definition at line 48 of file wdfpoolkm.cpp.

Referenced by FxMdlAllocateDebug().