|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 18/18] xenvbd:registry: sync with xenbus
Sync registr.c,h with xenbus latest version.
Signed-off-by: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
---
src/xenvbd/registry.c | 375 +++++++++++++++++++++++-------------------
src/xenvbd/registry.h | 139 +++++++---------
2 files changed, 270 insertions(+), 244 deletions(-)
diff --git a/src/xenvbd/registry.c b/src/xenvbd/registry.c
index a11d562..4f7c5ef 100644
--- a/src/xenvbd/registry.c
+++ b/src/xenvbd/registry.c
@@ -1,32 +1,32 @@
/* Copyright (c) Xen Project.
* Copyright (c) Cloud Software Group, Inc.
* All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
* that the following conditions are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
+ *
+ * * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the
* following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the
+ * following disclaimer in the documentation and/or other
* materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
@@ -64,13 +64,13 @@ __RegistryFree(
NTSTATUS
#pragma prefast(suppress:28101) // unannotated DriverEntry function
RegistryInitialize(
- _In_ PDRIVER_OBJECT DriverObject,
+ _In_opt_ PDRIVER_OBJECT DriverObject,
_In_ PUNICODE_STRING Path
)
{
- UNICODE_STRING Unicode;
- PVOID Func;
- NTSTATUS status;
+ UNICODE_STRING Unicode;
+ PVOID Func;
+ NTSTATUS status;
ASSERT3P(RegistryPath.Buffer, ==, NULL);
@@ -110,7 +110,54 @@ RegistryTeardown(
RegistryPath.MaximumLength = RegistryPath.Length = 0;
}
-_IRQL_requires_(PASSIVE_LEVEL)
+NTSTATUS
+RegistryOpenParametersKey(
+ _In_ ACCESS_MASK DesiredAccess,
+ _Out_ PHANDLE Key
+ )
+{
+ HANDLE ServiceKey;
+ NTSTATUS status;
+
+ if (__IoOpenDriverRegistryKey != NULL) {
+ status = __IoOpenDriverRegistryKey(RegistryDriverObject,
+ DriverRegKeyParameters,
+ DesiredAccess,
+ 0,
+ Key);
+ if (!NT_SUCCESS(status))
+ goto fail1;
+
+ goto done;
+ }
+
+ status = RegistryOpenKey(NULL, &RegistryPath, DesiredAccess, &ServiceKey);
+ if (!NT_SUCCESS(status))
+ goto fail2;
+
+ status = RegistryOpenSubKey(ServiceKey, "Parameters", DesiredAccess, Key);
+ if (!NT_SUCCESS(status))
+ goto fail3;
+
+ RegistryCloseKey(ServiceKey);
+
+done:
+ return STATUS_SUCCESS;
+
+fail3:
+ Error("fail3\n");
+
+ RegistryCloseKey(ServiceKey);
+
+fail2:
+ Error("fail2\n");
+
+fail1:
+ Error("fail1 %08x\n", status);
+
+ return status;
+}
+
NTSTATUS
RegistryOpenKey(
_In_opt_ HANDLE Parent,
@@ -119,8 +166,8 @@ RegistryOpenKey(
_Out_ PHANDLE Key
)
{
- OBJECT_ATTRIBUTES Attributes;
- NTSTATUS status;
+ OBJECT_ATTRIBUTES Attributes;
+ NTSTATUS status;
InitializeObjectAttributes(&Attributes,
Path,
@@ -140,7 +187,6 @@ fail1:
return status;
}
-_IRQL_requires_(PASSIVE_LEVEL)
static NTSTATUS
RegistryOpenRoot(
_In_ PWSTR Path,
@@ -148,7 +194,7 @@ RegistryOpenRoot(
_Outptr_result_z_ PWSTR *ChildPath
)
{
- const WCHAR Prefix[] = L"\\Registry\\Machine\\";
+ PCWSTR Prefix = L"\\Registry\\Machine\\";
ULONG Length;
UNICODE_STRING Unicode;
NTSTATUS status;
@@ -174,22 +220,21 @@ fail1:
return status;
}
-_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
RegistryCreateKey(
- _In_opt_ HANDLE Root,
+ _In_opt_ HANDLE Parent,
_In_ PUNICODE_STRING Path,
_In_ ULONG Options,
_Out_ PHANDLE Key
)
{
- PWCHAR Buffer;
- HANDLE Parent;
- PWCHAR ChildPath;
- PWCHAR ChildName;
- PWCHAR Context;
- HANDLE Child;
- NTSTATUS status;
+ PWSTR Buffer;
+ HANDLE Root;
+ PWSTR ChildPath;
+ PWSTR ChildName;
+ PWSTR Context;
+ HANDLE Child;
+ NTSTATUS status;
//
// UNICODE_STRINGs are not guaranteed to have NUL terminated
@@ -204,8 +249,9 @@ RegistryCreateKey(
RtlCopyMemory(Buffer, Path->Buffer, Path->Length);
- if (Root != NULL) {
- Parent = Root;
+ Root = Parent;
+
+ if (Parent != NULL) {
ChildPath = Buffer;
} else {
status = RegistryOpenRoot(Buffer, &Parent, &ChildPath);
@@ -274,7 +320,6 @@ fail1:
return status;
}
-_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
RegistryOpenServiceKey(
_In_ ACCESS_MASK DesiredAccess,
@@ -284,65 +329,14 @@ RegistryOpenServiceKey(
return RegistryOpenKey(NULL, &RegistryPath, DesiredAccess, Key);
}
-_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
RegistryCreateServiceKey(
- _Out_ PHANDLE Key
- )
-{
- return RegistryCreateKey(NULL, &RegistryPath, REG_OPTION_NON_VOLATILE,
Key);
-}
-
-_IRQL_requires_(PASSIVE_LEVEL)
-NTSTATUS
-RegistryOpenParametersKey(
- _In_ ACCESS_MASK DesiredAccess,
_Out_ PHANDLE Key
)
{
- HANDLE ServiceKey;
- NTSTATUS status;
-
- if (__IoOpenDriverRegistryKey != NULL) {
- status = __IoOpenDriverRegistryKey(RegistryDriverObject,
- DriverRegKeyParameters,
- DesiredAccess,
- 0,
- Key);
- if (!NT_SUCCESS(status))
- goto fail1;
-
- goto done;
- }
-
- status = RegistryOpenKey(NULL, &RegistryPath, DesiredAccess, &ServiceKey);
- if (!NT_SUCCESS(status))
- goto fail2;
-
- status = RegistryOpenSubKey(ServiceKey, "Parameters", DesiredAccess, Key);
- if (!NT_SUCCESS(status))
- goto fail3;
-
- RegistryCloseKey(ServiceKey);
-
-done:
- return STATUS_SUCCESS;
-
-fail3:
- Error("fail3\n");
-
- RegistryCloseKey(ServiceKey);
-
-fail2:
- Error("fail2\n");
-
-fail1:
- Error("fail1 %08x\n", status);
-
- return status;
+ return RegistryCreateKey(NULL, &RegistryPath, REG_OPTION_NON_VOLATILE,
Key);
}
-_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
RegistryOpenSoftwareKey(
_In_ PDEVICE_OBJECT DeviceObject,
@@ -365,7 +359,6 @@ fail1:
return status;
}
-_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
RegistryOpenHardwareKey(
_In_ PDEVICE_OBJECT DeviceObject,
@@ -376,7 +369,7 @@ RegistryOpenHardwareKey(
HANDLE SubKey;
ULONG Length;
PKEY_NAME_INFORMATION Info;
- PWCHAR Cursor;
+ PWSTR Cursor;
UNICODE_STRING Unicode;
NTSTATUS status;
@@ -393,11 +386,11 @@ RegistryOpenHardwareKey(
NULL,
0,
&Length);
- if (status != STATUS_BUFFER_OVERFLOW &&
+ if (!NT_SUCCESS(status) &&
+ status != STATUS_BUFFER_OVERFLOW &&
status != STATUS_BUFFER_TOO_SMALL)
goto fail2;
-#pragma prefast(suppress:6102)
Info = __RegistryAllocate(Length + sizeof (WCHAR));
status = STATUS_NO_MEMORY;
@@ -418,7 +411,7 @@ RegistryOpenHardwareKey(
ASSERT(Cursor != NULL);
*Cursor = L'\0';
-
+
RtlInitUnicodeString(&Unicode, Info->Name);
status = RegistryOpenKey(NULL, &Unicode, DesiredAccess, Key);
@@ -443,10 +436,9 @@ fail1:
return status;
}
-_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
RegistryOpenSubKey(
- _In_ PHANDLE Key,
+ _In_opt_ PHANDLE Key,
_In_ PSTR Name,
_In_ ACCESS_MASK DesiredAccess,
_Out_ PHANDLE SubKey
@@ -477,10 +469,9 @@ fail1:
return status;
}
-_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
RegistryCreateSubKey(
- _In_ PHANDLE Key,
+ _In_opt_ HANDLE Key,
_In_ PSTR Name,
_In_ ULONG Options,
_Out_ PHANDLE SubKey
@@ -511,7 +502,6 @@ fail1:
return status;
}
-_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
RegistryDeleteSubKey(
_In_ PHANDLE Key,
@@ -539,8 +529,6 @@ RegistryDeleteSubKey(
ZwClose(SubKey);
- (VOID) ZwFlushKey(Key);
-
RtlFreeUnicodeString(&Unicode);
return STATUS_SUCCESS;
@@ -555,7 +543,6 @@ fail1:
return status;
}
-_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
RegistryEnumerateSubKeys(
_In_ HANDLE Key,
@@ -578,7 +565,6 @@ RegistryEnumerateSubKeys(
status != STATUS_BUFFER_TOO_SMALL)
goto fail1;
-#pragma prefast(suppress:6102)
Full = __RegistryAllocate(Size);
status = STATUS_NO_MEMORY;
@@ -629,7 +615,7 @@ RegistryEnumerateSubKeys(
status = RtlUnicodeStringToAnsiString(&Ansi, &Unicode, FALSE);
ASSERT(NT_SUCCESS(status));
- Ansi.Length = (USHORT)(strlen(Ansi.Buffer) * sizeof (CHAR));
+ Ansi.Length = (USHORT)(strlen(Ansi.Buffer) * sizeof (CHAR));
status = Callback(Context, Key, &Ansi);
@@ -654,13 +640,12 @@ fail5:
fail4:
fail3:
__RegistryFree(Full);
-
+
fail2:
fail1:
return status;
}
-_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
RegistryEnumerateValues(
_In_ HANDLE Key,
@@ -683,7 +668,6 @@ RegistryEnumerateValues(
status != STATUS_BUFFER_TOO_SMALL)
goto fail1;
-#pragma prefast(suppress:6102)
Full = __RegistryAllocate(Size);
status = STATUS_NO_MEMORY;
@@ -727,17 +711,24 @@ RegistryEnumerateValues(
Ansi.MaximumLength = (USHORT)((Basic->NameLength / sizeof (WCHAR)) +
sizeof (CHAR));
Ansi.Buffer = __RegistryAllocate(Ansi.MaximumLength);
+ status = STATUS_NO_MEMORY;
+ if (Ansi.Buffer == NULL)
+ goto fail6;
+
status = RtlUnicodeStringToAnsiString(&Ansi, &Unicode, FALSE);
- ASSERT(NT_SUCCESS(status));
+ if (!NT_SUCCESS(status)) {
+ __RegistryFree(Ansi.Buffer);
+ goto fail7;
+ }
- Ansi.Length = (USHORT)(strlen(Ansi.Buffer) * sizeof (CHAR));
+ Ansi.Length = (USHORT)(strlen(Ansi.Buffer) * sizeof (CHAR));
status = Callback(Context, Key, &Ansi, Basic->Type);
__RegistryFree(Ansi.Buffer);
if (!NT_SUCCESS(status))
- goto fail6;
+ goto fail8;
}
__RegistryFree(Basic);
@@ -746,6 +737,8 @@ RegistryEnumerateValues(
return STATUS_SUCCESS;
+fail8:
+fail7:
fail6:
fail5:
__RegistryFree(Basic);
@@ -753,13 +746,12 @@ fail5:
fail4:
fail3:
__RegistryFree(Full);
-
+
fail2:
fail1:
return status;
}
-_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
RegistryDeleteValue(
_In_ PHANDLE Key,
@@ -782,8 +774,6 @@ RegistryDeleteValue(
RtlFreeUnicodeString(&Unicode);
- (VOID) ZwFlushKey(Key);
-
return STATUS_SUCCESS;
fail2:
@@ -793,7 +783,6 @@ fail1:
return status;
}
-_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
RegistryQueryDwordValue(
_In_ HANDLE Key,
@@ -812,18 +801,18 @@ RegistryQueryDwordValue(
status = RtlAnsiStringToUnicodeString(&Unicode, &Ansi, TRUE);
if (!NT_SUCCESS(status))
goto fail1;
-
+
status = ZwQueryValueKey(Key,
&Unicode,
KeyValuePartialInformation,
NULL,
0,
&Size);
- if (status != STATUS_BUFFER_OVERFLOW &&
+ if (!NT_SUCCESS(status) &&
+ status != STATUS_BUFFER_OVERFLOW &&
status != STATUS_BUFFER_TOO_SMALL)
goto fail2;
-#pragma prefast(suppress:6102)
Partial = __RegistryAllocate(Size);
status = STATUS_NO_MEMORY;
@@ -844,7 +833,77 @@ RegistryQueryDwordValue(
Partial->DataLength != sizeof (ULONG))
goto fail5;
- *Value = *(PULONG)Partial->Data;
+ *Value = *(PULONG)Partial->Data;
+
+ __RegistryFree(Partial);
+
+ RtlFreeUnicodeString(&Unicode);
+
+ return STATUS_SUCCESS;
+
+fail5:
+fail4:
+ __RegistryFree(Partial);
+
+fail3:
+fail2:
+ RtlFreeUnicodeString(&Unicode);
+
+fail1:
+ return status;
+}
+
+NTSTATUS
+RegistryQueryQwordValue(
+ _In_ HANDLE Key,
+ _In_ PSTR Name,
+ _Out_ PULONGLONG Value
+ )
+{
+ ANSI_STRING Ansi;
+ UNICODE_STRING Unicode;
+ PKEY_VALUE_PARTIAL_INFORMATION Partial;
+ ULONG Size;
+ NTSTATUS status;
+
+ RtlInitAnsiString(&Ansi, Name);
+
+ status = RtlAnsiStringToUnicodeString(&Unicode, &Ansi, TRUE);
+ if (!NT_SUCCESS(status))
+ goto fail1;
+
+ status = ZwQueryValueKey(Key,
+ &Unicode,
+ KeyValuePartialInformation,
+ NULL,
+ 0,
+ &Size);
+ if (!NT_SUCCESS(status) &&
+ status != STATUS_BUFFER_OVERFLOW &&
+ status != STATUS_BUFFER_TOO_SMALL)
+ goto fail2;
+
+ Partial = __RegistryAllocate(Size);
+
+ status = STATUS_NO_MEMORY;
+ if (Partial == NULL)
+ goto fail3;
+
+ status = ZwQueryValueKey(Key,
+ &Unicode,
+ KeyValuePartialInformation,
+ Partial,
+ Size,
+ &Size);
+ if (!NT_SUCCESS(status))
+ goto fail4;
+
+ status = STATUS_INVALID_PARAMETER;
+ if (Partial->Type != REG_QWORD ||
+ Partial->DataLength != sizeof (ULONGLONG))
+ goto fail5;
+
+ *Value = *(PULONGLONG)Partial->Data;
__RegistryFree(Partial);
@@ -864,7 +923,6 @@ fail1:
return status;
}
-_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
RegistryUpdateDwordValue(
_In_ HANDLE Key,
@@ -882,7 +940,7 @@ RegistryUpdateDwordValue(
status = RtlAnsiStringToUnicodeString(&Unicode, &Ansi, TRUE);
if (!NT_SUCCESS(status))
goto fail1;
-
+
Partial = __RegistryAllocate(FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION,
Data) +
sizeof (ULONG));
@@ -893,7 +951,7 @@ RegistryUpdateDwordValue(
Partial->TitleIndex = 0;
Partial->Type = REG_DWORD;
Partial->DataLength = sizeof (ULONG);
- *(PULONG)Partial->Data = Value;
+ *(PULONG)Partial->Data = Value;
status = ZwSetValueKey(Key,
&Unicode,
@@ -906,8 +964,6 @@ RegistryUpdateDwordValue(
__RegistryFree(Partial);
- (VOID) ZwFlushKey(Key);
-
RtlFreeUnicodeString(&Unicode);
return STATUS_SUCCESS;
@@ -923,7 +979,6 @@ fail1:
return status;
}
-_IRQL_requires_(PASSIVE_LEVEL)
static PANSI_STRING
RegistrySzToAnsi(
_In_ PWSTR Buffer
@@ -963,7 +1018,6 @@ fail1:
return NULL;
}
-_IRQL_requires_(PASSIVE_LEVEL)
static PANSI_STRING
RegistryMultiSzToAnsi(
_In_ PWSTR Buffer
@@ -1026,7 +1080,6 @@ fail1:
return NULL;
}
-_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
RegistryQuerySzValue(
_In_ HANDLE Key,
@@ -1046,18 +1099,18 @@ RegistryQuerySzValue(
status = RtlAnsiStringToUnicodeString(&Unicode, &Ansi, TRUE);
if (!NT_SUCCESS(status))
goto fail1;
-
+
status = ZwQueryValueKey(Key,
&Unicode,
KeyValuePartialInformation,
NULL,
0,
&Size);
- if (status != STATUS_BUFFER_OVERFLOW &&
+ if (!NT_SUCCESS(status) &&
+ status != STATUS_BUFFER_OVERFLOW &&
status != STATUS_BUFFER_TOO_SMALL)
goto fail2;
-#pragma prefast(suppress:6102)
Value = __RegistryAllocate(Size);
status = STATUS_NO_MEMORY;
@@ -1076,12 +1129,12 @@ RegistryQuerySzValue(
switch (Value->Type) {
case REG_SZ:
status = STATUS_NO_MEMORY;
- *Array = RegistrySzToAnsi((PWCHAR)Value->Data);
+ *Array = RegistrySzToAnsi((PWSTR)Value->Data);
break;
case REG_MULTI_SZ:
status = STATUS_NO_MEMORY;
- *Array = RegistryMultiSzToAnsi((PWCHAR)Value->Data);
+ *Array = RegistryMultiSzToAnsi((PWSTR)Value->Data);
break;
default:
@@ -1114,13 +1167,12 @@ fail1:
return status;
}
-_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
RegistryQueryBinaryValue(
- _In_ HANDLE Key,
- _In_ PSTR Name,
- _Outptr_result_bytebuffer_(*Length) PVOID *Buffer,
- _Out_ PULONG Length
+ _In_ HANDLE Key,
+ _In_ PSTR Name,
+ _Outptr_ PVOID *Buffer,
+ _Out_ PULONG Length
)
{
ANSI_STRING Ansi;
@@ -1141,11 +1193,11 @@ RegistryQueryBinaryValue(
NULL,
0,
&Size);
- if (status != STATUS_BUFFER_OVERFLOW &&
+ if (!NT_SUCCESS(status) &&
+ status != STATUS_BUFFER_OVERFLOW &&
status != STATUS_BUFFER_TOO_SMALL)
goto fail2;
-#pragma prefast(suppress:6102)
Partial = __RegistryAllocate(Size);
status = STATUS_NO_MEMORY;
@@ -1200,12 +1252,11 @@ fail1:
return status;
}
-_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
RegistryUpdateBinaryValue(
_In_ HANDLE Key,
_In_ PSTR Name,
- _In_reads_bytes_(Length) PVOID Buffer,
+ _In_ PVOID Buffer,
_In_ ULONG Length
)
{
@@ -1243,8 +1294,6 @@ RegistryUpdateBinaryValue(
__RegistryFree(Partial);
- (VOID) ZwFlushKey(Key);
-
RtlFreeUnicodeString(&Unicode);
return STATUS_SUCCESS;
@@ -1260,7 +1309,6 @@ fail1:
return status;
}
-_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
RegistryQueryKeyName(
_In_ HANDLE Key,
@@ -1276,12 +1324,12 @@ RegistryQueryKeyName(
NULL,
0,
&Size);
- if (status != STATUS_BUFFER_OVERFLOW &&
+ if (!NT_SUCCESS(status) &&
+ status != STATUS_BUFFER_OVERFLOW &&
status != STATUS_BUFFER_TOO_SMALL)
goto fail1;
// Name information is not intrinsically NULL terminated
-#pragma prefast(suppress:6102)
Value = __RegistryAllocate(Size + sizeof (WCHAR));
status = STATUS_NO_MEMORY;
@@ -1297,7 +1345,7 @@ RegistryQueryKeyName(
goto fail3;
Value->Name[Value->NameLength / sizeof (WCHAR)] = L'\0';
- *Array = RegistrySzToAnsi((PWCHAR)Value->Name);
+ *Array = RegistrySzToAnsi((PWSTR)Value->Name);
status = STATUS_NO_MEMORY;
if (*Array == NULL)
@@ -1316,10 +1364,9 @@ fail1:
return status;
}
-_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
RegistryQuerySystemStartOption(
- _In_ PCSTR Prefix,
+ _In_ PSTR Prefix,
_Outptr_ PANSI_STRING *Value
)
{
@@ -1327,12 +1374,12 @@ RegistryQuerySystemStartOption(
HANDLE Key;
PANSI_STRING Ansi;
ULONG Length;
- PCHAR Option;
- PCHAR Context;
+ PSTR Option;
+ PSTR Context;
NTSTATUS status;
RtlInitUnicodeString(&Unicode,
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control");
-
+
status = RegistryOpenKey(NULL, &Unicode, KEY_READ, &Key);
if (!NT_SUCCESS(status))
goto fail1;
@@ -1395,10 +1442,9 @@ fail1:
return status;
}
-_IRQL_requires_(PASSIVE_LEVEL)
static PKEY_VALUE_PARTIAL_INFORMATION
RegistryAnsiToSz(
- _In_ PANSI_STRING Ansi
+ PANSI_STRING Ansi
)
{
ULONG Length;
@@ -1442,10 +1488,9 @@ fail1:
return NULL;
}
-_IRQL_requires_(PASSIVE_LEVEL)
static PKEY_VALUE_PARTIAL_INFORMATION
RegistryAnsiToMultiSz(
- _In_ PANSI_STRING Ansi
+ PANSI_STRING Ansi
)
{
ULONG Length;
@@ -1502,7 +1547,6 @@ fail1:
return NULL;
}
-_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
RegistryUpdateSzValue(
_In_ HANDLE Key,
@@ -1553,8 +1597,6 @@ RegistryUpdateSzValue(
__RegistryFree(Partial);
- (VOID) ZwFlushKey(Key);
-
RtlFreeUnicodeString(&Unicode);
return STATUS_SUCCESS;
@@ -1593,7 +1635,6 @@ RegistryFreeBinaryValue(
__RegistryFree(Buffer);
}
-_IRQL_requires_(PASSIVE_LEVEL)
VOID
RegistryCloseKey(
_In_ HANDLE Key
diff --git a/src/xenvbd/registry.h b/src/xenvbd/registry.h
index 654c919..26bc0c6 100644
--- a/src/xenvbd/registry.h
+++ b/src/xenvbd/registry.h
@@ -1,43 +1,43 @@
/* Copyright (c) Xen Project.
* Copyright (c) Cloud Software Group, Inc.
* All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
* that the following conditions are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
+ *
+ * * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the
* following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the
+ * following disclaimer in the documentation and/or other
* materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#ifndef _XENVBD_REGISTRY_H
-#define _XENVBD_REGISTRY_H
+#ifndef _COMMON_REGISTRY_H
+#define _COMMON_REGISTRY_H
#include <ntddk.h>
extern NTSTATUS
RegistryInitialize(
- _In_ PDRIVER_OBJECT DriverObject,
+ _In_opt_ PDRIVER_OBJECT DrvObj,
_In_ PUNICODE_STRING Path
);
@@ -46,7 +46,12 @@ RegistryTeardown(
VOID
);
-_IRQL_requires_(PASSIVE_LEVEL)
+extern NTSTATUS
+RegistryOpenParametersKey(
+ _In_ ACCESS_MASK DesiredAccess,
+ _Out_ PHANDLE Key
+ );
+
extern NTSTATUS
RegistryOpenKey(
_In_opt_ HANDLE Parent,
@@ -55,7 +60,6 @@ RegistryOpenKey(
_Out_ PHANDLE Key
);
-_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryCreateKey(
_In_opt_ HANDLE Parent,
@@ -64,27 +68,17 @@ RegistryCreateKey(
_Out_ PHANDLE Key
);
-_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryOpenServiceKey(
_In_ ACCESS_MASK DesiredAccess,
_Out_ PHANDLE Key
);
-_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryCreateServiceKey(
_Out_ PHANDLE Key
);
-_IRQL_requires_(PASSIVE_LEVEL)
-extern NTSTATUS
-RegistryOpenParametersKey(
- _In_ ACCESS_MASK DesiredAccess,
- _Out_ PHANDLE Key
- );
-
-_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryOpenSoftwareKey(
_In_ PDEVICE_OBJECT DeviceObject,
@@ -92,7 +86,6 @@ RegistryOpenSoftwareKey(
_Out_ PHANDLE Key
);
-_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryOpenHardwareKey(
_In_ PDEVICE_OBJECT DeviceObject,
@@ -100,32 +93,28 @@ RegistryOpenHardwareKey(
_Out_ PHANDLE Key
);
-_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryOpenSubKey(
- _In_ HANDLE Key,
+ _In_opt_ HANDLE Key,
_In_ PSTR Name,
_In_ ACCESS_MASK DesiredAccess,
_Out_ PHANDLE SubKey
);
-_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryCreateSubKey(
- _In_ HANDLE Key,
+ _In_opt_ HANDLE Key,
_In_ PSTR Name,
_In_ ULONG Options,
_Out_ PHANDLE SubKey
);
-_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryDeleteSubKey(
- _In_ HANDLE Key,
- _In_ PSTR Name
+ _In_ HANDLE Key,
+ _In_ PSTR Name
);
-_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryEnumerateSubKeys(
_In_ HANDLE Key,
@@ -133,7 +122,6 @@ RegistryEnumerateSubKeys(
_In_ PVOID Context
);
-_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryEnumerateValues(
_In_ HANDLE Key,
@@ -141,30 +129,33 @@ RegistryEnumerateValues(
_In_ PVOID Context
);
-_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryDeleteValue(
- _In_ HANDLE Key,
- _In_ PSTR Name
+ _In_ HANDLE Key,
+ _In_ PSTR Name
);
-_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryQueryDwordValue(
- _In_ HANDLE Key,
- _In_ PSTR Name,
- _Out_ PULONG Value
+ _In_ HANDLE Key,
+ _In_ PSTR Name,
+ _Out_ PULONG Value
+ );
+
+extern NTSTATUS
+RegistryQueryQwordValue(
+ _In_ HANDLE Key,
+ _In_ PSTR Name,
+ _Out_ PULONGLONG Value
);
-_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryUpdateDwordValue(
- _In_ HANDLE Key,
- _In_ PSTR Name,
- _In_ ULONG Value
+ _In_ HANDLE Key,
+ _In_ PSTR Name,
+ _In_ ULONG Value
);
-_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryQuerySzValue(
_In_ HANDLE Key,
@@ -173,35 +164,31 @@ RegistryQuerySzValue(
_Outptr_ PANSI_STRING *Array
);
-_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryQueryBinaryValue(
- _In_ HANDLE Key,
- _In_ PSTR Name,
- _Outptr_result_bytebuffer_(*Length) PVOID *Buffer,
- _Out_ PULONG Length
+ _In_ HANDLE Key,
+ _In_ PSTR Name,
+ _Outptr_ PVOID *Buffer,
+ _Out_ PULONG Length
);
-_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryUpdateBinaryValue(
- _In_ HANDLE Key,
- _In_ PSTR Name,
- _In_reads_bytes_(Length) PVOID Buffer,
- _In_ ULONG Length
+ _In_ HANDLE Key,
+ _In_ PSTR Name,
+ _In_ PVOID Buffer,
+ _In_ ULONG Length
);
-_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryQueryKeyName(
_In_ HANDLE Key,
_Outptr_ PANSI_STRING *Array
);
-_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryQuerySystemStartOption(
- _In_ PCSTR Prefix,
+ _In_ PSTR Name,
_Outptr_ PANSI_STRING *Option
);
@@ -212,10 +199,9 @@ RegistryFreeSzValue(
extern VOID
RegistryFreeBinaryValue(
- _In_ PVOID Buffer
+ _In_ PVOID Buffer
);
-_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryUpdateSzValue(
_In_ HANDLE Key,
@@ -224,10 +210,9 @@ RegistryUpdateSzValue(
_In_ PANSI_STRING Array
);
-_IRQL_requires_(PASSIVE_LEVEL)
extern VOID
RegistryCloseKey(
_In_ HANDLE Key
);
-#endif // _XENVBD_REGISTRY_H
+#endif // _COMMON_REGISTRY_H
--
2.55.0.windows.5
--
Césaire Mounah | Vates Windows Guest Tools Engineer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |