Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/tests/devinst.c | 204 ++++++++++++++++++------------------------ 1 file changed, 87 insertions(+), 117 deletions(-)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 7d485dd145..7461eb5841 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -36,7 +36,6 @@ static BOOL is_wow64;
/* function pointers */ -static HDEVINFO (WINAPI *pSetupDiCreateDeviceInfoList)(GUID*,HWND); static HDEVINFO (WINAPI *pSetupDiCreateDeviceInfoListExW)(GUID*,HWND,PCWSTR,PVOID); static BOOL (WINAPI *pSetupDiCreateDeviceInterfaceA)(HDEVINFO, PSP_DEVINFO_DATA, const GUID *, PCSTR, DWORD, PSP_DEVICE_INTERFACE_DATA); static BOOL (WINAPI *pSetupDiCallClassInstaller)(DI_FUNCTION, HDEVINFO, PSP_DEVINFO_DATA); @@ -44,8 +43,6 @@ static BOOL (WINAPI *pSetupDiDestroyDeviceInfoList)(HDEVINFO); static BOOL (WINAPI *pSetupDiEnumDeviceInterfaces)(HDEVINFO, PSP_DEVINFO_DATA, const GUID *, DWORD, PSP_DEVICE_INTERFACE_DATA); static BOOL (WINAPI *pSetupDiGetINFClassA)(PCSTR, LPGUID, PSTR, DWORD, PDWORD); static HKEY (WINAPI *pSetupDiOpenClassRegKeyExA)(GUID*,REGSAM,DWORD,PCSTR,PVOID); -static HKEY (WINAPI *pSetupDiOpenDevRegKey)(HDEVINFO, PSP_DEVINFO_DATA, DWORD, DWORD, DWORD, REGSAM); -static HKEY (WINAPI *pSetupDiCreateDevRegKeyW)(HDEVINFO, PSP_DEVINFO_DATA, DWORD, DWORD, DWORD, HINF, PCWSTR); static BOOL (WINAPI *pSetupDiCreateDeviceInfoA)(HDEVINFO, PCSTR, GUID *, PCSTR, HWND, DWORD, PSP_DEVINFO_DATA); static BOOL (WINAPI *pSetupDiCreateDeviceInfoW)(HDEVINFO, PCWSTR, GUID *, PCWSTR, HWND, DWORD, PSP_DEVINFO_DATA); static BOOL (WINAPI *pSetupDiGetDeviceInterfaceDetailA)(HDEVINFO, PSP_DEVICE_INTERFACE_DATA, PSP_DEVICE_INTERFACE_DETAIL_DATA_A, DWORD, PDWORD, PSP_DEVINFO_DATA); @@ -71,7 +68,6 @@ static void init_function_pointers(void)
pSetupDiCreateDeviceInfoA = (void *)GetProcAddress(hSetupAPI, "SetupDiCreateDeviceInfoA"); pSetupDiCreateDeviceInfoW = (void *)GetProcAddress(hSetupAPI, "SetupDiCreateDeviceInfoW"); - pSetupDiCreateDeviceInfoList = (void *)GetProcAddress(hSetupAPI, "SetupDiCreateDeviceInfoList"); pSetupDiCreateDeviceInfoListExW = (void *)GetProcAddress(hSetupAPI, "SetupDiCreateDeviceInfoListExW"); pSetupDiCreateDeviceInterfaceA = (void *)GetProcAddress(hSetupAPI, "SetupDiCreateDeviceInterfaceA"); pSetupDiDestroyDeviceInfoList = (void *)GetProcAddress(hSetupAPI, "SetupDiDestroyDeviceInfoList"); @@ -79,8 +75,6 @@ static void init_function_pointers(void) pSetupDiEnumDeviceInterfaces = (void *)GetProcAddress(hSetupAPI, "SetupDiEnumDeviceInterfaces"); pSetupDiGetDeviceInterfaceDetailA = (void *)GetProcAddress(hSetupAPI, "SetupDiGetDeviceInterfaceDetailA"); pSetupDiOpenClassRegKeyExA = (void *)GetProcAddress(hSetupAPI, "SetupDiOpenClassRegKeyExA"); - pSetupDiOpenDevRegKey = (void *)GetProcAddress(hSetupAPI, "SetupDiOpenDevRegKey"); - pSetupDiCreateDevRegKeyW = (void *)GetProcAddress(hSetupAPI, "SetupDiCreateDevRegKeyW"); pSetupDiRegisterDeviceInfo = (void *)GetProcAddress(hSetupAPI, "SetupDiRegisterDeviceInfo"); pSetupDiGetClassDevsA = (void *)GetProcAddress(hSetupAPI, "SetupDiGetClassDevsA"); pSetupDiGetClassDevsW = (void *)GetProcAddress(hSetupAPI, "SetupDiGetClassDevsW"); @@ -823,7 +817,7 @@ static void test_device_iface_detail(void) devinst_RegDeleteTreeW(HKEY_LOCAL_MACHINE, devclass); }
-static void testDevRegKey(void) +static void test_device_key(void) { static const WCHAR classKey[] = {'S','y','s','t','e','m','\', 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\', @@ -835,128 +829,104 @@ static void testDevRegKey(void) 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\', 'E','n','u','m','\','R','o','o','t','\', 'L','E','G','A','C','Y','_','B','O','G','U','S',0}; + SP_DEVINFO_DATA device = {sizeof(device)}; BOOL ret; HDEVINFO set; HKEY key = NULL; + LONG res;
SetLastError(0xdeadbeef); - key = pSetupDiCreateDevRegKeyW(NULL, NULL, 0, 0, 0, NULL, NULL); - ok(key == INVALID_HANDLE_VALUE, - "Expected INVALID_HANDLE_VALUE, got %p\n", key); - ok(GetLastError() == ERROR_INVALID_HANDLE, - "Expected ERROR_INVALID_HANDLE, got %08x\n", GetLastError()); + key = SetupDiCreateDevRegKeyW(NULL, NULL, 0, 0, 0, NULL, NULL); + ok(key == INVALID_HANDLE_VALUE, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected error %#x.\n", GetLastError());
- set = pSetupDiCreateDeviceInfoList(&guid, NULL); - ok(set != NULL, "SetupDiCreateDeviceInfoList failed: %d\n", GetLastError()); - if (set) - { - SP_DEVINFO_DATA devInfo = { sizeof(devInfo), { 0 } }; - LONG res; + set = SetupDiCreateDeviceInfoList(&guid, NULL); + ok(set != NULL, "Failed to create device list, error %#x.\n", GetLastError()); + + res = RegOpenKeyW(HKEY_LOCAL_MACHINE, bogus, &key); + ok(res != ERROR_SUCCESS, "Key should not exist.\n"); + RegCloseKey(key); + + ret = SetupDiCreateDeviceInfoA(set, "ROOT\LEGACY_BOGUS\0000", &guid, NULL, NULL, 0, &device); + ok(ret, "Failed to create device, error %#x.\n", GetLastError()); + ok(!RegOpenKeyW(HKEY_LOCAL_MACHINE, bogus, &key), "Key should exist.\n"); + RegCloseKey(key); + + SetLastError(0xdeadbeef); + key = SetupDiOpenDevRegKey(NULL, NULL, 0, 0, 0, 0); + ok(key == INVALID_HANDLE_VALUE, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected error %#x.\n", GetLastError());
- /* The device info key shouldn't be there */ - res = RegOpenKeyW(HKEY_LOCAL_MACHINE, bogus, &key); - ok(res != ERROR_SUCCESS, "Expected key to not exist\n"); + SetLastError(0xdeadbeef); + key = SetupDiOpenDevRegKey(set, NULL, 0, 0, 0, 0); + ok(key == INVALID_HANDLE_VALUE, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error %#x.\n", GetLastError()); + + SetLastError(0xdeadbeef); + key = SetupDiOpenDevRegKey(set, &device, 0, 0, 0, 0); + ok(key == INVALID_HANDLE_VALUE, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_FLAGS, "Got unexpected error %#x.\n", GetLastError()); + + SetLastError(0xdeadbeef); + key = SetupDiOpenDevRegKey(set, &device, DICS_FLAG_GLOBAL, 0, 0, 0); + ok(key == INVALID_HANDLE_VALUE, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_FLAGS, "Got unexpected error %#x.\n", GetLastError()); + + SetLastError(0xdeadbeef); + key = SetupDiOpenDevRegKey(set, &device, DICS_FLAG_GLOBAL, 0, DIREG_BOTH, 0); + ok(key == INVALID_HANDLE_VALUE, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_FLAGS, "Got unexpected error %#x.\n", GetLastError()); + + SetLastError(0xdeadbeef); + key = SetupDiOpenDevRegKey(set, &device, DICS_FLAG_GLOBAL, 0, DIREG_DRV, 0); + ok(key == INVALID_HANDLE_VALUE, "Expected failure.\n"); + ok(GetLastError() == ERROR_DEVINFO_NOT_REGISTERED, "Got unexpected error %#x.\n", GetLastError()); + + ret = SetupDiRegisterDeviceInfo(set, &device, 0, NULL, NULL, NULL); + ok(ret, "Failed to register device, error %#x.\n", GetLastError()); + + SetLastError(0xdeadbeef); + key = SetupDiOpenDevRegKey(set, &device, DICS_FLAG_GLOBAL, 0, DIREG_DRV, 0); + ok(key == INVALID_HANDLE_VALUE, "Expected failure.\n"); + ok(GetLastError() == ERROR_KEY_DOES_NOT_EXIST, "Got unexpected error %#x.\n", GetLastError()); + + SetLastError(0xdeadbeef); + res = RegOpenKeyW(HKEY_LOCAL_MACHINE, classKey, &key); +todo_wine + ok(res == ERROR_FILE_NOT_FOUND, "Key should not exist.\n"); + RegCloseKey(key); + + key = SetupDiCreateDevRegKeyW(set, &device, DICS_FLAG_GLOBAL, 0, DIREG_DRV, NULL, NULL); + ok(key != INVALID_HANDLE_VALUE || GetLastError() == ERROR_KEY_DOES_NOT_EXIST, /* Vista+ */ + "Failed to create device key, error %#x.\n", GetLastError()); + if (key != INVALID_HANDLE_VALUE) + { RegCloseKey(key); - /* Create the device information */ - ret = pSetupDiCreateDeviceInfoA(set, "ROOT\LEGACY_BOGUS\0000", &guid, - NULL, NULL, 0, &devInfo); - ok(ret, "SetupDiCreateDeviceInfoA failed: %08x\n", GetLastError()); - /* The device info key should have been created */ - ok(!RegOpenKeyW(HKEY_LOCAL_MACHINE, bogus, &key), - "Expected registry key to exist\n"); + + ok(!RegOpenKeyW(HKEY_LOCAL_MACHINE, classKey, &key), "Key should exist.\n"); RegCloseKey(key); + SetLastError(0xdeadbeef); - key = pSetupDiOpenDevRegKey(NULL, NULL, 0, 0, 0, 0); - ok(!key || key == INVALID_HANDLE_VALUE, - "Expected INVALID_HANDLE_VALUE or a NULL key (NT4)\n"); - ok(GetLastError() == ERROR_INVALID_HANDLE, - "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError()); - SetLastError(0xdeadbeef); - key = pSetupDiOpenDevRegKey(set, NULL, 0, 0, 0, 0); - ok(key == INVALID_HANDLE_VALUE && - GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); - SetLastError(0xdeadbeef); - key = pSetupDiOpenDevRegKey(set, &devInfo, 0, 0, 0, 0); - ok(key == INVALID_HANDLE_VALUE && - GetLastError() == ERROR_INVALID_FLAGS, - "Expected ERROR_INVALID_FLAGS, got %d\n", GetLastError()); - SetLastError(0xdeadbeef); - key = pSetupDiOpenDevRegKey(set, &devInfo, DICS_FLAG_GLOBAL, 0, 0, 0); - ok(key == INVALID_HANDLE_VALUE && - GetLastError() == ERROR_INVALID_FLAGS, - "Expected ERROR_INVALID_FLAGS, got %d\n", GetLastError()); - SetLastError(0xdeadbeef); - key = pSetupDiOpenDevRegKey(set, &devInfo, DICS_FLAG_GLOBAL, 0, - DIREG_BOTH, 0); - ok(key == INVALID_HANDLE_VALUE && - GetLastError() == ERROR_INVALID_FLAGS, - "Expected ERROR_INVALID_FLAGS, got %d\n", GetLastError()); - SetLastError(0xdeadbeef); - key = pSetupDiOpenDevRegKey(set, &devInfo, DICS_FLAG_GLOBAL, 0, - DIREG_DRV, 0); - ok(key == INVALID_HANDLE_VALUE && - GetLastError() == ERROR_DEVINFO_NOT_REGISTERED, - "Expected ERROR_DEVINFO_NOT_REGISTERED, got %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = pSetupDiRegisterDeviceInfo(set, &devInfo, 0, NULL, NULL, NULL); - ok(ret, "SetupDiRegisterDeviceInfo failed: %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - key = pSetupDiOpenDevRegKey(set, &devInfo, DICS_FLAG_GLOBAL, 0, - DIREG_DRV, 0); - /* The software key isn't created by default */ - ok(key == INVALID_HANDLE_VALUE && - GetLastError() == ERROR_KEY_DOES_NOT_EXIST, - "Expected ERROR_KEY_DOES_NOT_EXIST, got %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - key = pSetupDiOpenDevRegKey(set, &devInfo, DICS_FLAG_GLOBAL, 0, - DIREG_DEV, 0); - todo_wine - ok(key == INVALID_HANDLE_VALUE && - GetLastError() == ERROR_KEY_DOES_NOT_EXIST, - "Expected ERROR_KEY_DOES_NOT_EXIST, got %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - /* The class key shouldn't be there */ - res = RegOpenKeyW(HKEY_LOCAL_MACHINE, classKey, &key); - todo_wine - ok(res != ERROR_SUCCESS, "Expected key to not exist\n"); + key = SetupDiOpenDevRegKey(set, &device, DICS_FLAG_GLOBAL, 0, DIREG_DRV, 0); +todo_wine { + ok(key == INVALID_HANDLE_VALUE, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_DATA || GetLastError() == ERROR_ACCESS_DENIED, /* win2k3 */ + "Got unexpected error %#x.\n", GetLastError()); +} + + key = SetupDiOpenDevRegKey(set, &device, DICS_FLAG_GLOBAL, 0, DIREG_DRV, KEY_READ); + ok(key != INVALID_HANDLE_VALUE, "Failed to open device key, error %#x.\n", GetLastError()); RegCloseKey(key); - /* Create the device reg key */ - key = pSetupDiCreateDevRegKeyW(set, &devInfo, DICS_FLAG_GLOBAL, 0, - DIREG_DRV, NULL, NULL); - /* Vista and higher don't actually create the key */ - ok(key != INVALID_HANDLE_VALUE || GetLastError() == ERROR_KEY_DOES_NOT_EXIST, - "SetupDiCreateDevRegKey failed: %08x\n", GetLastError()); - if (key != INVALID_HANDLE_VALUE) - { - RegCloseKey(key); - /* The class key should have been created */ - ok(!RegOpenKeyW(HKEY_LOCAL_MACHINE, classKey, &key), - "Expected registry key to exist\n"); - RegCloseKey(key); - SetLastError(0xdeadbeef); - key = pSetupDiOpenDevRegKey(set, &devInfo, DICS_FLAG_GLOBAL, 0, - DIREG_DRV, 0); - todo_wine - ok(key == INVALID_HANDLE_VALUE && - (GetLastError() == ERROR_INVALID_DATA || - GetLastError() == ERROR_ACCESS_DENIED), /* win2k3 */ - "Expected ERROR_INVALID_DATA or ERROR_ACCESS_DENIED, got %08x\n", GetLastError()); - key = pSetupDiOpenDevRegKey(set, &devInfo, DICS_FLAG_GLOBAL, 0, - DIREG_DRV, KEY_READ); - ok(key != INVALID_HANDLE_VALUE, "SetupDiOpenDevRegKey failed: %08x\n", - GetLastError()); - RegCloseKey(key); - } + }
- ret = pSetupDiRemoveDevice(set, &devInfo); - todo_wine ok(ret, "got %u\n", GetLastError()); - pSetupDiDestroyDeviceInfoList(set); + ret = SetupDiRemoveDevice(set, &device); +todo_wine + ok(ret, "Failed to remove device, error %#x.\n", GetLastError()); + SetupDiDestroyDeviceInfoList(set);
- /* remove once Wine is fixed */ - devinst_RegDeleteTreeW(HKEY_LOCAL_MACHINE, bogus); - devinst_RegDeleteTreeW(HKEY_LOCAL_MACHINE, classKey); - } + /* remove once Wine is fixed */ + devinst_RegDeleteTreeW(HKEY_LOCAL_MACHINE, bogus); + devinst_RegDeleteTreeW(HKEY_LOCAL_MACHINE, classKey); }
static void testRegisterAndGetDetail(void) @@ -1557,7 +1527,7 @@ START_TEST(devinst) test_register_device_info(); test_device_iface(); test_device_iface_detail(); - testDevRegKey(); + test_device_key(); testRegisterAndGetDetail(); testDeviceRegistryPropertyA(); testDeviceRegistryPropertyW();
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/tests/devinst.c | 113 ++++++++---------------------------------- 1 file changed, 22 insertions(+), 91 deletions(-)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 7461eb5841..394b925de4 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -37,24 +37,18 @@ static BOOL is_wow64;
/* function pointers */ static HDEVINFO (WINAPI *pSetupDiCreateDeviceInfoListExW)(GUID*,HWND,PCWSTR,PVOID); -static BOOL (WINAPI *pSetupDiCreateDeviceInterfaceA)(HDEVINFO, PSP_DEVINFO_DATA, const GUID *, PCSTR, DWORD, PSP_DEVICE_INTERFACE_DATA); static BOOL (WINAPI *pSetupDiCallClassInstaller)(DI_FUNCTION, HDEVINFO, PSP_DEVINFO_DATA); static BOOL (WINAPI *pSetupDiDestroyDeviceInfoList)(HDEVINFO); -static BOOL (WINAPI *pSetupDiEnumDeviceInterfaces)(HDEVINFO, PSP_DEVINFO_DATA, const GUID *, DWORD, PSP_DEVICE_INTERFACE_DATA); static BOOL (WINAPI *pSetupDiGetINFClassA)(PCSTR, LPGUID, PSTR, DWORD, PDWORD); static HKEY (WINAPI *pSetupDiOpenClassRegKeyExA)(GUID*,REGSAM,DWORD,PCSTR,PVOID); static BOOL (WINAPI *pSetupDiCreateDeviceInfoA)(HDEVINFO, PCSTR, GUID *, PCSTR, HWND, DWORD, PSP_DEVINFO_DATA); static BOOL (WINAPI *pSetupDiCreateDeviceInfoW)(HDEVINFO, PCWSTR, GUID *, PCWSTR, HWND, DWORD, PSP_DEVINFO_DATA); -static BOOL (WINAPI *pSetupDiGetDeviceInterfaceDetailA)(HDEVINFO, PSP_DEVICE_INTERFACE_DATA, PSP_DEVICE_INTERFACE_DETAIL_DATA_A, DWORD, PDWORD, PSP_DEVINFO_DATA); -static BOOL (WINAPI *pSetupDiRegisterDeviceInfo)(HDEVINFO, PSP_DEVINFO_DATA, DWORD, PSP_DETSIG_CMPPROC, PVOID, PSP_DEVINFO_DATA); static HDEVINFO (WINAPI *pSetupDiGetClassDevsA)(const GUID *, LPCSTR, HWND, DWORD); static HDEVINFO (WINAPI *pSetupDiGetClassDevsW)(const GUID *, LPCWSTR, HWND, DWORD); static BOOL (WINAPI *pSetupDiSetDeviceRegistryPropertyA)(HDEVINFO, PSP_DEVINFO_DATA, DWORD, const BYTE *, DWORD); static BOOL (WINAPI *pSetupDiSetDeviceRegistryPropertyW)(HDEVINFO, PSP_DEVINFO_DATA, DWORD, const BYTE *, DWORD); static BOOL (WINAPI *pSetupDiGetDeviceRegistryPropertyA)(HDEVINFO, PSP_DEVINFO_DATA, DWORD, PDWORD, PBYTE, DWORD, PDWORD); static BOOL (WINAPI *pSetupDiGetDeviceRegistryPropertyW)(HDEVINFO, PSP_DEVINFO_DATA, DWORD, PDWORD, PBYTE, DWORD, PDWORD); -static BOOL (WINAPI *pSetupDiRemoveDevice)(HDEVINFO, PSP_DEVINFO_DATA); -static BOOL (WINAPI *pSetupDiRemoveDeviceInterface)(HDEVINFO, PSP_DEVICE_INTERFACE_DATA); static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
/* This is a unique guid for testing purposes */ @@ -69,13 +63,9 @@ static void init_function_pointers(void) pSetupDiCreateDeviceInfoA = (void *)GetProcAddress(hSetupAPI, "SetupDiCreateDeviceInfoA"); pSetupDiCreateDeviceInfoW = (void *)GetProcAddress(hSetupAPI, "SetupDiCreateDeviceInfoW"); pSetupDiCreateDeviceInfoListExW = (void *)GetProcAddress(hSetupAPI, "SetupDiCreateDeviceInfoListExW"); - pSetupDiCreateDeviceInterfaceA = (void *)GetProcAddress(hSetupAPI, "SetupDiCreateDeviceInterfaceA"); pSetupDiDestroyDeviceInfoList = (void *)GetProcAddress(hSetupAPI, "SetupDiDestroyDeviceInfoList"); pSetupDiCallClassInstaller = (void *)GetProcAddress(hSetupAPI, "SetupDiCallClassInstaller"); - pSetupDiEnumDeviceInterfaces = (void *)GetProcAddress(hSetupAPI, "SetupDiEnumDeviceInterfaces"); - pSetupDiGetDeviceInterfaceDetailA = (void *)GetProcAddress(hSetupAPI, "SetupDiGetDeviceInterfaceDetailA"); pSetupDiOpenClassRegKeyExA = (void *)GetProcAddress(hSetupAPI, "SetupDiOpenClassRegKeyExA"); - pSetupDiRegisterDeviceInfo = (void *)GetProcAddress(hSetupAPI, "SetupDiRegisterDeviceInfo"); pSetupDiGetClassDevsA = (void *)GetProcAddress(hSetupAPI, "SetupDiGetClassDevsA"); pSetupDiGetClassDevsW = (void *)GetProcAddress(hSetupAPI, "SetupDiGetClassDevsW"); pSetupDiGetINFClassA = (void *)GetProcAddress(hSetupAPI, "SetupDiGetINFClassA"); @@ -83,8 +73,6 @@ static void init_function_pointers(void) pSetupDiSetDeviceRegistryPropertyW = (void *)GetProcAddress(hSetupAPI, "SetupDiSetDeviceRegistryPropertyW"); pSetupDiGetDeviceRegistryPropertyA = (void *)GetProcAddress(hSetupAPI, "SetupDiGetDeviceRegistryPropertyA"); pSetupDiGetDeviceRegistryPropertyW = (void *)GetProcAddress(hSetupAPI, "SetupDiGetDeviceRegistryPropertyW"); - pSetupDiRemoveDeviceInterface = (void *)GetProcAddress(hSetupAPI, "SetupDiRemoveDeviceInterface"); - pSetupDiRemoveDevice = (void *)GetProcAddress(hSetupAPI, "SetupDiRemoveDevice"); pIsWow64Process = (void *)GetProcAddress(hKernel32, "IsWow64Process"); }
@@ -929,104 +917,47 @@ todo_wine devinst_RegDeleteTreeW(HKEY_LOCAL_MACHINE, classKey); }
-static void testRegisterAndGetDetail(void) +static void test_register_device_iface(void) { - static const WCHAR classKey[] = {'S','y','s','t','e','m','\', - 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\', - 'C','o','n','t','r','o','l','\','C','l','a','s','s','\', - '{','6','a','5','5','b','5','a','4','-','3','f','6','5','-', - '1','1','d','b','-','b','7','0','4','-', - '0','0','1','1','9','5','5','c','2','b','d','b','}',0}; static const WCHAR bogus[] = {'S','y','s','t','e','m','\', 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\', 'E','n','u','m','\','R','o','o','t','\', 'L','E','G','A','C','Y','_','B','O','G','U','S',0}; + SP_DEVICE_INTERFACE_DATA iface = {sizeof(iface)}, ret_iface = {sizeof(ret_iface)}; + SP_DEVINFO_DATA device = {sizeof(device)}; HDEVINFO set, set2; BOOL ret; - SP_DEVINFO_DATA devInfo = { sizeof(SP_DEVINFO_DATA), { 0 } }; - SP_DEVICE_INTERFACE_DATA interfaceData = { sizeof(interfaceData), { 0 } }; - SP_DEVICE_INTERFACE_DATA interfaceData2 = { sizeof(interfaceData2), { 0 } }; - DWORD dwSize = 0; HKEY key; LONG res;
- if (!pSetupDiCreateDeviceInterfaceA || !pSetupDiEnumDeviceInterfaces || - !pSetupDiGetDeviceInterfaceDetailA) - { - win_skip("Needed functions are not available\n"); - return; - } - - SetLastError(0xdeadbeef); - set = pSetupDiGetClassDevsA(&guid, NULL, 0, DIGCF_ALLCLASSES); - ok(set != INVALID_HANDLE_VALUE, "SetupDiGetClassDevsA failed: %08x\n", - GetLastError()); + set = SetupDiGetClassDevsA(&guid, NULL, 0, DIGCF_ALLCLASSES); + ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError());
res = RegOpenKeyW(HKEY_LOCAL_MACHINE, bogus, &key); - ok(res != ERROR_SUCCESS, "Expected key to not exist\n"); - RegCloseKey(key); - - SetLastError(0xdeadbeef); - ret = pSetupDiCreateDeviceInfoA(set, "LEGACY_BOGUS", &guid, NULL, 0, - DICD_GENERATE_ID, &devInfo); - ok(ret, "SetupDiCreateDeviceInfoA failed: %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = pSetupDiCreateDeviceInterfaceA(set, &devInfo, &guid, NULL, 0, &interfaceData); - ok(ret, "SetupDiCreateDeviceInterfaceA failed: %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = pSetupDiRegisterDeviceInfo(set, &devInfo, 0, NULL, NULL, NULL); - ok(ret, "SetupDiRegisterDeviceInfo failed: %08x\n", GetLastError()); + ok(res == ERROR_FILE_NOT_FOUND, "Key should not exist.\n");
- SetLastError(0xdeadbeef); - set2 = pSetupDiGetClassDevsA(&guid, NULL, 0, DIGCF_DEVICEINTERFACE); - ok(set2 != INVALID_HANDLE_VALUE, "SetupDiGetClassDevsA failed: %08x\n", - GetLastError()); + ret = SetupDiCreateDeviceInfoA(set, "Root\LEGACY_BOGUS\0000", &guid, NULL, NULL, 0, &device); + ok(ret, "Failed to create device, error %#x.\n", GetLastError()); + ret = SetupDiCreateDeviceInterfaceA(set, &device, &guid, NULL, 0, &iface); + ok(ret, "Failed to create interface, error %#x.\n", GetLastError()); + ret = SetupDiRegisterDeviceInfo(set, &device, 0, NULL, NULL, NULL); + ok(ret, "Failed to register device, error %#x.\n", GetLastError());
- SetLastError(0xdeadbeef); - ret = pSetupDiEnumDeviceInterfaces(set2, NULL, &guid, 0, &interfaceData2); - ok(ret, "SetupDiEnumDeviceInterfaces failed: %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceInterfaceDetailA(set2, &interfaceData2, NULL, 0, &dwSize, NULL); - ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, - "Expected ERROR_INSUFFICIENT_BUFFER, got %08x\n", GetLastError()); - if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER) - { - static const char path[] = - "\\?\root#legacy_bogus#0000#{6a55b5a4-3f65-11db-b704-0011955c2bdb}"; - static const char path_w10[] = - "\\?\root#legacy_bogus#0001#{6a55b5a4-3f65-11db-b704-0011955c2bdb}"; - static const char path_w2k[] = - "\\?\root#legacy_bogus#0000#{6a55b5a4-3f65-11db-b704-0011955c2bdb}\"; - PSP_DEVICE_INTERFACE_DETAIL_DATA_A detail = NULL; - - detail = HeapAlloc(GetProcessHeap(), 0, dwSize); - if (detail) - { - detail->cbSize = sizeof(*detail); - SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceInterfaceDetailA(set2, &interfaceData2, - detail, dwSize, &dwSize, NULL); - ok(ret, "SetupDiGetDeviceInterfaceDetailA failed: %08x\n", GetLastError()); - ok(!lstrcmpiA(path, detail->DevicePath) || - !lstrcmpiA(path_w10, detail->DevicePath) || - !lstrcmpiA(path_w2k, detail->DevicePath), - "Unexpected path %s\n", detail->DevicePath); - HeapFree(GetProcessHeap(), 0, detail); - } - } + set2 = SetupDiGetClassDevsA(&guid, NULL, 0, DIGCF_DEVICEINTERFACE); + ok(set2 != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError());
- ret = pSetupDiRemoveDeviceInterface(set, &interfaceData); - todo_wine ok(ret, "SetupDiRemoveDeviceInterface failed: %08x\n", GetLastError()); + check_device_iface(set2, NULL, &guid, 0, 0, "\\?\root#legacy_bogus#0000#{6a55b5a4-3f65-11db-b704-0011955c2bdb}"); + check_device_iface(set2, NULL, &guid, 1, 0, NULL);
- ret = pSetupDiRemoveDevice(set, &devInfo); - todo_wine ok(ret, "got %u\n", GetLastError()); + ret = SetupDiRemoveDevice(set, &device); +todo_wine + ok(ret, "Failed to remove device, error %#x.\n", GetLastError());
- pSetupDiDestroyDeviceInfoList(set); - pSetupDiDestroyDeviceInfoList(set2); + SetupDiDestroyDeviceInfoList(set); + SetupDiDestroyDeviceInfoList(set2);
/* remove once Wine is fixed */ devinst_RegDeleteTreeW(HKEY_LOCAL_MACHINE, bogus); - devinst_RegDeleteTreeW(HKEY_LOCAL_MACHINE, classKey); }
static void testDeviceRegistryPropertyA(void) @@ -1528,7 +1459,7 @@ START_TEST(devinst) test_device_iface(); test_device_iface_detail(); test_device_key(); - testRegisterAndGetDetail(); + test_register_device_iface(); testDeviceRegistryPropertyA(); testDeviceRegistryPropertyW(); testSetupDiGetINFClassA();
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/tests/devinst.c | 160 ++++++++++++++++++++---------------------- 1 file changed, 77 insertions(+), 83 deletions(-)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 394b925de4..118d607bcd 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -43,11 +43,8 @@ static BOOL (WINAPI *pSetupDiGetINFClassA)(PCSTR, LPGUID, PSTR, DWORD, PDWOR static HKEY (WINAPI *pSetupDiOpenClassRegKeyExA)(GUID*,REGSAM,DWORD,PCSTR,PVOID); static BOOL (WINAPI *pSetupDiCreateDeviceInfoA)(HDEVINFO, PCSTR, GUID *, PCSTR, HWND, DWORD, PSP_DEVINFO_DATA); static BOOL (WINAPI *pSetupDiCreateDeviceInfoW)(HDEVINFO, PCWSTR, GUID *, PCWSTR, HWND, DWORD, PSP_DEVINFO_DATA); -static HDEVINFO (WINAPI *pSetupDiGetClassDevsA)(const GUID *, LPCSTR, HWND, DWORD); static HDEVINFO (WINAPI *pSetupDiGetClassDevsW)(const GUID *, LPCWSTR, HWND, DWORD); -static BOOL (WINAPI *pSetupDiSetDeviceRegistryPropertyA)(HDEVINFO, PSP_DEVINFO_DATA, DWORD, const BYTE *, DWORD); static BOOL (WINAPI *pSetupDiSetDeviceRegistryPropertyW)(HDEVINFO, PSP_DEVINFO_DATA, DWORD, const BYTE *, DWORD); -static BOOL (WINAPI *pSetupDiGetDeviceRegistryPropertyA)(HDEVINFO, PSP_DEVINFO_DATA, DWORD, PDWORD, PBYTE, DWORD, PDWORD); static BOOL (WINAPI *pSetupDiGetDeviceRegistryPropertyW)(HDEVINFO, PSP_DEVINFO_DATA, DWORD, PDWORD, PBYTE, DWORD, PDWORD); static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
@@ -66,12 +63,9 @@ static void init_function_pointers(void) pSetupDiDestroyDeviceInfoList = (void *)GetProcAddress(hSetupAPI, "SetupDiDestroyDeviceInfoList"); pSetupDiCallClassInstaller = (void *)GetProcAddress(hSetupAPI, "SetupDiCallClassInstaller"); pSetupDiOpenClassRegKeyExA = (void *)GetProcAddress(hSetupAPI, "SetupDiOpenClassRegKeyExA"); - pSetupDiGetClassDevsA = (void *)GetProcAddress(hSetupAPI, "SetupDiGetClassDevsA"); pSetupDiGetClassDevsW = (void *)GetProcAddress(hSetupAPI, "SetupDiGetClassDevsW"); pSetupDiGetINFClassA = (void *)GetProcAddress(hSetupAPI, "SetupDiGetINFClassA"); - pSetupDiSetDeviceRegistryPropertyA = (void *)GetProcAddress(hSetupAPI, "SetupDiSetDeviceRegistryPropertyA"); pSetupDiSetDeviceRegistryPropertyW = (void *)GetProcAddress(hSetupAPI, "SetupDiSetDeviceRegistryPropertyW"); - pSetupDiGetDeviceRegistryPropertyA = (void *)GetProcAddress(hSetupAPI, "SetupDiGetDeviceRegistryPropertyA"); pSetupDiGetDeviceRegistryPropertyW = (void *)GetProcAddress(hSetupAPI, "SetupDiGetDeviceRegistryPropertyW"); pIsWow64Process = (void *)GetProcAddress(hKernel32, "IsWow64Process"); } @@ -960,105 +954,105 @@ todo_wine devinst_RegDeleteTreeW(HKEY_LOCAL_MACHINE, bogus); }
-static void testDeviceRegistryPropertyA(void) +static void test_registry_property_a(void) { - HDEVINFO set; - SP_DEVINFO_DATA devInfo = { sizeof(SP_DEVINFO_DATA), { 0 } }; - CHAR devName[] = "LEGACY_BOGUS"; - CHAR friendlyName[] = "Bogus"; + static const CHAR bogus[] = "System\CurrentControlSet\Enum\Root\LEGACY_BOGUS"; + SP_DEVINFO_DATA device = {sizeof(device)}; CHAR buf[6] = ""; - DWORD buflen = 6; - DWORD size; - DWORD regType; + DWORD size, type; + HDEVINFO set; BOOL ret; LONG res; HKEY key; - static const CHAR bogus[] = - "System\CurrentControlSet\Enum\Root\LEGACY_BOGUS"; + + set = SetupDiGetClassDevsA(&guid, NULL, 0, DIGCF_DEVICEINTERFACE); + ok(set != INVALID_HANDLE_VALUE, "Failed to get device list, error %#x.\n", GetLastError()); + + ret = SetupDiCreateDeviceInfoA(set, "LEGACY_BOGUS", &guid, NULL, NULL, DICD_GENERATE_ID, &device); + ok(ret, "Failed to create device, error %#x.\n", GetLastError());
SetLastError(0xdeadbeef); - set = pSetupDiGetClassDevsA(&guid, NULL, 0, DIGCF_DEVICEINTERFACE); - ok(set != INVALID_HANDLE_VALUE, "SetupDiGetClassDevsA failed: %08x\n", - GetLastError()); - SetLastError(0xdeadbeef); - ret = pSetupDiCreateDeviceInfoA(set, devName, &guid, NULL, NULL, - DICD_GENERATE_ID, &devInfo); - ok(ret, "SetupDiCreateDeviceInfoA failed: %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = pSetupDiSetDeviceRegistryPropertyA(NULL, NULL, -1, NULL, 0); - ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, - "Expected ERROR_INVALID_HANDLE, got %08x\n", GetLastError()); + ret = SetupDiSetDeviceRegistryPropertyA(NULL, NULL, -1, NULL, 0); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected error %#x.\n", GetLastError()); + SetLastError(0xdeadbeef); - ret = pSetupDiSetDeviceRegistryPropertyA(set, NULL, -1, NULL, 0); - ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError()); + ret = SetupDiSetDeviceRegistryPropertyA(set, NULL, -1, NULL, 0); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error %#x.\n", GetLastError()); + SetLastError(0xdeadbeef); - ret = pSetupDiSetDeviceRegistryPropertyA(set, &devInfo, -1, NULL, 0); + ret = SetupDiSetDeviceRegistryPropertyA(set, &device, -1, NULL, 0); + ok(!ret, "Expected failure.\n"); +todo_wine + ok(GetLastError() == ERROR_INVALID_REG_PROPERTY, "Got unexpected error %#x.\n", GetLastError()); + + ret = SetupDiSetDeviceRegistryPropertyA(set, &device, SPDRP_FRIENDLYNAME, NULL, 0); todo_wine - ok(!ret && GetLastError() == ERROR_INVALID_REG_PROPERTY, - "Expected ERROR_INVALID_REG_PROPERTY, got %08x\n", GetLastError()); + ok(!ret, "Expected failure.\n"); /* GetLastError() returns nonsense in win2k3 */ - ret = pSetupDiSetDeviceRegistryPropertyA(set, &devInfo, SPDRP_FRIENDLYNAME, - NULL, 0); - todo_wine - ok(!ret, "Expected failure, got %d\n", ret); + SetLastError(0xdeadbeef); - ret = pSetupDiSetDeviceRegistryPropertyA(set, &devInfo, SPDRP_FRIENDLYNAME, - (PBYTE)friendlyName, buflen); - ok(ret, "SetupDiSetDeviceRegistryPropertyA failed: %08x\n", GetLastError()); + ret = SetupDiSetDeviceRegistryPropertyA(set, &device, SPDRP_FRIENDLYNAME, (BYTE *)"Bogus", sizeof("Bogus")); + ok(ret, "Failed to set property, error %#x.\n", GetLastError()); + SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceRegistryPropertyA(NULL, NULL, -1, NULL, NULL, 0, NULL); - ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, - "Expected ERROR_INVALID_HANDLE, got %08x\n", GetLastError()); + ret = SetupDiGetDeviceRegistryPropertyA(NULL, NULL, -1, NULL, NULL, 0, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected error %#x.\n", GetLastError()); + SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceRegistryPropertyA(set, NULL, -1, NULL, NULL, 0, NULL); - ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError()); + ret = SetupDiGetDeviceRegistryPropertyA(set, NULL, -1, NULL, NULL, 0, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error %#x.\n", GetLastError()); + SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceRegistryPropertyA(set, &devInfo, -1, NULL, NULL, 0, NULL); - todo_wine - ok(!ret && GetLastError() == ERROR_INVALID_REG_PROPERTY, - "Expected ERROR_INVALID_REG_PROPERTY, got %08x\n", GetLastError()); - /* GetLastError() returns nonsense in win2k3 */ - ret = pSetupDiGetDeviceRegistryPropertyA(set, &devInfo, SPDRP_FRIENDLYNAME, - NULL, NULL, buflen, NULL); + ret = SetupDiGetDeviceRegistryPropertyA(set, &device, -1, NULL, NULL, 0, NULL); + ok(!ret, "Expected failure.\n"); +todo_wine + ok(GetLastError() == ERROR_INVALID_REG_PROPERTY, "Got unexpected error %#x.\n", GetLastError()); + + ret = SetupDiGetDeviceRegistryPropertyA(set, &device, SPDRP_FRIENDLYNAME, NULL, NULL, sizeof("Bogus"), NULL); ok(!ret, "Expected failure, got %d\n", ret); + /* GetLastError() returns nonsense in win2k3 */ + SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceRegistryPropertyA(set, &devInfo, SPDRP_FRIENDLYNAME, - NULL, NULL, 0, &size); - ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, - "Expected ERROR_INSUFFICIENT_BUFFER, got %08x\n", GetLastError()); - ok(buflen == size, "Unexpected size: %d\n", size); + ret = SetupDiGetDeviceRegistryPropertyA(set, &device, SPDRP_FRIENDLYNAME, NULL, NULL, 0, &size); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got unexpected error %#x.\n", GetLastError()); + ok(size == sizeof("Bogus"), "Got unexpected size %d.\n", size); + SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceRegistryPropertyA(set, &devInfo, SPDRP_FRIENDLYNAME, - NULL, (PBYTE)buf, buflen, NULL); - ok(ret, "SetupDiGetDeviceRegistryPropertyA failed: %08x\n", GetLastError()); - ok(!lstrcmpiA(friendlyName, buf), "Unexpected property\n"); + ret = SetupDiGetDeviceRegistryPropertyA(set, &device, SPDRP_FRIENDLYNAME, NULL, (BYTE *)buf, sizeof(buf), NULL); + ok(ret, "Failed to get property, error %#x.\n", GetLastError()); + ok(!strcmp(buf, "Bogus"), "Got unexpected property %s.\n", buf); + SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceRegistryPropertyA(set, &devInfo, SPDRP_FRIENDLYNAME, - ®Type, (PBYTE)buf, buflen, NULL); - ok(ret, "SetupDiGetDeviceRegistryPropertyA failed: %08x\n", GetLastError()); - ok(!lstrcmpiA(friendlyName, buf), "Unexpected value of property\n"); - ok(regType == REG_SZ, "Unexpected type of property: %d\n", regType); + ret = SetupDiGetDeviceRegistryPropertyA(set, &device, SPDRP_FRIENDLYNAME, &type, (BYTE *)buf, sizeof(buf), NULL); + ok(ret, "Failed to get property, error %#x.\n", GetLastError()); + ok(!strcmp(buf, "Bogus"), "Got unexpected property %s.\n", buf); + ok(type == REG_SZ, "Got unexpected type %d.\n", type); + SetLastError(0xdeadbeef); - ret = pSetupDiSetDeviceRegistryPropertyA(set, &devInfo, SPDRP_FRIENDLYNAME, - NULL, 0); - ok(ret, "SetupDiSetDeviceRegistryPropertyA failed: %08x\n", GetLastError()); + ret = SetupDiSetDeviceRegistryPropertyA(set, &device, SPDRP_FRIENDLYNAME, NULL, 0); + ok(ret, "Failed to set property, error %#x.\n", GetLastError()); + SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceRegistryPropertyA(set, &devInfo, SPDRP_FRIENDLYNAME, - NULL, (PBYTE)buf, buflen, &size); - todo_wine - ok(!ret && GetLastError() == ERROR_INVALID_DATA, - "Expected ERROR_INVALID_DATA, got %08x\n", GetLastError()); - ret = pSetupDiGetDeviceRegistryPropertyA(set, &devInfo, SPDRP_HARDWAREID, - NULL, NULL, 0, &size); - ok(!ret && GetLastError() == ERROR_INVALID_DATA, - "Expected ERROR_INVALID_DATA, got %08x\n", GetLastError()); - pSetupDiDestroyDeviceInfoList(set); + ret = SetupDiGetDeviceRegistryPropertyA(set, &device, SPDRP_FRIENDLYNAME, NULL, (BYTE *)buf, sizeof(buf), &size); +todo_wine { + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_DATA, "Got unexpected error %#x.\n", GetLastError()); +} + + ret = SetupDiGetDeviceRegistryPropertyA(set, &device, SPDRP_HARDWAREID, NULL, NULL, 0, &size); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_DATA, "Got unexpected error %#x.\n", GetLastError()); + + SetupDiDestroyDeviceInfoList(set);
res = RegOpenKeyA(HKEY_LOCAL_MACHINE, bogus, &key); - if(!is_wow64) - todo_wine ok(res == ERROR_FILE_NOT_FOUND, "Expected key to not exist\n"); +todo_wine + ok(res == ERROR_FILE_NOT_FOUND, "Key should not exist.\n"); /* FIXME: Remove when Wine is fixed */ if (res == ERROR_SUCCESS) { @@ -1460,7 +1454,7 @@ START_TEST(devinst) test_device_iface_detail(); test_device_key(); test_register_device_iface(); - testDeviceRegistryPropertyA(); + test_registry_property_a(); testDeviceRegistryPropertyW(); testSetupDiGetINFClassA(); test_devnode();
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/tests/devinst.c | 178 +++++++++++++++++++----------------------- 1 file changed, 81 insertions(+), 97 deletions(-)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 118d607bcd..c58e35f482 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -33,20 +33,12 @@ #include "wine/heap.h" #include "wine/test.h"
-static BOOL is_wow64; - /* function pointers */ static HDEVINFO (WINAPI *pSetupDiCreateDeviceInfoListExW)(GUID*,HWND,PCWSTR,PVOID); static BOOL (WINAPI *pSetupDiCallClassInstaller)(DI_FUNCTION, HDEVINFO, PSP_DEVINFO_DATA); static BOOL (WINAPI *pSetupDiDestroyDeviceInfoList)(HDEVINFO); static BOOL (WINAPI *pSetupDiGetINFClassA)(PCSTR, LPGUID, PSTR, DWORD, PDWORD); static HKEY (WINAPI *pSetupDiOpenClassRegKeyExA)(GUID*,REGSAM,DWORD,PCSTR,PVOID); -static BOOL (WINAPI *pSetupDiCreateDeviceInfoA)(HDEVINFO, PCSTR, GUID *, PCSTR, HWND, DWORD, PSP_DEVINFO_DATA); -static BOOL (WINAPI *pSetupDiCreateDeviceInfoW)(HDEVINFO, PCWSTR, GUID *, PCWSTR, HWND, DWORD, PSP_DEVINFO_DATA); -static HDEVINFO (WINAPI *pSetupDiGetClassDevsW)(const GUID *, LPCWSTR, HWND, DWORD); -static BOOL (WINAPI *pSetupDiSetDeviceRegistryPropertyW)(HDEVINFO, PSP_DEVINFO_DATA, DWORD, const BYTE *, DWORD); -static BOOL (WINAPI *pSetupDiGetDeviceRegistryPropertyW)(HDEVINFO, PSP_DEVINFO_DATA, DWORD, PDWORD, PBYTE, DWORD, PDWORD); -static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
/* This is a unique guid for testing purposes */ static GUID guid = {0x6a55b5a4, 0x3f65, 0x11db, {0xb7,0x04,0x00,0x11,0x95,0x5c,0x2b,0xdb}}; @@ -55,19 +47,12 @@ static GUID guid2 = {0x6a55b5a5, 0x3f65, 0x11db, {0xb7,0x04,0x00,0x11,0x95,0x5c, static void init_function_pointers(void) { HMODULE hSetupAPI = GetModuleHandleA("setupapi.dll"); - HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");
- pSetupDiCreateDeviceInfoA = (void *)GetProcAddress(hSetupAPI, "SetupDiCreateDeviceInfoA"); - pSetupDiCreateDeviceInfoW = (void *)GetProcAddress(hSetupAPI, "SetupDiCreateDeviceInfoW"); pSetupDiCreateDeviceInfoListExW = (void *)GetProcAddress(hSetupAPI, "SetupDiCreateDeviceInfoListExW"); pSetupDiDestroyDeviceInfoList = (void *)GetProcAddress(hSetupAPI, "SetupDiDestroyDeviceInfoList"); pSetupDiCallClassInstaller = (void *)GetProcAddress(hSetupAPI, "SetupDiCallClassInstaller"); pSetupDiOpenClassRegKeyExA = (void *)GetProcAddress(hSetupAPI, "SetupDiOpenClassRegKeyExA"); - pSetupDiGetClassDevsW = (void *)GetProcAddress(hSetupAPI, "SetupDiGetClassDevsW"); pSetupDiGetINFClassA = (void *)GetProcAddress(hSetupAPI, "SetupDiGetINFClassA"); - pSetupDiSetDeviceRegistryPropertyW = (void *)GetProcAddress(hSetupAPI, "SetupDiSetDeviceRegistryPropertyW"); - pSetupDiGetDeviceRegistryPropertyW = (void *)GetProcAddress(hSetupAPI, "SetupDiGetDeviceRegistryPropertyW"); - pIsWow64Process = (void *)GetProcAddress(hKernel32, "IsWow64Process"); }
static LSTATUS devinst_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey) @@ -1061,16 +1046,13 @@ todo_wine } }
-static void testDeviceRegistryPropertyW(void) +static void test_registry_property_w(void) { - HDEVINFO set; - SP_DEVINFO_DATA devInfo = { sizeof(SP_DEVINFO_DATA), { 0 } }; - WCHAR devName[] = {'L','E','G','A','C','Y','_','B','O','G','U','S',0}; - WCHAR friendlyName[] = {'B','o','g','u','s',0}; + WCHAR friendly_name[] = {'B','o','g','u','s',0}; + SP_DEVINFO_DATA device = {sizeof(device)}; WCHAR buf[6] = {0}; - DWORD buflen = 6 * sizeof(WCHAR); - DWORD size; - DWORD regType; + DWORD size, type; + HDEVINFO set; BOOL ret; LONG res; HKEY key; @@ -1079,89 +1061,94 @@ static void testDeviceRegistryPropertyW(void) 'E','n','u','m','\','R','o','o','t','\', 'L','E','G','A','C','Y','_','B','O','G','U','S',0};
+ set = SetupDiGetClassDevsA(&guid, NULL, 0, DIGCF_DEVICEINTERFACE); + ok(set != INVALID_HANDLE_VALUE, "Failed to get device list, error %#x.\n", GetLastError()); + + ret = SetupDiCreateDeviceInfoA(set, "LEGACY_BOGUS", &guid, NULL, NULL, DICD_GENERATE_ID, &device); + ok(ret, "Failed to create device, error %#x.\n", GetLastError()); + SetLastError(0xdeadbeef); - set = pSetupDiGetClassDevsW(&guid, NULL, 0, DIGCF_DEVICEINTERFACE); - ok(set != INVALID_HANDLE_VALUE, "SetupDiGetClassDevsW failed: %08x\n", - GetLastError()); - SetLastError(0xdeadbeef); - ret = pSetupDiCreateDeviceInfoW(set, devName, &guid, NULL, NULL, - DICD_GENERATE_ID, &devInfo); - ok(ret, "SetupDiCreateDeviceInfoW failed: %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = pSetupDiSetDeviceRegistryPropertyW(NULL, NULL, -1, NULL, 0); - ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, - "Expected ERROR_INVALID_HANDLE, got %08x\n", GetLastError()); + ret = SetupDiSetDeviceRegistryPropertyW(NULL, NULL, -1, NULL, 0); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected error %#x.\n", GetLastError()); + SetLastError(0xdeadbeef); - ret = pSetupDiSetDeviceRegistryPropertyW(set, NULL, -1, NULL, 0); - ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError()); + ret = SetupDiSetDeviceRegistryPropertyW(set, NULL, -1, NULL, 0); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error %#x.\n", GetLastError()); + SetLastError(0xdeadbeef); - ret = pSetupDiSetDeviceRegistryPropertyW(set, &devInfo, -1, NULL, 0); + ret = SetupDiSetDeviceRegistryPropertyW(set, &device, -1, NULL, 0); + ok(!ret, "Expected failure.\n"); +todo_wine + ok(GetLastError() == ERROR_INVALID_REG_PROPERTY, "Got unexpected error %#x.\n", GetLastError()); + + ret = SetupDiSetDeviceRegistryPropertyW(set, &device, SPDRP_FRIENDLYNAME, NULL, 0); todo_wine - ok(!ret && GetLastError() == ERROR_INVALID_REG_PROPERTY, - "Expected ERROR_INVALID_REG_PROPERTY, got %08x\n", GetLastError()); + ok(!ret, "Expected failure.\n"); /* GetLastError() returns nonsense in win2k3 */ - ret = pSetupDiSetDeviceRegistryPropertyW(set, &devInfo, SPDRP_FRIENDLYNAME, - NULL, 0); - todo_wine - ok(!ret, "Expected failure, got %d\n", ret); + SetLastError(0xdeadbeef); - ret = pSetupDiSetDeviceRegistryPropertyW(set, &devInfo, SPDRP_FRIENDLYNAME, - (PBYTE)friendlyName, buflen); - ok(ret, "SetupDiSetDeviceRegistryPropertyW failed: %08x\n", GetLastError()); + ret = SetupDiSetDeviceRegistryPropertyW(set, &device, SPDRP_FRIENDLYNAME, (BYTE *)friendly_name, sizeof(friendly_name)); + ok(ret, "Failed to set property, error %#x.\n", GetLastError()); + SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceRegistryPropertyW(NULL, NULL, -1, NULL, NULL, 0, NULL); - ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, - "Expected ERROR_INVALID_HANDLE, got %08x\n", GetLastError()); + ret = SetupDiGetDeviceRegistryPropertyW(NULL, NULL, -1, NULL, NULL, 0, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected error %#x.\n", GetLastError()); + SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceRegistryPropertyW(set, NULL, -1, NULL, NULL, 0, NULL); - ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError()); + ret = SetupDiGetDeviceRegistryPropertyW(set, NULL, -1, NULL, NULL, 0, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error %#x.\n", GetLastError()); + SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceRegistryPropertyW(set, &devInfo, -1, NULL, NULL, 0, NULL); - todo_wine - ok(!ret && GetLastError() == ERROR_INVALID_REG_PROPERTY, - "Expected ERROR_INVALID_REG_PROPERTY, got %08x\n", GetLastError()); + ret = SetupDiGetDeviceRegistryPropertyW(set, &device, -1, NULL, NULL, 0, NULL); + ok(!ret, "Expected failure.\n"); +todo_wine + ok(GetLastError() == ERROR_INVALID_REG_PROPERTY, "Got unexpected error %#x.\n", GetLastError()); + + ret = SetupDiGetDeviceRegistryPropertyW(set, &device, SPDRP_FRIENDLYNAME, NULL, NULL, sizeof(buf), NULL); + ok(!ret, "Expected failure.\n"); /* GetLastError() returns nonsense in win2k3 */ - ret = pSetupDiGetDeviceRegistryPropertyW(set, &devInfo, SPDRP_FRIENDLYNAME, - NULL, NULL, buflen, NULL); - ok(!ret, "Expected failure, got %d\n", ret); + SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceRegistryPropertyW(set, &devInfo, SPDRP_FRIENDLYNAME, - NULL, NULL, 0, &size); - ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, - "Expected ERROR_INSUFFICIENT_BUFFER, got %08x\n", GetLastError()); - ok(buflen == size, "Unexpected size: %d\n", size); - SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceRegistryPropertyW(set, &devInfo, SPDRP_FRIENDLYNAME, - NULL, (PBYTE)buf, buflen, NULL); - ok(ret, "SetupDiGetDeviceRegistryPropertyW failed: %08x\n", GetLastError()); - ok(!lstrcmpiW(friendlyName, buf), "Unexpected property\n"); - SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceRegistryPropertyW(set, &devInfo, SPDRP_FRIENDLYNAME, - ®Type, (PBYTE)buf, buflen, NULL); - ok(ret, "SetupDiGetDeviceRegistryPropertyW failed: %08x\n", GetLastError()); - ok(!lstrcmpiW(friendlyName, buf), "Unexpected value of property\n"); - ok(regType == REG_SZ, "Unexpected type of property: %d\n", regType); - SetLastError(0xdeadbeef); - ret = pSetupDiSetDeviceRegistryPropertyW(set, &devInfo, SPDRP_FRIENDLYNAME, - NULL, 0); - ok(ret, "SetupDiSetDeviceRegistryPropertyW failed: %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceRegistryPropertyW(set, &devInfo, SPDRP_FRIENDLYNAME, - NULL, (PBYTE)buf, buflen, &size); - todo_wine - ok(!ret && GetLastError() == ERROR_INVALID_DATA, - "Expected ERROR_INVALID_DATA, got %08x\n", GetLastError()); - ret = pSetupDiGetDeviceRegistryPropertyW(set, &devInfo, SPDRP_HARDWAREID, - NULL, NULL, 0, &size); - ok(!ret && GetLastError() == ERROR_INVALID_DATA, - "Expected ERROR_INVALID_DATA, got %08x\n", GetLastError()); - pSetupDiDestroyDeviceInfoList(set); + ret = SetupDiGetDeviceRegistryPropertyW(set, &device, SPDRP_FRIENDLYNAME, NULL, NULL, 0, &size); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got unexpected error %#x.\n", GetLastError()); + ok(size == sizeof(friendly_name), "Got unexpected size %d.\n", size); + + SetLastError(0xdeadbeef); + ret = SetupDiGetDeviceRegistryPropertyW(set, &device, SPDRP_FRIENDLYNAME, NULL, (BYTE *)buf, sizeof(buf), NULL); + ok(ret, "Failed to get property, error %#x.\n", GetLastError()); + ok(!lstrcmpW(buf, friendly_name), "Got unexpected property %s.\n", wine_dbgstr_w(buf)); + + SetLastError(0xdeadbeef); + ret = SetupDiGetDeviceRegistryPropertyW(set, &device, SPDRP_FRIENDLYNAME, &type, (BYTE *)buf, sizeof(buf), NULL); + ok(ret, "Failed to get property, error %#x.\n", GetLastError()); + ok(!lstrcmpW(buf, friendly_name), "Got unexpected property %s.\n", wine_dbgstr_w(buf)); + ok(type == REG_SZ, "Got unexpected type %d.\n", type); + + SetLastError(0xdeadbeef); + ret = SetupDiSetDeviceRegistryPropertyW(set, &device, SPDRP_FRIENDLYNAME, NULL, 0); + ok(ret, "Failed to set property, error %#x.\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = SetupDiGetDeviceRegistryPropertyW(set, &device, SPDRP_FRIENDLYNAME, NULL, (BYTE *)buf, sizeof(buf), &size); +todo_wine { + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_DATA, "Got unexpected error %#x.\n", GetLastError()); +} + + ret = SetupDiGetDeviceRegistryPropertyW(set, &device, SPDRP_HARDWAREID, NULL, NULL, 0, &size); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_DATA, "Got unexpected error %#x.\n", GetLastError()); + + SetupDiDestroyDeviceInfoList(set);
res = RegOpenKeyW(HKEY_LOCAL_MACHINE, bogus, &key); - if(!is_wow64) - todo_wine ok(res == ERROR_FILE_NOT_FOUND, "Expected key to not exist\n"); +todo_wine + ok(res == ERROR_FILE_NOT_FOUND, "Key should not exist.\n"); /* FIXME: Remove when Wine is fixed */ if (res == ERROR_SUCCESS) { @@ -1433,9 +1420,6 @@ START_TEST(devinst) } RegCloseKey(hkey);
- if (pIsWow64Process) - pIsWow64Process(GetCurrentProcess(), &is_wow64); - if (pSetupDiCreateDeviceInfoListExW) test_SetupDiCreateDeviceInfoListEx(); else @@ -1455,7 +1439,7 @@ START_TEST(devinst) test_device_key(); test_register_device_iface(); test_registry_property_a(); - testDeviceRegistryPropertyW(); + test_registry_property_w(); testSetupDiGetINFClassA(); test_devnode(); test_device_interface_key();