VirtualBox

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

Last change on this file since 76585 was 76585, checked in by vboxsync, 6 years ago

*: scm --fix-header-guard-endif

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