]> xenbits.xensource.com Git - pvdrivers/win/xenbus.git/commitdiff
Conditionally use IoOpenDriverRegistryKey
authorOwen Smith <owen.smith@cloud.com>
Mon, 1 Jul 2024 10:32:41 +0000 (11:32 +0100)
committerPaul Durrant <pdurrant@amazon.com>
Tue, 2 Jul 2024 08:36:16 +0000 (09:36 +0100)
IoOpenDriverRegistryKey is not available in Server 2016 and Windows 10 before 1803.
Use a conditinal to modify the RegistryOpenParametersKey function to use the
correct API to open the parameters key.
Set '#define VERIFIER_REG_ISOLATION' when compiling for Server 2025, and do not
include this definition when compiling to include support for Server 2016.

Signed-off-by: Owen Smith <owen.smith@cloud.com>
src/common/registry.c

index 3f45a238a4e2bb07874ae917fd2b85b1f7d15d2f..211c177f41eaf85db86fb3d3c01c3dde84a5246e 100644 (file)
@@ -100,11 +100,38 @@ RegistryOpenParametersKey(
     OUT PHANDLE         Key
     )
 {
+#ifdef VERIFIER_REG_ISOLATION
     return IoOpenDriverRegistryKey(RegistryDriverObject,
                                    DriverRegKeyParameters,
                                    DesiredAccess,
                                    0,
                                    Key);
+#else
+    HANDLE              ServiceKey;
+    NTSTATUS            status;
+
+    status = RegistryOpenKey(NULL, &RegistryPath, DesiredAccess, &ServiceKey);
+    if (!NT_SUCCESS(status))
+        goto fail1;
+
+    status = RegistryOpenSubKey(ServiceKey, "Parameters", DesiredAccess, Key);
+    if (!NT_SUCCESS(status))
+        goto fail2;
+
+    RegistryCloseKey(ServiceKey);
+
+    return STATUS_SUCCESS;
+
+fail2:
+    Error("fail2\n");
+
+    RegistryCloseKey(ServiceKey);
+
+fail1:
+    Error("fail1 %08x\n", status);
+
+    return status;
+#endif
 }
 
 NTSTATUS