VirtualBox

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

Last change on this file since 78177 was 76568, checked in by vboxsync, 6 years ago

HostDrivers: Use VBOX_INCLUDED_SRC_ as header guard prefix with scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1/* $Id: VBoxDrvTool.h 76568 2019-01-01 04:34:11Z vboxsync $ */
2/** @file
3 * Windows Driver R0 Tooling.
4 */
5
6/*
7 * Copyright (C) 2011-2019 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 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef VBOX_INCLUDED_SRC_VBoxUSB_win_cmn_VBoxDrvTool_h
28#define VBOX_INCLUDED_SRC_VBoxUSB_win_cmn_VBoxDrvTool_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include <VBox/cdefs.h>
34#include <iprt/stdint.h>
35#include <iprt/assert.h>
36#include <iprt/asm.h>
37#include <iprt/nt/wdm.h>
38
39
40RT_C_DECLS_BEGIN
41
42#if 0
43/* enable this in case we include this in a dll*/
44# ifdef IN_VBOXDRVTOOL
45# define VBOXDRVTOOL_DECL(a_Type) DECLEXPORT(a_Type)
46# else
47# define VBOXDRVTOOL_DECL(a_Type) DECLIMPORT(a_Type)
48# endif
49#else
50/*enable this in case we include this in a static lib*/
51# define VBOXDRVTOOL_DECL(a_Type) a_Type VBOXCALL
52#endif
53
54VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolRegOpenKeyU(OUT PHANDLE phKey, IN PUNICODE_STRING pName, IN ACCESS_MASK fAccess);
55VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolRegOpenKey(OUT PHANDLE phKey, IN PWCHAR pName, IN ACCESS_MASK fAccess);
56VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolRegCloseKey(IN HANDLE hKey);
57VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolRegQueryValueDword(IN HANDLE hKey, IN PWCHAR pName, OUT PULONG pDword);
58VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolRegSetValueDword(IN HANDLE hKey, IN PWCHAR pName, OUT ULONG val);
59
60VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolIoPostAsync(PDEVICE_OBJECT pDevObj, PIRP pIrp, PKEVENT pEvent);
61VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolIoPostSync(PDEVICE_OBJECT pDevObj, PIRP pIrp);
62VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolIoPostSyncWithTimeout(PDEVICE_OBJECT pDevObj, PIRP pIrp, ULONG dwTimeoutMs);
63DECLINLINE(NTSTATUS) VBoxDrvToolIoComplete(PIRP pIrp, NTSTATUS Status, ULONG ulInfo)
64{
65 pIrp->IoStatus.Status = Status;
66 pIrp->IoStatus.Information = ulInfo;
67 IoCompleteRequest(pIrp, IO_NO_INCREMENT);
68 return Status;
69}
70
71typedef struct VBOXDRVTOOL_REF
72{
73 volatile uint32_t cRefs;
74} VBOXDRVTOOL_REF, *PVBOXDRVTOOL_REF;
75
76DECLINLINE(void) VBoxDrvToolRefInit(PVBOXDRVTOOL_REF pRef)
77{
78 pRef->cRefs = 1;
79}
80
81DECLINLINE(uint32_t) VBoxDrvToolRefRetain(PVBOXDRVTOOL_REF pRef)
82{
83 Assert(pRef->cRefs);
84 Assert(pRef->cRefs < UINT32_MAX / 2);
85 return ASMAtomicIncU32(&pRef->cRefs);
86}
87
88DECLINLINE(uint32_t) VBoxDrvToolRefRelease(PVBOXDRVTOOL_REF pRef)
89{
90 uint32_t cRefs = ASMAtomicDecU32(&pRef->cRefs);
91 Assert(cRefs < UINT32_MAX/2);
92 return cRefs;
93}
94
95VBOXDRVTOOL_DECL(VOID) VBoxDrvToolRefWaitEqual(PVBOXDRVTOOL_REF pRef, uint32_t u32Val);
96
97VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolStrCopy(PUNICODE_STRING pDst, CONST PUNICODE_STRING pSrc);
98VBOXDRVTOOL_DECL(VOID) VBoxDrvToolStrFree(PUNICODE_STRING pStr);
99
100RT_C_DECLS_END
101
102#endif /* !VBOX_INCLUDED_SRC_VBoxUSB_win_cmn_VBoxDrvTool_h */
103
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