setupapi: Merge the DeviceInstance and DeviceInfo structs.
These are two different representations of the same underlying object; there's no reason to keep them separate. Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b5b09649e6
commit
5d7b123d09
|
@ -104,10 +104,15 @@ struct DeviceInfoSet
|
||||||
struct list devices;
|
struct list devices;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DeviceInstance
|
struct device
|
||||||
{
|
{
|
||||||
struct list entry;
|
struct DeviceInfoSet *set;
|
||||||
SP_DEVINFO_DATA data;
|
HKEY key;
|
||||||
|
BOOL phantom;
|
||||||
|
WCHAR *instanceId;
|
||||||
|
struct list interfaces;
|
||||||
|
SP_DEVINFO_DATA data;
|
||||||
|
struct list entry;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Pointed to by SP_DEVICE_INTERFACE_DATA's Reserved member */
|
/* Pointed to by SP_DEVICE_INTERFACE_DATA's Reserved member */
|
||||||
|
@ -130,21 +135,10 @@ struct InterfaceInstances
|
||||||
struct list entry;
|
struct list entry;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Pointed to by SP_DEVINFO_DATA's Reserved member */
|
static struct device **devnode_table;
|
||||||
struct DeviceInfo
|
|
||||||
{
|
|
||||||
struct DeviceInfoSet *set;
|
|
||||||
HKEY key;
|
|
||||||
BOOL phantom;
|
|
||||||
DWORD devId;
|
|
||||||
LPWSTR instanceId;
|
|
||||||
struct list interfaces;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct DeviceInfo **devnode_table;
|
|
||||||
static unsigned int devnode_table_size;
|
static unsigned int devnode_table_size;
|
||||||
|
|
||||||
static DEVINST alloc_devnode(struct DeviceInfo *device)
|
static DEVINST alloc_devnode(struct device *device)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
@ -178,7 +172,7 @@ static void free_devnode(DEVINST devnode)
|
||||||
devnode_table[devnode] = NULL;
|
devnode_table[devnode] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct DeviceInfo *get_devnode_device(DEVINST devnode)
|
static struct device *get_devnode_device(DEVINST devnode)
|
||||||
{
|
{
|
||||||
if (devnode < devnode_table_size)
|
if (devnode < devnode_table_size)
|
||||||
return devnode_table[devnode];
|
return devnode_table[devnode];
|
||||||
|
@ -210,11 +204,10 @@ static void SETUPDI_FreeInterfaceInstances(struct InterfaceInstances *instances)
|
||||||
|
|
||||||
if (ifaceInfo->device && ifaceInfo->device->Reserved)
|
if (ifaceInfo->device && ifaceInfo->device->Reserved)
|
||||||
{
|
{
|
||||||
struct DeviceInfo *devInfo =
|
struct device *device = (struct device *)ifaceInfo->device->Reserved;
|
||||||
(struct DeviceInfo *)ifaceInfo->device->Reserved;
|
|
||||||
|
|
||||||
if (devInfo->phantom)
|
if (device->phantom)
|
||||||
SetupDiDeleteDeviceInterfaceRegKey(devInfo->set,
|
SetupDiDeleteDeviceInterfaceRegKey(device->set,
|
||||||
&instances->instances[i], 0);
|
&instances->instances[i], 0);
|
||||||
}
|
}
|
||||||
HeapFree(GetProcessHeap(), 0, ifaceInfo->referenceString);
|
HeapFree(GetProcessHeap(), 0, ifaceInfo->referenceString);
|
||||||
|
@ -229,7 +222,7 @@ static void SETUPDI_FreeInterfaceInstances(struct InterfaceInstances *instances)
|
||||||
* interfaces member where the given interface was found.
|
* interfaces member where the given interface was found.
|
||||||
* Returns FALSE if not found.
|
* Returns FALSE if not found.
|
||||||
*/
|
*/
|
||||||
static BOOL SETUPDI_FindInterface(const struct DeviceInfo *devInfo,
|
static BOOL SETUPDI_FindInterface(const struct device *device,
|
||||||
const GUID *InterfaceClassGuid, struct InterfaceInstances **iface_ret)
|
const GUID *InterfaceClassGuid, struct InterfaceInstances **iface_ret)
|
||||||
{
|
{
|
||||||
BOOL found = FALSE;
|
BOOL found = FALSE;
|
||||||
|
@ -237,7 +230,7 @@ static BOOL SETUPDI_FindInterface(const struct DeviceInfo *devInfo,
|
||||||
|
|
||||||
TRACE("%s\n", debugstr_guid(InterfaceClassGuid));
|
TRACE("%s\n", debugstr_guid(InterfaceClassGuid));
|
||||||
|
|
||||||
LIST_FOR_EACH_ENTRY(iface, &devInfo->interfaces, struct InterfaceInstances,
|
LIST_FOR_EACH_ENTRY(iface, &device->interfaces, struct InterfaceInstances,
|
||||||
entry)
|
entry)
|
||||||
{
|
{
|
||||||
if (IsEqualGUID(&iface->guid, InterfaceClassGuid))
|
if (IsEqualGUID(&iface->guid, InterfaceClassGuid))
|
||||||
|
@ -330,7 +323,7 @@ static BOOL SETUPDI_AddInterfaceInstance(PSP_DEVINFO_DATA DeviceInfoData,
|
||||||
const GUID *InterfaceClassGuid, LPCWSTR ReferenceString,
|
const GUID *InterfaceClassGuid, LPCWSTR ReferenceString,
|
||||||
SP_DEVICE_INTERFACE_DATA **ifaceData)
|
SP_DEVICE_INTERFACE_DATA **ifaceData)
|
||||||
{
|
{
|
||||||
struct DeviceInfo *devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
struct device *devInfo = (struct device *)DeviceInfoData->Reserved;
|
||||||
BOOL newInterface = FALSE, ret;
|
BOOL newInterface = FALSE, ret;
|
||||||
struct InterfaceInstances *iface = NULL;
|
struct InterfaceInstances *iface = NULL;
|
||||||
|
|
||||||
|
@ -382,7 +375,7 @@ static BOOL SETUPDI_AddInterfaceInstance(PSP_DEVINFO_DATA DeviceInfoData,
|
||||||
if (ifaceInfo)
|
if (ifaceInfo)
|
||||||
{
|
{
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
ifaceInfo->device = DeviceInfoData;
|
ifaceInfo->device = &devInfo->data;
|
||||||
ifaceInfo->symbolicLink = SETUPDI_CreateSymbolicLinkPath(
|
ifaceInfo->symbolicLink = SETUPDI_CreateSymbolicLinkPath(
|
||||||
devInfo->instanceId, InterfaceClassGuid,
|
devInfo->instanceId, InterfaceClassGuid,
|
||||||
ReferenceString);
|
ReferenceString);
|
||||||
|
@ -462,7 +455,7 @@ static BOOL SETUPDI_SetInterfaceSymbolicLink(SP_DEVICE_INTERFACE_DATA *iface,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HKEY SETUPDI_CreateDevKey(struct DeviceInfo *devInfo)
|
static HKEY SETUPDI_CreateDevKey(struct device *device)
|
||||||
{
|
{
|
||||||
HKEY enumKey, key = INVALID_HANDLE_VALUE;
|
HKEY enumKey, key = INVALID_HANDLE_VALUE;
|
||||||
LONG l;
|
LONG l;
|
||||||
|
@ -471,14 +464,14 @@ static HKEY SETUPDI_CreateDevKey(struct DeviceInfo *devInfo)
|
||||||
NULL, &enumKey, NULL);
|
NULL, &enumKey, NULL);
|
||||||
if (!l)
|
if (!l)
|
||||||
{
|
{
|
||||||
RegCreateKeyExW(enumKey, devInfo->instanceId, 0, NULL, 0,
|
RegCreateKeyExW(enumKey, device->instanceId, 0, NULL, 0,
|
||||||
KEY_READ | KEY_WRITE, NULL, &key, NULL);
|
KEY_READ | KEY_WRITE, NULL, &key, NULL);
|
||||||
RegCloseKey(enumKey);
|
RegCloseKey(enumKey);
|
||||||
}
|
}
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HKEY SETUPDI_CreateDrvKey(struct DeviceInfo *devInfo)
|
static HKEY SETUPDI_CreateDrvKey(struct device *device)
|
||||||
{
|
{
|
||||||
static const WCHAR slash[] = { '\\',0 };
|
static const WCHAR slash[] = { '\\',0 };
|
||||||
WCHAR classKeyPath[MAX_PATH];
|
WCHAR classKeyPath[MAX_PATH];
|
||||||
|
@ -487,7 +480,7 @@ static HKEY SETUPDI_CreateDrvKey(struct DeviceInfo *devInfo)
|
||||||
|
|
||||||
lstrcpyW(classKeyPath, ControlClass);
|
lstrcpyW(classKeyPath, ControlClass);
|
||||||
lstrcatW(classKeyPath, slash);
|
lstrcatW(classKeyPath, slash);
|
||||||
SETUPDI_GuidToString(&devInfo->set->ClassGuid,
|
SETUPDI_GuidToString(&device->set->ClassGuid,
|
||||||
classKeyPath + lstrlenW(classKeyPath));
|
classKeyPath + lstrlenW(classKeyPath));
|
||||||
l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, classKeyPath, 0, NULL, 0,
|
l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, classKeyPath, 0, NULL, 0,
|
||||||
KEY_ALL_ACCESS, NULL, &classKey, NULL);
|
KEY_ALL_ACCESS, NULL, &classKey, NULL);
|
||||||
|
@ -496,7 +489,7 @@ static HKEY SETUPDI_CreateDrvKey(struct DeviceInfo *devInfo)
|
||||||
static const WCHAR fmt[] = { '%','0','4','u',0 };
|
static const WCHAR fmt[] = { '%','0','4','u',0 };
|
||||||
WCHAR devId[10];
|
WCHAR devId[10];
|
||||||
|
|
||||||
sprintfW(devId, fmt, devInfo->devId);
|
sprintfW(devId, fmt, device->data.DevInst);
|
||||||
RegCreateKeyExW(classKey, devId, 0, NULL, 0, KEY_READ | KEY_WRITE,
|
RegCreateKeyExW(classKey, devId, 0, NULL, 0, KEY_READ | KEY_WRITE,
|
||||||
NULL, &key, NULL);
|
NULL, &key, NULL);
|
||||||
RegCloseKey(classKey);
|
RegCloseKey(classKey);
|
||||||
|
@ -533,7 +526,7 @@ static const struct PropertyMapEntry PropertyMap[] = {
|
||||||
{ REG_MULTI_SZ, "LowerFilters", LowerFilters },
|
{ REG_MULTI_SZ, "LowerFilters", LowerFilters },
|
||||||
};
|
};
|
||||||
|
|
||||||
static BOOL SETUPDI_SetDeviceRegistryPropertyW(struct DeviceInfo *device,
|
static BOOL SETUPDI_SetDeviceRegistryPropertyW(struct device *device,
|
||||||
DWORD prop, const BYTE *buffer, DWORD size)
|
DWORD prop, const BYTE *buffer, DWORD size)
|
||||||
{
|
{
|
||||||
if (prop < ARRAY_SIZE(PropertyMap) && PropertyMap[prop].nameW)
|
if (prop < ARRAY_SIZE(PropertyMap) && PropertyMap[prop].nameW)
|
||||||
|
@ -548,49 +541,13 @@ static BOOL SETUPDI_SetDeviceRegistryPropertyW(struct DeviceInfo *device,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct DeviceInfo *SETUPDI_AllocateDeviceInfo(struct DeviceInfoSet *set,
|
static void SETUPDI_RemoveDevice(struct device *device)
|
||||||
DWORD devId, LPCWSTR instanceId, BOOL phantom)
|
|
||||||
{
|
|
||||||
struct DeviceInfo *devInfo = heap_alloc(sizeof(*devInfo));
|
|
||||||
|
|
||||||
if (devInfo)
|
|
||||||
{
|
|
||||||
devInfo->set = set;
|
|
||||||
devInfo->devId = alloc_devnode(devInfo);
|
|
||||||
|
|
||||||
devInfo->instanceId = HeapAlloc(GetProcessHeap(), 0,
|
|
||||||
(lstrlenW(instanceId) + 1) * sizeof(WCHAR));
|
|
||||||
if (devInfo->instanceId)
|
|
||||||
{
|
|
||||||
devInfo->key = INVALID_HANDLE_VALUE;
|
|
||||||
devInfo->phantom = phantom;
|
|
||||||
lstrcpyW(devInfo->instanceId, instanceId);
|
|
||||||
struprW(devInfo->instanceId);
|
|
||||||
devInfo->key = SETUPDI_CreateDevKey(devInfo);
|
|
||||||
if (devInfo->key != INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
if (phantom)
|
|
||||||
RegSetValueExW(devInfo->key, Phantom, 0, REG_DWORD,
|
|
||||||
(LPBYTE)&phantom, sizeof(phantom));
|
|
||||||
}
|
|
||||||
list_init(&devInfo->interfaces);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
heap_free(devInfo);
|
|
||||||
devInfo = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return devInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SETUPDI_FreeDeviceInfo(struct DeviceInfo *devInfo)
|
|
||||||
{
|
{
|
||||||
struct InterfaceInstances *iface, *next;
|
struct InterfaceInstances *iface, *next;
|
||||||
|
|
||||||
if (devInfo->key != INVALID_HANDLE_VALUE)
|
if (device->key != INVALID_HANDLE_VALUE)
|
||||||
RegCloseKey(devInfo->key);
|
RegCloseKey(device->key);
|
||||||
if (devInfo->phantom)
|
if (device->phantom)
|
||||||
{
|
{
|
||||||
HKEY enumKey;
|
HKEY enumKey;
|
||||||
LONG l;
|
LONG l;
|
||||||
|
@ -599,70 +556,61 @@ static void SETUPDI_FreeDeviceInfo(struct DeviceInfo *devInfo)
|
||||||
KEY_ALL_ACCESS, NULL, &enumKey, NULL);
|
KEY_ALL_ACCESS, NULL, &enumKey, NULL);
|
||||||
if (!l)
|
if (!l)
|
||||||
{
|
{
|
||||||
RegDeleteTreeW(enumKey, devInfo->instanceId);
|
RegDeleteTreeW(enumKey, device->instanceId);
|
||||||
RegCloseKey(enumKey);
|
RegCloseKey(enumKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HeapFree(GetProcessHeap(), 0, devInfo->instanceId);
|
heap_free(device->instanceId);
|
||||||
LIST_FOR_EACH_ENTRY_SAFE(iface, next, &devInfo->interfaces,
|
LIST_FOR_EACH_ENTRY_SAFE(iface, next, &device->interfaces,
|
||||||
struct InterfaceInstances, entry)
|
struct InterfaceInstances, entry)
|
||||||
{
|
{
|
||||||
list_remove(&iface->entry);
|
list_remove(&iface->entry);
|
||||||
SETUPDI_FreeInterfaceInstances(iface);
|
SETUPDI_FreeInterfaceInstances(iface);
|
||||||
HeapFree(GetProcessHeap(), 0, iface);
|
HeapFree(GetProcessHeap(), 0, iface);
|
||||||
}
|
}
|
||||||
free_devnode(devInfo->devId);
|
free_devnode(device->data.DevInst);
|
||||||
heap_free(devInfo);
|
list_remove(&device->entry);
|
||||||
|
heap_free(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Adds a device with GUID guid and identifier devInst to set. Allocates a
|
static SP_DEVINFO_DATA *SETUPDI_CreateDeviceInfo(struct DeviceInfoSet *set,
|
||||||
* struct DeviceInfo, and points the returned device info's Reserved member
|
const GUID *class, const WCHAR *instanceid, BOOL phantom)
|
||||||
* to it. "Phantom" devices are deleted from the registry when closed.
|
|
||||||
* Returns a pointer to the newly allocated device info.
|
|
||||||
*/
|
|
||||||
static BOOL SETUPDI_AddDeviceToSet(struct DeviceInfoSet *set,
|
|
||||||
const GUID *guid,
|
|
||||||
DWORD dev_inst,
|
|
||||||
LPCWSTR instanceId,
|
|
||||||
BOOL phantom,
|
|
||||||
SP_DEVINFO_DATA **dev)
|
|
||||||
{
|
{
|
||||||
BOOL ret = FALSE;
|
struct device *device;
|
||||||
struct DeviceInfo *devInfo = SETUPDI_AllocateDeviceInfo(set, set->cDevices,
|
WCHAR guidstr[39];
|
||||||
instanceId, phantom);
|
|
||||||
|
|
||||||
TRACE("%p, %s, %d, %s, %d\n", set, debugstr_guid(guid), dev_inst,
|
TRACE("%p, %s, %s, %d\n", set, debugstr_guid(class),
|
||||||
debugstr_w(instanceId), phantom);
|
debugstr_w(instanceid), phantom);
|
||||||
|
|
||||||
if (devInfo)
|
if (!(device = heap_alloc(sizeof(*device))))
|
||||||
{
|
{
|
||||||
struct DeviceInstance *devInst =
|
SetLastError(ERROR_OUTOFMEMORY);
|
||||||
HeapAlloc(GetProcessHeap(), 0, sizeof(struct DeviceInstance));
|
return NULL;
|
||||||
|
|
||||||
if (devInst)
|
|
||||||
{
|
|
||||||
WCHAR classGuidStr[39];
|
|
||||||
|
|
||||||
list_add_tail(&set->devices, &devInst->entry);
|
|
||||||
set->cDevices++;
|
|
||||||
devInst->data.cbSize = sizeof(SP_DEVINFO_DATA);
|
|
||||||
devInst->data.ClassGuid = *guid;
|
|
||||||
devInst->data.DevInst = devInfo->devId;
|
|
||||||
devInst->data.Reserved = (ULONG_PTR)devInfo;
|
|
||||||
SETUPDI_GuidToString(guid, classGuidStr);
|
|
||||||
SetupDiSetDeviceRegistryPropertyW(set, &devInst->data,
|
|
||||||
SPDRP_CLASSGUID, (const BYTE *)classGuidStr,
|
|
||||||
lstrlenW(classGuidStr) * sizeof(WCHAR));
|
|
||||||
if (dev) *dev = &devInst->data;
|
|
||||||
ret = TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
HeapFree(GetProcessHeap(), 0, devInfo);
|
|
||||||
SetLastError(ERROR_OUTOFMEMORY);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
|
if (!(device->instanceId = strdupW(instanceid)))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_OUTOFMEMORY);
|
||||||
|
heap_free(device);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
struprW(device->instanceId);
|
||||||
|
device->set = set;
|
||||||
|
device->key = SETUPDI_CreateDevKey(device);
|
||||||
|
device->phantom = phantom;
|
||||||
|
list_init(&device->interfaces);
|
||||||
|
device->data.cbSize = sizeof(SP_DEVINFO_DATA);
|
||||||
|
device->data.ClassGuid = *class;
|
||||||
|
device->data.DevInst = alloc_devnode(device);
|
||||||
|
device->data.Reserved = (ULONG_PTR)device;
|
||||||
|
list_add_tail(&set->devices, &device->entry);
|
||||||
|
set->cDevices++;
|
||||||
|
|
||||||
|
SETUPDI_GuidToString(class, guidstr);
|
||||||
|
SETUPDI_SetDeviceRegistryPropertyW(device, SPDRP_CLASSGUID,
|
||||||
|
(const BYTE *)guidstr, sizeof(guidstr));
|
||||||
|
return &device->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -1332,7 +1280,7 @@ HKEY WINAPI SetupDiCreateDevRegKeyW(
|
||||||
PCWSTR InfSectionName)
|
PCWSTR InfSectionName)
|
||||||
{
|
{
|
||||||
struct DeviceInfoSet *set = DeviceInfoSet;
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
||||||
struct DeviceInfo *devInfo;
|
struct device *device;
|
||||||
HKEY key = INVALID_HANDLE_VALUE;
|
HKEY key = INVALID_HANDLE_VALUE;
|
||||||
|
|
||||||
TRACE("%p %p %d %d %d %p %s\n", DeviceInfoSet, DeviceInfoData, Scope,
|
TRACE("%p %p %d %d %d %p %s\n", DeviceInfoSet, DeviceInfoData, Scope,
|
||||||
|
@ -1354,8 +1302,8 @@ HKEY WINAPI SetupDiCreateDevRegKeyW(
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return INVALID_HANDLE_VALUE;
|
return INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
device = (struct device *)DeviceInfoData->Reserved;
|
||||||
if (devInfo->set != set)
|
if (device->set != set)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return INVALID_HANDLE_VALUE;
|
return INVALID_HANDLE_VALUE;
|
||||||
|
@ -1370,7 +1318,7 @@ HKEY WINAPI SetupDiCreateDevRegKeyW(
|
||||||
SetLastError(ERROR_INVALID_FLAGS);
|
SetLastError(ERROR_INVALID_FLAGS);
|
||||||
return INVALID_HANDLE_VALUE;
|
return INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
if (devInfo->phantom)
|
if (device->phantom)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_DEVINFO_NOT_REGISTERED);
|
SetLastError(ERROR_DEVINFO_NOT_REGISTERED);
|
||||||
return INVALID_HANDLE_VALUE;
|
return INVALID_HANDLE_VALUE;
|
||||||
|
@ -1380,10 +1328,10 @@ HKEY WINAPI SetupDiCreateDevRegKeyW(
|
||||||
switch (KeyType)
|
switch (KeyType)
|
||||||
{
|
{
|
||||||
case DIREG_DEV:
|
case DIREG_DEV:
|
||||||
key = SETUPDI_CreateDevKey(devInfo);
|
key = SETUPDI_CreateDevKey(device);
|
||||||
break;
|
break;
|
||||||
case DIREG_DRV:
|
case DIREG_DRV:
|
||||||
key = SETUPDI_CreateDrvKey(devInfo);
|
key = SETUPDI_CreateDrvKey(device);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
WARN("unknown KeyType %d\n", KeyType);
|
WARN("unknown KeyType %d\n", KeyType);
|
||||||
|
@ -1507,18 +1455,17 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO DeviceInfoSet, PCWSTR DeviceName,
|
||||||
if (set->cDevices)
|
if (set->cDevices)
|
||||||
{
|
{
|
||||||
DWORD highestDevID = 0;
|
DWORD highestDevID = 0;
|
||||||
struct DeviceInstance *devInst;
|
struct device *device;
|
||||||
|
|
||||||
LIST_FOR_EACH_ENTRY(devInst, &set->devices, struct DeviceInstance, entry)
|
LIST_FOR_EACH_ENTRY(device, &set->devices, struct device, entry)
|
||||||
{
|
{
|
||||||
struct DeviceInfo *devInfo = (struct DeviceInfo *)devInst->data.Reserved;
|
const WCHAR *devName = strrchrW(device->instanceId, '\\');
|
||||||
LPCWSTR devName = strrchrW(devInfo->instanceId, '\\');
|
|
||||||
DWORD id;
|
DWORD id;
|
||||||
|
|
||||||
if (devName)
|
if (devName)
|
||||||
devName++;
|
devName++;
|
||||||
else
|
else
|
||||||
devName = devInfo->instanceId;
|
devName = device->instanceId;
|
||||||
id = SETUPDI_DevNameToDevID(devName);
|
id = SETUPDI_DevNameToDevID(devName);
|
||||||
if (id != 0xffffffff && id > highestDevID)
|
if (id != 0xffffffff && id > highestDevID)
|
||||||
highestDevID = id;
|
highestDevID = id;
|
||||||
|
@ -1543,15 +1490,13 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO DeviceInfoSet, PCWSTR DeviceName,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct DeviceInstance *devInst;
|
struct device *device;
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
instanceId = DeviceName;
|
instanceId = DeviceName;
|
||||||
LIST_FOR_EACH_ENTRY(devInst, &set->devices, struct DeviceInstance, entry)
|
LIST_FOR_EACH_ENTRY(device, &set->devices, struct device, entry)
|
||||||
{
|
{
|
||||||
struct DeviceInfo *devInfo = (struct DeviceInfo *)devInst->data.Reserved;
|
if (!lstrcmpiW(DeviceName, device->instanceId))
|
||||||
|
|
||||||
if (!lstrcmpiW(DeviceName, devInfo->instanceId))
|
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_DEVINST_ALREADY_EXISTS);
|
SetLastError(ERROR_DEVINST_ALREADY_EXISTS);
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
|
@ -1562,9 +1507,7 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO DeviceInfoSet, PCWSTR DeviceName,
|
||||||
{
|
{
|
||||||
SP_DEVINFO_DATA *dev = NULL;
|
SP_DEVINFO_DATA *dev = NULL;
|
||||||
|
|
||||||
ret = SETUPDI_AddDeviceToSet(set, ClassGuid, 0 /* FIXME: DevInst */,
|
if ((dev = SETUPDI_CreateDeviceInfo(set, ClassGuid, instanceId, TRUE)))
|
||||||
instanceId, TRUE, &dev);
|
|
||||||
if (ret)
|
|
||||||
{
|
{
|
||||||
if (DeviceDescription)
|
if (DeviceDescription)
|
||||||
SetupDiSetDeviceRegistryPropertyW(DeviceInfoSet,
|
SetupDiSetDeviceRegistryPropertyW(DeviceInfoSet,
|
||||||
|
@ -1600,7 +1543,7 @@ BOOL WINAPI SetupDiRegisterDeviceInfo(
|
||||||
PSP_DEVINFO_DATA DupDeviceInfoData)
|
PSP_DEVINFO_DATA DupDeviceInfoData)
|
||||||
{
|
{
|
||||||
struct DeviceInfoSet *set = DeviceInfoSet;
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
||||||
struct DeviceInfo *devInfo;
|
struct device *device;
|
||||||
|
|
||||||
TRACE("%p %p %08x %p %p %p\n", DeviceInfoSet, DeviceInfoData, Flags,
|
TRACE("%p %p %08x %p %p %p\n", DeviceInfoSet, DeviceInfoData, Flags,
|
||||||
CompareProc, CompareContext, DupDeviceInfoData);
|
CompareProc, CompareContext, DupDeviceInfoData);
|
||||||
|
@ -1621,16 +1564,16 @@ BOOL WINAPI SetupDiRegisterDeviceInfo(
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
device = (struct device *)DeviceInfoData->Reserved;
|
||||||
if (devInfo->set != set)
|
if (device->set != set)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (devInfo->phantom)
|
if (device->phantom)
|
||||||
{
|
{
|
||||||
devInfo->phantom = FALSE;
|
device->phantom = FALSE;
|
||||||
RegDeleteValueW(devInfo->key, Phantom);
|
RegDeleteValueW(device->key, Phantom);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1683,15 +1626,14 @@ BOOL WINAPI SetupDiEnumDeviceInfo(
|
||||||
{
|
{
|
||||||
if (info->cbSize == sizeof(SP_DEVINFO_DATA))
|
if (info->cbSize == sizeof(SP_DEVINFO_DATA))
|
||||||
{
|
{
|
||||||
struct DeviceInstance *devInst;
|
struct device *device;
|
||||||
DWORD i = 0;
|
DWORD i = 0;
|
||||||
|
|
||||||
LIST_FOR_EACH_ENTRY(devInst, &list->devices,
|
LIST_FOR_EACH_ENTRY(device, &list->devices, struct device, entry)
|
||||||
struct DeviceInstance, entry)
|
|
||||||
{
|
{
|
||||||
if (i++ == index)
|
if (i++ == index)
|
||||||
{
|
{
|
||||||
*info = devInst->data;
|
*info = device->data;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1778,7 +1720,7 @@ BOOL WINAPI SetupDiGetDeviceInstanceIdW(
|
||||||
PDWORD RequiredSize)
|
PDWORD RequiredSize)
|
||||||
{
|
{
|
||||||
struct DeviceInfoSet *set = DeviceInfoSet;
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
||||||
struct DeviceInfo *devInfo;
|
struct device *device;
|
||||||
|
|
||||||
TRACE("%p %p %p %d %p\n", DeviceInfoSet, DeviceInfoData, DeviceInstanceId,
|
TRACE("%p %p %p %d %p\n", DeviceInfoSet, DeviceInfoData, DeviceInstanceId,
|
||||||
DeviceInstanceIdSize, RequiredSize);
|
DeviceInstanceIdSize, RequiredSize);
|
||||||
|
@ -1799,23 +1741,23 @@ BOOL WINAPI SetupDiGetDeviceInstanceIdW(
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
device = (struct device *)DeviceInfoData->Reserved;
|
||||||
if (devInfo->set != set)
|
if (device->set != set)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
TRACE("instance ID: %s\n", debugstr_w(devInfo->instanceId));
|
TRACE("instance ID: %s\n", debugstr_w(device->instanceId));
|
||||||
if (DeviceInstanceIdSize < strlenW(devInfo->instanceId) + 1)
|
if (DeviceInstanceIdSize < strlenW(device->instanceId) + 1)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
if (RequiredSize)
|
if (RequiredSize)
|
||||||
*RequiredSize = lstrlenW(devInfo->instanceId) + 1;
|
*RequiredSize = lstrlenW(device->instanceId) + 1;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
lstrcpyW(DeviceInstanceId, devInfo->instanceId);
|
lstrcpyW(DeviceInstanceId, device->instanceId);
|
||||||
if (RequiredSize)
|
if (RequiredSize)
|
||||||
*RequiredSize = lstrlenW(devInfo->instanceId) + 1;
|
*RequiredSize = lstrlenW(device->instanceId) + 1;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2178,9 +2120,8 @@ static void SETUPDI_EnumerateMatchingInterfaces(HDEVINFO DeviceInfoSet,
|
||||||
deviceClassStr[37] = 0;
|
deviceClassStr[37] = 0;
|
||||||
UuidFromStringW(&deviceClassStr[1],
|
UuidFromStringW(&deviceClassStr[1],
|
||||||
&deviceClass);
|
&deviceClass);
|
||||||
if (SETUPDI_AddDeviceToSet(set, &deviceClass,
|
if ((dev = SETUPDI_CreateDeviceInfo(set,
|
||||||
0 /* FIXME: DevInst */, deviceInst,
|
&deviceClass, deviceInst, FALSE)))
|
||||||
FALSE, &dev))
|
|
||||||
SETUPDI_AddDeviceInterfaces(dev, subKey, guid);
|
SETUPDI_AddDeviceInterfaces(dev, subKey, guid);
|
||||||
}
|
}
|
||||||
RegCloseKey(deviceKey);
|
RegCloseKey(deviceKey);
|
||||||
|
@ -2305,9 +2246,8 @@ static void SETUPDI_EnumerateMatchingDeviceInstances(struct DeviceInfoSet *set,
|
||||||
{
|
{
|
||||||
sprintfW(instanceId, fmt, enumerator,
|
sprintfW(instanceId, fmt, enumerator,
|
||||||
deviceName, deviceInstance);
|
deviceName, deviceInstance);
|
||||||
SETUPDI_AddDeviceToSet(set, &deviceClass,
|
SETUPDI_CreateDeviceInfo(set, &deviceClass,
|
||||||
0 /* FIXME: DevInst */, instanceId,
|
instanceId, FALSE);
|
||||||
FALSE, NULL);
|
|
||||||
HeapFree(GetProcessHeap(), 0, instanceId);
|
HeapFree(GetProcessHeap(), 0, instanceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2569,7 +2509,7 @@ BOOL WINAPI SetupDiCreateDeviceInterfaceW(
|
||||||
PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
|
PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
|
||||||
{
|
{
|
||||||
struct DeviceInfoSet *set = DeviceInfoSet;
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
||||||
struct DeviceInfo *devInfo;
|
struct device *device;
|
||||||
SP_DEVICE_INTERFACE_DATA *iface = NULL;
|
SP_DEVICE_INTERFACE_DATA *iface = NULL;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
|
@ -2593,8 +2533,8 @@ BOOL WINAPI SetupDiCreateDeviceInterfaceW(
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
device = (struct device *)DeviceInfoData->Reserved;
|
||||||
if (devInfo->set != set)
|
if (device->set != set)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -2751,12 +2691,12 @@ HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyW(
|
||||||
samDesired, NULL, &interfKey, NULL);
|
samDesired, NULL, &interfKey, NULL);
|
||||||
if (!l)
|
if (!l)
|
||||||
{
|
{
|
||||||
struct DeviceInfo *devInfo =
|
struct device *device =
|
||||||
(struct DeviceInfo *)ifaceInfo->device->Reserved;
|
(struct device *)ifaceInfo->device->Reserved;
|
||||||
|
|
||||||
l = RegSetValueExW(interfKey, DeviceInstance, 0, REG_SZ,
|
l = RegSetValueExW(interfKey, DeviceInstance, 0, REG_SZ,
|
||||||
(BYTE *)devInfo->instanceId,
|
(BYTE *)device->instanceId,
|
||||||
(lstrlenW(devInfo->instanceId) + 1) * sizeof(WCHAR));
|
(lstrlenW(device->instanceId) + 1) * sizeof(WCHAR));
|
||||||
if (!l)
|
if (!l)
|
||||||
{
|
{
|
||||||
if (instancePath)
|
if (instancePath)
|
||||||
|
@ -2901,11 +2841,10 @@ BOOL WINAPI SetupDiEnumDeviceInterfaces(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA
|
||||||
|
|
||||||
if (DeviceInfoData)
|
if (DeviceInfoData)
|
||||||
{
|
{
|
||||||
struct DeviceInfo *devInfo =
|
struct device *device = (struct device *)DeviceInfoData->Reserved;
|
||||||
(struct DeviceInfo *)DeviceInfoData->Reserved;
|
|
||||||
struct InterfaceInstances *iface;
|
struct InterfaceInstances *iface;
|
||||||
|
|
||||||
if ((ret = SETUPDI_FindInterface(devInfo, InterfaceClassGuid, &iface)))
|
if ((ret = SETUPDI_FindInterface(device, InterfaceClassGuid, &iface)))
|
||||||
{
|
{
|
||||||
if (MemberIndex < iface->cInstances)
|
if (MemberIndex < iface->cInstances)
|
||||||
*DeviceInterfaceData = iface->instances[MemberIndex];
|
*DeviceInterfaceData = iface->instances[MemberIndex];
|
||||||
|
@ -2920,18 +2859,17 @@ BOOL WINAPI SetupDiEnumDeviceInterfaces(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct DeviceInstance *devInst;
|
struct device *device;
|
||||||
DWORD cEnumerated = 0;
|
DWORD cEnumerated = 0;
|
||||||
BOOL found = FALSE;
|
BOOL found = FALSE;
|
||||||
|
|
||||||
LIST_FOR_EACH_ENTRY(devInst, &set->devices, struct DeviceInstance, entry)
|
LIST_FOR_EACH_ENTRY(device, &set->devices, struct device, entry)
|
||||||
{
|
{
|
||||||
struct DeviceInfo *devInfo = (struct DeviceInfo *)devInst->data.Reserved;
|
|
||||||
struct InterfaceInstances *iface;
|
struct InterfaceInstances *iface;
|
||||||
|
|
||||||
if (found || cEnumerated >= MemberIndex + 1)
|
if (found || cEnumerated >= MemberIndex + 1)
|
||||||
break;
|
break;
|
||||||
if (SETUPDI_FindInterface(devInfo, InterfaceClassGuid, &iface))
|
if (SETUPDI_FindInterface(device, InterfaceClassGuid, &iface))
|
||||||
{
|
{
|
||||||
if (cEnumerated + iface->cInstances < MemberIndex + 1)
|
if (cEnumerated + iface->cInstances < MemberIndex + 1)
|
||||||
cEnumerated += iface->cInstances;
|
cEnumerated += iface->cInstances;
|
||||||
|
@ -2975,14 +2913,12 @@ BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
|
||||||
|
|
||||||
if (list->magic == SETUP_DEVICE_INFO_SET_MAGIC)
|
if (list->magic == SETUP_DEVICE_INFO_SET_MAGIC)
|
||||||
{
|
{
|
||||||
struct DeviceInstance *devInst, *devInst2;
|
struct device *device, *device2;
|
||||||
|
|
||||||
LIST_FOR_EACH_ENTRY_SAFE(devInst, devInst2, &list->devices,
|
LIST_FOR_EACH_ENTRY_SAFE(device, device2, &list->devices,
|
||||||
struct DeviceInstance, entry)
|
struct device, entry)
|
||||||
{
|
{
|
||||||
SETUPDI_FreeDeviceInfo( (struct DeviceInfo *)devInst->data.Reserved );
|
SETUPDI_RemoveDevice(device);
|
||||||
list_remove(&devInst->entry);
|
|
||||||
HeapFree(GetProcessHeap(), 0, devInst);
|
|
||||||
}
|
}
|
||||||
HeapFree(GetProcessHeap(), 0, list);
|
HeapFree(GetProcessHeap(), 0, list);
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
@ -3148,7 +3084,7 @@ BOOL WINAPI SetupDiGetDeviceRegistryPropertyA(
|
||||||
{
|
{
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
struct DeviceInfoSet *set = DeviceInfoSet;
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
||||||
struct DeviceInfo *devInfo;
|
struct device *device;
|
||||||
|
|
||||||
TRACE("%p %p %d %p %p %d %p\n", DeviceInfoSet, DeviceInfoData,
|
TRACE("%p %p %d %p %p %d %p\n", DeviceInfoSet, DeviceInfoData,
|
||||||
Property, PropertyRegDataType, PropertyBuffer, PropertyBufferSize,
|
Property, PropertyRegDataType, PropertyBuffer, PropertyBufferSize,
|
||||||
|
@ -3175,12 +3111,12 @@ BOOL WINAPI SetupDiGetDeviceRegistryPropertyA(
|
||||||
SetLastError(ERROR_INVALID_DATA);
|
SetLastError(ERROR_INVALID_DATA);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
device = (struct device *)DeviceInfoData->Reserved;
|
||||||
if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
|
if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
|
||||||
&& PropertyMap[Property].nameA)
|
&& PropertyMap[Property].nameA)
|
||||||
{
|
{
|
||||||
DWORD size = PropertyBufferSize;
|
DWORD size = PropertyBufferSize;
|
||||||
LONG l = RegQueryValueExA(devInfo->key, PropertyMap[Property].nameA,
|
LONG l = RegQueryValueExA(device->key, PropertyMap[Property].nameA,
|
||||||
NULL, PropertyRegDataType, PropertyBuffer, &size);
|
NULL, PropertyRegDataType, PropertyBuffer, &size);
|
||||||
|
|
||||||
if (l == ERROR_FILE_NOT_FOUND)
|
if (l == ERROR_FILE_NOT_FOUND)
|
||||||
|
@ -3211,7 +3147,7 @@ BOOL WINAPI SetupDiGetDeviceRegistryPropertyW(
|
||||||
{
|
{
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
struct DeviceInfoSet *set = DeviceInfoSet;
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
||||||
struct DeviceInfo *devInfo;
|
struct device *device;
|
||||||
|
|
||||||
TRACE("%p %p %d %p %p %d %p\n", DeviceInfoSet, DeviceInfoData,
|
TRACE("%p %p %d %p %p %d %p\n", DeviceInfoSet, DeviceInfoData,
|
||||||
Property, PropertyRegDataType, PropertyBuffer, PropertyBufferSize,
|
Property, PropertyRegDataType, PropertyBuffer, PropertyBufferSize,
|
||||||
|
@ -3238,12 +3174,12 @@ BOOL WINAPI SetupDiGetDeviceRegistryPropertyW(
|
||||||
SetLastError(ERROR_INVALID_DATA);
|
SetLastError(ERROR_INVALID_DATA);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
device = (struct device *)DeviceInfoData->Reserved;
|
||||||
if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
|
if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
|
||||||
&& PropertyMap[Property].nameW)
|
&& PropertyMap[Property].nameW)
|
||||||
{
|
{
|
||||||
DWORD size = PropertyBufferSize;
|
DWORD size = PropertyBufferSize;
|
||||||
LONG l = RegQueryValueExW(devInfo->key, PropertyMap[Property].nameW,
|
LONG l = RegQueryValueExW(device->key, PropertyMap[Property].nameW,
|
||||||
NULL, PropertyRegDataType, PropertyBuffer, &size);
|
NULL, PropertyRegDataType, PropertyBuffer, &size);
|
||||||
|
|
||||||
if (l == ERROR_FILE_NOT_FOUND)
|
if (l == ERROR_FILE_NOT_FOUND)
|
||||||
|
@ -3272,7 +3208,7 @@ BOOL WINAPI SetupDiSetDeviceRegistryPropertyA(
|
||||||
{
|
{
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
struct DeviceInfoSet *set = DeviceInfoSet;
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
||||||
struct DeviceInfo *devInfo;
|
struct device *device;
|
||||||
|
|
||||||
TRACE("%p %p %d %p %d\n", DeviceInfoSet, DeviceInfoData, Property,
|
TRACE("%p %p %d %p %d\n", DeviceInfoSet, DeviceInfoData, Property,
|
||||||
PropertyBuffer, PropertyBufferSize);
|
PropertyBuffer, PropertyBufferSize);
|
||||||
|
@ -3293,11 +3229,11 @@ BOOL WINAPI SetupDiSetDeviceRegistryPropertyA(
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
device = (struct device *)DeviceInfoData->Reserved;
|
||||||
if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
|
if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
|
||||||
&& PropertyMap[Property].nameA)
|
&& PropertyMap[Property].nameA)
|
||||||
{
|
{
|
||||||
LONG l = RegSetValueExA(devInfo->key, PropertyMap[Property].nameA, 0,
|
LONG l = RegSetValueExA(device->key, PropertyMap[Property].nameA, 0,
|
||||||
PropertyMap[Property].regType, PropertyBuffer,
|
PropertyMap[Property].regType, PropertyBuffer,
|
||||||
PropertyBufferSize);
|
PropertyBufferSize);
|
||||||
if (!l)
|
if (!l)
|
||||||
|
@ -3315,7 +3251,7 @@ BOOL WINAPI SetupDiSetDeviceRegistryPropertyW(HDEVINFO devinfo,
|
||||||
SP_DEVINFO_DATA *device_data, DWORD prop, const BYTE *buffer, DWORD size)
|
SP_DEVINFO_DATA *device_data, DWORD prop, const BYTE *buffer, DWORD size)
|
||||||
{
|
{
|
||||||
struct DeviceInfoSet *set = devinfo;
|
struct DeviceInfoSet *set = devinfo;
|
||||||
struct DeviceInfo *device;
|
struct device *device;
|
||||||
|
|
||||||
TRACE("%p %p %d %p %d\n", devinfo, device_data, prop, buffer, size);
|
TRACE("%p %p %d %p %d\n", devinfo, device_data, prop, buffer, size);
|
||||||
|
|
||||||
|
@ -3336,7 +3272,7 @@ BOOL WINAPI SetupDiSetDeviceRegistryPropertyW(HDEVINFO devinfo,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
device = (struct DeviceInfo *)device_data->Reserved;
|
device = (struct device *)device_data->Reserved;
|
||||||
return SETUPDI_SetDeviceRegistryPropertyW(device, prop, buffer, size);
|
return SETUPDI_SetDeviceRegistryPropertyW(device, prop, buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3781,7 +3717,7 @@ BOOL WINAPI SetupDiSetDeviceInstallParamsW(
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HKEY SETUPDI_OpenDevKey(struct DeviceInfo *devInfo, REGSAM samDesired)
|
static HKEY SETUPDI_OpenDevKey(struct device *device, REGSAM samDesired)
|
||||||
{
|
{
|
||||||
HKEY enumKey, key = INVALID_HANDLE_VALUE;
|
HKEY enumKey, key = INVALID_HANDLE_VALUE;
|
||||||
LONG l;
|
LONG l;
|
||||||
|
@ -3790,13 +3726,13 @@ static HKEY SETUPDI_OpenDevKey(struct DeviceInfo *devInfo, REGSAM samDesired)
|
||||||
NULL, &enumKey, NULL);
|
NULL, &enumKey, NULL);
|
||||||
if (!l)
|
if (!l)
|
||||||
{
|
{
|
||||||
RegOpenKeyExW(enumKey, devInfo->instanceId, 0, samDesired, &key);
|
RegOpenKeyExW(enumKey, device->instanceId, 0, samDesired, &key);
|
||||||
RegCloseKey(enumKey);
|
RegCloseKey(enumKey);
|
||||||
}
|
}
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HKEY SETUPDI_OpenDrvKey(struct DeviceInfo *devInfo, REGSAM samDesired)
|
static HKEY SETUPDI_OpenDrvKey(struct device *device, REGSAM samDesired)
|
||||||
{
|
{
|
||||||
static const WCHAR slash[] = { '\\',0 };
|
static const WCHAR slash[] = { '\\',0 };
|
||||||
WCHAR classKeyPath[MAX_PATH];
|
WCHAR classKeyPath[MAX_PATH];
|
||||||
|
@ -3805,7 +3741,7 @@ static HKEY SETUPDI_OpenDrvKey(struct DeviceInfo *devInfo, REGSAM samDesired)
|
||||||
|
|
||||||
lstrcpyW(classKeyPath, ControlClass);
|
lstrcpyW(classKeyPath, ControlClass);
|
||||||
lstrcatW(classKeyPath, slash);
|
lstrcatW(classKeyPath, slash);
|
||||||
SETUPDI_GuidToString(&devInfo->set->ClassGuid,
|
SETUPDI_GuidToString(&device->set->ClassGuid,
|
||||||
classKeyPath + lstrlenW(classKeyPath));
|
classKeyPath + lstrlenW(classKeyPath));
|
||||||
l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, classKeyPath, 0, NULL, 0,
|
l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, classKeyPath, 0, NULL, 0,
|
||||||
KEY_ALL_ACCESS, NULL, &classKey, NULL);
|
KEY_ALL_ACCESS, NULL, &classKey, NULL);
|
||||||
|
@ -3814,7 +3750,7 @@ static HKEY SETUPDI_OpenDrvKey(struct DeviceInfo *devInfo, REGSAM samDesired)
|
||||||
static const WCHAR fmt[] = { '%','0','4','u',0 };
|
static const WCHAR fmt[] = { '%','0','4','u',0 };
|
||||||
WCHAR devId[10];
|
WCHAR devId[10];
|
||||||
|
|
||||||
sprintfW(devId, fmt, devInfo->devId);
|
sprintfW(devId, fmt, device->data.DevInst);
|
||||||
l = RegOpenKeyExW(classKey, devId, 0, samDesired, &key);
|
l = RegOpenKeyExW(classKey, devId, 0, samDesired, &key);
|
||||||
RegCloseKey(classKey);
|
RegCloseKey(classKey);
|
||||||
if (l)
|
if (l)
|
||||||
|
@ -3838,7 +3774,7 @@ HKEY WINAPI SetupDiOpenDevRegKey(
|
||||||
REGSAM samDesired)
|
REGSAM samDesired)
|
||||||
{
|
{
|
||||||
struct DeviceInfoSet *set = DeviceInfoSet;
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
||||||
struct DeviceInfo *devInfo;
|
struct device *device;
|
||||||
HKEY key = INVALID_HANDLE_VALUE;
|
HKEY key = INVALID_HANDLE_VALUE;
|
||||||
|
|
||||||
TRACE("%p %p %d %d %d %x\n", DeviceInfoSet, DeviceInfoData,
|
TRACE("%p %p %d %d %d %x\n", DeviceInfoSet, DeviceInfoData,
|
||||||
|
@ -3870,13 +3806,13 @@ HKEY WINAPI SetupDiOpenDevRegKey(
|
||||||
SetLastError(ERROR_INVALID_FLAGS);
|
SetLastError(ERROR_INVALID_FLAGS);
|
||||||
return INVALID_HANDLE_VALUE;
|
return INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
device = (struct device *)DeviceInfoData->Reserved;
|
||||||
if (devInfo->set != set)
|
if (device->set != set)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return INVALID_HANDLE_VALUE;
|
return INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
if (devInfo->phantom)
|
if (device->phantom)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_DEVINFO_NOT_REGISTERED);
|
SetLastError(ERROR_DEVINFO_NOT_REGISTERED);
|
||||||
return INVALID_HANDLE_VALUE;
|
return INVALID_HANDLE_VALUE;
|
||||||
|
@ -3886,10 +3822,10 @@ HKEY WINAPI SetupDiOpenDevRegKey(
|
||||||
switch (KeyType)
|
switch (KeyType)
|
||||||
{
|
{
|
||||||
case DIREG_DEV:
|
case DIREG_DEV:
|
||||||
key = SETUPDI_OpenDevKey(devInfo, samDesired);
|
key = SETUPDI_OpenDevKey(device, samDesired);
|
||||||
break;
|
break;
|
||||||
case DIREG_DRV:
|
case DIREG_DRV:
|
||||||
key = SETUPDI_OpenDrvKey(devInfo, samDesired);
|
key = SETUPDI_OpenDrvKey(device, samDesired);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
WARN("unknown KeyType %d\n", KeyType);
|
WARN("unknown KeyType %d\n", KeyType);
|
||||||
|
@ -3897,7 +3833,7 @@ HKEY WINAPI SetupDiOpenDevRegKey(
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL SETUPDI_DeleteDevKey(struct DeviceInfo *devInfo)
|
static BOOL SETUPDI_DeleteDevKey(struct device *device)
|
||||||
{
|
{
|
||||||
HKEY enumKey;
|
HKEY enumKey;
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
|
@ -3907,7 +3843,7 @@ static BOOL SETUPDI_DeleteDevKey(struct DeviceInfo *devInfo)
|
||||||
NULL, &enumKey, NULL);
|
NULL, &enumKey, NULL);
|
||||||
if (!l)
|
if (!l)
|
||||||
{
|
{
|
||||||
ret = RegDeleteTreeW(enumKey, devInfo->instanceId);
|
ret = RegDeleteTreeW(enumKey, device->instanceId);
|
||||||
RegCloseKey(enumKey);
|
RegCloseKey(enumKey);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3915,7 +3851,7 @@ static BOOL SETUPDI_DeleteDevKey(struct DeviceInfo *devInfo)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL SETUPDI_DeleteDrvKey(struct DeviceInfo *devInfo)
|
static BOOL SETUPDI_DeleteDrvKey(struct device *device)
|
||||||
{
|
{
|
||||||
static const WCHAR slash[] = { '\\',0 };
|
static const WCHAR slash[] = { '\\',0 };
|
||||||
WCHAR classKeyPath[MAX_PATH];
|
WCHAR classKeyPath[MAX_PATH];
|
||||||
|
@ -3925,7 +3861,7 @@ static BOOL SETUPDI_DeleteDrvKey(struct DeviceInfo *devInfo)
|
||||||
|
|
||||||
lstrcpyW(classKeyPath, ControlClass);
|
lstrcpyW(classKeyPath, ControlClass);
|
||||||
lstrcatW(classKeyPath, slash);
|
lstrcatW(classKeyPath, slash);
|
||||||
SETUPDI_GuidToString(&devInfo->set->ClassGuid,
|
SETUPDI_GuidToString(&device->set->ClassGuid,
|
||||||
classKeyPath + lstrlenW(classKeyPath));
|
classKeyPath + lstrlenW(classKeyPath));
|
||||||
l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, classKeyPath, 0, NULL, 0,
|
l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, classKeyPath, 0, NULL, 0,
|
||||||
KEY_ALL_ACCESS, NULL, &classKey, NULL);
|
KEY_ALL_ACCESS, NULL, &classKey, NULL);
|
||||||
|
@ -3934,7 +3870,7 @@ static BOOL SETUPDI_DeleteDrvKey(struct DeviceInfo *devInfo)
|
||||||
static const WCHAR fmt[] = { '%','0','4','u',0 };
|
static const WCHAR fmt[] = { '%','0','4','u',0 };
|
||||||
WCHAR devId[10];
|
WCHAR devId[10];
|
||||||
|
|
||||||
sprintfW(devId, fmt, devInfo->devId);
|
sprintfW(devId, fmt, device->data.DevInst);
|
||||||
ret = RegDeleteTreeW(classKey, devId);
|
ret = RegDeleteTreeW(classKey, devId);
|
||||||
RegCloseKey(classKey);
|
RegCloseKey(classKey);
|
||||||
}
|
}
|
||||||
|
@ -3954,7 +3890,7 @@ BOOL WINAPI SetupDiDeleteDevRegKey(
|
||||||
DWORD KeyType)
|
DWORD KeyType)
|
||||||
{
|
{
|
||||||
struct DeviceInfoSet *set = DeviceInfoSet;
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
||||||
struct DeviceInfo *devInfo;
|
struct device *device;
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
TRACE("%p %p %d %d %d\n", DeviceInfoSet, DeviceInfoData, Scope, HwProfile,
|
TRACE("%p %p %d %d %d\n", DeviceInfoSet, DeviceInfoData, Scope, HwProfile,
|
||||||
|
@ -3986,13 +3922,13 @@ BOOL WINAPI SetupDiDeleteDevRegKey(
|
||||||
SetLastError(ERROR_INVALID_FLAGS);
|
SetLastError(ERROR_INVALID_FLAGS);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
device = (struct device *)DeviceInfoData->Reserved;
|
||||||
if (devInfo->set != set)
|
if (device->set != set)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (devInfo->phantom)
|
if (device->phantom)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_DEVINFO_NOT_REGISTERED);
|
SetLastError(ERROR_DEVINFO_NOT_REGISTERED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -4002,15 +3938,15 @@ BOOL WINAPI SetupDiDeleteDevRegKey(
|
||||||
switch (KeyType)
|
switch (KeyType)
|
||||||
{
|
{
|
||||||
case DIREG_DEV:
|
case DIREG_DEV:
|
||||||
ret = SETUPDI_DeleteDevKey(devInfo);
|
ret = SETUPDI_DeleteDevKey(device);
|
||||||
break;
|
break;
|
||||||
case DIREG_DRV:
|
case DIREG_DRV:
|
||||||
ret = SETUPDI_DeleteDrvKey(devInfo);
|
ret = SETUPDI_DeleteDrvKey(device);
|
||||||
break;
|
break;
|
||||||
case DIREG_BOTH:
|
case DIREG_BOTH:
|
||||||
ret = SETUPDI_DeleteDevKey(devInfo);
|
ret = SETUPDI_DeleteDevKey(device);
|
||||||
if (ret)
|
if (ret)
|
||||||
ret = SETUPDI_DeleteDrvKey(devInfo);
|
ret = SETUPDI_DeleteDrvKey(device);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
WARN("unknown KeyType %d\n", KeyType);
|
WARN("unknown KeyType %d\n", KeyType);
|
||||||
|
@ -4023,7 +3959,7 @@ BOOL WINAPI SetupDiDeleteDevRegKey(
|
||||||
*/
|
*/
|
||||||
CONFIGRET WINAPI CM_Get_Device_IDA(DEVINST devnode, char *buffer, ULONG len, ULONG flags)
|
CONFIGRET WINAPI CM_Get_Device_IDA(DEVINST devnode, char *buffer, ULONG len, ULONG flags)
|
||||||
{
|
{
|
||||||
struct DeviceInfo *device = get_devnode_device(devnode);
|
struct device *device = get_devnode_device(devnode);
|
||||||
|
|
||||||
TRACE("%u, %p, %u, %#x\n", devnode, buffer, len, flags);
|
TRACE("%u, %p, %u, %#x\n", devnode, buffer, len, flags);
|
||||||
|
|
||||||
|
@ -4040,7 +3976,7 @@ CONFIGRET WINAPI CM_Get_Device_IDA(DEVINST devnode, char *buffer, ULONG len, ULO
|
||||||
*/
|
*/
|
||||||
CONFIGRET WINAPI CM_Get_Device_IDW(DEVINST devnode, WCHAR *buffer, ULONG len, ULONG flags)
|
CONFIGRET WINAPI CM_Get_Device_IDW(DEVINST devnode, WCHAR *buffer, ULONG len, ULONG flags)
|
||||||
{
|
{
|
||||||
struct DeviceInfo *device = get_devnode_device(devnode);
|
struct device *device = get_devnode_device(devnode);
|
||||||
|
|
||||||
TRACE("%u, %p, %u, %#x\n", devnode, buffer, len, flags);
|
TRACE("%u, %p, %u, %#x\n", devnode, buffer, len, flags);
|
||||||
|
|
||||||
|
@ -4057,7 +3993,7 @@ CONFIGRET WINAPI CM_Get_Device_IDW(DEVINST devnode, WCHAR *buffer, ULONG len, UL
|
||||||
*/
|
*/
|
||||||
CONFIGRET WINAPI CM_Get_Device_ID_Size(ULONG *len, DEVINST devnode, ULONG flags)
|
CONFIGRET WINAPI CM_Get_Device_ID_Size(ULONG *len, DEVINST devnode, ULONG flags)
|
||||||
{
|
{
|
||||||
struct DeviceInfo *device = get_devnode_device(devnode);
|
struct device *device = get_devnode_device(devnode);
|
||||||
|
|
||||||
TRACE("%p, %u, %#x\n", len, devnode, flags);
|
TRACE("%p, %u, %#x\n", len, devnode, flags);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue