mirror of
https://github.com/reactos/reactos.git
synced 2025-04-06 05:34:22 +00:00
[NEWDEV] Fix HardwareId
match logic in UpdateDriverForPlugAndPlayDevicesW
(#7808)
Match Hardware ID correctly. This fix is required to install the latest (7.1.6) Virtual Box Guest Additions drivers. - Add Compatible IDs match, call SetupDiGetDeviceRegistryPropertyW twice, once for SPDRP_HARDWAREID and once for SPDRP_COMPATIBLEIDS. - Use case-insensitive comparison (wcscmp -> _wcsicmp) - Convert code file to UTF-8 encoding
This commit is contained in:
parent
ffa81857c2
commit
cfcc8d85b2
1 changed files with 49 additions and 41 deletions
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* New device installer (newdev.dll)
|
* New device installer (newdev.dll)
|
||||||
*
|
*
|
||||||
* Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
|
* Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
|
||||||
* 2005 Christoph von Wittich (Christoph@ActiveVB.de)
|
* 2005 Christoph von Wittich (Christoph@ActiveVB.de)
|
||||||
* 2009 Colin Finck (colin@reactos.org)
|
* 2009 Colin Finck (colin@reactos.org)
|
||||||
*
|
*
|
||||||
|
@ -50,6 +50,7 @@ UpdateDriverForPlugAndPlayDevicesW(
|
||||||
LPWSTR Buffer = NULL;
|
LPWSTR Buffer = NULL;
|
||||||
DWORD BufferSize;
|
DWORD BufferSize;
|
||||||
LPCWSTR CurrentHardwareId; /* Pointer into Buffer */
|
LPCWSTR CurrentHardwareId; /* Pointer into Buffer */
|
||||||
|
DWORD Property;
|
||||||
BOOL FoundHardwareId, FoundAtLeastOneDevice = FALSE;
|
BOOL FoundHardwareId, FoundAtLeastOneDevice = FALSE;
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
|
@ -86,51 +87,58 @@ UpdateDriverForPlugAndPlayDevicesW(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get Hardware ID */
|
/* Match Hardware ID */
|
||||||
HeapFree(GetProcessHeap(), 0, Buffer);
|
|
||||||
Buffer = NULL;
|
|
||||||
BufferSize = 0;
|
|
||||||
while (!SetupDiGetDeviceRegistryPropertyW(
|
|
||||||
DevInstData.hDevInfo,
|
|
||||||
&DevInstData.devInfoData,
|
|
||||||
SPDRP_HARDWAREID,
|
|
||||||
NULL,
|
|
||||||
(PBYTE)Buffer,
|
|
||||||
BufferSize,
|
|
||||||
&BufferSize))
|
|
||||||
{
|
|
||||||
if (GetLastError() == ERROR_FILE_NOT_FOUND)
|
|
||||||
{
|
|
||||||
Buffer = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
|
||||||
{
|
|
||||||
TRACE("SetupDiGetDeviceRegistryPropertyW() failed with error 0x%x\n", GetLastError());
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
/* This error was expected */
|
|
||||||
HeapFree(GetProcessHeap(), 0, Buffer);
|
|
||||||
Buffer = HeapAlloc(GetProcessHeap(), 0, BufferSize);
|
|
||||||
if (!Buffer)
|
|
||||||
{
|
|
||||||
TRACE("HeapAlloc() failed\n", GetLastError());
|
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Buffer == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Check if we match the given hardware ID */
|
|
||||||
FoundHardwareId = FALSE;
|
FoundHardwareId = FALSE;
|
||||||
for (CurrentHardwareId = Buffer; *CurrentHardwareId != UNICODE_NULL; CurrentHardwareId += wcslen(CurrentHardwareId) + 1)
|
Property = SPDRP_HARDWAREID;
|
||||||
|
while (TRUE)
|
||||||
{
|
{
|
||||||
if (wcscmp(CurrentHardwareId, HardwareId) == 0)
|
/* Get IDs data */
|
||||||
|
Buffer = NULL;
|
||||||
|
BufferSize = 0;
|
||||||
|
while (!SetupDiGetDeviceRegistryPropertyW(DevInstData.hDevInfo,
|
||||||
|
&DevInstData.devInfoData,
|
||||||
|
Property,
|
||||||
|
NULL,
|
||||||
|
(PBYTE)Buffer,
|
||||||
|
BufferSize,
|
||||||
|
&BufferSize))
|
||||||
|
{
|
||||||
|
if (GetLastError() == ERROR_FILE_NOT_FOUND)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
||||||
|
{
|
||||||
|
TRACE("SetupDiGetDeviceRegistryPropertyW() failed with error 0x%x\n", GetLastError());
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
/* This error was expected */
|
||||||
|
HeapFree(GetProcessHeap(), 0, Buffer);
|
||||||
|
Buffer = HeapAlloc(GetProcessHeap(), 0, BufferSize);
|
||||||
|
if (!Buffer)
|
||||||
|
{
|
||||||
|
TRACE("HeapAlloc() failed\n", GetLastError());
|
||||||
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Buffer)
|
||||||
|
{
|
||||||
|
/* Check if we match the given hardware ID */
|
||||||
|
for (CurrentHardwareId = Buffer; *CurrentHardwareId != UNICODE_NULL; CurrentHardwareId += wcslen(CurrentHardwareId) + 1)
|
||||||
|
{
|
||||||
|
if (_wcsicmp(CurrentHardwareId, HardwareId) == 0)
|
||||||
|
{
|
||||||
|
FoundHardwareId = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (FoundHardwareId || Property == SPDRP_COMPATIBLEIDS)
|
||||||
{
|
{
|
||||||
FoundHardwareId = TRUE;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Property = SPDRP_COMPATIBLEIDS;
|
||||||
}
|
}
|
||||||
if (!FoundHardwareId)
|
if (!FoundHardwareId)
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in a new issue