]> xenbits.xensource.com Git - people/pauldu/xenbus.git/commitdiff
Step through hardware revision list in reverse order
authorOwen Smith <owen.smith@citrix.com>
Tue, 20 Sep 2016 17:06:14 +0000 (18:06 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Tue, 20 Sep 2016 17:19:31 +0000 (18:19 +0100)
Windows treats the HardwareID list as a decending order of specialization
where the first entry is the most specific, and last entry is least
specific. This can lead to install issues when the newer driver has a
less-specific HardwareID, as the older ("more-specific") HardwareID is
used for the match. Reordering the HardwareID list, so that the newest
revision is first, will stop Windows selecting the wrong driver package
to install.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Re-factored slightly for code consistency.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
src/xenbus/pdo.c

index 3a8540e22bdd7e4ba6ed6b5b4c0db44e6ff7c84c..461ca7bbdd808f191c2f55df8ac2024e368847f9 100644 (file)
@@ -1426,21 +1426,23 @@ PdoQueryId(
     }
     case BusQueryHardwareIDs:
     case BusQueryCompatibleIDs: {
-        ULONG   Index;
+        LONG    Index;
         ULONG   Length;
 
         Type = REG_MULTI_SZ;
+        Index = ARRAYSIZE(PdoRevision) - 1;
+
         Length = Id.MaximumLength;
 
-        for (Index = 0; Index < ARRAYSIZE(PdoRevision); Index++) {
+        while (Index >= 0) {
             PXENBUS_PDO_REVISION Revision = &PdoRevision[Index];
 
-           status = RtlStringCbPrintfW(Buffer,
-                                       Length,
-                                       L"XENBUS\\VEN_%hs&DEV_%hs&REV_%08X",
-                                       __PdoGetVendorName(Pdo),
-                                       __PdoGetName(Pdo),
-                                       Revision->Number);
+            status = RtlStringCbPrintfW(Buffer,
+                                        Length,
+                                        L"XENBUS\\VEN_%hs&DEV_%hs&REV_%08X",
+                                        __PdoGetVendorName(Pdo),
+                                        __PdoGetName(Pdo),
+                                        Revision->Number);
             ASSERT(NT_SUCCESS(status));
 
             Buffer += wcslen(Buffer);
@@ -1448,6 +1450,8 @@ PdoQueryId(
 
             Buffer++;
             Length -= sizeof (WCHAR);
+
+            --Index;
         }
 
         status = RtlStringCbPrintfW(Buffer,