1 | /* $Id: VBoxUsbHook.h 82968 2020-02-04 10:35:17Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Driver Dispatch Table Hooking API impl
|
---|
4 | */
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2011-2020 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 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef VBOX_INCLUDED_SRC_VBoxUSB_win_mon_VBoxUsbHook_h
|
---|
27 | #define VBOX_INCLUDED_SRC_VBoxUSB_win_mon_VBoxUsbHook_h
|
---|
28 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
29 | # pragma once
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | #include "VBoxUsbMon.h"
|
---|
33 |
|
---|
34 | typedef struct VBOXUSBHOOK_ENTRY
|
---|
35 | {
|
---|
36 | LIST_ENTRY RequestList;
|
---|
37 | KSPIN_LOCK Lock;
|
---|
38 | BOOLEAN fIsInstalled;
|
---|
39 | PDRIVER_DISPATCH pfnOldHandler;
|
---|
40 | VBOXDRVTOOL_REF HookRef;
|
---|
41 | PDRIVER_OBJECT pDrvObj;
|
---|
42 | UCHAR iMjFunction;
|
---|
43 | PDRIVER_DISPATCH pfnHook;
|
---|
44 | } VBOXUSBHOOK_ENTRY, *PVBOXUSBHOOK_ENTRY;
|
---|
45 |
|
---|
46 | typedef struct VBOXUSBHOOK_REQUEST
|
---|
47 | {
|
---|
48 | LIST_ENTRY ListEntry;
|
---|
49 | PVBOXUSBHOOK_ENTRY pHook;
|
---|
50 | IO_STACK_LOCATION OldLocation;
|
---|
51 | PDEVICE_OBJECT pDevObj;
|
---|
52 | PIRP pIrp;
|
---|
53 | BOOLEAN bCompletionStopped;
|
---|
54 | } VBOXUSBHOOK_REQUEST, *PVBOXUSBHOOK_REQUEST;
|
---|
55 |
|
---|
56 | DECLINLINE(BOOLEAN) VBoxUsbHookRetain(PVBOXUSBHOOK_ENTRY pHook)
|
---|
57 | {
|
---|
58 | KIRQL Irql;
|
---|
59 | KeAcquireSpinLock(&pHook->Lock, &Irql);
|
---|
60 | if (!pHook->fIsInstalled)
|
---|
61 | {
|
---|
62 | KeReleaseSpinLock(&pHook->Lock, Irql);
|
---|
63 | return FALSE;
|
---|
64 | }
|
---|
65 |
|
---|
66 | VBoxDrvToolRefRetain(&pHook->HookRef);
|
---|
67 | KeReleaseSpinLock(&pHook->Lock, Irql);
|
---|
68 | return TRUE;
|
---|
69 | }
|
---|
70 |
|
---|
71 | DECLINLINE(VOID) VBoxUsbHookRelease(PVBOXUSBHOOK_ENTRY pHook)
|
---|
72 | {
|
---|
73 | VBoxDrvToolRefRelease(&pHook->HookRef);
|
---|
74 | }
|
---|
75 |
|
---|
76 | VOID VBoxUsbHookInit(PVBOXUSBHOOK_ENTRY pHook, PDRIVER_OBJECT pDrvObj, UCHAR iMjFunction, PDRIVER_DISPATCH pfnHook);
|
---|
77 | NTSTATUS VBoxUsbHookInstall(PVBOXUSBHOOK_ENTRY pHook);
|
---|
78 | NTSTATUS VBoxUsbHookUninstall(PVBOXUSBHOOK_ENTRY pHook);
|
---|
79 | BOOLEAN VBoxUsbHookIsInstalled(PVBOXUSBHOOK_ENTRY pHook);
|
---|
80 | NTSTATUS VBoxUsbHookRequestPassDownHookCompletion(PVBOXUSBHOOK_ENTRY pHook, PDEVICE_OBJECT pDevObj, PIRP pIrp, PIO_COMPLETION_ROUTINE pfnCompletion, PVBOXUSBHOOK_REQUEST pRequest);
|
---|
81 | NTSTATUS VBoxUsbHookRequestPassDownHookSkip(PVBOXUSBHOOK_ENTRY pHook, PDEVICE_OBJECT pDevObj, PIRP pIrp);
|
---|
82 | NTSTATUS VBoxUsbHookRequestMoreProcessingRequired(PVBOXUSBHOOK_ENTRY pHook, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVBOXUSBHOOK_REQUEST pRequest);
|
---|
83 | NTSTATUS VBoxUsbHookRequestComplete(PVBOXUSBHOOK_ENTRY pHook, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVBOXUSBHOOK_REQUEST pRequest);
|
---|
84 | VOID VBoxUsbHookVerifyCompletion(PVBOXUSBHOOK_ENTRY pHook, PVBOXUSBHOOK_REQUEST pRequest, PIRP pIrp);
|
---|
85 |
|
---|
86 | #endif /* !VBOX_INCLUDED_SRC_VBoxUSB_win_mon_VBoxUsbHook_h */
|
---|