2014-02-06 11:18:34 +00:00
|
|
|
#ifndef _HIDCLASS_PCH_
|
|
|
|
#define _HIDCLASS_PCH_
|
2011-12-25 20:21:34 +00:00
|
|
|
|
|
|
|
#define _HIDPI_NO_FUNCTION_MACROS_
|
2014-01-03 10:56:03 +00:00
|
|
|
#include <wdm.h>
|
2011-12-30 14:34:07 +00:00
|
|
|
#include <hidpddi.h>
|
2011-12-31 03:33:14 +00:00
|
|
|
#include <stdio.h>
|
2014-01-03 10:56:03 +00:00
|
|
|
#include <hidport.h>
|
2011-12-25 20:21:34 +00:00
|
|
|
|
2013-05-12 15:44:58 +00:00
|
|
|
#define HIDCLASS_TAG 'CdiH'
|
|
|
|
|
2011-12-25 20:21:34 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
PDRIVER_OBJECT DriverObject;
|
|
|
|
ULONG DeviceExtensionSize;
|
|
|
|
BOOLEAN DevicesArePolled;
|
2011-12-30 14:34:07 +00:00
|
|
|
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
|
2011-12-25 20:21:34 +00:00
|
|
|
PDRIVER_ADD_DEVICE AddDevice;
|
|
|
|
PDRIVER_UNLOAD DriverUnload;
|
|
|
|
KSPIN_LOCK Lock;
|
|
|
|
|
2013-05-12 15:23:34 +00:00
|
|
|
} HIDCLASS_DRIVER_EXTENSION, *PHIDCLASS_DRIVER_EXTENSION;
|
2011-12-25 23:07:50 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2011-12-31 03:33:14 +00:00
|
|
|
//
|
|
|
|
// hid device extension
|
|
|
|
//
|
2011-12-25 23:07:50 +00:00
|
|
|
HID_DEVICE_EXTENSION HidDeviceExtension;
|
2011-12-31 03:33:14 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// if it is a pdo
|
|
|
|
//
|
2011-12-25 23:07:50 +00:00
|
|
|
BOOLEAN IsFDO;
|
2011-12-30 14:34:07 +00:00
|
|
|
|
2011-12-31 03:33:14 +00:00
|
|
|
//
|
|
|
|
// driver extension
|
|
|
|
//
|
|
|
|
PHIDCLASS_DRIVER_EXTENSION DriverExtension;
|
2011-12-30 14:34:07 +00:00
|
|
|
|
2011-12-31 19:09:26 +00:00
|
|
|
//
|
|
|
|
// device description
|
|
|
|
//
|
|
|
|
HIDP_DEVICE_DESC DeviceDescription;
|
|
|
|
|
|
|
|
//
|
|
|
|
// hid attributes
|
|
|
|
//
|
|
|
|
HID_DEVICE_ATTRIBUTES Attributes;
|
|
|
|
|
2013-05-12 15:23:34 +00:00
|
|
|
} HIDCLASS_COMMON_DEVICE_EXTENSION, *PHIDCLASS_COMMON_DEVICE_EXTENSION;
|
2011-12-30 14:34:07 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// parts shared by fdo and pdo
|
|
|
|
//
|
|
|
|
HIDCLASS_COMMON_DEVICE_EXTENSION Common;
|
|
|
|
|
|
|
|
//
|
|
|
|
// device capabilities
|
|
|
|
//
|
|
|
|
DEVICE_CAPABILITIES Capabilities;
|
|
|
|
|
|
|
|
//
|
|
|
|
// hid descriptor
|
|
|
|
//
|
|
|
|
HID_DESCRIPTOR HidDescriptor;
|
|
|
|
|
|
|
|
//
|
|
|
|
// report descriptor
|
|
|
|
//
|
|
|
|
PUCHAR ReportDescriptor;
|
|
|
|
|
2011-12-31 03:33:14 +00:00
|
|
|
//
|
|
|
|
// device relations
|
|
|
|
//
|
2012-01-02 12:00:51 +00:00
|
|
|
PDEVICE_RELATIONS DeviceRelations;
|
2011-12-31 03:33:14 +00:00
|
|
|
|
2013-05-12 15:23:34 +00:00
|
|
|
} HIDCLASS_FDO_EXTENSION, *PHIDCLASS_FDO_EXTENSION;
|
2011-12-30 14:34:07 +00:00
|
|
|
|
2011-12-31 03:33:14 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// parts shared by fdo and pdo
|
|
|
|
//
|
|
|
|
HIDCLASS_COMMON_DEVICE_EXTENSION Common;
|
|
|
|
|
|
|
|
//
|
|
|
|
// device capabilities
|
|
|
|
//
|
|
|
|
DEVICE_CAPABILITIES Capabilities;
|
|
|
|
|
|
|
|
//
|
|
|
|
// collection index
|
|
|
|
//
|
2012-01-02 12:00:51 +00:00
|
|
|
ULONG CollectionNumber;
|
2011-12-31 03:33:14 +00:00
|
|
|
|
2011-12-31 04:13:37 +00:00
|
|
|
//
|
2013-05-12 15:23:34 +00:00
|
|
|
// device interface
|
2011-12-31 04:13:37 +00:00
|
|
|
//
|
|
|
|
UNICODE_STRING DeviceInterface;
|
2012-01-01 22:48:08 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// FDO device object
|
|
|
|
//
|
|
|
|
PDEVICE_OBJECT FDODeviceObject;
|
|
|
|
|
2012-02-04 14:10:18 +00:00
|
|
|
//
|
|
|
|
// fdo device extension
|
|
|
|
//
|
|
|
|
PHIDCLASS_FDO_EXTENSION FDODeviceExtension;
|
|
|
|
|
2013-05-12 15:23:34 +00:00
|
|
|
} HIDCLASS_PDO_DEVICE_EXTENSION, *PHIDCLASS_PDO_DEVICE_EXTENSION;
|
2011-12-31 03:33:14 +00:00
|
|
|
|
2011-12-31 19:09:26 +00:00
|
|
|
typedef struct __HIDCLASS_FILEOP_CONTEXT__
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// device extension
|
|
|
|
//
|
|
|
|
PHIDCLASS_PDO_DEVICE_EXTENSION DeviceExtension;
|
|
|
|
|
|
|
|
//
|
|
|
|
// spin lock
|
|
|
|
//
|
|
|
|
KSPIN_LOCK Lock;
|
|
|
|
|
|
|
|
//
|
|
|
|
// read irp pending list
|
|
|
|
//
|
|
|
|
LIST_ENTRY ReadPendingIrpListHead;
|
|
|
|
|
|
|
|
//
|
|
|
|
// completed irp list
|
|
|
|
//
|
|
|
|
LIST_ENTRY IrpCompletedListHead;
|
|
|
|
|
2012-02-21 01:16:56 +00:00
|
|
|
//
|
|
|
|
// stop in progress indicator
|
|
|
|
//
|
|
|
|
BOOLEAN StopInProgress;
|
|
|
|
|
|
|
|
//
|
|
|
|
// read complete event
|
|
|
|
//
|
|
|
|
KEVENT IrpReadComplete;
|
|
|
|
|
2013-05-12 15:23:34 +00:00
|
|
|
} HIDCLASS_FILEOP_CONTEXT, *PHIDCLASS_FILEOP_CONTEXT;
|
2011-12-31 19:09:26 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// original request
|
|
|
|
//
|
|
|
|
PIRP OriginalIrp;
|
|
|
|
|
|
|
|
//
|
|
|
|
// file op
|
|
|
|
//
|
|
|
|
PHIDCLASS_FILEOP_CONTEXT FileOp;
|
|
|
|
|
|
|
|
//
|
|
|
|
// buffer for reading report
|
|
|
|
//
|
|
|
|
PVOID InputReportBuffer;
|
|
|
|
|
|
|
|
//
|
|
|
|
// buffer length
|
|
|
|
//
|
|
|
|
ULONG InputReportBufferLength;
|
|
|
|
|
|
|
|
//
|
|
|
|
// work item
|
|
|
|
//
|
|
|
|
PIO_WORKITEM CompletionWorkItem;
|
|
|
|
|
2013-05-12 15:23:34 +00:00
|
|
|
} HIDCLASS_IRP_CONTEXT, *PHIDCLASS_IRP_CONTEXT;
|
2011-12-30 14:34:07 +00:00
|
|
|
|
|
|
|
/* fdo.c */
|
|
|
|
NTSTATUS
|
|
|
|
HidClassFDO_PnP(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp);
|
|
|
|
|
2013-05-24 17:36:14 +00:00
|
|
|
NTSTATUS
|
|
|
|
HidClassFDO_DispatchRequest(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp);
|
|
|
|
|
2011-12-31 03:33:14 +00:00
|
|
|
NTSTATUS
|
|
|
|
HidClassFDO_DispatchRequestSynchronous(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp);
|
|
|
|
|
|
|
|
/* pdo.c */
|
|
|
|
NTSTATUS
|
|
|
|
HidClassPDO_CreatePDO(
|
2012-01-02 12:00:51 +00:00
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
OUT PDEVICE_RELATIONS *OutDeviceRelations);
|
2011-12-31 03:33:14 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
HidClassPDO_PnP(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp);
|
|
|
|
|
2012-01-02 12:00:51 +00:00
|
|
|
PHIDP_COLLECTION_DESC
|
|
|
|
HidClassPDO_GetCollectionDescription(
|
|
|
|
PHIDP_DEVICE_DESC DeviceDescription,
|
|
|
|
ULONG CollectionNumber);
|
|
|
|
|
|
|
|
PHIDP_REPORT_IDS
|
|
|
|
HidClassPDO_GetReportDescription(
|
|
|
|
PHIDP_DEVICE_DESC DeviceDescription,
|
|
|
|
ULONG CollectionNumber);
|
2011-12-31 03:33:14 +00:00
|
|
|
|
2019-04-19 20:40:32 +00:00
|
|
|
PHIDP_REPORT_IDS
|
|
|
|
HidClassPDO_GetReportDescriptionByReportID(
|
|
|
|
PHIDP_DEVICE_DESC DeviceDescription,
|
|
|
|
UCHAR ReportID);
|
|
|
|
|
2014-02-06 11:18:34 +00:00
|
|
|
#endif /* _HIDCLASS_PCH_ */
|