setupapi: Store the class and reference string keys in the device_iface structure.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b9e556d5e8
commit
72c5f3b57d
|
@ -93,6 +93,7 @@ static const WCHAR Phantom[] = {'P','h','a','n','t','o','m',0};
|
||||||
static const WCHAR SymbolicLink[] = {'S','y','m','b','o','l','i','c','L','i','n','k',0};
|
static const WCHAR SymbolicLink[] = {'S','y','m','b','o','l','i','c','L','i','n','k',0};
|
||||||
static const WCHAR Control[] = {'C','o','n','t','r','o','l',0};
|
static const WCHAR Control[] = {'C','o','n','t','r','o','l',0};
|
||||||
static const WCHAR Linked[] = {'L','i','n','k','e','d',0};
|
static const WCHAR Linked[] = {'L','i','n','k','e','d',0};
|
||||||
|
static const WCHAR emptyW[] = {0};
|
||||||
|
|
||||||
/* is used to identify if a DeviceInfoSet pointer is
|
/* is used to identify if a DeviceInfoSet pointer is
|
||||||
valid or not */
|
valid or not */
|
||||||
|
@ -126,6 +127,8 @@ struct device_iface
|
||||||
struct device *device;
|
struct device *device;
|
||||||
GUID class;
|
GUID class;
|
||||||
DWORD flags;
|
DWORD flags;
|
||||||
|
HKEY class_key;
|
||||||
|
HKEY refstr_key;
|
||||||
struct list entry;
|
struct list entry;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -377,7 +380,7 @@ static struct device_iface *SETUPDI_CreateDeviceInterface(struct device *device,
|
||||||
{
|
{
|
||||||
struct device_iface *iface = NULL;
|
struct device_iface *iface = NULL;
|
||||||
WCHAR *refstr2 = NULL, *symlink = NULL, *path = NULL;
|
WCHAR *refstr2 = NULL, *symlink = NULL, *path = NULL;
|
||||||
HKEY key = NULL;
|
HKEY key;
|
||||||
LONG ret;
|
LONG ret;
|
||||||
|
|
||||||
TRACE("%p %s %s\n", device, debugstr_guid(class), debugstr_w(refstr));
|
TRACE("%p %s %s\n", device, debugstr_guid(class), debugstr_w(refstr));
|
||||||
|
@ -422,9 +425,10 @@ static struct device_iface *SETUPDI_CreateDeviceInterface(struct device *device,
|
||||||
}
|
}
|
||||||
RegSetValueExW(key, DeviceInstance, 0, REG_SZ, (BYTE *)device->instanceId,
|
RegSetValueExW(key, DeviceInstance, 0, REG_SZ, (BYTE *)device->instanceId,
|
||||||
lstrlenW(device->instanceId) * sizeof(WCHAR));
|
lstrlenW(device->instanceId) * sizeof(WCHAR));
|
||||||
RegCloseKey(key);
|
|
||||||
heap_free(path);
|
heap_free(path);
|
||||||
|
|
||||||
|
iface->class_key = key;
|
||||||
|
|
||||||
if (!(path = get_refstr_key_path(iface)))
|
if (!(path = get_refstr_key_path(iface)))
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_OUTOFMEMORY);
|
SetLastError(ERROR_OUTOFMEMORY);
|
||||||
|
@ -442,9 +446,10 @@ static struct device_iface *SETUPDI_CreateDeviceInterface(struct device *device,
|
||||||
if (is_linked(key))
|
if (is_linked(key))
|
||||||
iface->flags |= SPINT_ACTIVE;
|
iface->flags |= SPINT_ACTIVE;
|
||||||
|
|
||||||
RegCloseKey(key);
|
|
||||||
heap_free(path);
|
heap_free(path);
|
||||||
|
|
||||||
|
iface->refstr_key = key;
|
||||||
|
|
||||||
list_add_tail(&device->interfaces, &iface->entry);
|
list_add_tail(&device->interfaces, &iface->entry);
|
||||||
return iface;
|
return iface;
|
||||||
|
|
||||||
|
@ -554,7 +559,6 @@ static BOOL SETUPDI_SetDeviceRegistryPropertyW(struct device *device,
|
||||||
static void SETUPDI_RemoveDevice(struct device *device)
|
static void SETUPDI_RemoveDevice(struct device *device)
|
||||||
{
|
{
|
||||||
struct device_iface *iface, *next;
|
struct device_iface *iface, *next;
|
||||||
WCHAR *path;
|
|
||||||
|
|
||||||
if (device->key != INVALID_HANDLE_VALUE)
|
if (device->key != INVALID_HANDLE_VALUE)
|
||||||
RegCloseKey(device->key);
|
RegCloseKey(device->key);
|
||||||
|
@ -576,11 +580,10 @@ static void SETUPDI_RemoveDevice(struct device *device)
|
||||||
struct device_iface, entry)
|
struct device_iface, entry)
|
||||||
{
|
{
|
||||||
list_remove(&iface->entry);
|
list_remove(&iface->entry);
|
||||||
if (device->phantom && (path = get_refstr_key_path(iface)))
|
if (device->phantom)
|
||||||
{
|
RegDeleteKeyW(iface->refstr_key, emptyW);
|
||||||
RegDeleteKeyW(HKEY_LOCAL_MACHINE, path);
|
RegCloseKey(iface->refstr_key);
|
||||||
heap_free(path);
|
RegCloseKey(iface->class_key);
|
||||||
}
|
|
||||||
heap_free(iface->refstr);
|
heap_free(iface->refstr);
|
||||||
heap_free(iface->symlink);
|
heap_free(iface->symlink);
|
||||||
heap_free(iface);
|
heap_free(iface);
|
||||||
|
@ -2486,8 +2489,7 @@ HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyW(HDEVINFO devinfo,
|
||||||
HINF hinf, const WCHAR *section)
|
HINF hinf, const WCHAR *section)
|
||||||
{
|
{
|
||||||
struct device_iface *iface;
|
struct device_iface *iface;
|
||||||
HKEY refstr_key, params_key;
|
HKEY params_key;
|
||||||
WCHAR *path;
|
|
||||||
LONG ret;
|
LONG ret;
|
||||||
|
|
||||||
TRACE("devinfo %p, iface_data %p, reserved %d, access %#x, hinf %p, section %s.\n",
|
TRACE("devinfo %p, iface_data %p, reserved %d, access %#x, hinf %p, section %s.\n",
|
||||||
|
@ -2501,24 +2503,8 @@ HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyW(HDEVINFO devinfo,
|
||||||
return INVALID_HANDLE_VALUE;
|
return INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(path = get_refstr_key_path(iface)))
|
ret = RegCreateKeyExW(iface->refstr_key, DeviceParameters, 0, NULL, 0, access,
|
||||||
{
|
|
||||||
SetLastError(ERROR_OUTOFMEMORY);
|
|
||||||
return INVALID_HANDLE_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = RegCreateKeyExW(HKEY_LOCAL_MACHINE, path, 0, NULL, 0, 0, NULL,
|
|
||||||
&refstr_key, NULL);
|
|
||||||
heap_free(path);
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
SetLastError(ret);
|
|
||||||
return INVALID_HANDLE_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = RegCreateKeyExW(refstr_key, DeviceParameters, 0, NULL, 0, access,
|
|
||||||
NULL, ¶ms_key, NULL);
|
NULL, ¶ms_key, NULL);
|
||||||
RegCloseKey(refstr_key);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
SetLastError(ret);
|
SetLastError(ret);
|
||||||
|
@ -2535,8 +2521,6 @@ BOOL WINAPI SetupDiDeleteDeviceInterfaceRegKey(HDEVINFO devinfo,
|
||||||
SP_DEVICE_INTERFACE_DATA *iface_data, DWORD reserved)
|
SP_DEVICE_INTERFACE_DATA *iface_data, DWORD reserved)
|
||||||
{
|
{
|
||||||
struct device_iface *iface;
|
struct device_iface *iface;
|
||||||
HKEY refstr_key;
|
|
||||||
WCHAR *path;
|
|
||||||
LONG ret;
|
LONG ret;
|
||||||
|
|
||||||
TRACE("devinfo %p, iface_data %p, reserved %d.\n", devinfo, iface_data, reserved);
|
TRACE("devinfo %p, iface_data %p, reserved %d.\n", devinfo, iface_data, reserved);
|
||||||
|
@ -2544,23 +2528,7 @@ BOOL WINAPI SetupDiDeleteDeviceInterfaceRegKey(HDEVINFO devinfo,
|
||||||
if (!(iface = get_device_iface(devinfo, iface_data)))
|
if (!(iface = get_device_iface(devinfo, iface_data)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!(path = get_refstr_key_path(iface)))
|
ret = RegDeleteKeyW(iface->refstr_key, DeviceParameters);
|
||||||
{
|
|
||||||
SetLastError(ERROR_OUTOFMEMORY);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = RegCreateKeyExW(HKEY_LOCAL_MACHINE, path, 0, NULL, 0, 0, NULL,
|
|
||||||
&refstr_key, NULL);
|
|
||||||
heap_free(path);
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
SetLastError(ret);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = RegDeleteKeyW(refstr_key, DeviceParameters);
|
|
||||||
RegCloseKey(refstr_key);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
SetLastError(ret);
|
SetLastError(ret);
|
||||||
|
|
Loading…
Reference in New Issue