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

[PATCH 3/4] registry: sync with xenbus


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
  • Date: Thu, 22 Oct 2026 09:33:12 +0200
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID"
  • Cc: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
  • Delivery-date: Thu, 22 Oct 2026 07:33:27 +0000
  • Feedback-id: default:8631fc262581453bbf619ec5b2062170:Sweego
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

Syncing op changes the signature of RegistryInitialize() which now takes
the DriverObject, so update call sites accordingly.

Signed-off-by: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
---
 src/xenvif/driver.c   |  2 +-
 src/xenvif/registry.c | 42 ++++++++++++++++++++++++------------------
 src/xenvif/registry.h | 36 ++++++++++++++++--------------------
 3 files changed, 41 insertions(+), 39 deletions(-)

diff --git a/src/xenvif/driver.c b/src/xenvif/driver.c
index 69d0622..fc97be2 100644
--- a/src/xenvif/driver.c
+++ b/src/xenvif/driver.c
@@ -335,7 +335,7 @@ DriverEntry(
          MONTH,
          YEAR);
 
-    status = RegistryInitialize(RegistryPath);
+    status = RegistryInitialize(DriverObject, RegistryPath);
     if (!NT_SUCCESS(status))
         goto fail1;
 
diff --git a/src/xenvif/registry.c b/src/xenvif/registry.c
index 76bfddb..602b96a 100644
--- a/src/xenvif/registry.c
+++ b/src/xenvif/registry.c
@@ -62,11 +62,15 @@ __RegistryFree(
 }
 
 NTSTATUS
+#pragma prefast(suppress:28101) // unannotated DriverEntry function
 RegistryInitialize(
+    _In_opt_ PDRIVER_OBJECT DriverObject,
     _In_ PUNICODE_STRING    Path
     )
 {
-    NTSTATUS                status;
+    UNICODE_STRING      Unicode;
+    PVOID               Func;
+    NTSTATUS            status;
 
     ASSERT3P(RegistryPath.Buffer, ==, NULL);
 
@@ -74,6 +78,16 @@ RegistryInitialize(
     if (!NT_SUCCESS(status))
         goto fail1;
 
+    ASSERT3P(RegistryDriverObject, ==, NULL);
+    RegistryDriverObject = DriverObject;
+
+    ASSERT3P(__IoOpenDriverRegistryKey, ==, NULL);
+    RtlInitUnicodeString(&Unicode, L"IoOpenDriverRegistryKey");
+
+    Func = MmGetSystemRoutineAddress(&Unicode);
+    if (Func != NULL)
+        __IoOpenDriverRegistryKey = (IOOPENDRIVERREGISTRYKEY)Func;
+
     return STATUS_SUCCESS;
 
 fail1:
@@ -1155,17 +1169,17 @@ fail1:
 
 NTSTATUS
 RegistryQueryBinaryValue(
-    _In_ HANDLE                             Key,
-    _In_ PSTR                               Name,
-    _Outptr_result_buffer_(*Length) PVOID   *Buffer,
-    _Out_ PULONG                            Length
+    _In_ HANDLE                                 Key,
+    _In_ PSTR                                   Name,
+    _Outptr_result_bytebuffer_(*Length) PVOID   *Buffer,
+    _Out_ PULONG                                Length
     )
 {
-    ANSI_STRING                             Ansi;
-    UNICODE_STRING                          Unicode;
-    PKEY_VALUE_PARTIAL_INFORMATION          Partial;
-    ULONG                                   Size;
-    NTSTATUS                                status;
+    ANSI_STRING                                 Ansi;
+    UNICODE_STRING                              Unicode;
+    PKEY_VALUE_PARTIAL_INFORMATION              Partial;
+    ULONG                                       Size;
+    NTSTATUS                                    status;
 
     RtlInitAnsiString(&Ansi, Name);
 
@@ -1628,11 +1642,3 @@ RegistryCloseKey(
 {
     ZwClose(Key);
 }
-
-PUNICODE_STRING
-RegistryGetPath(
-    VOID
-    )
-{
-    return &RegistryPath;
-}
\ No newline at end of file
diff --git a/src/xenvif/registry.h b/src/xenvif/registry.h
index c9a5488..98de95e 100644
--- a/src/xenvif/registry.h
+++ b/src/xenvif/registry.h
@@ -37,6 +37,7 @@
 
 extern NTSTATUS
 RegistryInitialize(
+    _In_opt_ PDRIVER_OBJECT DrvObj,
     _In_ PUNICODE_STRING    Path
     );
 
@@ -110,8 +111,8 @@ RegistryCreateSubKey(
 
 extern NTSTATUS
 RegistryDeleteSubKey(
-    _In_ HANDLE Key,
-    _In_ PSTR   Name
+    _In_ HANDLE     Key,
+    _In_ PSTR       Name
     );
 
 extern NTSTATUS
@@ -130,15 +131,15 @@ RegistryEnumerateValues(
 
 extern NTSTATUS
 RegistryDeleteValue(
-    _In_ HANDLE Key,
-    _In_ PSTR   Name
+    _In_ HANDLE     Key,
+    _In_ PSTR       Name
     );
 
 extern NTSTATUS
 RegistryQueryDwordValue(
-    _In_ HANDLE     Key,
-    _In_ PSTR       Name,
-    _Out_ PULONG    Value
+    _In_ HANDLE         Key,
+    _In_ PSTR           Name,
+    _Out_ PULONG        Value
     );
 
 extern NTSTATUS
@@ -150,9 +151,9 @@ RegistryQueryQwordValue(
 
 extern NTSTATUS
 RegistryUpdateDwordValue(
-    _In_ HANDLE Key,
-    _In_ PSTR   Name,
-    _In_ ULONG  Value
+    _In_ HANDLE         Key,
+    _In_ PSTR           Name,
+    _In_ ULONG          Value
     );
 
 extern NTSTATUS
@@ -165,10 +166,10 @@ RegistryQuerySzValue(
 
 extern NTSTATUS
 RegistryQueryBinaryValue(
-    _In_ HANDLE                             Key,
-    _In_ PSTR                               Name,
-    _Outptr_result_buffer_(*Length) PVOID   *Buffer,
-    _Out_ PULONG                            Length
+    _In_ HANDLE                                 Key,
+    _In_ PSTR                                   Name,
+    _Outptr_result_bytebuffer_(*Length) PVOID   *Buffer,
+    _Out_ PULONG                                Length
     );
 
 extern NTSTATUS
@@ -198,7 +199,7 @@ RegistryFreeSzValue(
 
 extern VOID
 RegistryFreeBinaryValue(
-    _In_ PVOID  Buffer
+    _In_ PVOID          Buffer
     );
 
 extern NTSTATUS
@@ -214,9 +215,4 @@ RegistryCloseKey(
     _In_ HANDLE Key
     );
 
-extern PUNICODE_STRING
-RegistryGetPath(
-    VOID
-    );
-
 #endif  // _XENVIF_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

 


Rackspace

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