[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [RFC PATCH 4/5] Move Registry operations to xen.sys
Driver Verifier's registry isolation rules are not applied to xen.sys during WHQL testing. Move remaining operations that do not comply to xen.sys. Operations related to Active Device, Reboot Requests and SystemStartOptions are exposed by xen.sys to allow xenbus.sys and other drivers to successfully execute with Driver Verifier enabled. Signed-off-by: Owen Smith <owen.smith@xxxxxxxxx> --- include/xen.h | 45 ++++ src/xen/config.c | 497 +++++++++++++++++++++++++++++++++++++++++ src/xenbus/driver.c | 448 +------------------------------------ src/xenbus/driver.h | 30 --- src/xenbus/fdo.c | 12 +- vs2019/xen/xen.vcxproj | 1 + vs2022/xen/xen.vcxproj | 1 + 7 files changed, 551 insertions(+), 483 deletions(-) create mode 100644 src/xen/config.c diff --git a/include/xen.h b/include/xen.h index 566d9e3..a874ed1 100644 --- a/include/xen.h +++ b/include/xen.h @@ -540,4 +540,49 @@ FiltersUninstall( VOID ); +// CONFIG + +XEN_API +NTSTATUS +ConfigGetActive( + IN const CHAR *Key, + OUT PCHAR *Value + ); + +XEN_API +NTSTATUS +ConfigSetActive( + IN PCHAR DeviceID, + IN PCHAR InstanceID, + IN PCHAR LocationInformation + ); + +XEN_API +NTSTATUS +ConfigUpdateActive( + IN PCHAR DeviceID, + IN PCHAR InstanceID, + IN PCHAR LocationInformation + ); + +XEN_API +NTSTATUS +ConfigClearActive( + VOID + ); + +XEN_API +NTSTATUS +ConfigRequestReboot( + IN HANDLE ParametersKey, + IN PCHAR Module + ); + +XEN_API +NTSTATUS +ConfigQuerySystemStartOption( + IN PCHAR Key, + OUT PANSI_STRING *Option + ); + #endif // _XEN_H diff --git a/src/xen/config.c b/src/xen/config.c new file mode 100644 index 0000000..e600732 --- /dev/null +++ b/src/xen/config.c @@ -0,0 +1,497 @@ +/* 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 + * that the following conditions are met: + * + * * 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 + * 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 + * SUCH DAMAGE. + */ + +#define XEN_API __declspec(dllexport) + +#define INITGUID 1 + +#include <ntddk.h> +#include <ntstrsafe.h> +#include <devguid.h> +#include <xen.h> + +#include "registry.h" +#include "driver.h" +#include "dbg_print.h" +#include "assert.h" +#include "util.h" + +#define MAXNAMELEN 128 + +// +// The canonical location for active device information is the XENFILT +// Parameters key. +// +#define ACTIVE_PATH "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services\\XENFILT\\Parameters" + +XEN_API +NTSTATUS +ConfigGetActive( + IN const CHAR *Key, + OUT PCHAR *Value + ) +{ + HANDLE ActiveKey; + CHAR Name[MAXNAMELEN]; + PANSI_STRING Ansi; + ULONG Length; + NTSTATUS status; + + Trace("====>\n"); + + ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL); + + status = RegistryOpenSubKey(NULL, + ACTIVE_PATH, + KEY_READ, + &ActiveKey); + if (!NT_SUCCESS(status)) + goto fail1; + + status = RtlStringCbPrintfA(Name, MAXNAMELEN, "Active%s", Key); + ASSERT(NT_SUCCESS(status)); + + status = RegistryQuerySzValue(ActiveKey, + Name, + NULL, + &Ansi); + if (!NT_SUCCESS(status)) + goto fail2; + + Length = Ansi[0].Length + sizeof (CHAR); + *Value = __AllocatePoolWithTag(PagedPool, Length, 'SUB'); + + status = STATUS_NO_MEMORY; + if (*Value == NULL) + goto fail3; + + status = RtlStringCbPrintfA(*Value, + Length, + "%Z", + &Ansi[0]); + ASSERT(NT_SUCCESS(status)); + + RegistryFreeSzValue(Ansi); + + RegistryCloseKey(ActiveKey); + + Trace("<====\n"); + + return STATUS_SUCCESS; + +fail3: + Error("fail3\n"); + +fail2: + if (status != STATUS_OBJECT_NAME_NOT_FOUND) + Error("fail2\n"); + + RegistryCloseKey(ActiveKey); + +fail1: + if (status != STATUS_OBJECT_NAME_NOT_FOUND) + Error("fail1 (%08x)\n", status); + + return status; +} + +static FORCEINLINE BOOLEAN +__ConfigIsDeviceLegacy( + IN PCHAR DeviceID + ) +{ + UNREFERENCED_PARAMETER(DeviceID); + +#ifdef VENDOR_DEVICE_ID_STR + const CHAR *VendorDeviceID = "PCI\\VEN_5853&DEV_" VENDOR_DEVICE_ID_STR; + + return _strnicmp(DeviceID, VendorDeviceID, strlen(VendorDeviceID)) != 0; +#endif + + return TRUE; +} + +#define ENUM_PATH "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Enum" + +static FORCEINLINE BOOLEAN +__ConfigIsVendorDevicePresent( + VOID + ) +{ +#ifdef VENDOR_DEVICE_ID_STR + HANDLE EnumKey; + HANDLE DeviceKey; + BOOLEAN Found; + NTSTATUS status; + const CHAR *VendorDeviceID = "PCI\\VEN_5853&DEV_" VENDOR_DEVICE_ID_STR "&SUBSYS_C0005853&REV_01"; + + status = RegistryOpenSubKey(NULL, + ENUM_PATH, + KEY_READ, + &EnumKey); + if (!NT_SUCCESS(status)) + goto fail1; + + Found = FALSE; + + status = RegistryOpenSubKey(EnumKey, + (PCHAR)VendorDeviceID, + KEY_READ, + &DeviceKey); + if (!NT_SUCCESS(status)) + goto done; + + RegistryCloseKey(DeviceKey); + Found = TRUE; + +done: + RegistryCloseKey(EnumKey); + + return Found; + +fail1: + Error("fail1 (%08x)\n", status); + +#endif + return FALSE; +} + +XEN_API +NTSTATUS +ConfigSetActive( + IN PCHAR DeviceID, + IN PCHAR InstanceID, + IN PCHAR LocationInformation + ) +{ + HANDLE ActiveKey; + ANSI_STRING Ansi[2]; + NTSTATUS status; + + Trace("====>\n"); + + ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL); + + status = RegistryOpenSubKey(NULL, + ACTIVE_PATH, + KEY_ALL_ACCESS, + &ActiveKey); + if (!NT_SUCCESS(status)) + goto fail1; + + status = STATUS_UNSUCCESSFUL; + if (__ConfigIsDeviceLegacy(DeviceID) && + __ConfigIsVendorDevicePresent()) + goto fail2; + + RtlZeroMemory(Ansi, sizeof (ANSI_STRING) * 2); + + RtlInitAnsiString(&Ansi[0], DeviceID); + + status = RegistryUpdateSzValue(ActiveKey, + "ActiveDeviceID", + REG_SZ, + Ansi); + if (!NT_SUCCESS(status)) + goto fail3; + + RtlInitAnsiString(&Ansi[0], InstanceID); + + status = RegistryUpdateSzValue(ActiveKey, + "ActiveInstanceID", + REG_SZ, + Ansi); + if (!NT_SUCCESS(status)) + goto fail4; + + RtlInitAnsiString(&Ansi[0], LocationInformation); + + status = RegistryUpdateSzValue(ActiveKey, + "ActiveLocationInformation", + REG_SZ, + Ansi); + if (!NT_SUCCESS(status)) + goto fail5; + + Info("%s\\%s: %s\n", DeviceID, InstanceID, LocationInformation); + + RegistryCloseKey(ActiveKey); + + Trace("<====\n"); + + return STATUS_SUCCESS; + +fail5: + Error("fail5\n"); + +fail4: + Error("fail4\n"); + +fail3: + Error("fail3\n"); + +fail2: + Error("fail2\n"); + + RegistryCloseKey(ActiveKey); + +fail1: + Error("fail1 (%08x)\n", status); + + return status; +} + +XEN_API +NTSTATUS +ConfigUpdateActive( + IN PCHAR DeviceID, + IN PCHAR InstanceID, + IN PCHAR LocationInformation + ) +{ + HANDLE ActiveKey; + ANSI_STRING Ansi[2]; + PCHAR ActiveInstanceID; + PCHAR ActiveLocationInformation; + NTSTATUS status; + + Trace("====>\n"); + + ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL); + + status = RegistryOpenSubKey(NULL, + ACTIVE_PATH, + KEY_ALL_ACCESS, + &ActiveKey); + if (!NT_SUCCESS(status)) + goto fail1; + + status = STATUS_UNSUCCESSFUL; + if (__ConfigIsDeviceLegacy(DeviceID) && + __ConfigIsVendorDevicePresent()) + goto fail2; + + RtlZeroMemory(Ansi, sizeof (ANSI_STRING) * 2); + + status = ConfigGetActive("InstanceID", &ActiveInstanceID); + if (NT_SUCCESS(status)) { + ExFreePool(ActiveInstanceID); + } else { + RtlInitAnsiString(&Ansi[0], InstanceID); + + status = RegistryUpdateSzValue(ActiveKey, + "ActiveInstanceID", + REG_SZ, + Ansi); + if (!NT_SUCCESS(status)) + goto fail3; + } + + status = ConfigGetActive("LocationInformation", &ActiveLocationInformation); + if (NT_SUCCESS(status)) { + ExFreePool(ActiveLocationInformation); + } else { + RtlInitAnsiString(&Ansi[0], LocationInformation); + + status = RegistryUpdateSzValue(ActiveKey, + "ActiveLocationInformation", + REG_SZ, + Ansi); + if (!NT_SUCCESS(status)) + goto fail4; + } + + Info("%s\\%s: %s\n", DeviceID, InstanceID, LocationInformation); + + RegistryCloseKey(ActiveKey); + + Trace("<====\n"); + + return STATUS_SUCCESS; + +fail4: + Error("fail4\n"); + +fail3: + Error("fail3\n"); + +fail2: + Error("fail2\n"); + + RegistryCloseKey(ActiveKey); + +fail1: + Error("fail1 (%08x)\n", status); + + return status; +} + +XEN_API +NTSTATUS +ConfigClearActive( + VOID + ) +{ + HANDLE ActiveKey; + NTSTATUS status; + + Trace("====>\n"); + + ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL); + + status = RegistryOpenSubKey(NULL, + ACTIVE_PATH, + KEY_ALL_ACCESS, + &ActiveKey); + if (!NT_SUCCESS(status)) + goto fail1; + + status = RegistryDeleteValue(ActiveKey, + "ActiveDeviceID"); + if (!NT_SUCCESS(status)) + goto fail2; + + status = RegistryDeleteValue(ActiveKey, + "ActiveInstanceID"); + if (!NT_SUCCESS(status)) + goto fail3; + + Info("DONE\n"); + + RegistryCloseKey(ActiveKey); + + Trace("<====\n"); + + return STATUS_SUCCESS; + +fail3: + Error("fail3\n"); + +fail2: + Error("fail2\n"); + + RegistryCloseKey(ActiveKey); + +fail1: + Error("fail1 (%08x)\n", status); + + return status; +} + +XEN_API +NTSTATUS +ConfigRequestReboot( + IN HANDLE ParametersKey, + IN PCHAR Module + ) +{ + PANSI_STRING Ansi; + CHAR RequestKeyName[MAXNAMELEN]; + HANDLE RequestKey; + HANDLE SubKey; + NTSTATUS status; + + Info("====>\n"); + + ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL); + + status = RegistryQuerySzValue(ParametersKey, + "RequestKey", + NULL, + &Ansi); + if (!NT_SUCCESS(status)) + goto fail1; + + status = RtlStringCbPrintfA(RequestKeyName, + MAXNAMELEN, + "\\Registry\\Machine\\%Z", + &Ansi[0]); + ASSERT(NT_SUCCESS(status)); + + status = RegistryCreateSubKey(NULL, + RequestKeyName, + REG_OPTION_NON_VOLATILE, + &RequestKey); + if (!NT_SUCCESS(status)) + goto fail2; + + status = RegistryCreateSubKey(RequestKey, + Module, + REG_OPTION_VOLATILE, + &SubKey); + if (!NT_SUCCESS(status)) + goto fail3; + + status = RegistryUpdateDwordValue(SubKey, + "Reboot", + 1); + if (!NT_SUCCESS(status)) + goto fail4; + + RegistryCloseKey(SubKey); + + RegistryFreeSzValue(Ansi); + + Info("<====\n"); + + return STATUS_SUCCESS; + +fail4: + Error("fail4\n"); + + RegistryCloseKey(SubKey); + +fail3: + Error("fail3\n"); + + RegistryCloseKey(RequestKey); + +fail2: + Error("fail2\n"); + + RegistryFreeSzValue(Ansi); + +fail1: + Error("fail1 (%08x)\n", status); + + return status; +} + +XEN_API +NTSTATUS +ConfigQuerySystemStartOption( + IN PCHAR Key, + OUT PANSI_STRING *Option + ) +{ + return RegistryQuerySystemStartOption(Key, Option); +} diff --git a/src/xenbus/driver.c b/src/xenbus/driver.c index e8d0c1f..4aae2cc 100644 --- a/src/xenbus/driver.c +++ b/src/xenbus/driver.c @@ -149,83 +149,6 @@ DriverGetConsoleLogLevel( return __DriverGetConsoleLogLevel(); } -#define MAXNAMELEN 128 - -static FORCEINLINE VOID -__DriverRequestReboot( - VOID - ) -{ - PANSI_STRING Ansi; - CHAR RequestKeyName[MAXNAMELEN]; - HANDLE RequestKey; - HANDLE SubKey; - NTSTATUS status; - - Info("====>\n"); - - ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL); - - status = RegistryQuerySzValue(__DriverGetParametersKey(), - "RequestKey", - NULL, - &Ansi); - if (!NT_SUCCESS(status)) - goto fail1; - - status = RtlStringCbPrintfA(RequestKeyName, - MAXNAMELEN, - "\\Registry\\Machine\\%Z", - &Ansi[0]); - ASSERT(NT_SUCCESS(status)); - - status = RegistryCreateSubKey(NULL, - RequestKeyName, - REG_OPTION_NON_VOLATILE, - &RequestKey); - if (!NT_SUCCESS(status)) - goto fail2; - - status = RegistryCreateSubKey(RequestKey, - __MODULE__, - REG_OPTION_VOLATILE, - &SubKey); - if (!NT_SUCCESS(status)) - goto fail3; - - status = RegistryUpdateDwordValue(SubKey, - "Reboot", - 1); - if (!NT_SUCCESS(status)) - goto fail4; - - RegistryCloseKey(SubKey); - - RegistryFreeSzValue(Ansi); - - Info("<====\n"); - - return; - -fail4: - Error("fail4\n"); - - RegistryCloseKey(SubKey); - -fail3: - Error("fail3\n"); - - RegistryCloseKey(RequestKey); - -fail2: - Error("fail2\n"); - - RegistryFreeSzValue(Ansi); - -fail1: - Error("fail1 (%08x)\n", status); -} - static FORCEINLINE VOID __DriverAcquireMutex( VOID @@ -299,375 +222,6 @@ DriverRemoveFunctionDeviceObject( FiltersUninstall(); } -// -// The canonical location for active device information is the XENFILT -// Parameters key. -// -#define ACTIVE_PATH "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services\\XENFILT\\Parameters" - -NTSTATUS -DriverGetActive( - IN const CHAR *Key, - OUT PCHAR *Value - ) -{ - HANDLE ActiveKey; - CHAR Name[MAXNAMELEN]; - PANSI_STRING Ansi; - ULONG Length; - NTSTATUS status; - - Trace("====>\n"); - - ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL); - - status = RegistryOpenSubKey(NULL, - ACTIVE_PATH, - KEY_READ, - &ActiveKey); - if (!NT_SUCCESS(status)) - goto fail1; - - status = RtlStringCbPrintfA(Name, MAXNAMELEN, "Active%s", Key); - ASSERT(NT_SUCCESS(status)); - - status = RegistryQuerySzValue(ActiveKey, - Name, - NULL, - &Ansi); - if (!NT_SUCCESS(status)) - goto fail2; - - Length = Ansi[0].Length + sizeof (CHAR); - *Value = __AllocatePoolWithTag(PagedPool, Length, 'SUB'); - - status = STATUS_NO_MEMORY; - if (*Value == NULL) - goto fail3; - - status = RtlStringCbPrintfA(*Value, - Length, - "%Z", - &Ansi[0]); - ASSERT(NT_SUCCESS(status)); - - RegistryFreeSzValue(Ansi); - - RegistryCloseKey(ActiveKey); - - Trace("<====\n"); - - return STATUS_SUCCESS; - -fail3: - Error("fail3\n"); - -fail2: - if (status != STATUS_OBJECT_NAME_NOT_FOUND) - Error("fail2\n"); - - RegistryCloseKey(ActiveKey); - -fail1: - if (status != STATUS_OBJECT_NAME_NOT_FOUND) - Error("fail1 (%08x)\n", status); - - return status; -} - -static const CHAR *DriverLegacyDevicePrefix[] = { - "PCI\\VEN_5853&DEV_0001", - "PCI\\VEN_5853&DEV_0002" -}; - -static FORCEINLINE BOOLEAN -__DriverIsDeviceLegacy( - IN PCHAR DeviceID - ) -{ - ULONG Index; - - for (Index = 0; Index < ARRAYSIZE(DriverLegacyDevicePrefix); Index++) { - const CHAR *Prefix = DriverLegacyDevicePrefix[Index]; - - if (_strnicmp(DeviceID, Prefix, strlen(Prefix)) == 0) - return TRUE; - } - - return FALSE; -} - -static const CHAR *DriverVendorDeviceID = -#ifdef VENDOR_DEVICE_ID_STR - "PCI\\VEN_5853&DEV_" VENDOR_DEVICE_ID_STR "&SUBSYS_C0005853&REV_01"; -#else - NULL; -#endif - -#define ENUM_PATH "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Enum" - -static FORCEINLINE BOOLEAN -__DriverIsVendorDevicePresent( - VOID - ) -{ - HANDLE EnumKey; - HANDLE DeviceKey; - BOOLEAN Found; - NTSTATUS status; - - if (DriverVendorDeviceID == NULL) - return FALSE; - - status = RegistryOpenSubKey(NULL, - ENUM_PATH, - KEY_READ, - &EnumKey); - if (!NT_SUCCESS(status)) - goto fail1; - - Found = FALSE; - - status = RegistryOpenSubKey(EnumKey, - (PCHAR)DriverVendorDeviceID, - KEY_READ, - &DeviceKey); - if (!NT_SUCCESS(status)) - goto done; - - RegistryCloseKey(DeviceKey); - Found = TRUE; - -done: - RegistryCloseKey(EnumKey); - - return Found; - -fail1: - Error("fail1 (%08x)\n", status); - - return FALSE; -} - -NTSTATUS -DriverSetActive( - IN PCHAR DeviceID, - IN PCHAR InstanceID, - IN PCHAR LocationInformation - ) -{ - HANDLE ActiveKey; - ANSI_STRING Ansi[2]; - NTSTATUS status; - - Trace("====>\n"); - - ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL); - - status = RegistryOpenSubKey(NULL, - ACTIVE_PATH, - KEY_ALL_ACCESS, - &ActiveKey); - if (!NT_SUCCESS(status)) - goto fail1; - - status = STATUS_UNSUCCESSFUL; - if (__DriverIsDeviceLegacy(DeviceID) && - __DriverIsVendorDevicePresent()) - goto fail2; - - RtlZeroMemory(Ansi, sizeof (ANSI_STRING) * 2); - - RtlInitAnsiString(&Ansi[0], DeviceID); - - status = RegistryUpdateSzValue(ActiveKey, - "ActiveDeviceID", - REG_SZ, - Ansi); - if (!NT_SUCCESS(status)) - goto fail3; - - RtlInitAnsiString(&Ansi[0], InstanceID); - - status = RegistryUpdateSzValue(ActiveKey, - "ActiveInstanceID", - REG_SZ, - Ansi); - if (!NT_SUCCESS(status)) - goto fail4; - - RtlInitAnsiString(&Ansi[0], LocationInformation); - - status = RegistryUpdateSzValue(ActiveKey, - "ActiveLocationInformation", - REG_SZ, - Ansi); - if (!NT_SUCCESS(status)) - goto fail5; - - Info("%s\\%s: %s\n", DeviceID, InstanceID, LocationInformation); - - RegistryCloseKey(ActiveKey); - - Trace("<====\n"); - - return STATUS_SUCCESS; - -fail5: - Error("fail5\n"); - -fail4: - Error("fail4\n"); - -fail3: - Error("fail3\n"); - -fail2: - Error("fail2\n"); - - RegistryCloseKey(ActiveKey); - -fail1: - Error("fail1 (%08x)\n", status); - - return status; -} - -NTSTATUS -DriverUpdateActive( - IN PCHAR DeviceID, - IN PCHAR InstanceID, - IN PCHAR LocationInformation - ) -{ - HANDLE ActiveKey; - ANSI_STRING Ansi[2]; - PCHAR ActiveInstanceID; - PCHAR ActiveLocationInformation; - NTSTATUS status; - - Trace("====>\n"); - - ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL); - - status = RegistryOpenSubKey(NULL, - ACTIVE_PATH, - KEY_ALL_ACCESS, - &ActiveKey); - if (!NT_SUCCESS(status)) - goto fail1; - - status = STATUS_UNSUCCESSFUL; - if (__DriverIsDeviceLegacy(DeviceID) && - __DriverIsVendorDevicePresent()) - goto fail2; - - RtlZeroMemory(Ansi, sizeof (ANSI_STRING) * 2); - - status = DriverGetActive("InstanceID", &ActiveInstanceID); - if (NT_SUCCESS(status)) { - ExFreePool(ActiveInstanceID); - } else { - RtlInitAnsiString(&Ansi[0], InstanceID); - - status = RegistryUpdateSzValue(ActiveKey, - "ActiveInstanceID", - REG_SZ, - Ansi); - if (!NT_SUCCESS(status)) - goto fail3; - } - - status = DriverGetActive("LocationInformation", &ActiveLocationInformation); - if (NT_SUCCESS(status)) { - ExFreePool(ActiveLocationInformation); - } else { - RtlInitAnsiString(&Ansi[0], LocationInformation); - - status = RegistryUpdateSzValue(ActiveKey, - "ActiveLocationInformation", - REG_SZ, - Ansi); - if (!NT_SUCCESS(status)) - goto fail4; - } - - Info("%s\\%s: %s\n", DeviceID, InstanceID, LocationInformation); - - RegistryCloseKey(ActiveKey); - - Trace("<====\n"); - - return STATUS_SUCCESS; - -fail4: - Error("fail4\n"); - -fail3: - Error("fail3\n"); - -fail2: - Error("fail2\n"); - - RegistryCloseKey(ActiveKey); - -fail1: - Error("fail1 (%08x)\n", status); - - return status; -} - -NTSTATUS -DriverClearActive( - VOID - ) -{ - HANDLE ActiveKey; - NTSTATUS status; - - Trace("====>\n"); - - ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL); - - status = RegistryOpenSubKey(NULL, - ACTIVE_PATH, - KEY_ALL_ACCESS, - &ActiveKey); - if (!NT_SUCCESS(status)) - goto fail1; - - status = RegistryDeleteValue(ActiveKey, - "ActiveDeviceID"); - if (!NT_SUCCESS(status)) - goto fail2; - - status = RegistryDeleteValue(ActiveKey, - "ActiveInstanceID"); - if (!NT_SUCCESS(status)) - goto fail3; - - Info("DONE\n"); - - RegistryCloseKey(ActiveKey); - - Trace("<====\n"); - - return STATUS_SUCCESS; - -fail3: - Error("fail3\n"); - -fail2: - Error("fail2\n"); - - RegistryCloseKey(ActiveKey); - -fail1: - Error("fail1 (%08x)\n", status); - - return status; -} - DRIVER_UNLOAD DriverUnload; VOID @@ -867,7 +421,7 @@ DriverEntry( // Insert XenFilt to avoid a 2nd reboot in upgrade cases, as AddDevice // will not be called to insert XenFilt. FiltersInstall(); - __DriverRequestReboot(); + ConfigRequestReboot(DriverGetParametersKey(), __MODULE__); } goto done; diff --git a/src/xenbus/driver.h b/src/xenbus/driver.h index 7cd5add..99290e0 100644 --- a/src/xenbus/driver.h +++ b/src/xenbus/driver.h @@ -50,11 +50,6 @@ DriverGetConsoleLogLevel( VOID ); -extern VOID -DriverRequestReboot( - VOID - ); - extern VOID DriverAcquireMutex( VOID @@ -65,31 +60,6 @@ DriverReleaseMutex( VOID ); -extern NTSTATUS -DriverGetActive( - IN const CHAR *Key, - OUT PCHAR *Value - ); - -NTSTATUS -DriverSetActive( - IN PCHAR DeviceID, - IN PCHAR InstanceID, - IN PCHAR LocationInformation - ); - -NTSTATUS -DriverUpdateActive( - IN PCHAR DeviceID, - IN PCHAR InstanceID, - IN PCHAR LocationInformation - ); - -NTSTATUS -DriverClearActive( - VOID - ); - typedef struct _XENBUS_FDO XENBUS_FDO, *PXENBUS_FDO; typedef struct _XENBUS_PDO XENBUS_PDO, *PXENBUS_PDO; diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c index 429933c..3a4a1a2 100644 --- a/src/xenbus/fdo.c +++ b/src/xenbus/fdo.c @@ -765,16 +765,16 @@ FdoSetActive( if (!NT_SUCCESS(status)) goto fail3; - status = DriverGetActive("DeviceID", &ActiveDeviceID); + status = ConfigGetActive("DeviceID", &ActiveDeviceID); if (NT_SUCCESS(status)) { Fdo->Active = (_stricmp(DeviceID, ActiveDeviceID) == 0) ? TRUE : FALSE; if (Fdo->Active) - (VOID) DriverUpdateActive(DeviceID, InstanceID, LocationInformation); + (VOID) ConfigUpdateActive(DeviceID, InstanceID, LocationInformation); ExFreePool(ActiveDeviceID); } else { - status = DriverSetActive(DeviceID, InstanceID, LocationInformation); + status = ConfigSetActive(DeviceID, InstanceID, LocationInformation); if (NT_SUCCESS(status)) Fdo->Active = TRUE; } @@ -806,7 +806,7 @@ FdoClearActive( IN PXENBUS_FDO Fdo ) { - (VOID) DriverClearActive(); + (VOID) ConfigClearActive(); Fdo->Active = FALSE; } @@ -5626,7 +5626,7 @@ FdoBalloonInitialize( Enabled = TRUE; - status = RegistryQuerySystemStartOption(Key, &Option); + status = ConfigQuerySystemStartOption(Key, &Option); if (!NT_SUCCESS(status)) goto done; @@ -5667,7 +5667,7 @@ FdoSetWatchdog( ULONG Value; NTSTATUS status; - status = RegistryQuerySystemStartOption(Key, &Option); + status = ConfigQuerySystemStartOption(Key, &Option); if (!NT_SUCCESS(status)) return; diff --git a/vs2019/xen/xen.vcxproj b/vs2019/xen/xen.vcxproj index ec0f7e1..08d18f6 100644 --- a/vs2019/xen/xen.vcxproj +++ b/vs2019/xen/xen.vcxproj @@ -68,6 +68,7 @@ </ItemGroup> <ItemGroup> <ClCompile Include="..\..\src\common\registry.c" /> + <ClCompile Include="..\..\src\xen\config.c" /> <ClCompile Include="..\..\src\xen\driver.c" /> <ClCompile Include="..\..\src\xen\event_channel.c" /> <ClCompile Include="..\..\src\xen\filters.c" /> diff --git a/vs2022/xen/xen.vcxproj b/vs2022/xen/xen.vcxproj index 7efdce8..f857269 100644 --- a/vs2022/xen/xen.vcxproj +++ b/vs2022/xen/xen.vcxproj @@ -63,6 +63,7 @@ </ItemGroup> <ItemGroup> <ClCompile Include="..\..\src\common\registry.c" /> + <ClCompile Include="..\..\src\xen\config.c" /> <ClCompile Include="..\..\src\xen\driver.c" /> <ClCompile Include="..\..\src\xen\event_channel.c" /> <ClCompile Include="..\..\src\xen\filters.c" /> -- 2.44.0.windows.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |