[NTOSKRNL]
authorCameron Gutman <aicommander@gmail.com>
Sat, 27 Mar 2010 21:45:35 +0000 (21:45 +0000)
committerCameron Gutman <aicommander@gmail.com>
Sat, 27 Mar 2010 21:45:35 +0000 (21:45 +0000)
- Don't always use the value name as the device description
- Fixes bug 3416

svn path=/trunk/; revision=46500

reactos/ntoskrnl/io/pnpmgr/pnpmgr.c

index f40c505..cd0859b 100644 (file)
@@ -2192,6 +2192,7 @@ IopEnumerateDetectedDevices(
    UNICODE_STRING HardwareIdKey;
    PUNICODE_STRING pHardwareId;
    ULONG DeviceIndex = 0;
+   BOOLEAN IsDeviceDesc;
 
     if (RelativePath)
     {
@@ -2418,16 +2419,19 @@ IopEnumerateDetectedDevices(
       {
          pHardwareId = &HardwareIdSerial;
          DeviceIndex = DeviceIndexSerial++;
+         IsDeviceDesc = TRUE;
       }
       else if (RelativePath && RtlCompareUnicodeString(RelativePath, &IdentifierKeyboard, FALSE) == 0)
       {
          pHardwareId = &HardwareIdKeyboard;
          DeviceIndex = DeviceIndexKeyboard++;
+         IsDeviceDesc = FALSE;
       }
       else if (RelativePath && RtlCompareUnicodeString(RelativePath, &IdentifierMouse, FALSE) == 0)
       {
          pHardwareId = &HardwareIdMouse;
          DeviceIndex = DeviceIndexMouse++;
+         IsDeviceDesc = FALSE;
       }
       else if (NT_SUCCESS(Status))
       {
@@ -2436,17 +2440,20 @@ IopEnumerateDetectedDevices(
          {
             pHardwareId = &HardwareIdPci;
             DeviceIndex = DeviceIndexPci++;
+            IsDeviceDesc = FALSE;
          }
          else if (RtlCompareUnicodeString(&ValueName, &IdentifierIsa, FALSE) == 0)
          {
             pHardwareId = &HardwareIdIsa;
             DeviceIndex = DeviceIndexIsa++;
+            IsDeviceDesc = FALSE;
          }
 #ifdef ENABLE_ACPI
          else if (RtlCompareUnicodeString(&ValueName, &IdentifierAcpi, FALSE) == 0)
          {
             pHardwareId = &HardwareIdAcpi;
             DeviceIndex = DeviceIndexAcpi++;
+            IsDeviceDesc = FALSE;
          }
 #endif
          else /* Now let's detect devices with a device number at the end */
@@ -2459,12 +2466,14 @@ IopEnumerateDetectedDevices(
             {
                 pHardwareId = &HardwareIdFloppy;
                 DeviceIndex = DeviceIndexFloppy++;
+                IsDeviceDesc = FALSE;
             }
             /* Nope, is it a parallel port? */
             else if (RtlCompareUnicodeString(&ValueName, &IdentifierParallel, FALSE) == 0)
             {
                 pHardwareId = &HardwareIdParallel;
                 DeviceIndex = DeviceIndexParallel++;
+                IsDeviceDesc = FALSE;
             }
             /* Nope, out of ideas so let's skip this one */
             else
@@ -2522,12 +2531,15 @@ IopEnumerateDetectedDevices(
          goto nextdevice;
       }
       DPRINT("Found %wZ #%lu (%wZ)\n", &ValueName, DeviceIndex, &HardwareIdKey);
-      Status = ZwSetValueKey(hLevel2Key, &DeviceDescU, 0, REG_SZ, ValueName.Buffer, ValueName.MaximumLength);
-      if (!NT_SUCCESS(Status))
+      if (IsDeviceDesc)
       {
-         DPRINT("ZwSetValueKey() failed with status 0x%08lx\n", Status);
-         ZwDeleteKey(hLevel2Key);
-         goto nextdevice;
+         Status = ZwSetValueKey(hLevel2Key, &DeviceDescU, 0, REG_SZ, ValueName.Buffer, ValueName.MaximumLength);
+         if (!NT_SUCCESS(Status))
+         {
+            DPRINT("ZwSetValueKey() failed with status 0x%08lx\n", Status);
+            ZwDeleteKey(hLevel2Key);
+            goto nextdevice;
+         }
       }
       Status = ZwSetValueKey(hLevel2Key, &HardwareIDU, 0, REG_MULTI_SZ, pHardwareId->Buffer, pHardwareId->MaximumLength);
       if (!NT_SUCCESS(Status))