VirtualBox

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

Last change on this file since 73019 was 69500, checked in by vboxsync, 7 years ago

*: scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1/* $Id: VBoxUsbHook.h 69500 2017-10-28 15:14:05Z vboxsync $ */
2/** @file
3 * Driver Dispatch Table Hooking API impl
4 */
5/*
6 * Copyright (C) 2011-2017 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 ___VBoxUsbHook_h___
27#define ___VBoxUsbHook_h___
28
29#include "VBoxUsbMon.h"
30
31typedef struct VBOXUSBHOOK_ENTRY
32{
33 LIST_ENTRY RequestList;
34 KSPIN_LOCK Lock;
35 BOOLEAN fIsInstalled;
36 PDRIVER_DISPATCH pfnOldHandler;
37 VBOXDRVTOOL_REF HookRef;
38 PDRIVER_OBJECT pDrvObj;
39 UCHAR iMjFunction;
40 PDRIVER_DISPATCH pfnHook;
41} VBOXUSBHOOK_ENTRY, *PVBOXUSBHOOK_ENTRY;
42
43typedef struct VBOXUSBHOOK_REQUEST
44{
45 LIST_ENTRY ListEntry;
46 PVBOXUSBHOOK_ENTRY pHook;
47 IO_STACK_LOCATION OldLocation;
48 PDEVICE_OBJECT pDevObj;
49 PIRP pIrp;
50 BOOLEAN bCompletionStopped;
51} VBOXUSBHOOK_REQUEST, *PVBOXUSBHOOK_REQUEST;
52
53DECLINLINE(BOOLEAN) VBoxUsbHookRetain(PVBOXUSBHOOK_ENTRY pHook)
54{
55 KIRQL Irql;
56 KeAcquireSpinLock(&pHook->Lock, &Irql);
57 if (!pHook->fIsInstalled)
58 {
59 KeReleaseSpinLock(&pHook->Lock, Irql);
60 return FALSE;
61 }
62
63 VBoxDrvToolRefRetain(&pHook->HookRef);
64 KeReleaseSpinLock(&pHook->Lock, Irql);
65 return TRUE;
66}
67
68DECLINLINE(VOID) VBoxUsbHookRelease(PVBOXUSBHOOK_ENTRY pHook)
69{
70 VBoxDrvToolRefRelease(&pHook->HookRef);
71}
72
73VOID VBoxUsbHookInit(PVBOXUSBHOOK_ENTRY pHook, PDRIVER_OBJECT pDrvObj, UCHAR iMjFunction, PDRIVER_DISPATCH pfnHook);
74NTSTATUS VBoxUsbHookInstall(PVBOXUSBHOOK_ENTRY pHook);
75NTSTATUS VBoxUsbHookUninstall(PVBOXUSBHOOK_ENTRY pHook);
76BOOLEAN VBoxUsbHookIsInstalled(PVBOXUSBHOOK_ENTRY pHook);
77NTSTATUS VBoxUsbHookRequestPassDownHookCompletion(PVBOXUSBHOOK_ENTRY pHook, PDEVICE_OBJECT pDevObj, PIRP pIrp, PIO_COMPLETION_ROUTINE pfnCompletion, PVBOXUSBHOOK_REQUEST pRequest);
78NTSTATUS VBoxUsbHookRequestPassDownHookSkip(PVBOXUSBHOOK_ENTRY pHook, PDEVICE_OBJECT pDevObj, PIRP pIrp);
79NTSTATUS VBoxUsbHookRequestMoreProcessingRequired(PVBOXUSBHOOK_ENTRY pHook, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVBOXUSBHOOK_REQUEST pRequest);
80NTSTATUS VBoxUsbHookRequestComplete(PVBOXUSBHOOK_ENTRY pHook, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVBOXUSBHOOK_REQUEST pRequest);
81VOID VBoxUsbHookVerifyCompletion(PVBOXUSBHOOK_ENTRY pHook, PVBOXUSBHOOK_REQUEST pRequest, PIRP pIrp);
82
83#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