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 user/kernel mode 20 21 Revision History: 22 23 --*/ 24 25 #if FX_CORE_MODE==FX_CORE_KERNEL_MODE 26 #include "vfprivkm.hpp" 27 #else if ((FX_CORE_MODE)==(FX_CORE_USER_MODE)) 28 #include "vfprivum.hpp" 29 #endif 30 31 extern "C" { 32 #include "fxdynamics.h" 33 } 34 #include "vfeventhooks.hpp" 35 36 37 #define FX_ENHANCED_VERIFIER_SECTION_NAME WDF_FX_VF_SECTION_NAME 38 39 #define GET_CONTEXT(_objectHandle, _type) \ 40 (_type *)VfWdfObjectGetTypedContext(_objectHandle, WDF_GET_CONTEXT_TYPE_INFO(_type)); 41 42 #define SET_HOOK_IF_CALLBACK_PRESENT(Source, Target, Name) \ 43 if ((Source)-> ## Name != NULL) { \ 44 (Target)-> ## Name = Vf ## Name; \ 45 } 46 47 typedef struct _VF_HOOK_PROCESS_INFO { 48 // 49 // Return status of the DDI of called by hook routine. 50 // this will be returned by stub if it does not call the DDI (since 51 // hook already called. 52 // 53 ULONG DdiCallStatus; 54 55 // 56 // Whether kmdf lib needs to be called after hook functin returns 57 // 58 BOOLEAN DonotCallKmdfLib; 59 60 } VF_HOOK_PROCESS_INFO, *PVF_HOOK_PROCESS_INFO; 61 62 typedef struct _VF_COMMON_CONTEXT_HEADER { 63 64 PWDF_DRIVER_GLOBALS DriverGlobals; 65 66 } VF_COMMON_CONTEXT_HEADER, *PVF_COMMON_CONTEXT_HEADER; 67 68 typedef struct _VF_WDFDEVICECREATE_CONTEXT { 69 70 VF_COMMON_CONTEXT_HEADER CommonHeader; 71 72 WDF_PNPPOWER_EVENT_CALLBACKS PnpPowerEventCallbacksOriginal; 73 74 } VF_WDFDEVICECREATE_CONTEXT, *PVF_WDFDEVICECREATE_CONTEXT; 75 76 WDF_DECLARE_CONTEXT_TYPE(VF_WDFDEVICECREATE_CONTEXT); 77 78 typedef struct _VF_WDFIOQUEUECREATE_CONTEXT { 79 80 VF_COMMON_CONTEXT_HEADER CommonHeader; 81 82 WDF_IO_QUEUE_CONFIG IoQueueConfigOriginal; 83 84 } VF_WDFIOQUEUECREATE_CONTEXT, *PVF_WDFIOQUEUECREATE_CONTEXT; 85 86 WDF_DECLARE_CONTEXT_TYPE(VF_WDFIOQUEUECREATE_CONTEXT); 87 88 extern "C" { 89 90 _Must_inspect_result_ 91 PVOID 92 FASTCALL 93 VfWdfObjectGetTypedContext( 94 __in 95 WDFOBJECT Handle, 96 __in 97 PCWDF_OBJECT_CONTEXT_TYPE_INFO TypeInfo 98 ); 99 100 _Must_inspect_result_ 101 NTSTATUS 102 VfAllocateContext( 103 __in PWDF_DRIVER_GLOBALS DriverGlobals, 104 __in PWDF_OBJECT_ATTRIBUTES Attributes, 105 __out PVOID* ContextHeader 106 ); 107 108 _Must_inspect_result_ 109 NTSTATUS 110 VfAddContextToHandle( 111 __in PVOID ContextHeader, 112 __in PWDF_OBJECT_ATTRIBUTES Attributes, 113 __in WDFOBJECT Handle, 114 __out_opt PVOID* Context 115 ); 116 117 _Must_inspect_result_ 118 NTSTATUS 119 AddEventHooksWdfDeviceCreate( 120 __inout PVF_HOOK_PROCESS_INFO HookProcessInfo, 121 __in PWDF_DRIVER_GLOBALS DriverGlobals, 122 __in PWDFDEVICE_INIT* DeviceInit, 123 __in PWDF_OBJECT_ATTRIBUTES DeviceAttributes, 124 __out WDFDEVICE* Device 125 ); 126 127 _Must_inspect_result_ 128 NTSTATUS 129 AddEventHooksWdfIoQueueCreate( 130 __inout PVF_HOOK_PROCESS_INFO HookProcessInfo, 131 __in PWDF_DRIVER_GLOBALS DriverGlobals, 132 __in WDFDEVICE Device, 133 __in PWDF_IO_QUEUE_CONFIG Config, 134 __in PWDF_OBJECT_ATTRIBUTES QueueAttributes, 135 __out WDFQUEUE* Queue 136 ); 137 138 } // extern "C" 139