1 | /* $Id: VBoxMPRegistry.cpp 37127 2011-05-17 14:14:53Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | * VBox WDDM Miniport registry related functions
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2011 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #include "common/VBoxMPCommon.h"
|
---|
20 |
|
---|
21 | VP_STATUS VBoxMPCmnRegInit(IN PVBOXMP_DEVEXT pExt, OUT VBOXMPCMNREGISTRY *pReg)
|
---|
22 | {
|
---|
23 | WCHAR Buf[512];
|
---|
24 | ULONG cbBuf = sizeof(Buf);
|
---|
25 | NTSTATUS Status = vboxWddmRegQueryDrvKeyName(pExt, cbBuf, Buf, &cbBuf);
|
---|
26 | Assert(Status == STATUS_SUCCESS);
|
---|
27 | if (Status == STATUS_SUCCESS)
|
---|
28 | {
|
---|
29 | Status = vboxWddmRegOpenKey(pReg, Buf, GENERIC_READ | GENERIC_WRITE);
|
---|
30 | Assert(Status == STATUS_SUCCESS);
|
---|
31 | if(Status == STATUS_SUCCESS)
|
---|
32 | return NO_ERROR;
|
---|
33 | }
|
---|
34 |
|
---|
35 | /* fall-back to make the subsequent VBoxVideoCmnRegXxx calls treat the fail accordingly
|
---|
36 | * basically needed to make as less modifications to the current XPDM code as possible */
|
---|
37 | *pReg = NULL;
|
---|
38 |
|
---|
39 | return ERROR_INVALID_PARAMETER;
|
---|
40 | }
|
---|
41 |
|
---|
42 | VP_STATUS VBoxMPCmnRegFini(IN VBOXMPCMNREGISTRY Reg)
|
---|
43 | {
|
---|
44 | if (!Reg)
|
---|
45 | {
|
---|
46 | return ERROR_INVALID_PARAMETER;
|
---|
47 | }
|
---|
48 |
|
---|
49 | NTSTATUS Status = ZwClose(Reg);
|
---|
50 | return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER;
|
---|
51 | }
|
---|
52 |
|
---|
53 | VP_STATUS VBoxMPCmnRegQueryDword(IN VBOXMPCMNREGISTRY Reg, PWSTR pName, uint32_t *pVal)
|
---|
54 | {
|
---|
55 | /* seems like the new code assumes the Reg functions zeroes up the value on failure */
|
---|
56 | *pVal = 0;
|
---|
57 |
|
---|
58 | if (!Reg)
|
---|
59 | {
|
---|
60 | return ERROR_INVALID_PARAMETER;
|
---|
61 | }
|
---|
62 |
|
---|
63 | NTSTATUS Status = vboxWddmRegQueryValueDword(Reg, pName, (PDWORD)pVal);
|
---|
64 | return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER;
|
---|
65 | }
|
---|
66 |
|
---|
67 | VP_STATUS VBoxMPCmnRegSetDword(IN VBOXMPCMNREGISTRY Reg, PWSTR pName, uint32_t Val)
|
---|
68 | {
|
---|
69 | if (!Reg)
|
---|
70 | {
|
---|
71 | return ERROR_INVALID_PARAMETER;
|
---|
72 | }
|
---|
73 |
|
---|
74 | NTSTATUS Status = vboxWddmRegSetValueDword(Reg, pName, Val);
|
---|
75 | return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER;
|
---|
76 | }
|
---|