1 // 2 // Copyright (C) Microsoft. All rights reserved. 3 // 4 #ifndef _FXIRPDYNAMICDISPATCHINFO_H_ 5 #define _FXIRPDYNAMICDISPATCHINFO_H_ 6 7 // 8 // Placeholder macro for a no-op 9 // 10 #ifndef DO_NOTHING 11 #define DO_NOTHING() (0) 12 #endif 13 14 struct FxIrpDynamicDispatchInfo : public FxStump { 15 FxIrpDynamicDispatchInfo() : 16 CxDeviceInfo(NULL) 17 { 18 InitializeListHead(&ListEntry); 19 RtlZeroMemory(Dispatch, sizeof(Dispatch)); 20 } 21 22 ~FxIrpDynamicDispatchInfo() 23 { 24 ASSERT(IsListEmpty(&ListEntry)); 25 } 26 27 enum DynamicDispatchType { 28 DynamicDispatchRead = 0, 29 DynamicDispatchWrite = 1, 30 DynamicDispatchIoctl = 2, 31 DynamicDispatchInternalIoctl = 3, 32 DynamicDispatchMax 33 }; 34 35 struct Info { 36 Info() : 37 EvtDeviceDynamicDispatch(NULL), 38 DriverContext(NULL) 39 { 40 } 41 42 ~Info() 43 { 44 DO_NOTHING(); 45 } 46 47 PFN_WDFDEVICE_WDM_IRP_DISPATCH EvtDeviceDynamicDispatch; 48 WDFCONTEXT DriverContext; 49 }; 50 51 __inline 52 static 53 int 54 Mj2Index( 55 UCHAR MajorFunction 56 ) 57 { 58 DynamicDispatchType type; 59 60 switch (MajorFunction) { 61 case IRP_MJ_READ: 62 type = DynamicDispatchRead; 63 break; 64 65 case IRP_MJ_WRITE: 66 type = DynamicDispatchWrite; 67 break; 68 69 case IRP_MJ_DEVICE_CONTROL: 70 type = DynamicDispatchIoctl; 71 break; 72 73 case IRP_MJ_INTERNAL_DEVICE_CONTROL: 74 type = DynamicDispatchInternalIoctl; 75 break; 76 77 default: 78 type = DynamicDispatchMax; 79 break; 80 } 81 82 return (int)type; 83 } 84 85 LIST_ENTRY ListEntry; 86 Info Dispatch[DynamicDispatchMax]; 87 88 // 89 // If not null, weak ref to class extension info struct. 90 // 91 FxCxDeviceInfo* CxDeviceInfo; 92 }; 93 94 #endif // _FXIRPDYNAMICDISPATCHINFO_H_ 95