setupapi: Return the "Device Parameters" subkey for DIREG_DEV.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=21023 Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e6b9a83bb4
commit
486fffa45c
|
@ -1426,6 +1426,7 @@ HKEY WINAPI SetupDiCreateDevRegKeyW(HDEVINFO devinfo, SP_DEVINFO_DATA *device_da
|
|||
{
|
||||
struct device *device;
|
||||
HKEY key = INVALID_HANDLE_VALUE;
|
||||
LONG l;
|
||||
|
||||
TRACE("devinfo %p, device_data %p, scope %d, profile %d, type %d, inf_handle %p, inf_section %s.\n",
|
||||
devinfo, device_data, Scope, HwProfile, KeyType, InfHandle, debugstr_w(InfSectionName));
|
||||
|
@ -1453,7 +1454,12 @@ HKEY WINAPI SetupDiCreateDevRegKeyW(HDEVINFO devinfo, SP_DEVINFO_DATA *device_da
|
|||
switch (KeyType)
|
||||
{
|
||||
case DIREG_DEV:
|
||||
key = SETUPDI_CreateDevKey(device);
|
||||
if ((l = RegCreateKeyExW(device->key, DeviceParameters, 0, NULL, 0,
|
||||
KEY_READ | KEY_WRITE, NULL, &key, NULL)))
|
||||
{
|
||||
key = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
SetLastError(l);
|
||||
break;
|
||||
case DIREG_DRV:
|
||||
key = create_driver_key(device);
|
||||
|
@ -3512,21 +3518,6 @@ BOOL WINAPI SetupDiSetDevicePropertyW(HDEVINFO devinfo, PSP_DEVINFO_DATA device_
|
|||
}
|
||||
}
|
||||
|
||||
static HKEY SETUPDI_OpenDevKey(struct device *device, REGSAM samDesired)
|
||||
{
|
||||
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)
|
||||
{
|
||||
RegOpenKeyExW(enumKey, device->instanceId, 0, samDesired, &key);
|
||||
RegCloseKey(enumKey);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupDiOpenDevRegKey (SETUPAPI.@)
|
||||
*/
|
||||
|
@ -3535,6 +3526,7 @@ HKEY WINAPI SetupDiOpenDevRegKey(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data,
|
|||
{
|
||||
struct device *device;
|
||||
HKEY key = INVALID_HANDLE_VALUE;
|
||||
LONG l;
|
||||
|
||||
TRACE("devinfo %p, device_data %p, scope %d, profile %d, type %d, access %#x.\n",
|
||||
devinfo, device_data, Scope, HwProfile, KeyType, samDesired);
|
||||
|
@ -3563,7 +3555,9 @@ HKEY WINAPI SetupDiOpenDevRegKey(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data,
|
|||
switch (KeyType)
|
||||
{
|
||||
case DIREG_DEV:
|
||||
key = SETUPDI_OpenDevKey(device, samDesired);
|
||||
if ((l = RegOpenKeyExW(device->key, DeviceParameters, 0, samDesired, &key)))
|
||||
key = INVALID_HANDLE_VALUE;
|
||||
SetLastError(l);
|
||||
break;
|
||||
case DIREG_DRV:
|
||||
key = open_driver_key(device, samDesired);
|
||||
|
@ -3574,24 +3568,6 @@ HKEY WINAPI SetupDiOpenDevRegKey(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data,
|
|||
return key;
|
||||
}
|
||||
|
||||
static BOOL SETUPDI_DeleteDevKey(struct device *device)
|
||||
{
|
||||
HKEY enumKey;
|
||||
BOOL ret = FALSE;
|
||||
LONG l;
|
||||
|
||||
l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, Enum, 0, NULL, 0, KEY_ALL_ACCESS,
|
||||
NULL, &enumKey, NULL);
|
||||
if (!l)
|
||||
{
|
||||
ret = RegDeleteTreeW(enumKey, device->instanceId);
|
||||
RegCloseKey(enumKey);
|
||||
}
|
||||
else
|
||||
SetLastError(l);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupDiDeleteDevRegKey (SETUPAPI.@)
|
||||
*/
|
||||
|
@ -3600,6 +3576,7 @@ BOOL WINAPI SetupDiDeleteDevRegKey(HDEVINFO devinfo, SP_DEVINFO_DATA *device_dat
|
|||
{
|
||||
struct device *device;
|
||||
BOOL ret = FALSE;
|
||||
LONG l;
|
||||
|
||||
TRACE("devinfo %p, device_data %p, scope %d, profile %d, type %d.\n",
|
||||
devinfo, device_data, Scope, HwProfile, KeyType);
|
||||
|
@ -3627,16 +3604,17 @@ BOOL WINAPI SetupDiDeleteDevRegKey(HDEVINFO devinfo, SP_DEVINFO_DATA *device_dat
|
|||
FIXME("unimplemented for scope %d\n", Scope);
|
||||
switch (KeyType)
|
||||
{
|
||||
case DIREG_DEV:
|
||||
ret = SETUPDI_DeleteDevKey(device);
|
||||
break;
|
||||
case DIREG_DRV:
|
||||
ret = delete_driver_key(device);
|
||||
break;
|
||||
case DIREG_BOTH:
|
||||
ret = SETUPDI_DeleteDevKey(device);
|
||||
if (ret)
|
||||
ret = delete_driver_key(device);
|
||||
if (!(ret = delete_driver_key(device)))
|
||||
break;
|
||||
/* fall through */
|
||||
case DIREG_DEV:
|
||||
l = RegDeleteKeyW(device->key, DeviceParameters);
|
||||
SetLastError(l);
|
||||
ret = !l;
|
||||
break;
|
||||
default:
|
||||
WARN("unknown KeyType %d\n", KeyType);
|
||||
|
|
|
@ -1030,6 +1030,8 @@ static void test_device_iface_detail(void)
|
|||
|
||||
static void test_device_key(void)
|
||||
{
|
||||
static const char params_key_path[] = "System\\CurrentControlSet\\Enum\\Root"
|
||||
"\\LEGACY_BOGUS\\0000\\Device Parameters";
|
||||
static const char class_key_path[] = "System\\CurrentControlSet\\Control\\Class"
|
||||
"\\{6a55b5a4-3f65-11db-b704-0011955c2bdb}";
|
||||
static const WCHAR bogus[] = {'S','y','s','t','e','m','\\',
|
||||
|
@ -1159,6 +1161,43 @@ todo_wine {
|
|||
ok(key == INVALID_HANDLE_VALUE, "Expected failure.\n");
|
||||
ok(GetLastError() == ERROR_KEY_DOES_NOT_EXIST, "Got unexpected error %#x.\n", GetLastError());
|
||||
|
||||
key = SetupDiOpenDevRegKey(set, &device, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_READ);
|
||||
ok(key == INVALID_HANDLE_VALUE, "Expected failure.\n");
|
||||
todo_wine
|
||||
ok(GetLastError() == ERROR_KEY_DOES_NOT_EXIST, "Got unexpected error %#x.\n", GetLastError());
|
||||
|
||||
res = RegOpenKeyA(HKEY_LOCAL_MACHINE, params_key_path, &key);
|
||||
ok(res == ERROR_FILE_NOT_FOUND, "Key should not exist.\n");
|
||||
|
||||
key = SetupDiCreateDevRegKeyA(set, &device, DICS_FLAG_GLOBAL, 0, DIREG_DEV, NULL, NULL);
|
||||
ok(key != INVALID_HANDLE_VALUE, "Got unexpected error %#x.\n", GetLastError());
|
||||
RegCloseKey(key);
|
||||
|
||||
res = RegOpenKeyA(HKEY_LOCAL_MACHINE, params_key_path, &key);
|
||||
ok(!res, "Failed to open device key, error %u.\n", res);
|
||||
res = RegSetValueExA(key, "foo", 0, REG_SZ, (BYTE *)"bar", sizeof("bar"));
|
||||
ok(!res, "Failed to set value, error %u.\n", res);
|
||||
RegCloseKey(key);
|
||||
|
||||
key = SetupDiOpenDevRegKey(set, &device, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_READ);
|
||||
ok(key != INVALID_HANDLE_VALUE, "Got unexpected error %#x.\n", GetLastError());
|
||||
size = sizeof(data);
|
||||
res = RegQueryValueExA(key, "foo", NULL, NULL, (BYTE *)data, &size);
|
||||
ok(!res, "Failed to get value, error %u.\n", res);
|
||||
ok(!strcmp(data, "bar"), "Got wrong data %s.\n", data);
|
||||
RegCloseKey(key);
|
||||
|
||||
ret = SetupDiDeleteDevRegKey(set, &device, DICS_FLAG_GLOBAL, 0, DIREG_DEV);
|
||||
ok(ret, "Got unexpected error %#x.\n", GetLastError());
|
||||
|
||||
key = SetupDiOpenDevRegKey(set, &device, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_READ);
|
||||
ok(key == INVALID_HANDLE_VALUE, "Expected failure.\n");
|
||||
todo_wine
|
||||
ok(GetLastError() == ERROR_KEY_DOES_NOT_EXIST, "Got unexpected error %#x.\n", GetLastError());
|
||||
|
||||
res = RegOpenKeyA(HKEY_LOCAL_MACHINE, params_key_path, &key);
|
||||
ok(res == ERROR_FILE_NOT_FOUND, "Key should not exist.\n");
|
||||
|
||||
key = SetupDiCreateDevRegKeyW(set, &device, DICS_FLAG_GLOBAL, 0, DIREG_DRV, NULL, NULL);
|
||||
ok(key != INVALID_HANDLE_VALUE, "Failed to create device key, error %#x.\n", GetLastError());
|
||||
RegCloseKey(key);
|
||||
|
|
Loading…
Reference in New Issue