]> xenbits.xensource.com Git - pvdrivers/win/xenbus.git/commitdiff
Move Registry operations to xen.sys
authorOwen Smith <owen.smith@cloud.com>
Fri, 7 Jun 2024 07:16:59 +0000 (08:16 +0100)
committerPaul Durrant <pdurrant@amazon.com>
Mon, 1 Jul 2024 08:49:50 +0000 (09:49 +0100)
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@cloud.com>
include/xen.h
src/xen/config.c [new file with mode: 0644]
src/xenbus/driver.c
src/xenbus/driver.h
src/xenbus/fdo.c
vs2019/xen/xen.vcxproj
vs2022/xen/xen.vcxproj

index 566d9e3848a3ab23067328779964cb1211d8b8e4..a874ed1083834ec80ea76eada7f5237133ffec9c 100644 (file)
@@ -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 (file)
index 0000000..e600732
--- /dev/null
@@ -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);
+}
index e8d0c1fe04b33ed006e962a70dfb621f34e08ad3..4aae2cca1b888f09336c1470e8b1a79c9c56b394 100644 (file)
@@ -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;
index 7cd5add8033426246f583a5dd5df4f895db040b6..99290e0cea740ec1b18beddc39b33fa6bb3aec3a 100644 (file)
@@ -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;
 
index 429933c6849e38b19e3e16631aab01d701e01071..3a4a1a2a3f1449361b4cf8d3986cc0550192cec8 100644 (file)
@@ -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;
 
index ec0f7e1aa12190e94cec98a655d74e14018085db..08d18f608721bd685b938109ddebfb390eee8b2b 100644 (file)
@@ -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" />
index 7efdce89e656f5e3a539e7a9ff6911d1346b8a89..f85726927a8ed6c494c9f81959a9e3a9f5a5c3c5 100644 (file)
@@ -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" />