VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/VBoxUSB/win/Monitor/USBMon.h@ 36068

Last change on this file since 36068 was 36068, checked in by vboxsync, 14 years ago

VBoxUSBMon.sys: initialize RemoveLock once.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.2 KB
Line 
1#ifndef __USBFilter_h__
2#define __USBFilter_h__
3
4/*******************************************************************************
5* Header Files *
6*******************************************************************************/
7#include <VBox/cdefs.h>
8#include <VBox/types.h>
9#include <iprt/assert.h>
10#include <VBox/sup.h>
11#include <iprt/asm.h>
12
13RT_C_DECLS_BEGIN
14#if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
15# define _InterlockedExchange _InterlockedExchange_StupidDDKVsCompilerCrap
16# define _InterlockedExchangeAdd _InterlockedExchangeAdd_StupidDDKVsCompilerCrap
17# define _InterlockedCompareExchange _InterlockedCompareExchange_StupidDDKVsCompilerCrap
18# define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap
19# pragma warning(disable : 4163)
20#endif
21#if (_MSC_VER >= 1600) && !defined(VBOX_WITH_PATCHED_DDK)
22# define _interlockedbittestandset _interlockedbittestandset_StillStupidDdkVsCompilerCrap
23# define _interlockedbittestandreset _interlockedbittestandreset_StillStupidDdkVsCompilerCrap
24# define _interlockedbittestandset64 _interlockedbittestandset64_StillStupidDdkVsCompilerCrap
25# define _interlockedbittestandreset64 _interlockedbittestandreset64_StillStupidDdkVsCompilerCrap
26# pragma warning(disable : 4163)
27#endif
28
29#include <initguid.h>
30#include <wdm.h>
31#include <wmilib.h>
32#include <wmistr.h>
33
34#if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
35# pragma warning(default : 4163)
36# undef _InterlockedExchange
37# undef _InterlockedExchangeAdd
38# undef _InterlockedCompareExchange
39# undef _InterlockedAddLargeStatistic
40#endif
41#if (_MSC_VER >= 1600) && !defined(VBOX_WITH_PATCHED_DDK)
42# pragma warning(default : 4163)
43# undef _interlockedbittestandset
44# undef _interlockedbittestandreset
45# undef _interlockedbittestandset64
46# undef _interlockedbittestandreset64
47#endif
48RT_C_DECLS_END
49
50extern "C" {
51/* from ntddk.h */
52NTSYSAPI
53CHAR
54NTAPI
55RtlUpperChar (
56 CHAR Character
57 );
58}
59
60#ifdef DEBUG
61#define DebugPrint(_x_) DbgPrint _x_
62
63#define TRAP() DbgBreakPoint()
64
65#else
66#define DebugPrint(_x_)
67#define TRAP()
68#endif
69
70
71#ifndef STATUS_CONTINUE_COMPLETION
72#define STATUS_CONTINUE_COMPLETION STATUS_SUCCESS
73#endif
74
75#define POOL_TAG 'VBox'
76
77typedef struct _DEVICE_EXTENSION
78{
79 //
80 // Removelock to track IRPs so that device can be removed and
81 // the driver can be unloaded safely.
82 //
83 IO_REMOVE_LOCK RemoveLock;
84
85 /* Whether the lock has been initialized. */
86 LONG fRemoveLockInitialized;
87
88 /* Number of times the device was opened. */
89 LONG cOpened;
90
91 BOOLEAN fHookDevice;
92} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
93
94
95#ifdef __cplusplus
96extern "C" {
97#endif
98
99#ifdef DEBUG
100PCHAR
101PnPMinorFunctionString (
102 UCHAR MinorFunction
103);
104
105void DebugPrintUnicodeString(PUNICODE_STRING pString);
106#else
107
108#define DebugPrintUnicodeString(x)
109
110#endif
111
112NTSTATUS _stdcall
113VBoxUSBMonAddDevice(
114 IN PDRIVER_OBJECT DriverObject,
115 IN PDEVICE_OBJECT PhysicalDeviceObject
116 );
117
118
119NTSTATUS _stdcall
120VBoxUSBMonDispatchPnp (
121 IN PDEVICE_OBJECT DeviceObject,
122 IN PIRP pIrp
123 );
124
125NTSTATUS _stdcall
126VBoxUSBMonDispatchPower(
127 IN PDEVICE_OBJECT DeviceObject,
128 IN PIRP pIrp
129 );
130
131/**
132 * Unload the driver.
133 *
134 * @param pDrvObj Driver object.
135 */
136void _stdcall VBoxUSBMonUnload(PDRIVER_OBJECT pDrvObj);
137
138
139/**
140 * Driver entry point.
141 *
142 * @returns appropriate status code.
143 * @param pDrvObj Pointer to driver object.
144 * @param pRegPath Registry base path.
145 */
146NTSTATUS _stdcall DriverEntry(PDRIVER_OBJECT pDrvObj, PUNICODE_STRING pRegPath);
147
148/**
149 * Device I/O Control entry point.
150 *
151 * @param pDevObj Device object.
152 * @param pIrp Request packet.
153 */
154NTSTATUS _stdcall VBoxUSBMonDeviceControl(PDEVICE_OBJECT pDevObj, PIRP pIrp);
155
156/**
157 * Pass on or refuse entry point
158 *
159 * @param pDevObj Device object.
160 * @param pIrp Request packet.
161 */
162NTSTATUS _stdcall VBoxUSBMonStub(IN PDEVICE_OBJECT DeviceObject, IN PIRP pIrp);
163
164/**
165 * Create (i.e. Open) file entry point.
166 *
167 * @param pDevObj Device object.
168 * @param pIrp Request packet.
169 */
170NTSTATUS _stdcall VBoxUSBMonCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp);
171
172/**
173 * Close file entry point.
174 *
175 * @param pDevObj Device object.
176 * @param pIrp Request packet.
177 */
178NTSTATUS _stdcall VBoxUSBMonClose(PDEVICE_OBJECT pDevObj, PIRP pIrp);
179
180/**
181 * Device PnP hook
182 *
183 * @param pDevObj Device object.
184 * @param pIrp Request packet.
185 */
186NTSTATUS _stdcall VBoxUSBMonPnPHook(IN PDEVICE_OBJECT DeviceObject, IN PIRP pIrp);
187
188/**
189 * Send IRP_MN_QUERY_DEVICE_RELATIONS
190 *
191 * @returns NT Status
192 * @param pDevObj USB device pointer
193 * @param pFileObj Valid file object pointer
194 * @param pDevRelations Pointer to DEVICE_RELATIONS pointer (out)
195 */
196NTSTATUS VBoxUSBQueryBusRelations(PDEVICE_OBJECT pDevObj, PFILE_OBJECT pFileObj, PDEVICE_RELATIONS *pDevRelations);
197
198
199
200NTSTATUS _stdcall VBoxUSBPnPCompletion(DEVICE_OBJECT *fido, IRP *pIrp, void *context);
201NTSTATUS _stdcall VBoxUSBDispatchIO(PDEVICE_OBJECT DeviceObject, PIRP pIrp);
202NTSTATUS _stdcall VBoxUSBCreate();
203NTSTATUS _stdcall VBoxUSBClose();
204NTSTATUS _stdcall VBoxUSBInit();
205NTSTATUS _stdcall VBoxUSBTerm();
206
207/**
208 * Capture specified USB device
209 *
210 * @returns NT status code
211 * @param usVendorId Vendor id
212 * @param usProductId Product id
213 * @param usRevision Revision
214 */
215NTSTATUS VBoxUSBGrabDevice(USHORT usVendorId, USHORT usProductId, USHORT usRevision);
216
217/**
218 * Capture specified USB device
219 *
220 * @returns NT status code
221 * @param usVendorId Vendor id
222 * @param usProductId Product id
223 * @param usRevision Revision
224 */
225NTSTATUS VBoxUSBReleaseDevice(USHORT usVendorId, USHORT usProductId, USHORT usRevision);
226
227bool VBoxMatchFilter(PDEVICE_OBJECT pdo);
228
229bool VBoxUSBAddDevice(PDEVICE_OBJECT pdo);
230int VBoxUSBIsKnownPDO(PDEVICE_OBJECT pdo);
231bool VBoxUSBRemoveDevice(PDEVICE_OBJECT pdo);
232void VBoxUSBDeviceArrived(PDEVICE_OBJECT pdo);
233bool VBoxUSBDeviceIsCaptured(PDEVICE_OBJECT pdo);
234void VBoxUSBSignalChange();
235bool VBoxUSBCaptureDevice(PDEVICE_OBJECT pdo);
236
237
238#ifdef __cplusplus
239}
240#endif
241
242#endif /* __USBFilter_h__ */
243
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