Juan Lang : setupapi: Store pointer to set in device, and use it to make sure that a device is a member of a set.
Alexandre Julliard
julliard at winehq.org
Mon Sep 24 08:08:04 CDT 2007
Module: wine
Branch: master
Commit: d0a2866a90d420d90cf8f45879206ea944d3aeea
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d0a2866a90d420d90cf8f45879206ea944d3aeea
Author: Juan Lang <juan.lang at gmail.com>
Date: Fri Sep 21 17:07:37 2007 -0700
setupapi: Store pointer to set in device, and use it to make sure that a device is a member of a set.
---
dlls/setupapi/devinst.c | 33 ++++++++++++++++++++++++++-------
1 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c
index 6d90d15..acaa8ae 100644
--- a/dlls/setupapi/devinst.c
+++ b/dlls/setupapi/devinst.c
@@ -124,10 +124,11 @@ struct InterfaceInstances
/* Pointed to by SP_DEVINFO_DATA's Reserved member */
struct DeviceInfo
{
- HKEY key;
- BOOL phantom;
- LPWSTR instanceId;
- struct list interfaces;
+ struct DeviceInfoSet *set;
+ HKEY key;
+ BOOL phantom;
+ LPWSTR instanceId;
+ struct list interfaces;
};
static void SETUPDI_GuidToString(const GUID *guid, LPWSTR guidStr)
@@ -386,14 +387,15 @@ static BOOL SETUPDI_SetInterfaceSymbolicLink(SP_DEVICE_INTERFACE_DATA *iface,
return ret;
}
-static struct DeviceInfo *SETUPDI_AllocateDeviceInfo(LPCWSTR instanceId,
- BOOL phantom)
+static struct DeviceInfo *SETUPDI_AllocateDeviceInfo(struct DeviceInfoSet *set,
+ LPCWSTR instanceId, BOOL phantom)
{
struct DeviceInfo *devInfo = HeapAlloc(GetProcessHeap(), 0,
sizeof(struct DeviceInfo));
if (devInfo)
{
+ devInfo->set = set;
devInfo->instanceId = HeapAlloc(GetProcessHeap(), 0,
(lstrlenW(instanceId) + 1) * sizeof(WCHAR));
if (devInfo->instanceId)
@@ -470,7 +472,7 @@ static BOOL SETUPDI_AddDeviceToSet(struct DeviceInfoSet *set,
SP_DEVINFO_DATA **dev)
{
BOOL ret = FALSE;
- struct DeviceInfo *devInfo = SETUPDI_AllocateDeviceInfo(instanceId,
+ struct DeviceInfo *devInfo = SETUPDI_AllocateDeviceInfo(set, instanceId,
phantom);
TRACE("%p, %s, %d, %s, %d\n", set, debugstr_guid(guid), devInst,
@@ -1364,6 +1366,11 @@ BOOL WINAPI SetupDiRegisterDeviceInfo(
return FALSE;
}
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
+ if (devInfo->set != set)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
if (devInfo->phantom)
{
devInfo->phantom = FALSE;
@@ -1504,6 +1511,11 @@ BOOL WINAPI SetupDiGetDeviceInstanceIdW(
return FALSE;
}
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
+ if (devInfo->set != set)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
TRACE("instance ID: %s\n", debugstr_w(devInfo->instanceId));
if (DeviceInstanceIdSize < lstrlenW(devInfo->instanceId) + 1)
{
@@ -2115,6 +2127,7 @@ BOOL WINAPI SetupDiCreateDeviceInterfaceW(
PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
{
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
+ struct DeviceInfo *devInfo;
SP_DEVICE_INTERFACE_DATA *iface = NULL;
BOOL ret;
@@ -2138,6 +2151,12 @@ BOOL WINAPI SetupDiCreateDeviceInterfaceW(
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
+ devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
+ if (devInfo->set != set)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
if (!InterfaceClassGuid)
{
SetLastError(ERROR_INVALID_USER_BUFFER);
More information about the wine-cvs
mailing list