setupapi: Add helper function to open a device's hardware key.
This commit is contained in:
parent
e6a9eb6b85
commit
22724c2c8b
|
@ -407,6 +407,22 @@ static BOOL SETUPDI_SetInterfaceSymbolicLink(SP_DEVICE_INTERFACE_DATA *iface,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HKEY SETUPDI_CreateDevKey(struct DeviceInfo *devInfo)
|
||||||
|
{
|
||||||
|
HKEY enumKey, key = INVALID_HANDLE_VALUE;
|
||||||
|
LONG l;
|
||||||
|
|
||||||
|
l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, Enum, 0, NULL, 0, KEY_ALL_ACCESS,
|
||||||
|
NULL, &enumKey, NULL);
|
||||||
|
if (!l)
|
||||||
|
{
|
||||||
|
RegCreateKeyExW(enumKey, devInfo->instanceId, 0, NULL, 0,
|
||||||
|
KEY_READ | KEY_WRITE, NULL, &key, NULL);
|
||||||
|
RegCloseKey(enumKey);
|
||||||
|
}
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
static struct DeviceInfo *SETUPDI_AllocateDeviceInfo(struct DeviceInfoSet *set,
|
static struct DeviceInfo *SETUPDI_AllocateDeviceInfo(struct DeviceInfoSet *set,
|
||||||
LPCWSTR instanceId, BOOL phantom)
|
LPCWSTR instanceId, BOOL phantom)
|
||||||
{
|
{
|
||||||
|
@ -420,23 +436,16 @@ static struct DeviceInfo *SETUPDI_AllocateDeviceInfo(struct DeviceInfoSet *set,
|
||||||
(lstrlenW(instanceId) + 1) * sizeof(WCHAR));
|
(lstrlenW(instanceId) + 1) * sizeof(WCHAR));
|
||||||
if (devInfo->instanceId)
|
if (devInfo->instanceId)
|
||||||
{
|
{
|
||||||
HKEY enumKey;
|
|
||||||
LONG l;
|
|
||||||
|
|
||||||
devInfo->key = INVALID_HANDLE_VALUE;
|
devInfo->key = INVALID_HANDLE_VALUE;
|
||||||
devInfo->phantom = phantom;
|
devInfo->phantom = phantom;
|
||||||
lstrcpyW(devInfo->instanceId, instanceId);
|
lstrcpyW(devInfo->instanceId, instanceId);
|
||||||
struprW(devInfo->instanceId);
|
struprW(devInfo->instanceId);
|
||||||
l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, Enum, 0, NULL, 0,
|
devInfo->key = SETUPDI_CreateDevKey(devInfo);
|
||||||
KEY_ALL_ACCESS, NULL, &enumKey, NULL);
|
if (devInfo->key != INVALID_HANDLE_VALUE)
|
||||||
if (!l)
|
|
||||||
{
|
{
|
||||||
RegCreateKeyExW(enumKey, devInfo->instanceId, 0, NULL, 0,
|
|
||||||
KEY_ALL_ACCESS, NULL, &devInfo->key, NULL);
|
|
||||||
if (phantom)
|
if (phantom)
|
||||||
RegSetValueExW(devInfo->key, Phantom, 0, REG_DWORD,
|
RegSetValueExW(devInfo->key, Phantom, 0, REG_DWORD,
|
||||||
(LPBYTE)&phantom, sizeof(phantom));
|
(LPBYTE)&phantom, sizeof(phantom));
|
||||||
RegCloseKey(enumKey);
|
|
||||||
}
|
}
|
||||||
list_init(&devInfo->interfaces);
|
list_init(&devInfo->interfaces);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue