29#if (_WIN32_WINNT >= 0x0501)
35#define USBUSER_VERSION 0x0004
37#define IOCTL_USB_USER_REQUEST USB_CTL(HCD_USER_REQUEST)
39#ifndef IOCTL_USB_DIAGNOSTIC_MODE_ON
40#define IOCTL_USB_DIAGNOSTIC_MODE_ON USB_CTL(HCD_DIAGNOSTIC_MODE_ON)
42#ifndef IOCTL_USB_DIAGNOSTIC_MODE_OFF
43#define IOCTL_USB_DIAGNOSTIC_MODE_OFF USB_CTL(HCD_DIAGNOSTIC_MODE_OFF)
46#ifndef IOCTL_USB_GET_ROOT_HUB_NAME
47#define IOCTL_USB_GET_ROOT_HUB_NAME USB_CTL(HCD_GET_ROOT_HUB_NAME)
49#ifndef IOCTL_GET_HCD_DRIVERKEY_NAME
50#define IOCTL_GET_HCD_DRIVERKEY_NAME USB_CTL(HCD_GET_DRIVERKEY_NAME)
53typedef enum _USB_USER_ERROR_CODE {
56 UsbUserInvalidRequestCode,
57 UsbUserFeatureDisabled,
58 UsbUserInvalidHeaderParameter,
59 UsbUserInvalidParameter,
61 UsbUserBufferTooSmall,
62 UsbUserErrorNotMapped,
63 UsbUserDeviceNotStarted,
64 UsbUserNoDeviceConnected
67#define USBUSER_GET_CONTROLLER_INFO_0 0x00000001
68#define USBUSER_GET_CONTROLLER_DRIVER_KEY 0x00000002
69#define USBUSER_PASS_THRU 0x00000003
70#define USBUSER_GET_POWER_STATE_MAP 0x00000004
71#define USBUSER_GET_BANDWIDTH_INFORMATION 0x00000005
72#define USBUSER_GET_BUS_STATISTICS_0 0x00000006
73#define USBUSER_GET_ROOTHUB_SYMBOLIC_NAME 0x00000007
74#define USBUSER_GET_USB_DRIVER_VERSION 0x00000008
75#define USBUSER_GET_USB2_HW_VERSION 0x00000009
76#define USBUSER_USB_REFRESH_HCT_REG 0x0000000a
78#define USBUSER_OP_SEND_ONE_PACKET 0x10000001
79#define USBUSER_OP_RAW_RESET_PORT 0x20000001
80#define USBUSER_OP_OPEN_RAW_DEVICE 0x20000002
81#define USBUSER_OP_CLOSE_RAW_DEVICE 0x20000003
82#define USBUSER_OP_SEND_RAW_COMMAND 0x20000004
83#define USBUSER_SET_ROOTPORT_FEATURE 0x20000005
84#define USBUSER_CLEAR_ROOTPORT_FEATURE 0x20000006
85#define USBUSER_GET_ROOTPORT_STATUS 0x20000007
87#define USBUSER_INVALID_REQUEST 0xFFFFFFF0
88#define USBUSER_OP_MASK_DEVONLY_API 0x10000000
89#define USBUSER_OP_MASK_HCTEST_API 0x20000000
91#define USB_PACKETFLAG_LOW_SPEED 0x00000001
92#define USB_PACKETFLAG_FULL_SPEED 0x00000002
93#define USB_PACKETFLAG_HIGH_SPEED 0x00000004
94#define USB_PACKETFLAG_ASYNC_IN 0x00000008
95#define USB_PACKETFLAG_ASYNC_OUT 0x00000010
96#define USB_PACKETFLAG_ISO_IN 0x00000020
97#define USB_PACKETFLAG_ISO_OUT 0x00000040
98#define USB_PACKETFLAG_SETUP 0x00000080
99#define USB_PACKETFLAG_TOGGLE0 0x00000100
100#define USB_PACKETFLAG_TOGGLE1 0x00000200
103#define USB_HC_FEATURE_FLAG_PORT_POWER_SWITCHING 0x00000001
104#define USB_HC_FEATURE_FLAG_SEL_SUSPEND 0x00000002
105#define USB_HC_FEATURE_LEGACY_BIOS 0x00000004
107typedef struct _USBUSER_REQUEST_HEADER {
108 ULONG UsbUserRequest;
109 USB_USER_ERROR_CODE UsbUserStatusCode;
110 ULONG RequestBufferLength;
111 ULONG ActualBufferLength;
112} USBUSER_REQUEST_HEADER, *PUSBUSER_REQUEST_HEADER;
114typedef struct _PACKET_PARAMETERS {
116 UCHAR EndpointAddress;
127} PACKET_PARAMETERS, *PPACKET_PARAMETERS;
129typedef struct _USBUSER_SEND_ONE_PACKET {
130 USBUSER_REQUEST_HEADER
Header;
131 PACKET_PARAMETERS PacketParameters;
132} USBUSER_SEND_ONE_PACKET, *PUSBUSER_SEND_ONE_PACKET;
134typedef struct _RAW_RESET_PORT_PARAMETERS {
137} RAW_RESET_PORT_PARAMETERS, *PRAW_RESET_PORT_PARAMETERS;
139typedef struct _USBUSER_RAW_RESET_ROOT_PORT {
140 USBUSER_REQUEST_HEADER
Header;
142} USBUSER_RAW_RESET_ROOT_PORT, *PUSBUSER_RAW_RESET_ROOT_PORT;
144typedef struct _RAW_ROOTPORT_FEATURE {
148} RAW_ROOTPORT_FEATURE, *PRAW_ROOTPORT_FEATURE;
150typedef struct _USBUSER_ROOTPORT_FEATURE_REQUEST {
151 USBUSER_REQUEST_HEADER
Header;
153} USBUSER_ROOTPORT_FEATURE_REQUEST, *PUSBUSER_ROOTPORT_FEATURE_REQUEST;
155typedef struct _RAW_ROOTPORT_PARAMETERS {
158} RAW_ROOTPORT_PARAMETERS, *PRAW_ROOTPORT_PARAMETERS;
160typedef struct _USBUSER_ROOTPORT_PARAMETERS {
161 USBUSER_REQUEST_HEADER
Header;
163} USBUSER_ROOTPORT_PARAMETERS, *PUSBUSER_ROOTPORT_PARAMETERS;
165typedef struct _USB_CONTROLLER_INFO_0 {
169 ULONG NumberOfRootPorts;
171 ULONG HcFeatureFlags;
172} USB_CONTROLLER_INFO_0 , *PUSB_CONTROLLER_INFO_0;
174typedef struct _USBUSER_CONTROLLER_INFO_0 {
175 USBUSER_REQUEST_HEADER
Header;
176 USB_CONTROLLER_INFO_0 Info0;
177} USBUSER_CONTROLLER_INFO_0, *PUSBUSER_CONTROLLER_INFO_0;
179typedef struct _USB_UNICODE_NAME {
182} USB_UNICODE_NAME, *PUSB_UNICODE_NAME;
184typedef struct _USBUSER_CONTROLLER_UNICODE_NAME {
185 USBUSER_REQUEST_HEADER
Header;
187} USBUSER_CONTROLLER_UNICODE_NAME, *PUSBUSER_CONTROLLER_UNICODE_NAME;
189typedef struct _USB_PASS_THRU_PARAMETERS {
193} USB_PASS_THRU_PARAMETERS, *PUSB_PASS_THRU_PARAMETERS;
195typedef struct _USBUSER_PASS_THRU_REQUEST {
196 USBUSER_REQUEST_HEADER
Header;
197 USB_PASS_THRU_PARAMETERS PassThru;
198} USBUSER_PASS_THRU_REQUEST, *PUSBUSER_PASS_THRU_REQUEST;
200typedef enum _WDMUSB_POWER_STATE {
201 WdmUsbPowerNotMapped = 0,
202 WdmUsbPowerSystemUnspecified = 100,
203 WdmUsbPowerSystemWorking,
204 WdmUsbPowerSystemSleeping1,
205 WdmUsbPowerSystemSleeping2,
206 WdmUsbPowerSystemSleeping3,
207 WdmUsbPowerSystemHibernate,
208 WdmUsbPowerSystemShutdown,
209 WdmUsbPowerDeviceUnspecified = 200,
216typedef struct _USB_POWER_INFO {
217 WDMUSB_POWER_STATE SystemState;
218 WDMUSB_POWER_STATE HcDevicePowerState;
219 WDMUSB_POWER_STATE HcDeviceWake;
220 WDMUSB_POWER_STATE HcSystemWake;
221 WDMUSB_POWER_STATE RhDevicePowerState;
222 WDMUSB_POWER_STATE RhDeviceWake;
223 WDMUSB_POWER_STATE RhSystemWake;
224 WDMUSB_POWER_STATE LastSystemSleepState;
227} USB_POWER_INFO, *PUSB_POWER_INFO;
229typedef struct _USBUSER_POWER_INFO_REQUEST {
230 USBUSER_REQUEST_HEADER
Header;
231 USB_POWER_INFO PowerInformation;
232} USBUSER_POWER_INFO_REQUEST, *PUSBUSER_POWER_INFO_REQUEST;
234typedef struct _USB_OPEN_RAW_DEVICE_PARAMETERS {
237} USB_OPEN_RAW_DEVICE_PARAMETERS , *PUSB_OPEN_RAW_DEVICE_PARAMETERS;
239typedef struct _USBUSER_OPEN_RAW_DEVICE {
240 USBUSER_REQUEST_HEADER
Header;
242} USBUSER_OPEN_RAW_DEVICE, *PUSBUSER_OPEN_RAW_DEVICE;
244typedef struct _USB_CLOSE_RAW_DEVICE_PARAMETERS {
246} USB_CLOSE_RAW_DEVICE_PARAMETERS , *PUSB_CLOSE_RAW_DEVICE_PARAMETERS;
248typedef struct _USBUSER_CLOSE_RAW_DEVICE {
249 USBUSER_REQUEST_HEADER
Header;
251} USBUSER_CLOSE_RAW_DEVICE, *PUSBUSER_CLOSE_RAW_DEVICE;
253typedef struct _USB_SEND_RAW_COMMAND_PARAMETERS {
265} USB_SEND_RAW_COMMAND_PARAMETERS, *PUSB_SEND_RAW_COMMAND_PARAMETERS;
267typedef struct _USBUSER_SEND_RAW_COMMAND {
268 USBUSER_REQUEST_HEADER
Header;
270} USBUSER_SEND_RAW_COMMAND, *PUSBUSER_SEND_RAW_COMMAND;
272typedef struct _USB_BANDWIDTH_INFO {
274 ULONG TotalBusBandwidth;
275 ULONG Total32secBandwidth;
276 ULONG AllocedBulkAndControl;
278 ULONG AllocedInterrupt_1ms;
279 ULONG AllocedInterrupt_2ms;
280 ULONG AllocedInterrupt_4ms;
281 ULONG AllocedInterrupt_8ms;
282 ULONG AllocedInterrupt_16ms;
283 ULONG AllocedInterrupt_32ms;
284} USB_BANDWIDTH_INFO, *PUSB_BANDWIDTH_INFO;
286typedef struct _USBUSER_BANDWIDTH_INFO_REQUEST {
287 USBUSER_REQUEST_HEADER
Header;
288 USB_BANDWIDTH_INFO BandwidthInformation;
289} USBUSER_BANDWIDTH_INFO_REQUEST, *PUSBUSER_BANDWIDTH_INFO_REQUEST;
291typedef struct _USB_BUS_STATISTICS_0 {
294 ULONG CurrentUsbFrame;
297 ULONG InterruptBytes;
298 ULONG ControlDataBytes;
299 ULONG PciInterruptCount;
300 ULONG HardResetCount;
301 ULONG WorkerSignalCount;
302 ULONG CommonBufferBytes;
303 ULONG WorkerIdleTimeMs;
305 UCHAR RootHubDevicePowerState;
308} USB_BUS_STATISTICS_0, *PUSB_BUS_STATISTICS_0;
310typedef struct _USBUSER_BUS_STATISTICS_0_REQUEST {
311 USBUSER_REQUEST_HEADER
Header;
312 USB_BUS_STATISTICS_0 BusStatistics0;
313} USBUSER_BUS_STATISTICS_0_REQUEST, *PUSBUSER_BUS_STATISTICS_0_REQUEST;
315typedef struct _USB_DRIVER_VERSION_PARAMETERS {
316 ULONG DriverTrackingCode;
318 ULONG USBUSER_Version;
322} USB_DRIVER_VERSION_PARAMETERS , *PUSB_DRIVER_VERSION_PARAMETERS;
324typedef struct _USBUSER_GET_DRIVER_VERSION {
325 USBUSER_REQUEST_HEADER
Header;
327} USBUSER_GET_DRIVER_VERSION, *PUSBUSER_GET_DRIVER_VERSION;
329typedef struct _USB_USB2HW_VERSION_PARAMETERS {
330 UCHAR Usb2HwRevision;
331} USB_USB2HW_VERSION_PARAMETERS, *PUSB_USB2HW_VERSION_PARAMETERS;
333typedef struct _USBUSER_GET_USB2HW_VERSION {
334 USBUSER_REQUEST_HEADER
Header;
336} USBUSER_GET_USB2HW_VERSION, *PUSBUSER_GET_USB2HW_VERSION;
338typedef struct _USBUSER_REFRESH_HCT_REG {
339 USBUSER_REQUEST_HEADER
Header;
341} USBUSER_REFRESH_HCT_REG, *PUSBUSER_REFRESH_HCT_REG;
char * Pad(char *Str, char PadChar, ULONG Length)
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
IN PDCB IN POEM_STRING IN PUNICODE_STRING UnicodeName
_Outptr_ PUSB_DEVICE_HANDLE _In_ PUSB_DEVICE_HANDLE _In_ USHORT PortStatus
_In_ PUSB_DEVICE_HANDLE _Out_ PUSHORT DeviceAddress
_In_ ULONG _In_ ULONG _In_ ULONG Length
enum _USB_CONTROLLER_FLAVOR USB_CONTROLLER_FLAVOR
_In_ ULONG ParameterLength
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
_Must_inspect_result_ _In_ ULONG Flags