VirtualBox

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

Last change on this file since 69496 was 69496, 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.4 KB
Line 
1/* $Id: VBoxDrvTool.h 69496 2017-10-28 14:55:58Z vboxsync $ */
2/** @file
3 * Windows Driver R0 Tooling.
4 */
5
6/*
7 * Copyright (C) 2011-2017 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 ___VBoxDrvTool_win_h___
28#define ___VBoxDrvTool_win_h___
29
30#include <VBox/cdefs.h>
31#include <iprt/stdint.h>
32#include <iprt/assert.h>
33#include <iprt/asm.h>
34#include <iprt/nt/wdm.h>
35
36
37RT_C_DECLS_BEGIN
38
39#if 0
40/* enable this in case we include this in a dll*/
41# ifdef IN_VBOXDRVTOOL
42# define VBOXDRVTOOL_DECL(a_Type) DECLEXPORT(a_Type)
43# else
44# define VBOXDRVTOOL_DECL(a_Type) DECLIMPORT(a_Type)
45# endif
46#else
47/*enable this in case we include this in a static lib*/
48# define VBOXDRVTOOL_DECL(a_Type) a_Type VBOXCALL
49#endif
50
51VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolRegOpenKeyU(OUT PHANDLE phKey, IN PUNICODE_STRING pName, IN ACCESS_MASK fAccess);
52VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolRegOpenKey(OUT PHANDLE phKey, IN PWCHAR pName, IN ACCESS_MASK fAccess);
53VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolRegCloseKey(IN HANDLE hKey);
54VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolRegQueryValueDword(IN HANDLE hKey, IN PWCHAR pName, OUT PULONG pDword);
55VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolRegSetValueDword(IN HANDLE hKey, IN PWCHAR pName, OUT ULONG val);
56
57VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolIoPostAsync(PDEVICE_OBJECT pDevObj, PIRP pIrp, PKEVENT pEvent);
58VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolIoPostSync(PDEVICE_OBJECT pDevObj, PIRP pIrp);
59VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolIoPostSyncWithTimeout(PDEVICE_OBJECT pDevObj, PIRP pIrp, ULONG dwTimeoutMs);
60DECLINLINE(NTSTATUS) VBoxDrvToolIoComplete(PIRP pIrp, NTSTATUS Status, ULONG ulInfo)
61{
62 pIrp->IoStatus.Status = Status;
63 pIrp->IoStatus.Information = ulInfo;
64 IoCompleteRequest(pIrp, IO_NO_INCREMENT);
65 return Status;
66}
67
68typedef struct VBOXDRVTOOL_REF
69{
70 volatile uint32_t cRefs;
71} VBOXDRVTOOL_REF, *PVBOXDRVTOOL_REF;
72
73DECLINLINE(void) VBoxDrvToolRefInit(PVBOXDRVTOOL_REF pRef)
74{
75 pRef->cRefs = 1;
76}
77
78DECLINLINE(uint32_t) VBoxDrvToolRefRetain(PVBOXDRVTOOL_REF pRef)
79{
80 Assert(pRef->cRefs);
81 Assert(pRef->cRefs < UINT32_MAX / 2);
82 return ASMAtomicIncU32(&pRef->cRefs);
83}
84
85DECLINLINE(uint32_t) VBoxDrvToolRefRelease(PVBOXDRVTOOL_REF pRef)
86{
87 uint32_t cRefs = ASMAtomicDecU32(&pRef->cRefs);
88 Assert(cRefs < UINT32_MAX/2);
89 return cRefs;
90}
91
92VBOXDRVTOOL_DECL(VOID) VBoxDrvToolRefWaitEqual(PVBOXDRVTOOL_REF pRef, uint32_t u32Val);
93
94VBOXDRVTOOL_DECL(NTSTATUS) VBoxDrvToolStrCopy(PUNICODE_STRING pDst, CONST PUNICODE_STRING pSrc);
95VBOXDRVTOOL_DECL(VOID) VBoxDrvToolStrFree(PUNICODE_STRING pStr);
96
97RT_C_DECLS_END
98
99#endif
100
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