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

[win-pv-devel] [PATCH] Add Type parameter to RegistryQuerySzValue()



This allows the type of any existent UpperFilters value to be verified and
brings the registry code into line with XENVIF.

Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 src/common/registry.c  |  6 +++++-
 src/common/registry.h  |  1 +
 src/xen/system.c       |  2 +-
 src/xenbus/fdo.c       |  3 +++
 src/xenbus/filters.c   | 44 ++++++++++++++++++++++++++++++--------------
 src/xenfilt/driver.c   |  1 +
 src/xenfilt/pvdevice.c |  2 ++
 7 files changed, 43 insertions(+), 16 deletions(-)

diff --git a/src/common/registry.c b/src/common/registry.c
index d6499c1..b75f16b 100644
--- a/src/common/registry.c
+++ b/src/common/registry.c
@@ -850,6 +850,7 @@ NTSTATUS
 RegistryQuerySzValue(
     IN  HANDLE                      Key,
     IN  PCHAR                       Name,
+    OUT PULONG                      Type OPTIONAL,
     OUT PANSI_STRING                *Array
     )
 {
@@ -911,6 +912,9 @@ RegistryQuerySzValue(
     if (*Array == NULL)
         goto fail5;
 
+    if (Type != NULL)
+        *Type = Value->Type;
+
     __RegistryFree(Value);
 
     RtlFreeUnicodeString(&Unicode);
@@ -1146,7 +1150,7 @@ RegistryQuerySystemStartOption(
     if (!NT_SUCCESS(status))
         goto fail1;
 
-    status = RegistryQuerySzValue(Key, "SystemStartOptions", &Ansi);
+    status = RegistryQuerySzValue(Key, "SystemStartOptions", NULL, &Ansi);
     if (!NT_SUCCESS(status))
         goto fail2;
 
diff --git a/src/common/registry.h b/src/common/registry.h
index ef0cf91..1ac13b8 100644
--- a/src/common/registry.h
+++ b/src/common/registry.h
@@ -145,6 +145,7 @@ extern NTSTATUS
 RegistryQuerySzValue(
     IN  HANDLE          Key,
     IN  PCHAR           Name,
+    OUT PULONG          Type OPTIONAL,
     OUT PANSI_STRING    *Array
     );
 
diff --git a/src/xen/system.c b/src/xen/system.c
index f7be963..1a788ce 100644
--- a/src/xen/system.c
+++ b/src/xen/system.c
@@ -530,7 +530,7 @@ SystemGetStartOptions(
     if (!NT_SUCCESS(status))
         goto fail1;
 
-    status = RegistryQuerySzValue(Key, "SystemStartOptions", &Ansi);
+    status = RegistryQuerySzValue(Key, "SystemStartOptions", NULL, &Ansi);
     if (!NT_SUCCESS(status))
         goto fail2;
 
diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
index 68d6e76..0a516a4 100644
--- a/src/xenbus/fdo.c
+++ b/src/xenbus/fdo.c
@@ -732,6 +732,7 @@ FdoSetFriendlyName(
 
     status = RegistryQuerySzValue(SoftwareKey,
                                   "DriverDesc",
+                                  NULL,
                                   &DriverDesc);
     if (!NT_SUCCESS(status))
         goto fail3;
@@ -1366,6 +1367,7 @@ FdoScan(
 
         status = RegistryQuerySzValue(ParametersKey,
                                       "SyntheticClasses",
+                                      NULL,
                                       &SyntheticClasses);
         if (!NT_SUCCESS(status))
             SyntheticClasses = NULL;
@@ -1384,6 +1386,7 @@ FdoScan(
         if (ParametersKey != NULL) {
             status = RegistryQuerySzValue(ParametersKey,
                                           "SupportedClasses",
+                                          NULL,
                                           &SupportedClasses);
             if (!NT_SUCCESS(status))
                 SupportedClasses = NULL;
diff --git a/src/xenbus/filters.c b/src/xenbus/filters.c
index 651fcc2..8eb836b 100644
--- a/src/xenbus/filters.c
+++ b/src/xenbus/filters.c
@@ -72,6 +72,7 @@ FiltersInstallClass(
     HANDLE          ClassKey;
     UNICODE_STRING  Unicode;
     HANDLE          Key;
+    ULONG           Type;
     ULONG           Count;
     PANSI_STRING    Old;
     ULONG           Index;
@@ -100,8 +101,12 @@ FiltersInstallClass(
 
     Count = 0;
 
-    status = RegistryQuerySzValue(Key, "UpperFilters", &Old);
+    status = RegistryQuerySzValue(Key, "UpperFilters", &Type, &Old);
     if (NT_SUCCESS(status)) {
+        status = STATUS_INVALID_PARAMETER;
+        if (Type != REG_MULTI_SZ)
+            goto fail4;
+
         for (Index = 0; Old[Index].Buffer != NULL; Index++) {
             if (_stricmp(Old[Index].Buffer, DriverName) == 0)
                 goto done;
@@ -116,7 +121,7 @@ FiltersInstallClass(
 
     status = STATUS_NO_MEMORY;
     if (New == NULL)
-        goto fail4;
+        goto fail5;
 
     Index = 0;
     while (Index < Count) {
@@ -131,7 +136,7 @@ FiltersInstallClass(
                                    REG_MULTI_SZ,
                                    New);
     if (!NT_SUCCESS(status))
-        goto fail5;
+        goto fail6;
 
     __FiltersFree(New);
 
@@ -151,17 +156,20 @@ done:
 
     return STATUS_SUCCESS;
 
-fail5:
-    Error("fail5\n");
+fail6:
+    Error("fail6\n");
 
     __FiltersFree(New);
 
-fail4:
-    Error("fail4\n");
+fail5:
+    Error("fail5\n");
 
     if (Old != NULL)
         RegistryFreeSzValue(Old);
 
+fail4:
+    Error("fail4\n");
+
     RegistryCloseKey(Key);
 
 fail3:
@@ -193,6 +201,7 @@ FiltersUninstallClass(
     HANDLE          ClassKey;
     UNICODE_STRING  Unicode;
     HANDLE          Key;
+    ULONG           Type;
     ULONG           Count;
     PANSI_STRING    Old;
     ULONG           Index;
@@ -219,8 +228,12 @@ FiltersUninstallClass(
     if (!NT_SUCCESS(status))
         goto fail3;
 
-    status = RegistryQuerySzValue(Key, "UpperFilters", &Old);
+    status = RegistryQuerySzValue(Key, "UpperFilters", &Type, &Old);
     if (NT_SUCCESS(status)) {
+        status = STATUS_INVALID_PARAMETER;
+        if (Type != REG_MULTI_SZ)
+            goto fail4;
+
         for (Index = 0; Old[Index].Buffer != NULL; Index++) {
             if (_stricmp(Old[Index].Buffer, DriverName) == 0)
                 goto found;
@@ -238,7 +251,7 @@ found:
 
     status = STATUS_NO_MEMORY;
     if (New == NULL)
-        goto fail4;
+        goto fail5;
 
     Count = 0;
     for (Index = 0; Old[Index].Buffer != NULL; Index++) {
@@ -254,7 +267,7 @@ found:
                                    REG_MULTI_SZ,
                                    New);
     if (!NT_SUCCESS(status))
-        goto fail5;
+        goto fail6;
 
     __FiltersFree(New);
 
@@ -274,17 +287,20 @@ done:
 
     return STATUS_SUCCESS;
 
-fail5:
-    Error("fail5\n");
+fail6:
+    Error("fail6\n");
 
     __FiltersFree(New);
 
-fail4:
-    Error("fail4\n");
+fail5:
+    Error("fail5\n");
 
     if (Old != NULL)
         RegistryFreeSzValue(Old);
 
+fail4:
+    Error("fail4\n");
+
     RegistryCloseKey(Key);
 
 fail3:
diff --git a/src/xenfilt/driver.c b/src/xenfilt/driver.c
index 84766dd..342d2b2 100644
--- a/src/xenfilt/driver.c
+++ b/src/xenfilt/driver.c
@@ -570,6 +570,7 @@ DriverAddDevice(
 
     status = RegistryQuerySzValue(ParametersKey,
                                   DeviceID,
+                                  NULL,
                                   &Type);
     if (NT_SUCCESS(status)) {
         __DriverAcquireMutex();
diff --git a/src/xenfilt/pvdevice.c b/src/xenfilt/pvdevice.c
index 296608c..04d8193 100644
--- a/src/xenfilt/pvdevice.c
+++ b/src/xenfilt/pvdevice.c
@@ -140,6 +140,7 @@ PvdeviceGetActive(
 
     status = RegistryQuerySzValue(ParametersKey,
                                   "ActiveDeviceID",
+                                  NULL,
                                   &Ansi);
     if (!NT_SUCCESS(status))
         goto fail1;
@@ -154,6 +155,7 @@ PvdeviceGetActive(
 
     status = RegistryQuerySzValue(ParametersKey,
                                   "ActiveInstanceID",
+                                  NULL,
                                   &Ansi);
     if (!NT_SUCCESS(status))
         goto fail2;
-- 
2.1.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel


 


Rackspace

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