[NTOSKRNL]

- Don't always use the value name as the device description
- Fixes bug 3416

svn path=/trunk/; revision=46500
This commit is contained in:
Cameron Gutman 2010-03-27 21:45:35 +00:00
parent 79cb786ef5
commit fd3fa1abb6

View file

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