VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/VBoxUSB/win/cmn/VBoxDrvTool.h@ 54558

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

usb: filter misbehaved device dynamic black list

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1/* $Id: VBoxDrvTool.h 37047 2011-05-12 10:29:26Z vboxsync $ */
2/** @file
3 * Windows Driver R0 Tooling.
4 */
5
6/*
7 * Copyright (C) 2011 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17#ifndef ___VBoxDrvTool_win_h___
18#define ___VBoxDrvTool_win_h___
19#include <VBox/cdefs.h>
20#include <iprt/stdint.h>
21#include <iprt/assert.h>
22#include <iprt/asm.h>
23
24RT_C_DECLS_BEGIN
25#if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
26# define _InterlockedExchange _InterlockedExchange_StupidDDKVsCompilerCrap
27# define _InterlockedExchangeAdd _InterlockedExchangeAdd_StupidDDKVsCompilerCrap
28# define _InterlockedCompareExchange _InterlockedCompareExchange_StupidDDKVsCompilerCrap
29# define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap
30# pragma warning(disable : 4163)
31#endif
32#if (_MSC_VER >= 1600) && !defined(VBOX_WITH_PATCHED_DDK)
33# define _interlockedbittestandset _interlockedbittestandset_StillStupidDdkVsCompilerCrap
34# define _interlockedbittestandreset _interlockedbittestandreset_StillStupidDdkVsCompilerCrap
35# define _interlockedbittestandset64 _interlockedbittestandset64_StillStupidDdkVsCompilerCrap
36# define _interlockedbittestandreset64 _interlockedbittestandreset64_StillStupidDdkVsCompilerCrap
37# pragma warning(disable : 4163)
38#endif
39
40#include <wdm.h>
41
42#if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
43# pragma warning(default : 4163)
44# undef _InterlockedExchange
45# undef _InterlockedExchangeAdd
46# undef _InterlockedCompareExchange
47# undef _InterlockedAddLargeStatistic
48#endif
49#if (_MSC_VER >= 1600) && !defined(VBOX_WITH_PATCHED_DDK)
50# pragma warning(default : 4163)
51# undef _interlockedbittestandset
52# undef _interlockedbittestandreset
53# undef _interlockedbittestandset64
54# undef _interlockedbittestandreset64
55#endif
56
57
58#if 0
59/* enable this in case we include this in a dll*/
60# ifdef IN_VBOXDRVTOOL
61# define VBOXDRVTOOL_DECL(a_Type) DECLEXPORT(a_Type)
62# else
63# define VBOXDRVTOOL_DECL(a_Type) DECLIMPORT(a_Type)
64# endif
65#else
66/*enable this in case we include this in a static lib*/
67# define VBOXDRVTOOL_DECL(a_Type) a_Type VBOXCALL
68#endif
69
70VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolRegOpenKeyU(OUT PHANDLE phKey, IN PUNICODE_STRING pName, IN ACCESS_MASK fAccess);
71VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolRegOpenKey(OUT PHANDLE phKey, IN PWCHAR pName, IN ACCESS_MASK fAccess);
72VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolRegCloseKey(IN HANDLE hKey);
73VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolRegQueryValueDword(IN HANDLE hKey, IN PWCHAR pName, OUT PULONG pDword);
74VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolRegSetValueDword(IN HANDLE hKey, IN PWCHAR pName, OUT ULONG val);
75
76VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolIoPostAsync(PDEVICE_OBJECT pDevObj, PIRP pIrp, PKEVENT pEvent);
77VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolIoPostSync(PDEVICE_OBJECT pDevObj, PIRP pIrp);
78VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolIoPostSyncWithTimeout(PDEVICE_OBJECT pDevObj, PIRP pIrp, ULONG dwTimeoutMs);
79DECLINLINE(NTSTATUS) VBoxDrvToolIoComplete(PIRP pIrp, NTSTATUS Status, ULONG ulInfo)
80{
81 pIrp->IoStatus.Status = Status;
82 pIrp->IoStatus.Information = ulInfo;
83 IoCompleteRequest(pIrp, IO_NO_INCREMENT);
84 return Status;
85}
86
87typedef struct VBOXDRVTOOL_REF
88{
89 volatile uint32_t cRefs;
90} VBOXDRVTOOL_REF, *PVBOXDRVTOOL_REF;
91
92DECLINLINE(void) VBoxDrvToolRefInit(PVBOXDRVTOOL_REF pRef)
93{
94 pRef->cRefs = 1;
95}
96
97DECLINLINE(uint32_t) VBoxDrvToolRefRetain(PVBOXDRVTOOL_REF pRef)
98{
99 Assert(pRef->cRefs);
100 Assert(pRef->cRefs < UINT32_MAX / 2);
101 return ASMAtomicIncU32(&pRef->cRefs);
102}
103
104DECLINLINE(uint32_t) VBoxDrvToolRefRelease(PVBOXDRVTOOL_REF pRef)
105{
106 uint32_t cRefs = ASMAtomicDecU32(&pRef->cRefs);
107 Assert(cRefs < UINT32_MAX/2);
108 return cRefs;
109}
110
111VBOXDRVTOOL_DECL(VOID) VBoxDrvToolRefWaitEqual(PVBOXDRVTOOL_REF pRef, uint32_t u32Val);
112
113VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolStrCopy(PUNICODE_STRING pDst, CONST PUNICODE_STRING pSrc);
114VBOXDRVTOOL_DECL(VOID) VBoxDrvToolStrFree(PUNICODE_STRING pStr);
115
116RT_C_DECLS_END
117
118#endif /* #ifndef ___VBoxDrvTool_win_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