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 |
|
---|
22 | typedef 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 |
|
---|
34 | typedef 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 |
|
---|
44 | DECLINLINE(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 |
|
---|
59 | DECLINLINE(VOID) VBoxUsbHookRelease(PVBOXUSBHOOK_ENTRY pHook)
|
---|
60 | {
|
---|
61 | VBoxDrvToolRefRelease(&pHook->HookRef);
|
---|
62 | }
|
---|
63 |
|
---|
64 | VOID VBoxUsbHookInit(PVBOXUSBHOOK_ENTRY pHook, PDRIVER_OBJECT pDrvObj, UCHAR iMjFunction, PDRIVER_DISPATCH pfnHook);
|
---|
65 | NTSTATUS VBoxUsbHookInstall(PVBOXUSBHOOK_ENTRY pHook);
|
---|
66 | NTSTATUS VBoxUsbHookUninstall(PVBOXUSBHOOK_ENTRY pHook);
|
---|
67 | BOOLEAN VBoxUsbHookIsInstalled(PVBOXUSBHOOK_ENTRY pHook);
|
---|
68 | NTSTATUS VBoxUsbHookRequestPassDownHookCompletion(PVBOXUSBHOOK_ENTRY pHook, PDEVICE_OBJECT pDevObj, PIRP pIrp, PIO_COMPLETION_ROUTINE pfnCompletion, PVBOXUSBHOOK_REQUEST pRequest);
|
---|
69 | NTSTATUS VBoxUsbHookRequestPassDownHookSkip(PVBOXUSBHOOK_ENTRY pHook, PDEVICE_OBJECT pDevObj, PIRP pIrp);
|
---|
70 | NTSTATUS VBoxUsbHookRequestMoreProcessingRequired(PVBOXUSBHOOK_ENTRY pHook, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVBOXUSBHOOK_REQUEST pRequest);
|
---|
71 | NTSTATUS VBoxUsbHookRequestComplete(PVBOXUSBHOOK_ENTRY pHook, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVBOXUSBHOOK_REQUEST pRequest);
|
---|
72 | VOID VBoxUsbHookVerifyCompletion(PVBOXUSBHOOK_ENTRY pHook, PVBOXUSBHOOK_REQUEST pRequest, PIRP pIrp);
|
---|
73 |
|
---|
74 | #endif /* #ifndef ___VBoxUsbHook_h___ */
|
---|