Commit d0a2866a authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

setupapi: Store pointer to set in device, and use it to make sure that a device…

setupapi: Store pointer to set in device, and use it to make sure that a device is a member of a set.
parent 21b7e1fa
...@@ -124,10 +124,11 @@ struct InterfaceInstances ...@@ -124,10 +124,11 @@ struct InterfaceInstances
/* Pointed to by SP_DEVINFO_DATA's Reserved member */ /* Pointed to by SP_DEVINFO_DATA's Reserved member */
struct DeviceInfo struct DeviceInfo
{ {
HKEY key; struct DeviceInfoSet *set;
BOOL phantom; HKEY key;
LPWSTR instanceId; BOOL phantom;
struct list interfaces; LPWSTR instanceId;
struct list interfaces;
}; };
static void SETUPDI_GuidToString(const GUID *guid, LPWSTR guidStr) static void SETUPDI_GuidToString(const GUID *guid, LPWSTR guidStr)
...@@ -386,14 +387,15 @@ static BOOL SETUPDI_SetInterfaceSymbolicLink(SP_DEVICE_INTERFACE_DATA *iface, ...@@ -386,14 +387,15 @@ static BOOL SETUPDI_SetInterfaceSymbolicLink(SP_DEVICE_INTERFACE_DATA *iface,
return ret; return ret;
} }
static struct DeviceInfo *SETUPDI_AllocateDeviceInfo(LPCWSTR instanceId, static struct DeviceInfo *SETUPDI_AllocateDeviceInfo(struct DeviceInfoSet *set,
BOOL phantom) LPCWSTR instanceId, BOOL phantom)
{ {
struct DeviceInfo *devInfo = HeapAlloc(GetProcessHeap(), 0, struct DeviceInfo *devInfo = HeapAlloc(GetProcessHeap(), 0,
sizeof(struct DeviceInfo)); sizeof(struct DeviceInfo));
if (devInfo) if (devInfo)
{ {
devInfo->set = set;
devInfo->instanceId = HeapAlloc(GetProcessHeap(), 0, devInfo->instanceId = HeapAlloc(GetProcessHeap(), 0,
(lstrlenW(instanceId) + 1) * sizeof(WCHAR)); (lstrlenW(instanceId) + 1) * sizeof(WCHAR));
if (devInfo->instanceId) if (devInfo->instanceId)
...@@ -470,7 +472,7 @@ static BOOL SETUPDI_AddDeviceToSet(struct DeviceInfoSet *set, ...@@ -470,7 +472,7 @@ static BOOL SETUPDI_AddDeviceToSet(struct DeviceInfoSet *set,
SP_DEVINFO_DATA **dev) SP_DEVINFO_DATA **dev)
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
struct DeviceInfo *devInfo = SETUPDI_AllocateDeviceInfo(instanceId, struct DeviceInfo *devInfo = SETUPDI_AllocateDeviceInfo(set, instanceId,
phantom); phantom);
TRACE("%p, %s, %d, %s, %d\n", set, debugstr_guid(guid), devInst, TRACE("%p, %s, %d, %s, %d\n", set, debugstr_guid(guid), devInst,
...@@ -1364,6 +1366,11 @@ BOOL WINAPI SetupDiRegisterDeviceInfo( ...@@ -1364,6 +1366,11 @@ BOOL WINAPI SetupDiRegisterDeviceInfo(
return FALSE; return FALSE;
} }
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved; devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
if (devInfo->set != set)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if (devInfo->phantom) if (devInfo->phantom)
{ {
devInfo->phantom = FALSE; devInfo->phantom = FALSE;
...@@ -1504,6 +1511,11 @@ BOOL WINAPI SetupDiGetDeviceInstanceIdW( ...@@ -1504,6 +1511,11 @@ BOOL WINAPI SetupDiGetDeviceInstanceIdW(
return FALSE; return FALSE;
} }
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved; devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
if (devInfo->set != set)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
TRACE("instance ID: %s\n", debugstr_w(devInfo->instanceId)); TRACE("instance ID: %s\n", debugstr_w(devInfo->instanceId));
if (DeviceInstanceIdSize < lstrlenW(devInfo->instanceId) + 1) if (DeviceInstanceIdSize < lstrlenW(devInfo->instanceId) + 1)
{ {
...@@ -2115,6 +2127,7 @@ BOOL WINAPI SetupDiCreateDeviceInterfaceW( ...@@ -2115,6 +2127,7 @@ BOOL WINAPI SetupDiCreateDeviceInterfaceW(
PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData) PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
{ {
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet; struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
struct DeviceInfo *devInfo;
SP_DEVICE_INTERFACE_DATA *iface = NULL; SP_DEVICE_INTERFACE_DATA *iface = NULL;
BOOL ret; BOOL ret;
...@@ -2138,6 +2151,12 @@ BOOL WINAPI SetupDiCreateDeviceInterfaceW( ...@@ -2138,6 +2151,12 @@ BOOL WINAPI SetupDiCreateDeviceInterfaceW(
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
return FALSE; return FALSE;
} }
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
if (devInfo->set != set)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if (!InterfaceClassGuid) if (!InterfaceClassGuid)
{ {
SetLastError(ERROR_INVALID_USER_BUFFER); SetLastError(ERROR_INVALID_USER_BUFFER);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment