1/*
2 * usbscan.h
3 *
4 * This file is part of the mingw-w64 runtime package.
5 * No warranty is given; refer to the file DISCLAIMER within this package.
6 */
7
8#ifndef _USBSCAN_H_
9#define _USBSCAN_H_
10
11#include <winapifamily.h>
12
13#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
14
15#ifndef MAX_NUM_PIPES
16#define MAX_NUM_PIPES 8
17#endif
18
19#define BULKIN_FLAG 0x80
20
21#pragma pack(push, 8)
22typedef struct _DRV_VERSION {
23  unsigned major;
24  unsigned minor;
25  unsigned internal;
26} DRV_VERSION,*PDRV_VERSION;
27
28typedef struct _IO_BLOCK {
29  unsigned uOffset;
30  unsigned uLength;
31  PUCHAR pbyData;
32  unsigned uIndex;
33} IO_BLOCK,*PIO_BLOCK;
34
35typedef struct _IO_BLOCK_EX {
36  unsigned uOffset;
37  unsigned uLength;
38  PUCHAR pbyData;
39  unsigned uIndex;
40  UCHAR bRequest;
41  UCHAR bmRequestType;
42  UCHAR fTransferDirectionIn;
43} IO_BLOCK_EX,*PIO_BLOCK_EX;
44
45typedef struct _CHANNEL_INFO {
46  unsigned EventChannelSize;
47  unsigned uReadDataAlignment;
48  unsigned uWriteDataAlignment;
49} CHANNEL_INFO,*PCHANNEL_INFO;
50
51typedef enum {
52  EVENT_PIPE,
53  READ_DATA_PIPE,
54  WRITE_DATA_PIPE,
55  ALL_PIPE
56} PIPE_TYPE;
57
58typedef struct _USBSCAN_GET_DESCRIPTOR {
59  UCHAR DescriptorType;
60  UCHAR Index;
61  USHORT LanguageId;
62} USBSCAN_GET_DESCRIPTOR,*PUSBSCAN_GET_DESCRIPTOR;
63
64typedef struct _DEVICE_DESCRIPTOR {
65  USHORT usVendorId;
66  USHORT usProductId;
67  USHORT usBcdDevice;
68  USHORT usLanguageId;
69} DEVICE_DESCRIPTOR,*PDEVICE_DESCRIPTOR;
70
71typedef enum _RAW_PIPE_TYPE {
72  USBSCAN_PIPE_CONTROL,
73  USBSCAN_PIPE_ISOCHRONOUS,
74  USBSCAN_PIPE_BULK,
75  USBSCAN_PIPE_INTERRUPT
76} RAW_PIPE_TYPE;
77
78typedef struct _USBSCAN_PIPE_INFORMATION {
79  USHORT MaximumPacketSize;
80  UCHAR EndpointAddress;
81  UCHAR Interval;
82  RAW_PIPE_TYPE PipeType;
83} USBSCAN_PIPE_INFORMATION,*PUSBSCAN_PIPE_INFORMATION;
84
85typedef struct _USBSCAN_PIPE_CONFIGURATION {
86  ULONG NumberOfPipes;
87  USBSCAN_PIPE_INFORMATION PipeInfo[MAX_NUM_PIPES];
88} USBSCAN_PIPE_CONFIGURATION,*PUSBSCAN_PIPE_CONFIGURATION;
89
90typedef struct _USBSCAN_TIMEOUT {
91  ULONG TimeoutRead;
92  ULONG TimeoutWrite;
93  ULONG TimeoutEvent;
94} USBSCAN_TIMEOUT,*PUSBSCAN_TIMEOUT;
95#pragma pack(pop)
96
97#define FILE_DEVICE_USB_SCAN 0x8000
98#define IOCTL_INDEX 0x0800
99#define ALL ALL_PIPE
100#define IOCTL_ABORT_PIPE IOCTL_CANCEL_IO
101
102#define IOCTL_GET_VERSION CTL_CODE (FILE_DEVICE_USB_SCAN, IOCTL_INDEX, METHOD_BUFFERED, FILE_ANY_ACCESS)
103#define IOCTL_CANCEL_IO CTL_CODE (FILE_DEVICE_USB_SCAN, IOCTL_INDEX+1, METHOD_BUFFERED, FILE_ANY_ACCESS)
104#define IOCTL_WAIT_ON_DEVICE_EVENT CTL_CODE (FILE_DEVICE_USB_SCAN, IOCTL_INDEX+2, METHOD_BUFFERED, FILE_ANY_ACCESS)
105#define IOCTL_READ_REGISTERS CTL_CODE (FILE_DEVICE_USB_SCAN, IOCTL_INDEX+3, METHOD_BUFFERED, FILE_ANY_ACCESS)
106#define IOCTL_WRITE_REGISTERS CTL_CODE (FILE_DEVICE_USB_SCAN, IOCTL_INDEX+4, METHOD_BUFFERED, FILE_ANY_ACCESS)
107#define IOCTL_GET_CHANNEL_ALIGN_RQST CTL_CODE (FILE_DEVICE_USB_SCAN, IOCTL_INDEX+5, METHOD_BUFFERED, FILE_ANY_ACCESS)
108#define IOCTL_GET_DEVICE_DESCRIPTOR CTL_CODE (FILE_DEVICE_USB_SCAN, IOCTL_INDEX+6, METHOD_BUFFERED, FILE_ANY_ACCESS)
109#define IOCTL_RESET_PIPE CTL_CODE (FILE_DEVICE_USB_SCAN, IOCTL_INDEX+7, METHOD_BUFFERED, FILE_ANY_ACCESS)
110#define IOCTL_GET_USB_DESCRIPTOR CTL_CODE (FILE_DEVICE_USB_SCAN, IOCTL_INDEX+8, METHOD_BUFFERED, FILE_ANY_ACCESS)
111#define IOCTL_SEND_USB_REQUEST CTL_CODE (FILE_DEVICE_USB_SCAN, IOCTL_INDEX+9, METHOD_BUFFERED, FILE_ANY_ACCESS)
112#define IOCTL_GET_PIPE_CONFIGURATION CTL_CODE (FILE_DEVICE_USB_SCAN, IOCTL_INDEX+10, METHOD_BUFFERED, FILE_ANY_ACCESS)
113#define IOCTL_SET_TIMEOUT CTL_CODE (FILE_DEVICE_USB_SCAN, IOCTL_INDEX+11, METHOD_BUFFERED, FILE_ANY_ACCESS)
114
115#endif
116
117#endif
118