ReactOS  0.4.15-dev-2704-gd5265b0
vfprivkm.hpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation. All rights reserved.
4 
5 Module Name:
6 
7  vfpriv.hpp
8 
9 Abstract:
10 
11  common header file for verifier
12 
13 Author:
14 
15 
16 
17 Environment:
18 
19  kernel mode only
20 
21 Revision History:
22 
23 --*/
24 
25 #pragma once
26 extern "C" {
27 #include <ntddk.h>
28 }
29 
30 #include "fx.hpp"
31 
32 extern "C" {
33 
34 __inline
35 VOID
38  )
39 {
41 }
42 
43 __inline
44 VOID
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
64 VOID
66  __out BOOLEAN *CritRegion
67  )
68 {
69  if (KeGetCurrentIrql() <= APC_LEVEL) {
70  *CritRegion = KeAreApcsDisabled();
71  }
72 }
73 
74 __inline
75 VOID
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 
96 VOID
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 
118 BOOLEAN
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 
144 BOOLEAN
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
183 BOOLEAN
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
204 VOID
206  __in WDFDEVICE Handle,
207  __in GUID* pActivityId
208 )
209 {
210  EventWriteFX_POWER_D0_ENTRY_STOP(pActivityId, PerformanceGetDriverDeviceAdd(Handle), Handle);
211 }
212 
213 __inline
214 BOOLEAN
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
234 VOID
236  __in WDFDEVICE Handle,
237  __in GUID* pActivityId
238 )
239 {
240  EventWriteFX_POWER_D0_EXIT_STOP(pActivityId, PerformanceGetDriverDeviceAdd(Handle), Handle);
241 }
242 
243 __inline
244 BOOLEAN
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
265 VOID
267  __in WDFDEVICE Handle,
268  __in GUID* pActivityId
269 )
270 {
271  EventWriteFX_POWER_HW_PREPARE_STOP(pActivityId, PerformanceGetDriverDeviceAdd(Handle), Handle);
272 }
273 
274 __inline
275 BOOLEAN
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
295 VOID
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
306 BOOLEAN
308  __in WDFQUEUE Queue,
309  __inout GUID* pActivityId
310 )
311 {
313  WDFDEVICE device;
314  FxIoQueue* pQueue;
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
336 VOID
338  __in WDFQUEUE Queue,
339  __in GUID* pActivityId
340 )
341 {
343  WDFDEVICE device;
344  FxIoQueue* pQueue;
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 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
FxObject * pObject
__inline BOOLEAN PerfEvtDevicePrepareHardwareStart(__in WDFDEVICE Handle, __inout GUID *pActivityId)
Definition: vfprivkm.hpp:245
FxIoQueue * pQueue
__inline VOID VerifyIrqlEntry(__out KIRQL *Irql)
Definition: vfprivkm.hpp:36
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2221
EVT_WDF_DRIVER_DEVICE_ADD * PFN_WDF_DRIVER_DEVICE_ADD
Definition: wdfdriver.h:78
_Must_inspect_result_ FxIoQueue * GetCurrentQueue(VOID)
Definition: fxrequest.hpp:728
__inline VOID PerfEvtDeviceD0ExitStop(__in WDFDEVICE Handle, __in GUID *pActivityId)
Definition: vfprivkm.hpp:235
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), Fdo, FX_TYPE_DEVICE,(PVOID *)&pFdo)
DriverGlobals
__inline VOID PerfEvtDevicePrepareHardwareStop(__in WDFDEVICE Handle, __in GUID *pActivityId)
Definition: vfprivkm.hpp:266
#define EVENT_ACTIVITY_CTRL_CREATE_ID
Definition: evntprov.h:44
_Out_ PKIRQL Irql
Definition: csq.h:179
FORCEINLINE PFN_WDF_DRIVER_DEVICE_ADD PerformanceGetDriverDeviceAdd(__in WDFOBJECT Handle)
Definition: vfprivkm.hpp:171
#define FxVerifierBugCheck(FxDriverGlobals, Error,...)
Definition: fxverifier.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
FxDevice * device
UCHAR KIRQL
Definition: env_spec_w32.h:591
__inline BOOLEAN PerfEvtDeviceReleaseHardwareStart(__in WDFDEVICE Handle, __inout GUID *pActivityId)
Definition: vfprivkm.hpp:276
Definition: devices.h:37
FxDriver * Driver
Definition: fxglobals.h:374
#define __out
Definition: dbghelp.h:62
unsigned char BOOLEAN
USHORT WDFOBJECT_OFFSET
Definition: fxobject.hpp:80
__inline BOOLEAN PerfEvtDeviceD0EntryStart(__in WDFDEVICE Handle, __inout GUID *pActivityId)
Definition: vfprivkm.hpp:184
__inline VOID PerfEvtIoStopStop(__in WDFQUEUE Queue, __in GUID *pActivityId)
Definition: vfprivkm.hpp:337
FORCEINLINE BOOLEAN PerfIoComplete(__in WDFREQUEST Handle)
Definition: vfprivkm.hpp:145
FORCEINLINE VOID PerformanceAnalysisIOProcess(__in PFX_DRIVER_GLOBALS pFxDriverGlobals, __in WDFREQUEST Handle, __out FxRequest **ppReq, __inout GUID *pActivityId)
Definition: vfprivkm.hpp:97
#define STATUS_NOT_FOUND
Definition: shellext.h:72
PFX_DRIVER_GLOBALS pFxDriverGlobals
GLintptr offset
Definition: glext.h:5920
FxIrp * GetFxIrp(VOID)
Definition: fxrequest.hpp:957
FORCEINLINE BOOLEAN PerfIoStart(__in WDFREQUEST Handle)
Definition: vfprivkm.hpp:119
__inline VOID PerfEvtDeviceReleaseHardwareStop(__in WDFDEVICE Handle, __in GUID *pActivityId)
Definition: vfprivkm.hpp:296
#define __inout
Definition: dbghelp.h:50
BOOLEAN NTAPI KeAreApcsDisabled(VOID)
Definition: apc.c:958
__inline VOID VerifyCriticalRegionEntry(__out BOOLEAN *CritRegion)
Definition: vfprivkm.hpp:65
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
#define FORCEINLINE
Definition: wdftypes.h:67
__inline BOOLEAN PerfEvtDeviceD0ExitStart(__in WDFDEVICE Handle, __inout GUID *pActivityId)
Definition: vfprivkm.hpp:215
__inline VOID VerifyCriticalRegionExit(__in PWDF_DRIVER_GLOBALS DriverGlobals, __in BOOLEAN OldCritRegion, __in PVOID Pfn)
Definition: vfprivkm.hpp:76
static FxObject * _GetObjectFromHandle(__in WDFOBJECT Handle, __inout PWDFOBJECT_OFFSET ObjectOffset)
Definition: fxobject.hpp:613
__inline CfxDevice * GetDevice(VOID)
Definition: fxioqueue.hpp:773
_In_ HANDLE Handle
Definition: extypes.h:390
__inline VOID VerifyIrqlExit(__in PWDF_DRIVER_GLOBALS DriverGlobals, __in KIRQL PrevIrql)
Definition: vfprivkm.hpp:45
__inline VOID PerfEvtDeviceD0EntryStop(__in WDFDEVICE Handle, __in GUID *pActivityId)
Definition: vfprivkm.hpp:205
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
#define __in
Definition: dbghelp.h:35
__inline PFN_WDF_DRIVER_DEVICE_ADD GetDriverDeviceAddMethod()
Definition: fxdriver.hpp:362
static SERVICE_STATUS status
Definition: service.c:31
#define KdPrint(x)
Definition: env_spec_w32.h:288
#define APC_LEVEL
Definition: env_spec_w32.h:695
__inline BOOLEAN PerfEvtIoStopStart(__in WDFQUEUE Queue, __inout GUID *pActivityId)
Definition: vfprivkm.hpp:307
__inline BOOLEAN IsFxPerformanceAnalysis(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
Definition: fxverifier.h:250
Definition: ps.c:97