ReactOS 0.4.15-dev-7681-g776c3a3
vfprivkm.hpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation. All rights reserved.
4
5Module Name:
6
7 vfpriv.hpp
8
9Abstract:
10
11 common header file for verifier
12
13Author:
14
15
16
17Environment:
18
19 kernel mode only
20
21Revision History:
22
23--*/
24
25#pragma once
26extern "C" {
27#include <ntddk.h>
28}
29
30#include "fx.hpp"
31
32extern "C" {
33
34__inline
35VOID
38 )
39{
41}
42
43__inline
44VOID
47 __in KIRQL PrevIrql
48 )
49{
50 KIRQL currIrql;
51
52 currIrql = KeGetCurrentIrql();
53 if (PrevIrql != currIrql) {
54 KdPrint(("WDF VERIFIER: Irql at entry of event is not same as at exit.\n"));
57 PrevIrql,
58 currIrql
59 );
60 }
61}
62
63__inline
64VOID
66 __out BOOLEAN *CritRegion
67 )
68{
69 if (KeGetCurrentIrql() <= APC_LEVEL) {
70 *CritRegion = KeAreApcsDisabled();
71 }
72}
73
74__inline
75VOID
78 __in BOOLEAN OldCritRegion,
79 __in PVOID Pfn
80 )
81{
82 if (KeGetCurrentIrql() <= APC_LEVEL) {
83 if (OldCritRegion != KeAreApcsDisabled()) {
84 KdPrint(("WDF VERIFIER: Critical section entry and exit around event callback incorrect\n"));
87 (ULONG_PTR)Pfn,
88 0
89 );
90 }
91 }
92}
93} // extern "C"
94
96VOID
99 __in WDFREQUEST Handle,
100 __out FxRequest** ppReq,
101 __inout GUID* pActivityId
102 )
103{
104
106 Handle,
108 (PVOID *) ppReq);
109
110 if (IoGetActivityIdIrp((*ppReq)->GetFxIrp()->GetIrp(), pActivityId) == STATUS_NOT_FOUND)
111 {
112 EtwActivityIdControl(EVENT_ACTIVITY_CTRL_CREATE_ID, pActivityId);
113 IoSetActivityIdIrp((*ppReq)->GetFxIrp()->GetIrp(), pActivityId);
114 }
115}
116
120 __in WDFREQUEST Handle
121)
122{
123 FxRequest* pReq;
124 GUID activityId = { 0 };
126
130
131 if(status)
132 {
135 &activityId);
136
137 EventWriteFX_REQUEST_START(&activityId, pReq->GetFxIrp()->GetMajorFunction(),
138 pDriverDeviceAdd, pReq->GetCurrentQueue()->GetDevice()->GetHandle());
139 }
140 return status;
141}
142
146 __in WDFREQUEST Handle
147)
148{
149 FxRequest* pReq;
150 GUID activityId = { 0 };
152
156
157 if(status)
158 {
161 &activityId);
162
163 EventWriteFX_REQUEST_COMPLETE(&activityId, pReq->GetFxIrp()->GetMajorFunction(),
164 pDriverDeviceAdd, pReq->GetCurrentQueue()->GetDevice()->GetHandle());
165 }
166 return status;
167}
168
173)
174{
178
180}
181
182__inline
185 __in WDFDEVICE Handle,
186 __inout GUID* pActivityId
187)
188{
193
194 if(status) {
196 EtwActivityIdControl(EVENT_ACTIVITY_CTRL_CREATE_ID, pActivityId);
197 EventWriteFX_POWER_D0_ENTRY_START(pActivityId, pDriverDeviceAdd, Handle);
198 }
199
200 return status;
201}
202
203__inline
204VOID
206 __in WDFDEVICE Handle,
207 __in GUID* pActivityId
208)
209{
210 EventWriteFX_POWER_D0_ENTRY_STOP(pActivityId, PerformanceGetDriverDeviceAdd(Handle), Handle);
211}
212
213__inline
216 __in WDFDEVICE Handle,
217 __inout GUID* pActivityId
218)
219{
224
225 if(status) {
227 EtwActivityIdControl(EVENT_ACTIVITY_CTRL_CREATE_ID, pActivityId);
228 EventWriteFX_POWER_D0_EXIT_START(pActivityId, pDriverDeviceAdd, Handle);
229 }
230 return status;
231}
232
233__inline
234VOID
236 __in WDFDEVICE Handle,
237 __in GUID* pActivityId
238)
239{
240 EventWriteFX_POWER_D0_EXIT_STOP(pActivityId, PerformanceGetDriverDeviceAdd(Handle), Handle);
241}
242
243__inline
246 __in WDFDEVICE Handle,
247 __inout GUID* pActivityId
248)
249{
250
255
256 if(status) {
258 EtwActivityIdControl(EVENT_ACTIVITY_CTRL_CREATE_ID, pActivityId);
259 EventWriteFX_POWER_HW_PREPARE_START(pActivityId, pDriverDeviceAdd, Handle);
260 }
261 return status;
262}
263
264__inline
265VOID
267 __in WDFDEVICE Handle,
268 __in GUID* pActivityId
269)
270{
271 EventWriteFX_POWER_HW_PREPARE_STOP(pActivityId, PerformanceGetDriverDeviceAdd(Handle), Handle);
272}
273
274__inline
277 __in WDFDEVICE Handle,
278 __inout GUID* pActivityId
279)
280{
285
286 if(status) {
288 EtwActivityIdControl(EVENT_ACTIVITY_CTRL_CREATE_ID, pActivityId);
289 EventWriteFX_POWER_HW_RELEASE_START(pActivityId, pDriverDeviceAdd, Handle);
290 }
291 return status;
292}
293
294__inline
295VOID
297 __in WDFDEVICE Handle,
298 __in GUID* pActivityId
299)
300{
301 EventWriteFX_POWER_HW_RELEASE_STOP(pActivityId, PerformanceGetDriverDeviceAdd(Handle), Handle);
302}
303
304// EvtIoStop callback started.
305__inline
308 __in WDFQUEUE Queue,
309 __inout GUID* pActivityId
310)
311{
313 WDFDEVICE device;
315 PFN_WDF_DRIVER_DEVICE_ADD pDriverDeviceAdd;
316
320
321 if(status) {
323 Queue,
325 (PVOID*) &pQueue);
326 device = (WDFDEVICE) pQueue->GetDevice()->GetHandle();
327 pDriverDeviceAdd = pFxDriverGlobals->Driver->GetDriverDeviceAddMethod();
328 EtwActivityIdControl(EVENT_ACTIVITY_CTRL_CREATE_ID, pActivityId);
329 EventWriteFX_EVTIOSTOP_START(pActivityId, pDriverDeviceAdd, device);
330 }
331 return status;
332}
333
334// EvtIoStop callback returned.
335__inline
336VOID
338 __in WDFQUEUE Queue,
339 __in GUID* pActivityId
340)
341{
343 WDFDEVICE device;
345 PFN_WDF_DRIVER_DEVICE_ADD pDriverDeviceAdd;
346
350 Queue,
352 (PVOID*) &pQueue);
353 device = (WDFDEVICE) pQueue->GetDevice()->GetHandle();
354 pDriverDeviceAdd = pFxDriverGlobals->Driver->GetDriverDeviceAddMethod();
355
356 EventWriteFX_EVTIOSTOP_STOP(pActivityId, pDriverDeviceAdd, device);
357}
unsigned char BOOLEAN
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
__inline PFN_WDF_DRIVER_DEVICE_ADD GetDriverDeviceAddMethod()
Definition: fxdriver.hpp:362
__inline CfxDevice * GetDevice(VOID)
Definition: fxioqueue.hpp:773
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
static FxObject * _GetObjectFromHandle(__in WDFOBJECT Handle, __inout PWDFOBJECT_OFFSET ObjectOffset)
Definition: fxobject.hpp:613
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
_Must_inspect_result_ FxIoQueue * GetCurrentQueue(VOID)
Definition: fxrequest.hpp:728
FxIrp * GetFxIrp(VOID)
Definition: fxrequest.hpp:957
_Out_ PKIRQL Irql
Definition: csq.h:179
#define __in
Definition: dbghelp.h:35
#define __inout
Definition: dbghelp.h:50
#define __out
Definition: dbghelp.h:62
#define KdPrint(x)
Definition: env_spec_w32.h:288
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define APC_LEVEL
Definition: env_spec_w32.h:695
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define EVENT_ACTIVITY_CTRL_CREATE_ID
Definition: evntprov.h:44
PFX_DRIVER_GLOBALS pFxDriverGlobals
FxIoQueue * pQueue
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), Fdo, FX_TYPE_DEVICE,(PVOID *)&pFdo)
DriverGlobals
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
USHORT WDFOBJECT_OFFSET
Definition: fxobject.hpp:80
FxObject * pObject
@ FX_TYPE_QUEUE
Definition: fxtypes.h:48
@ FX_TYPE_REQUEST
Definition: fxtypes.h:53
#define FxVerifierBugCheck(FxDriverGlobals, Error,...)
Definition: fxverifier.h:58
__inline BOOLEAN IsFxPerformanceAnalysis(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
Definition: fxverifier.h:250
ULONG Handle
Definition: gdb_input.c:15
GLintptr offset
Definition: glext.h:5920
BOOLEAN NTAPI KeAreApcsDisabled(VOID)
Definition: apc.c:958
#define STATUS_NOT_FOUND
Definition: shellext.h:72
FxDriver * Driver
Definition: fxglobals.h:374
Definition: devices.h:37
Definition: ps.c:97
uint32_t ULONG_PTR
Definition: typedefs.h:65
__inline BOOLEAN PerfEvtDevicePrepareHardwareStart(__in WDFDEVICE Handle, __inout GUID *pActivityId)
Definition: vfprivkm.hpp:245
__inline BOOLEAN PerfEvtDeviceD0ExitStart(__in WDFDEVICE Handle, __inout GUID *pActivityId)
Definition: vfprivkm.hpp:215
__inline VOID PerfEvtDevicePrepareHardwareStop(__in WDFDEVICE Handle, __in GUID *pActivityId)
Definition: vfprivkm.hpp:266
FORCEINLINE BOOLEAN PerfIoStart(__in WDFREQUEST Handle)
Definition: vfprivkm.hpp:119
__inline BOOLEAN PerfEvtIoStopStart(__in WDFQUEUE Queue, __inout GUID *pActivityId)
Definition: vfprivkm.hpp:307
__inline VOID VerifyCriticalRegionEntry(__out BOOLEAN *CritRegion)
Definition: vfprivkm.hpp:65
__inline VOID PerfEvtDeviceD0EntryStop(__in WDFDEVICE Handle, __in GUID *pActivityId)
Definition: vfprivkm.hpp:205
__inline VOID VerifyCriticalRegionExit(__in PWDF_DRIVER_GLOBALS DriverGlobals, __in BOOLEAN OldCritRegion, __in PVOID Pfn)
Definition: vfprivkm.hpp:76
__inline VOID VerifyIrqlEntry(__out KIRQL *Irql)
Definition: vfprivkm.hpp:36
FORCEINLINE VOID PerformanceAnalysisIOProcess(__in PFX_DRIVER_GLOBALS pFxDriverGlobals, __in WDFREQUEST Handle, __out FxRequest **ppReq, __inout GUID *pActivityId)
Definition: vfprivkm.hpp:97
__inline VOID PerfEvtDeviceReleaseHardwareStop(__in WDFDEVICE Handle, __in GUID *pActivityId)
Definition: vfprivkm.hpp:296
__inline BOOLEAN PerfEvtDeviceReleaseHardwareStart(__in WDFDEVICE Handle, __inout GUID *pActivityId)
Definition: vfprivkm.hpp:276
FORCEINLINE PFN_WDF_DRIVER_DEVICE_ADD PerformanceGetDriverDeviceAdd(__in WDFOBJECT Handle)
Definition: vfprivkm.hpp:171
__inline VOID VerifyIrqlExit(__in PWDF_DRIVER_GLOBALS DriverGlobals, __in KIRQL PrevIrql)
Definition: vfprivkm.hpp:45
FORCEINLINE BOOLEAN PerfIoComplete(__in WDFREQUEST Handle)
Definition: vfprivkm.hpp:145
__inline BOOLEAN PerfEvtDeviceD0EntryStart(__in WDFDEVICE Handle, __inout GUID *pActivityId)
Definition: vfprivkm.hpp:184
__inline VOID PerfEvtDeviceD0ExitStop(__in WDFDEVICE Handle, __in GUID *pActivityId)
Definition: vfprivkm.hpp:235
__inline VOID PerfEvtIoStopStop(__in WDFQUEUE Queue, __in GUID *pActivityId)
Definition: vfprivkm.hpp:337
@ WDF_VERIFIER_CRITICAL_REGION_MISMATCH
Definition: wdfbugcodes.h:72
@ WDF_VERIFIER_IRQL_MISMATCH
Definition: wdfbugcodes.h:71
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2225
EVT_WDF_DRIVER_DEVICE_ADD * PFN_WDF_DRIVER_DEVICE_ADD
Definition: wdfdriver.h:78
#define FORCEINLINE
Definition: wdftypes.h:67