VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbHook.h@ 37042

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

usb: back out r71658 as it's not correct; some additional debugging

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1/* $Id: VBoxUsbHook.h 37042 2011-05-11 19:04:07Z vboxsync $ */
2/** @file
3 * Driver Dispatch Table Hooking API impl
4 */
5/*
6 * Copyright (C) 2011 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 */
16
17#ifndef ___VBoxUsbHook_h___
18#define ___VBoxUsbHook_h___
19
20#include "VBoxUsbMon.h"
21
22typedef struct VBOXUSBHOOK_ENTRY
23{
24 LIST_ENTRY RequestList;
25 KSPIN_LOCK Lock;
26 BOOLEAN fIsInstalled;
27 PDRIVER_DISPATCH pfnOldHandler;
28 VBOXDRVTOOL_REF HookRef;
29 PDRIVER_OBJECT pDrvObj;
30 UCHAR iMjFunction;
31 PDRIVER_DISPATCH pfnHook;
32} VBOXUSBHOOK_ENTRY, *PVBOXUSBHOOK_ENTRY;
33
34typedef struct VBOXUSBHOOK_REQUEST
35{
36 LIST_ENTRY ListEntry;
37 PVBOXUSBHOOK_ENTRY pHook;
38 IO_STACK_LOCATION OldLocation;
39 PDEVICE_OBJECT pDevObj;
40 PIRP pIrp;
41 BOOLEAN bCompletionStopped;
42} VBOXUSBHOOK_REQUEST, *PVBOXUSBHOOK_REQUEST;
43
44DECLINLINE(BOOLEAN) VBoxUsbHookRetain(PVBOXUSBHOOK_ENTRY pHook)
45{
46 KIRQL Irql;
47 KeAcquireSpinLock(&pHook->Lock, &Irql);
48 if (!pHook->fIsInstalled)
49 {
50 KeReleaseSpinLock(&pHook->Lock, Irql);
51 return FALSE;
52 }
53
54 VBoxDrvToolRefRetain(&pHook->HookRef);
55 KeReleaseSpinLock(&pHook->Lock, Irql);
56 return TRUE;
57}
58
59DECLINLINE(VOID) VBoxUsbHookRelease(PVBOXUSBHOOK_ENTRY pHook)
60{
61 VBoxDrvToolRefRelease(&pHook->HookRef);
62}
63
64VOID VBoxUsbHookInit(PVBOXUSBHOOK_ENTRY pHook, PDRIVER_OBJECT pDrvObj, UCHAR iMjFunction, PDRIVER_DISPATCH pfnHook);
65NTSTATUS VBoxUsbHookInstall(PVBOXUSBHOOK_ENTRY pHook);
66NTSTATUS VBoxUsbHookUninstall(PVBOXUSBHOOK_ENTRY pHook);
67BOOLEAN VBoxUsbHookIsInstalled(PVBOXUSBHOOK_ENTRY pHook);
68NTSTATUS VBoxUsbHookRequestPassDownHookCompletion(PVBOXUSBHOOK_ENTRY pHook, PDEVICE_OBJECT pDevObj, PIRP pIrp, PIO_COMPLETION_ROUTINE pfnCompletion, PVBOXUSBHOOK_REQUEST pRequest);
69NTSTATUS VBoxUsbHookRequestPassDownHookSkip(PVBOXUSBHOOK_ENTRY pHook, PDEVICE_OBJECT pDevObj, PIRP pIrp);
70NTSTATUS VBoxUsbHookRequestMoreProcessingRequired(PVBOXUSBHOOK_ENTRY pHook, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVBOXUSBHOOK_REQUEST pRequest);
71NTSTATUS VBoxUsbHookRequestComplete(PVBOXUSBHOOK_ENTRY pHook, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVBOXUSBHOOK_REQUEST pRequest);
72VOID VBoxUsbHookVerifyCompletion(PVBOXUSBHOOK_ENTRY pHook, PVBOXUSBHOOK_REQUEST pRequest, PIRP pIrp);
73
74#endif /* #ifndef ___VBoxUsbHook_h___ */
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