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