ReactOS 0.4.15-dev-7953-g1f49173
fxmdl.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define IoAllocateMdl   use_FxMdlAllocate_instead
 
#define IoFreeMdl   use_FxMdlFree_instead
 

Functions

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)
 
PMDL FORCEINLINE FxMdlAllocate (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *Owner, __in PVOID VirtualAddress, __in ULONG Length, __in BOOLEAN SecondaryBuffer, __in BOOLEAN ChargeQuota)
 
VOID __inline FxMdlFree (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PMDL Mdl)
 
VOID __inline FxIrpMdlFree (__in PMDL Mdl)
 

Macro Definition Documentation

◆ IoAllocateMdl

#define IoAllocateMdl   use_FxMdlAllocate_instead

Definition at line 88 of file fxmdl.h.

◆ IoFreeMdl

#define IoFreeMdl   use_FxMdlFree_instead

Definition at line 89 of file fxmdl.h.

Function Documentation

◆ FxIrpMdlFree()

VOID __inline FxIrpMdlFree ( __in PMDL  Mdl)

Definition at line 75 of file fxmdl.h.

78{
80}
#define IoFreeMdl
Definition: fxmdl.h:89
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl

Referenced by FxRequestBase::FreeMdls().

◆ FxMdlAllocate()

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

Definition at line 31 of file fxmdl.h.

39{
40 if (FxDriverGlobals->FxVerifierOn) {
41 return FxMdlAllocateDebug(FxDriverGlobals,
42 Owner,
44 Length,
48 }
49 else {
51 Length,
54 NULL);
55 }
56}
#define NULL
Definition: types.h:112
#define IoAllocateMdl
Definition: fxmdl.h:88
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: wdfpoolkm.cpp:81
#define _ReturnAddress()
Definition: intrin_arm.h:35
_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:1597
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress
_Must_inspect_result_ _In_ BOOLEAN ChargeQuota
Definition: iofuncs.h:651
_In_ ULONG _In_ BOOLEAN SecondaryBuffer
Definition: iofuncs.h:660

Referenced by FxRequest::GetDeviceControlOutputMdl(), FxRequest::GetMdl(), FxRequestBuffer::GetOrAllocateMdlWorker(), FxRequest::ProbeAndLockForRead(), and FxRequest::ProbeAndLockForWrite().

◆ 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}
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
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
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
__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:629

Referenced by FxPoolDestroy().

◆ FxMdlFree()

VOID __inline FxMdlFree ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in PMDL  Mdl 
)

◆ 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

Referenced by FxMdlFree().