-#pragma once
+#ifndef _HIDCLASS_PCH_
+#define _HIDCLASS_PCH_
#define _HIDPI_NO_FUNCTION_MACROS_
-#include <ntddk.h>
-#include <initguid.h>
-#include <hidport.h>
+#include <wdm.h>
#include <hidpddi.h>
#include <stdio.h>
-#include <wdmguid.h>
-#include <debug.h>
-
+#include <hidport.h>
+#define HIDCLASS_TAG 'CdiH'
typedef struct
{
PDRIVER_UNLOAD DriverUnload;
KSPIN_LOCK Lock;
-}HIDCLASS_DRIVER_EXTENSION, *PHIDCLASS_DRIVER_EXTENSION;
+} HIDCLASS_DRIVER_EXTENSION, *PHIDCLASS_DRIVER_EXTENSION;
typedef struct
{
//
PHIDCLASS_DRIVER_EXTENSION DriverExtension;
-}HIDCLASS_COMMON_DEVICE_EXTENSION, *PHIDCLASS_COMMON_DEVICE_EXTENSION;
+ //
+ // device description
+ //
+ HIDP_DEVICE_DESC DeviceDescription;
+
+ //
+ // hid attributes
+ //
+ HID_DEVICE_ATTRIBUTES Attributes;
+
+} HIDCLASS_COMMON_DEVICE_EXTENSION, *PHIDCLASS_COMMON_DEVICE_EXTENSION;
typedef struct
{
//
HID_DESCRIPTOR HidDescriptor;
- //
- // hid attributes
- //
- HID_DEVICE_ATTRIBUTES Attributes;
-
//
// report descriptor
//
PUCHAR ReportDescriptor;
- //
- // device description
- //
- HIDP_DEVICE_DESC DeviceDescription;
-
//
// device relations
//
- DEVICE_RELATIONS DeviceRelations;
+ PDEVICE_RELATIONS DeviceRelations;
-}HIDCLASS_FDO_EXTENSION, *PHIDCLASS_FDO_EXTENSION;
+} HIDCLASS_FDO_EXTENSION, *PHIDCLASS_FDO_EXTENSION;
typedef struct
{
HIDCLASS_COMMON_DEVICE_EXTENSION Common;
//
- // device descriptor
+ // device capabilities
//
- HID_DEVICE_ATTRIBUTES Attributes;
+ DEVICE_CAPABILITIES Capabilities;
//
- // device capabilities
+ // collection index
//
- DEVICE_CAPABILITIES Capabilities;
+ ULONG CollectionNumber;
//
- // device description
+ // device interface
//
- HIDP_DEVICE_DESC DeviceDescription;
+ UNICODE_STRING DeviceInterface;
//
- // collection index
+ // FDO device object
//
- ULONG CollectionIndex;
+ PDEVICE_OBJECT FDODeviceObject;
//
- // device interface
+ // fdo device extension
//
- UNICODE_STRING DeviceInterface;
-}HIDCLASS_PDO_DEVICE_EXTENSION, *PHIDCLASS_PDO_DEVICE_EXTENSION;
+ PHIDCLASS_FDO_EXTENSION FDODeviceExtension;
+
+} HIDCLASS_PDO_DEVICE_EXTENSION, *PHIDCLASS_PDO_DEVICE_EXTENSION;
+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;
+
+ //
+ // stop in progress indicator
+ //
+ BOOLEAN StopInProgress;
+
+ //
+ // read complete event
+ //
+ KEVENT IrpReadComplete;
+
+} HIDCLASS_FILEOP_CONTEXT, *PHIDCLASS_FILEOP_CONTEXT;
+
+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;
+
+} HIDCLASS_IRP_CONTEXT, *PHIDCLASS_IRP_CONTEXT;
/* fdo.c */
NTSTATUS
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
+NTSTATUS
+HidClassFDO_DispatchRequest(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp);
+
NTSTATUS
HidClassFDO_DispatchRequestSynchronous(
IN PDEVICE_OBJECT DeviceObject,
/* pdo.c */
NTSTATUS
HidClassPDO_CreatePDO(
- IN PDEVICE_OBJECT DeviceObject);
+ IN PDEVICE_OBJECT DeviceObject,
+ OUT PDEVICE_RELATIONS *OutDeviceRelations);
NTSTATUS
HidClassPDO_PnP(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
+PHIDP_COLLECTION_DESC
+HidClassPDO_GetCollectionDescription(
+ PHIDP_DEVICE_DESC DeviceDescription,
+ ULONG CollectionNumber);
+
+PHIDP_REPORT_IDS
+HidClassPDO_GetReportDescription(
+ PHIDP_DEVICE_DESC DeviceDescription,
+ ULONG CollectionNumber);
-/* eof */
+#endif /* _HIDCLASS_PCH_ */