VirtualBox

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

Last change on this file since 88675 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
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
34typedef 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
46typedef 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
56DECLINLINE(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
71DECLINLINE(VOID) VBoxUsbHookRelease(PVBOXUSBHOOK_ENTRY pHook)
72{
73 VBoxDrvToolRefRelease(&pHook->HookRef);
74}
75
76VOID VBoxUsbHookInit(PVBOXUSBHOOK_ENTRY pHook, PDRIVER_OBJECT pDrvObj, UCHAR iMjFunction, PDRIVER_DISPATCH pfnHook);
77NTSTATUS VBoxUsbHookInstall(PVBOXUSBHOOK_ENTRY pHook);
78NTSTATUS VBoxUsbHookUninstall(PVBOXUSBHOOK_ENTRY pHook);
79BOOLEAN VBoxUsbHookIsInstalled(PVBOXUSBHOOK_ENTRY pHook);
80NTSTATUS VBoxUsbHookRequestPassDownHookCompletion(PVBOXUSBHOOK_ENTRY pHook, PDEVICE_OBJECT pDevObj, PIRP pIrp, PIO_COMPLETION_ROUTINE pfnCompletion, PVBOXUSBHOOK_REQUEST pRequest);
81NTSTATUS VBoxUsbHookRequestPassDownHookSkip(PVBOXUSBHOOK_ENTRY pHook, PDEVICE_OBJECT pDevObj, PIRP pIrp);
82NTSTATUS VBoxUsbHookRequestMoreProcessingRequired(PVBOXUSBHOOK_ENTRY pHook, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVBOXUSBHOOK_REQUEST pRequest);
83NTSTATUS VBoxUsbHookRequestComplete(PVBOXUSBHOOK_ENTRY pHook, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVBOXUSBHOOK_REQUEST pRequest);
84VOID VBoxUsbHookVerifyCompletion(PVBOXUSBHOOK_ENTRY pHook, PVBOXUSBHOOK_REQUEST pRequest, PIRP pIrp);
85
86#endif /* !VBOX_INCLUDED_SRC_VBoxUSB_win_mon_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