mirror of
git://source.winehq.org/git/wine.git
synced 2024-07-18 23:23:20 +00:00
setupapi: Also check devices not in the set when using DICD_GENERATE_ID.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
8ec29106b3
commit
5480031653
|
@ -1513,6 +1513,7 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO devinfo, const WCHAR *name, const
|
||||||
HKEY enum_hkey;
|
HKEY enum_hkey;
|
||||||
HKEY instance_hkey;
|
HKEY instance_hkey;
|
||||||
struct device *device;
|
struct device *device;
|
||||||
|
LONG l;
|
||||||
|
|
||||||
TRACE("devinfo %p, name %s, class %s, description %s, hwnd %p, flags %#x, device_data %p.\n",
|
TRACE("devinfo %p, name %s, class %s, description %s, hwnd %p, flags %#x, device_data %p.\n",
|
||||||
devinfo, debugstr_w(name), debugstr_guid(class), debugstr_w(description),
|
devinfo, debugstr_w(name), debugstr_guid(class), debugstr_w(description),
|
||||||
|
@ -1540,8 +1541,8 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO devinfo, const WCHAR *name, const
|
||||||
}
|
}
|
||||||
if ((flags & DICD_GENERATE_ID))
|
if ((flags & DICD_GENERATE_ID))
|
||||||
{
|
{
|
||||||
static const WCHAR formatW[] = {'R','O','O','T','\\','%','s','\\','%','0','4','d',0};
|
static const WCHAR formatW[] = {'R','O','O','T','\\','%','s','\\','%','0','4','u',0};
|
||||||
int instance_id, highest_id = -1;
|
unsigned int instance_id;
|
||||||
|
|
||||||
if (strchrW(name, '\\'))
|
if (strchrW(name, '\\'))
|
||||||
{
|
{
|
||||||
|
@ -1549,25 +1550,20 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO devinfo, const WCHAR *name, const
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
LIST_FOR_EACH_ENTRY(device, &set->devices, struct device, entry)
|
for (instance_id = 0; ; ++instance_id)
|
||||||
{
|
{
|
||||||
const WCHAR *instance_str = strrchrW(device->instanceId, '\\');
|
if (snprintfW(id, ARRAY_SIZE(id), formatW, name, instance_id) == -1)
|
||||||
WCHAR *endptr;
|
{
|
||||||
|
SetLastError(ERROR_INVALID_DEVINST_NAME);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (instance_str)
|
RegCreateKeyExW(HKEY_LOCAL_MACHINE, Enum, 0, NULL, 0, KEY_READ, NULL, &enum_hkey, NULL);
|
||||||
instance_str++;
|
if (!(l = RegOpenKeyExW(enum_hkey, id, 0, KEY_READ, &instance_hkey)))
|
||||||
else
|
RegCloseKey(instance_hkey);
|
||||||
instance_str = device->instanceId;
|
if (l == ERROR_FILE_NOT_FOUND)
|
||||||
|
break;
|
||||||
instance_id = strtoulW(instance_str, &endptr, 10);
|
RegCloseKey(enum_hkey);
|
||||||
if (*instance_str && !*endptr)
|
|
||||||
highest_id = max(highest_id, instance_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (snprintfW(id, ARRAY_SIZE(id), formatW, name, highest_id + 1) == -1)
|
|
||||||
{
|
|
||||||
SetLastError(ERROR_INVALID_DEVINST_NAME);
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue