1 /* 2 * usbscan.h 3 * 4 * USB scanner definitions 5 * 6 * This file is part of the w32api package. 7 * 8 * Contributors: 9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net> 10 * 11 * THIS SOFTWARE IS NOT COPYRIGHTED 12 * 13 * This source code is offered for use in the public domain. You may 14 * use, modify or distribute it freely. 15 * 16 * This code is distributed in the hope that it will be useful but 17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 * DISCLAIMED. This includes but is not limited to warranties of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 * 21 */ 22 23 #pragma once 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 #if (NTDDI_VERSION >= NTDDI_WIN2K) 30 31 #pragma pack(push,8) 32 33 #ifndef MAX_NUM_PIPES 34 #define MAX_NUM_PIPES 8 35 #endif 36 37 #define BULKIN_FLAG 0x80 38 39 typedef struct _DRV_VERSION { 40 _Out_ ULONG major; 41 _Out_ ULONG minor; 42 _Out_ ULONG internal; 43 } DRV_VERSION, *PDRV_VERSION; 44 45 typedef struct _IO_BLOCK { 46 _In_ ULONG uOffset; 47 _In_ ULONG uLength; 48 _Inout_updates_bytes_(uLength) PUCHAR pbyData; 49 _In_ ULONG uIndex; 50 } IO_BLOCK, *PIO_BLOCK; 51 52 typedef struct _IO_BLOCK_EX { 53 _In_ ULONG uOffset; 54 _In_ ULONG uLength; 55 _Inout_updates_bytes_(uLength) PUCHAR pbyData; 56 _In_ ULONG uIndex; 57 _In_ UCHAR bRequest; 58 _In_ UCHAR bmRequestType; 59 _In_ UCHAR fTransferDirectionIn; 60 } IO_BLOCK_EX, *PIO_BLOCK_EX; 61 62 typedef struct _CHANNEL_INFO { 63 _Out_ ULONG EventChannelSize; 64 _Out_ ULONG uReadDataAlignment; 65 _Out_ ULONG uWriteDataAlignment; 66 }CHANNEL_INFO, *PCHANNEL_INFO; 67 68 typedef enum _PIPE_TYPE { 69 EVENT_PIPE, 70 READ_DATA_PIPE, 71 WRITE_DATA_PIPE, 72 ALL_PIPE 73 } PIPE_TYPE; 74 75 typedef struct _USBSCAN_GET_DESCRIPTOR { 76 _In_ UCHAR DescriptorType; 77 _In_ UCHAR Index; 78 _In_ USHORT LanguageId; 79 } USBSCAN_GET_DESCRIPTOR, *PUSBSCAN_GET_DESCRIPTOR; 80 81 typedef struct _DEVICE_DESCRIPTOR { 82 _Out_ USHORT usVendorId; 83 _Out_ USHORT usProductId; 84 _Out_ USHORT usBcdDevice; 85 _Out_ USHORT usLanguageId; 86 } DEVICE_DESCRIPTOR, *PDEVICE_DESCRIPTOR; 87 88 typedef enum _RAW_PIPE_TYPE { 89 USBSCAN_PIPE_CONTROL, 90 USBSCAN_PIPE_ISOCHRONOUS, 91 USBSCAN_PIPE_BULK, 92 USBSCAN_PIPE_INTERRUPT 93 } RAW_PIPE_TYPE; 94 95 typedef struct _USBSCAN_PIPE_INFORMATION { 96 USHORT MaximumPacketSize; 97 UCHAR EndpointAddress; 98 UCHAR Interval; 99 RAW_PIPE_TYPE PipeType; 100 } USBSCAN_PIPE_INFORMATION, *PUSBSCAN_PIPE_INFORMATION; 101 102 typedef struct _USBSCAN_PIPE_CONFIGURATION { 103 _Out_ ULONG NumberOfPipes; 104 _Out_writes_(NumberOfPipes) USBSCAN_PIPE_INFORMATION PipeInfo[MAX_NUM_PIPES]; 105 } USBSCAN_PIPE_CONFIGURATION, *PUSBSCAN_PIPE_CONFIGURATION; 106 107 #if (NTDDI_VERSION >= NTDDI_WINXP) 108 typedef struct _USBSCAN_TIMEOUT { 109 IN ULONG TimeoutRead; 110 IN ULONG TimeoutWrite; 111 IN ULONG TimeoutEvent; 112 } USBSCAN_TIMEOUT, *PUSBSCAN_TIMEOUT; 113 #endif 114 115 #define FILE_DEVICE_USB_SCAN 0x8000 116 #define IOCTL_INDEX 0x0800 117 118 #define IOCTL_GET_VERSION \ 119 CTL_CODE(FILE_DEVICE_USB_SCAN, IOCTL_INDEX + 0, METHOD_BUFFERED,FILE_ANY_ACCESS) 120 121 #define IOCTL_CANCEL_IO \ 122 CTL_CODE(FILE_DEVICE_USB_SCAN, IOCTL_INDEX + 1, METHOD_BUFFERED,FILE_ANY_ACCESS) 123 124 #define IOCTL_WAIT_ON_DEVICE_EVENT \ 125 CTL_CODE(FILE_DEVICE_USB_SCAN, IOCTL_INDEX + 2, METHOD_BUFFERED,FILE_ANY_ACCESS) 126 127 #define IOCTL_READ_REGISTERS \ 128 CTL_CODE(FILE_DEVICE_USB_SCAN, IOCTL_INDEX + 3, METHOD_BUFFERED,FILE_ANY_ACCESS) 129 130 #define IOCTL_WRITE_REGISTERS \ 131 CTL_CODE(FILE_DEVICE_USB_SCAN, IOCTL_INDEX + 4, METHOD_BUFFERED, FILE_ANY_ACCESS) 132 133 #define IOCTL_GET_CHANNEL_ALIGN_RQST \ 134 CTL_CODE(FILE_DEVICE_USB_SCAN, IOCTL_INDEX + 5, METHOD_BUFFERED,FILE_ANY_ACCESS) 135 136 #define IOCTL_GET_DEVICE_DESCRIPTOR \ 137 CTL_CODE(FILE_DEVICE_USB_SCAN, IOCTL_INDEX + 6, METHOD_BUFFERED,FILE_ANY_ACCESS) 138 139 #define IOCTL_RESET_PIPE \ 140 CTL_CODE(FILE_DEVICE_USB_SCAN, IOCTL_INDEX + 7, METHOD_BUFFERED,FILE_ANY_ACCESS) 141 142 #define IOCTL_GET_USB_DESCRIPTOR \ 143 CTL_CODE(FILE_DEVICE_USB_SCAN, IOCTL_INDEX + 8, METHOD_BUFFERED,FILE_ANY_ACCESS) 144 145 #define IOCTL_SEND_USB_REQUEST \ 146 CTL_CODE(FILE_DEVICE_USB_SCAN, IOCTL_INDEX + 9, METHOD_BUFFERED,FILE_ANY_ACCESS) 147 148 #define IOCTL_GET_PIPE_CONFIGURATION \ 149 CTL_CODE(FILE_DEVICE_USB_SCAN, IOCTL_INDEX + 10,METHOD_BUFFERED,FILE_ANY_ACCESS) 150 151 #if (NTDDI_VERSION >= NTDDI_WINXP) 152 #define IOCTL_SET_TIMEOUT \ 153 CTL_CODE(FILE_DEVICE_USB_SCAN, IOCTL_INDEX + 11,METHOD_BUFFERED,FILE_ANY_ACCESS) 154 #endif 155 156 #pragma pack(pop) 157 158 #endif // (NTDDI_VERSION >= NTDDI_WIN2K) 159 160 #ifdef __cplusplus 161 } 162 #endif 163