[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Conditionally use IoOpenDriverRegistryKey



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@xxxxxxxxx>
---
 src/common/registry.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/common/registry.c b/src/common/registry.c
index 3f45a23..211c177 100644
--- a/src/common/registry.c
+++ b/src/common/registry.c
@@ -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
-- 
2.44.0.windows.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.