Commit 629123ba authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

setupapi: Implement SetupDiOpenDevRegKey.

parent 559f89af
...@@ -3558,6 +3558,46 @@ BOOL WINAPI SetupDiGetDeviceInstallParamsA( ...@@ -3558,6 +3558,46 @@ BOOL WINAPI SetupDiGetDeviceInstallParamsA(
return FALSE; return FALSE;
} }
static HKEY SETUPDI_OpenDevKey(struct DeviceInfo *devInfo, 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, devInfo->instanceId, 0, samDesired, &key);
RegCloseKey(enumKey);
}
return key;
}
static HKEY SETUPDI_OpenDrvKey(struct DeviceInfo *devInfo, REGSAM samDesired)
{
static const WCHAR slash[] = { '\\',0 };
WCHAR classKeyPath[MAX_PATH];
HKEY classKey, key = INVALID_HANDLE_VALUE;
LONG l;
lstrcpyW(classKeyPath, ControlClass);
lstrcatW(classKeyPath, slash);
SETUPDI_GuidToString(&devInfo->set->ClassGuid,
classKeyPath + lstrlenW(classKeyPath));
l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, classKeyPath, 0, NULL, 0,
KEY_ALL_ACCESS, NULL, &classKey, NULL);
if (!l)
{
static const WCHAR fmt[] = { '%','0','4','u',0 };
WCHAR devId[10];
sprintfW(devId, fmt, devInfo->devId);
RegOpenKeyExW(classKey, devId, 0, samDesired, &key);
RegCloseKey(classKey);
}
return key;
}
/*********************************************************************** /***********************************************************************
* SetupDiOpenDevRegKey (SETUPAPI.@) * SetupDiOpenDevRegKey (SETUPAPI.@)
*/ */
...@@ -3569,7 +3609,62 @@ HKEY WINAPI SetupDiOpenDevRegKey( ...@@ -3569,7 +3609,62 @@ HKEY WINAPI SetupDiOpenDevRegKey(
DWORD KeyType, DWORD KeyType,
REGSAM samDesired) REGSAM samDesired)
{ {
FIXME("%p %p %d %d %d %x\n", DeviceInfoSet, DeviceInfoData, struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
struct DeviceInfo *devInfo;
HKEY key = INVALID_HANDLE_VALUE;
TRACE("%p %p %d %d %d %x\n", DeviceInfoSet, DeviceInfoData,
Scope, HwProfile, KeyType, samDesired); Scope, HwProfile, KeyType, samDesired);
return INVALID_HANDLE_VALUE;
if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
{
SetLastError(ERROR_INVALID_HANDLE);
return INVALID_HANDLE_VALUE;
}
if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
{
SetLastError(ERROR_INVALID_HANDLE);
return INVALID_HANDLE_VALUE;
}
if (!DeviceInfoData || DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA)
|| !DeviceInfoData->Reserved)
{
SetLastError(ERROR_INVALID_PARAMETER);
return INVALID_HANDLE_VALUE;
}
if (Scope != DICS_FLAG_GLOBAL && Scope != DICS_FLAG_CONFIGSPECIFIC)
{
SetLastError(ERROR_INVALID_FLAGS);
return INVALID_HANDLE_VALUE;
}
if (KeyType != DIREG_DEV && KeyType != DIREG_DRV)
{
SetLastError(ERROR_INVALID_FLAGS);
return INVALID_HANDLE_VALUE;
}
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
if (devInfo->set != set)
{
SetLastError(ERROR_INVALID_PARAMETER);
return INVALID_HANDLE_VALUE;
}
if (devInfo->phantom)
{
SetLastError(ERROR_DEVINFO_NOT_REGISTERED);
return INVALID_HANDLE_VALUE;
}
if (Scope != DICS_FLAG_GLOBAL)
FIXME("unimplemented for scope %d\n", Scope);
switch (KeyType)
{
case DIREG_DEV:
key = SETUPDI_OpenDevKey(devInfo, samDesired);
break;
case DIREG_DRV:
key = SETUPDI_OpenDrvKey(devInfo, samDesired);
break;
default:
WARN("unknown KeyType %d\n", KeyType);
}
return key;
} }
...@@ -618,39 +618,33 @@ static void testDevRegKey(void) ...@@ -618,39 +618,33 @@ static void testDevRegKey(void)
ok(ret, "SetupDiCreateDeviceInfoA failed: %08x\n", GetLastError()); ok(ret, "SetupDiCreateDeviceInfoA failed: %08x\n", GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
key = pSetupDiOpenDevRegKey(NULL, NULL, 0, 0, 0, 0); key = pSetupDiOpenDevRegKey(NULL, NULL, 0, 0, 0, 0);
todo_wine
ok(key == INVALID_HANDLE_VALUE && ok(key == INVALID_HANDLE_VALUE &&
GetLastError() == ERROR_INVALID_HANDLE, GetLastError() == ERROR_INVALID_HANDLE,
"Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError()); "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
key = pSetupDiOpenDevRegKey(set, NULL, 0, 0, 0, 0); key = pSetupDiOpenDevRegKey(set, NULL, 0, 0, 0, 0);
todo_wine
ok(key == INVALID_HANDLE_VALUE && ok(key == INVALID_HANDLE_VALUE &&
GetLastError() == ERROR_INVALID_PARAMETER, GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
key = pSetupDiOpenDevRegKey(set, &devInfo, 0, 0, 0, 0); key = pSetupDiOpenDevRegKey(set, &devInfo, 0, 0, 0, 0);
todo_wine
ok(key == INVALID_HANDLE_VALUE && ok(key == INVALID_HANDLE_VALUE &&
GetLastError() == ERROR_INVALID_FLAGS, GetLastError() == ERROR_INVALID_FLAGS,
"Expected ERROR_INVALID_FLAGS, got %d\n", GetLastError()); "Expected ERROR_INVALID_FLAGS, got %d\n", GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
key = pSetupDiOpenDevRegKey(set, &devInfo, DICS_FLAG_GLOBAL, 0, 0, 0); key = pSetupDiOpenDevRegKey(set, &devInfo, DICS_FLAG_GLOBAL, 0, 0, 0);
todo_wine
ok(key == INVALID_HANDLE_VALUE && ok(key == INVALID_HANDLE_VALUE &&
GetLastError() == ERROR_INVALID_FLAGS, GetLastError() == ERROR_INVALID_FLAGS,
"Expected ERROR_INVALID_FLAGS, got %d\n", GetLastError()); "Expected ERROR_INVALID_FLAGS, got %d\n", GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
key = pSetupDiOpenDevRegKey(set, &devInfo, DICS_FLAG_GLOBAL, 0, key = pSetupDiOpenDevRegKey(set, &devInfo, DICS_FLAG_GLOBAL, 0,
DIREG_BOTH, 0); DIREG_BOTH, 0);
todo_wine
ok(key == INVALID_HANDLE_VALUE && ok(key == INVALID_HANDLE_VALUE &&
GetLastError() == ERROR_INVALID_FLAGS, GetLastError() == ERROR_INVALID_FLAGS,
"Expected ERROR_INVALID_FLAGS, got %d\n", GetLastError()); "Expected ERROR_INVALID_FLAGS, got %d\n", GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
key = pSetupDiOpenDevRegKey(set, &devInfo, DICS_FLAG_GLOBAL, 0, key = pSetupDiOpenDevRegKey(set, &devInfo, DICS_FLAG_GLOBAL, 0,
DIREG_DRV, 0); DIREG_DRV, 0);
todo_wine
ok(key == INVALID_HANDLE_VALUE && ok(key == INVALID_HANDLE_VALUE &&
GetLastError() == ERROR_DEVINFO_NOT_REGISTERED, GetLastError() == ERROR_DEVINFO_NOT_REGISTERED,
"Expected ERROR_DEVINFO_NOT_REGISTERED, got %08x\n", GetLastError()); "Expected ERROR_DEVINFO_NOT_REGISTERED, got %08x\n", GetLastError());
...@@ -687,7 +681,6 @@ static void testDevRegKey(void) ...@@ -687,7 +681,6 @@ static void testDevRegKey(void)
"Expected ERROR_INVALID_DATA, got %08x\n", GetLastError()); "Expected ERROR_INVALID_DATA, got %08x\n", GetLastError());
key = pSetupDiOpenDevRegKey(set, &devInfo, DICS_FLAG_GLOBAL, 0, key = pSetupDiOpenDevRegKey(set, &devInfo, DICS_FLAG_GLOBAL, 0,
DIREG_DRV, KEY_READ); DIREG_DRV, KEY_READ);
todo_wine
ok(key != INVALID_HANDLE_VALUE, "SetupDiOpenDevRegKey failed: %08x\n", ok(key != INVALID_HANDLE_VALUE, "SetupDiOpenDevRegKey failed: %08x\n",
GetLastError()); GetLastError());
ret = pSetupDiCallClassInstaller(DIF_REMOVE, set, &devInfo); ret = pSetupDiCallClassInstaller(DIF_REMOVE, set, &devInfo);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment