-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathhidport.h
220 lines (161 loc) · 5.53 KB
/
hidport.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
/*++
Copyright (c) 1996 Microsoft Corporation
Module Name:
hidmini.h
Abstract
Definitions that are common to all HID minidrivers.
Authors:
Forrest Foltz
Ervin Peretz
Environment:
Kernel mode only
Revision History:
--*/
#ifndef __HIDPORT_H__
#define __HIDPORT_H__
#include <hidclass.h>
//
// HID_MINIDRIVER_REGISTRATION is a packet of information describing the
// HID minidriver to the class driver. It must be filled in by the minidriver
// and passed to the class driver via HidRegisterMinidriver() from the
// minidriver's DriverEntry() routine.
//
typedef struct _HID_MINIDRIVER_REGISTRATION {
//
// Revision must be set to HID_REVISION by the minidriver
//
ULONG Revision;
//
// DriverObject is a pointer to the minidriver's DriverObject that it
// received as a DriverEntry() parameter.
//
PDRIVER_OBJECT DriverObject;
//
// RegistryPath is a pointer to the minidriver's RegistryPath that it
// received as a DriverEntry() parameter.
//
PUNICODE_STRING RegistryPath;
//
// DeviceExtensionSize is the size of the minidriver's per-device
// extension.
//
ULONG DeviceExtensionSize;
//
// Either all or none of the devices driven by a given minidriver are polled.
//
BOOLEAN DevicesArePolled;
UCHAR Reserved[3];
} HID_MINIDRIVER_REGISTRATION, *PHID_MINIDRIVER_REGISTRATION;
//
// HID_DEVICE_EXTENSION is the public part of the device extension of a HID
// functional device object.
//
typedef struct _HID_DEVICE_EXTENSION {
//
// PhysicalDeviceObject... normally IRPs are not passed to this.
//
PDEVICE_OBJECT PhysicalDeviceObject;
//
// NextDeviceObject... IRPs are sent here by the minidriver. Note that
// NextDeviceObject and PhysicalDeviceObject are the same unless someone
// has inserted a 'filter' device object, in which case they are not the
// same. Sending IRPs to NextDeviceObject will hit the filter device
// objects on the way down.
//
PDEVICE_OBJECT NextDeviceObject;
//
// MiniDeviceExtension is the per-device extension area for use by
// the minidriver. It's size is determined by the DeviceExtensionSize
// parameter passed in to HidAddDevice().
//
// So, given a Functional Device Object, a mininidriver finds this
// structure by:
//
// HidDeviceExtension = (PHID_DEVICE_EXTENSION)(Fdo->DeviceExtension);
//
// And of course it's per-device extension is found by:
//
// MiniDeviceExtension = HidDeviceExtension->MiniDeviceExtension;
//
PVOID MiniDeviceExtension;
} HID_DEVICE_EXTENSION, *PHID_DEVICE_EXTENSION;
typedef struct _HID_DEVICE_ATTRIBUTES {
ULONG Size;
//
// sizeof (struct _HID_DEVICE_ATTRIBUTES)
//
//
// Vendor ids of this hid device
//
USHORT VendorID;
USHORT ProductID;
USHORT VersionNumber;
USHORT Reserved[11];
} HID_DEVICE_ATTRIBUTES, * PHID_DEVICE_ATTRIBUTES;
#include <pshpack1.h>
typedef struct _HID_DESCRIPTOR
{
UCHAR bLength;
UCHAR bDescriptorType;
USHORT bcdHID;
UCHAR bCountry;
UCHAR bNumDescriptors;
/*
* This is an array of one OR MORE descriptors.
*/
struct _HID_DESCRIPTOR_DESC_LIST {
UCHAR bReportType;
USHORT wReportLength;
} DescriptorList [1];
} HID_DESCRIPTOR, * PHID_DESCRIPTOR;
#include <poppack.h>
typedef
VOID
(*HID_SEND_IDLE_CALLBACK)(
PVOID Context
);
typedef struct _HID_SUBMIT_IDLE_NOTIFICATION_CALLBACK_INFO {
HID_SEND_IDLE_CALLBACK IdleCallback;
PVOID IdleContext;
} HID_SUBMIT_IDLE_NOTIFICATION_CALLBACK_INFO, *PHID_SUBMIT_IDLE_NOTIFICATION_CALLBACK_INFO;
//
// Function prototypes for the HID services exported by the hid class driver
// follow.
//
NTSTATUS
HidRegisterMinidriver(
IN PHID_MINIDRIVER_REGISTRATION MinidriverRegistration
);
#if(NTDDI_VERSION>=NTDDI_WINXPSP1) // Available on XP XP1 and above
NTSTATUS
HidNotifyPresence(
IN PDEVICE_OBJECT DeviceObject,
IN BOOLEAN IsPresent
);
#endif
//
// Internal IOCTLs for the class/mini driver interface.
//
#define IOCTL_HID_GET_DEVICE_DESCRIPTOR HID_CTL_CODE(0)
#define IOCTL_HID_GET_REPORT_DESCRIPTOR HID_CTL_CODE(1)
#define IOCTL_HID_READ_REPORT HID_CTL_CODE(2)
#define IOCTL_HID_WRITE_REPORT HID_CTL_CODE(3)
#define IOCTL_HID_GET_STRING HID_CTL_CODE(4)
#define IOCTL_HID_ACTIVATE_DEVICE HID_CTL_CODE(7)
#define IOCTL_HID_DEACTIVATE_DEVICE HID_CTL_CODE(8)
#define IOCTL_HID_GET_DEVICE_ATTRIBUTES HID_CTL_CODE(9)
#define IOCTL_HID_SEND_IDLE_NOTIFICATION_REQUEST HID_CTL_CODE(10)
/*
* Codes for HID-specific descriptor types, from HID USB spec.
*/
#define HID_HID_DESCRIPTOR_TYPE 0x21
#define HID_REPORT_DESCRIPTOR_TYPE 0x22
#define HID_PHYSICAL_DESCRIPTOR_TYPE 0x23 // for body part associations
/*
* These are string IDs for use with IOCTL_HID_GET_STRING
* They match the string field offsets in Chapter 9 of the USB Spec.
*/
#define HID_STRING_ID_IMANUFACTURER 14
#define HID_STRING_ID_IPRODUCT 15
#define HID_STRING_ID_ISERIALNUMBER 16
#endif // __HIDPORT_H__