1 #ifndef _HIDCLASS_PCH_ 2 #define _HIDCLASS_PCH_ 3 4 #define _HIDPI_NO_FUNCTION_MACROS_ 5 #include <wdm.h> 6 #include <hidpddi.h> 7 #include <stdio.h> 8 #include <hidport.h> 9 10 #define HIDCLASS_TAG 'CdiH' 11 12 typedef struct 13 { 14 PDRIVER_OBJECT DriverObject; 15 ULONG DeviceExtensionSize; 16 BOOLEAN DevicesArePolled; 17 PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1]; 18 PDRIVER_ADD_DEVICE AddDevice; 19 PDRIVER_UNLOAD DriverUnload; 20 KSPIN_LOCK Lock; 21 22 } HIDCLASS_DRIVER_EXTENSION, *PHIDCLASS_DRIVER_EXTENSION; 23 24 typedef struct 25 { 26 // 27 // hid device extension 28 // 29 HID_DEVICE_EXTENSION HidDeviceExtension; 30 31 // 32 // if it is a pdo 33 // 34 BOOLEAN IsFDO; 35 36 // 37 // driver extension 38 // 39 PHIDCLASS_DRIVER_EXTENSION DriverExtension; 40 41 // 42 // device description 43 // 44 HIDP_DEVICE_DESC DeviceDescription; 45 46 // 47 // hid attributes 48 // 49 HID_DEVICE_ATTRIBUTES Attributes; 50 51 } HIDCLASS_COMMON_DEVICE_EXTENSION, *PHIDCLASS_COMMON_DEVICE_EXTENSION; 52 53 typedef struct 54 { 55 // 56 // parts shared by fdo and pdo 57 // 58 HIDCLASS_COMMON_DEVICE_EXTENSION Common; 59 60 // 61 // device capabilities 62 // 63 DEVICE_CAPABILITIES Capabilities; 64 65 // 66 // hid descriptor 67 // 68 HID_DESCRIPTOR HidDescriptor; 69 70 // 71 // report descriptor 72 // 73 PUCHAR ReportDescriptor; 74 75 // 76 // device relations 77 // 78 PDEVICE_RELATIONS DeviceRelations; 79 80 } HIDCLASS_FDO_EXTENSION, *PHIDCLASS_FDO_EXTENSION; 81 82 typedef struct 83 { 84 // 85 // parts shared by fdo and pdo 86 // 87 HIDCLASS_COMMON_DEVICE_EXTENSION Common; 88 89 // 90 // device capabilities 91 // 92 DEVICE_CAPABILITIES Capabilities; 93 94 // 95 // collection index 96 // 97 ULONG CollectionNumber; 98 99 // 100 // device interface 101 // 102 UNICODE_STRING DeviceInterface; 103 104 // 105 // FDO device object 106 // 107 PDEVICE_OBJECT FDODeviceObject; 108 109 // 110 // fdo device extension 111 // 112 PHIDCLASS_FDO_EXTENSION FDODeviceExtension; 113 114 } HIDCLASS_PDO_DEVICE_EXTENSION, *PHIDCLASS_PDO_DEVICE_EXTENSION; 115 116 typedef struct __HIDCLASS_FILEOP_CONTEXT__ 117 { 118 // 119 // device extension 120 // 121 PHIDCLASS_PDO_DEVICE_EXTENSION DeviceExtension; 122 123 // 124 // spin lock 125 // 126 KSPIN_LOCK Lock; 127 128 // 129 // read irp pending list 130 // 131 LIST_ENTRY ReadPendingIrpListHead; 132 133 // 134 // completed irp list 135 // 136 LIST_ENTRY IrpCompletedListHead; 137 138 // 139 // stop in progress indicator 140 // 141 BOOLEAN StopInProgress; 142 143 // 144 // read complete event 145 // 146 KEVENT IrpReadComplete; 147 148 } HIDCLASS_FILEOP_CONTEXT, *PHIDCLASS_FILEOP_CONTEXT; 149 150 typedef struct 151 { 152 // 153 // original request 154 // 155 PIRP OriginalIrp; 156 157 // 158 // file op 159 // 160 PHIDCLASS_FILEOP_CONTEXT FileOp; 161 162 // 163 // buffer for reading report 164 // 165 PVOID InputReportBuffer; 166 167 // 168 // buffer length 169 // 170 ULONG InputReportBufferLength; 171 172 // 173 // work item 174 // 175 PIO_WORKITEM CompletionWorkItem; 176 177 } HIDCLASS_IRP_CONTEXT, *PHIDCLASS_IRP_CONTEXT; 178 179 /* fdo.c */ 180 NTSTATUS 181 HidClassFDO_PnP( 182 IN PDEVICE_OBJECT DeviceObject, 183 IN PIRP Irp); 184 185 NTSTATUS 186 HidClassFDO_DispatchRequest( 187 IN PDEVICE_OBJECT DeviceObject, 188 IN PIRP Irp); 189 190 NTSTATUS 191 HidClassFDO_DispatchRequestSynchronous( 192 IN PDEVICE_OBJECT DeviceObject, 193 IN PIRP Irp); 194 195 /* pdo.c */ 196 NTSTATUS 197 HidClassPDO_CreatePDO( 198 IN PDEVICE_OBJECT DeviceObject, 199 OUT PDEVICE_RELATIONS *OutDeviceRelations); 200 201 NTSTATUS 202 HidClassPDO_PnP( 203 IN PDEVICE_OBJECT DeviceObject, 204 IN PIRP Irp); 205 206 PHIDP_COLLECTION_DESC 207 HidClassPDO_GetCollectionDescription( 208 PHIDP_DEVICE_DESC DeviceDescription, 209 ULONG CollectionNumber); 210 211 PHIDP_REPORT_IDS 212 HidClassPDO_GetReportDescription( 213 PHIDP_DEVICE_DESC DeviceDescription, 214 ULONG CollectionNumber); 215 216 PHIDP_REPORT_IDS 217 HidClassPDO_GetReportDescriptionByReportID( 218 PHIDP_DEVICE_DESC DeviceDescription, 219 UCHAR ReportID); 220 221 #endif /* _HIDCLASS_PCH_ */ 222