VirtualBox

source: vbox/trunk/include/VBox/usblib-win.h@ 71075

Last change on this file since 71075 was 70289, checked in by vboxsync, 7 years ago

USB/win: Removed no longer needed flags (IOCTL interface change, version bump, see bugref:7280).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.9 KB
Line 
1/** @file
2 * USBLib - Library for wrapping up the VBoxUSB functionality, Windows flavor.
3 * (DEV,HDrv,Main)
4 */
5
6/*
7 * Copyright (C) 2006-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef ___VBox_usblib_win_h
28#define ___VBox_usblib_win_h
29
30#include <VBox/cdefs.h>
31#include <VBox/types.h>
32#include <VBox/usb.h>
33
34#include <initguid.h>
35
36
37/** @defgroup grp_usblib_win Windows USB Specifics
38 * @ingroup grp_usblib
39 * @{
40 */
41
42// {6068EB61-98E7-4c98-9E20-1F068295909A}
43DEFINE_GUID(GUID_CLASS_VBOXUSB, 0x873fdf, 0xCAFE, 0x80EE, 0xaa, 0x5e, 0x0, 0xc0, 0x4f, 0xb1, 0x72, 0xb);
44
45#define USBFLT_SERVICE_NAME "\\\\.\\VBoxUSBFlt"
46#define USBFLT_NTDEVICE_NAME_STRING L"\\Device\\VBoxUSBFlt"
47#define USBFLT_SYMBOLIC_NAME_STRING L"\\DosDevices\\VBoxUSBFlt"
48
49#define USBMON_SERVICE_NAME_W L"VBoxUSBMon"
50#define USBMON_DEVICE_NAME "\\\\.\\VBoxUSBMon"
51#define USBMON_DEVICE_NAME_NT L"\\Device\\VBoxUSBMon"
52#define USBMON_DEVICE_NAME_DOS L"\\DosDevices\\VBoxUSBMon"
53
54/*
55 * IOCtl numbers.
56 * We're using the Win32 type of numbers here, thus the macros below.
57 */
58
59#ifndef CTL_CODE
60# if defined(RT_OS_WINDOWS)
61# define CTL_CODE(DeviceType, Function, Method, Access) \
62 ( ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
63#else /* unix: */
64# define CTL_CODE(DeviceType, Function, Method_ignored, Access_ignored) \
65 ( (3 << 30) | ((DeviceType) << 8) | (Function) | (sizeof(SUPDRVIOCTLDATA) << 16) )
66# endif
67#endif
68#ifndef METHOD_BUFFERED
69# define METHOD_BUFFERED 0
70#endif
71#ifndef FILE_WRITE_ACCESS
72# define FILE_WRITE_ACCESS 0x0002
73#endif
74#ifndef FILE_DEVICE_UNKNOWN
75# define FILE_DEVICE_UNKNOWN 0x00000022
76#endif
77
78#define USBMON_MAJOR_VERSION 5
79#define USBMON_MINOR_VERSION 0
80
81#define USBDRV_MAJOR_VERSION 5
82#define USBDRV_MINOR_VERSION 0
83
84#define SUPUSB_IOCTL_TEST CTL_CODE(FILE_DEVICE_UNKNOWN, 0x601, METHOD_BUFFERED, FILE_WRITE_ACCESS)
85#define SUPUSB_IOCTL_GET_DEVICE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x603, METHOD_BUFFERED, FILE_WRITE_ACCESS)
86#define SUPUSB_IOCTL_SEND_URB CTL_CODE(FILE_DEVICE_UNKNOWN, 0x607, METHOD_BUFFERED, FILE_WRITE_ACCESS)
87#define SUPUSB_IOCTL_USB_RESET CTL_CODE(FILE_DEVICE_UNKNOWN, 0x608, METHOD_BUFFERED, FILE_WRITE_ACCESS)
88#define SUPUSB_IOCTL_USB_SELECT_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x609, METHOD_BUFFERED, FILE_WRITE_ACCESS)
89#define SUPUSB_IOCTL_USB_SET_CONFIG CTL_CODE(FILE_DEVICE_UNKNOWN, 0x60A, METHOD_BUFFERED, FILE_WRITE_ACCESS)
90#define SUPUSB_IOCTL_USB_CLAIM_DEVICE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x60B, METHOD_BUFFERED, FILE_WRITE_ACCESS)
91#define SUPUSB_IOCTL_USB_RELEASE_DEVICE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x60C, METHOD_BUFFERED, FILE_WRITE_ACCESS)
92#define SUPUSB_IOCTL_IS_OPERATIONAL CTL_CODE(FILE_DEVICE_UNKNOWN, 0x60D, METHOD_BUFFERED, FILE_WRITE_ACCESS)
93#define SUPUSB_IOCTL_USB_CLEAR_ENDPOINT CTL_CODE(FILE_DEVICE_UNKNOWN, 0x60E, METHOD_BUFFERED, FILE_WRITE_ACCESS)
94#define SUPUSB_IOCTL_GET_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN, 0x60F, METHOD_BUFFERED, FILE_WRITE_ACCESS)
95#define SUPUSB_IOCTL_USB_ABORT_ENDPOINT CTL_CODE(FILE_DEVICE_UNKNOWN, 0x610, METHOD_BUFFERED, FILE_WRITE_ACCESS)
96
97#define SUPUSBFLT_IOCTL_GET_NUM_DEVICES CTL_CODE(FILE_DEVICE_UNKNOWN, 0x602, METHOD_BUFFERED, FILE_WRITE_ACCESS)
98#define SUPUSBFLT_IOCTL_USB_CHANGE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x604, METHOD_BUFFERED, FILE_WRITE_ACCESS)
99#define SUPUSBFLT_IOCTL_DISABLE_CAPTURE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x605, METHOD_BUFFERED, FILE_WRITE_ACCESS)
100#define SUPUSBFLT_IOCTL_ENABLE_CAPTURE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x606, METHOD_BUFFERED, FILE_WRITE_ACCESS)
101#define SUPUSBFLT_IOCTL_IGNORE_DEVICE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x60F, METHOD_BUFFERED, FILE_WRITE_ACCESS)
102#define SUPUSBFLT_IOCTL_GET_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN, 0x610, METHOD_BUFFERED, FILE_WRITE_ACCESS)
103#define SUPUSBFLT_IOCTL_ADD_FILTER CTL_CODE(FILE_DEVICE_UNKNOWN, 0x611, METHOD_BUFFERED, FILE_WRITE_ACCESS)
104#define SUPUSBFLT_IOCTL_REMOVE_FILTER CTL_CODE(FILE_DEVICE_UNKNOWN, 0x612, METHOD_BUFFERED, FILE_WRITE_ACCESS)
105#define SUPUSBFLT_IOCTL_CAPTURE_DEVICE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x613, METHOD_BUFFERED, FILE_WRITE_ACCESS)
106#define SUPUSBFLT_IOCTL_RELEASE_DEVICE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x614, METHOD_BUFFERED, FILE_WRITE_ACCESS)
107#define SUPUSBFLT_IOCTL_RUN_FILTERS CTL_CODE(FILE_DEVICE_UNKNOWN, 0x615, METHOD_BUFFERED, FILE_WRITE_ACCESS)
108#define SUPUSBFLT_IOCTL_SET_NOTIFY_EVENT CTL_CODE(FILE_DEVICE_UNKNOWN, 0x616, METHOD_BUFFERED, FILE_WRITE_ACCESS)
109#define SUPUSBFLT_IOCTL_GET_DEVICE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x617, METHOD_BUFFERED, FILE_WRITE_ACCESS)
110
111#pragma pack(4)
112
113#define MAX_FILTER_NAME 128
114#define MAX_USB_SERIAL_STRING 64
115
116/* a user-mode handle that could be used for retriving device information
117 * from the monitor driver */
118typedef void* HVBOXUSBDEVUSR;
119
120typedef struct
121{
122 HVBOXUSBDEVUSR hDevice;
123} USBSUP_GETDEV, *PUSBSUP_GETDEV;
124
125typedef struct
126{
127 USBDEVICESTATE enmState;
128} USBSUP_GETDEV_MON, *PUSBSUP_GETDEV_MON;
129
130typedef struct
131{
132 uint32_t u32Major;
133 uint32_t u32Minor;
134} USBSUP_VERSION, *PUSBSUP_VERSION;
135
136
137typedef struct USBSUP_FLTADDOUT
138{
139 uintptr_t uId; /* The ID. */
140 int rc; /* The return code. */
141} USBSUP_FLTADDOUT, *PUSBSUP_FLTADDOUT;
142
143typedef struct
144{
145 uint16_t usVendorId;
146 uint16_t usProductId;
147 uint16_t usRevision;
148} USBSUP_CAPTURE, *PUSBSUP_CAPTURE;
149
150typedef USBSUP_CAPTURE USBSUP_RELEASE;
151typedef PUSBSUP_CAPTURE PUSBSUP_RELEASE;
152
153typedef struct
154{
155 uint8_t bInterfaceNumber;
156 uint8_t fClaimed;
157} USBSUP_CLAIMDEV, *PUSBSUP_CLAIMDEV;
158
159typedef USBSUP_CLAIMDEV USBSUP_RELEASEDEV;
160typedef PUSBSUP_CLAIMDEV PUSBSUP_RELEASEDEV;
161
162typedef struct
163{
164 uint32_t cUSBDevices;
165} USBSUP_GETNUMDEV, *PUSBSUP_GETNUMDEV;
166
167typedef struct
168{
169 uint8_t fUSBChange;
170 uint32_t cUSBStateChange;
171} USBSUP_USB_CHANGE, *PUSBSUP_USB_CHANGE;
172
173typedef struct
174{
175 uint8_t bConfigurationValue;
176} USBSUP_SET_CONFIG, *PUSBSUP_SET_CONFIG;
177
178typedef struct
179{
180 uint8_t bInterfaceNumber;
181 uint8_t bAlternateSetting;
182} USBSUP_SELECT_INTERFACE, *PUSBSUP_SELECT_INTERFACE;
183
184typedef struct
185{
186 uint8_t bEndpoint;
187} USBSUP_CLEAR_ENDPOINT, *PUSBSUP_CLEAR_ENDPOINT;
188
189typedef enum
190{
191 USBSUP_TRANSFER_TYPE_CTRL = 0,
192 USBSUP_TRANSFER_TYPE_ISOC = 1,
193 USBSUP_TRANSFER_TYPE_BULK = 2,
194 USBSUP_TRANSFER_TYPE_INTR = 3,
195 USBSUP_TRANSFER_TYPE_MSG = 4
196} USBSUP_TRANSFER_TYPE;
197
198typedef enum
199{
200 USBSUP_DIRECTION_SETUP = 0,
201 USBSUP_DIRECTION_IN = 1,
202 USBSUP_DIRECTION_OUT = 2
203} USBSUP_DIRECTION;
204
205typedef enum
206{
207 USBSUP_FLAG_NONE = 0,
208 USBSUP_FLAG_SHORT_OK = 1
209} USBSUP_XFER_FLAG;
210
211typedef enum
212{
213 USBSUP_XFER_OK = 0,
214 USBSUP_XFER_STALL = 1,
215 USBSUP_XFER_DNR = 2,
216 USBSUP_XFER_CRC = 3,
217 USBSUP_XFER_NAC = 4,
218 USBSUP_XFER_UNDERRUN = 5,
219 USBSUP_XFER_OVERRUN = 6
220} USBSUP_ERROR;
221
222typedef struct USBSUP_ISOCPKT
223{
224 uint16_t cb; /* [in/out] packet size/size transferred */
225 uint16_t off; /* [in] offset of packet in buffer */
226 USBSUP_ERROR stat; /* [out] packet status */
227} USBSUP_ISOCPKT;
228
229typedef struct
230{
231 USBSUP_TRANSFER_TYPE type; /* [in] USBSUP_TRANSFER_TYPE_XXX */
232 uint32_t ep; /* [in] index to dev->pipe */
233 USBSUP_DIRECTION dir; /* [in] USBSUP_DIRECTION_XXX */
234 USBSUP_XFER_FLAG flags; /* [in] USBSUP_FLAG_XXX */
235 USBSUP_ERROR error; /* [out] USBSUP_XFER_XXX */
236 size_t len; /* [in/out] may change */
237 void *buf; /* [in/out] depends on dir */
238 uint32_t numIsoPkts; /* [in] number of isochronous packets (8 max) */
239 USBSUP_ISOCPKT aIsoPkts[8]; /* [in/out] isochronous packet descriptors */
240} USBSUP_URB, *PUSBSUP_URB;
241
242typedef struct
243{
244 union
245 {
246 /* in: event handle */
247 void* hEvent;
248 /* out: result */
249 int rc;
250 } u;
251} USBSUP_SET_NOTIFY_EVENT, *PUSBSUP_SET_NOTIFY_EVENT;
252
253typedef struct
254{
255 uint16_t usVendorId;
256 uint16_t usProductId;
257 uint16_t usRevision;
258 uint16_t usAlignment;
259 char DrvKeyName[512];
260} USBSUP_DEVID, *PUSBSUP_DEVID;
261
262#pragma pack() /* paranoia */
263
264
265RT_C_DECLS_BEGIN
266
267#ifdef IN_RING3
268
269/** @defgroup grp_usblib_r3 USBLIB Host Context Ring 3 API
270 * @{
271 */
272
273/**
274 * Return all attached USB devices.
275 *
276 * @returns VBox status code
277 * @param ppDevices Receives pointer to list of devices
278 * @param pcbNumDevices Number of USB devices in the list
279 */
280USBLIB_DECL(int) USBLibGetDevices(PUSBDEVICE *ppDevices, uint32_t *pcbNumDevices);
281
282USBLIB_DECL(int) USBLibWaitChange(RTMSINTERVAL cMillies);
283
284USBLIB_DECL(int) USBLibInterruptWaitChange(void);
285
286USBLIB_DECL(int) USBLibRunFilters(void);
287
288/** @} */
289#endif
290
291/** @} */
292
293RT_C_DECLS_END
294
295#endif
296
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette