-- v9: dlls/setupapi: Implement SetupDiGetDevicePropertyKeys. dlls/setupapi/tests: Add tests for SetupDiGetDevicePropertyKeys.
From: Vibhav Pant vibhavp@gmail.com
--- dlls/setupapi/devinst.c | 10 ++++++++++ dlls/setupapi/setupapi.spec | 1 + include/setupapi.h | 1 + 3 files changed, 12 insertions(+)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index e70431e4ec9..dc0e5ff5f2a 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -4495,6 +4495,16 @@ static LSTATUS get_device_property(struct device *device, const DEVPROPKEY *prop return ls; }
+BOOL WINAPI SetupDiGetDevicePropertyKeys( HDEVINFO devinfo, PSP_DEVINFO_DATA device_data, + DEVPROPKEY *prop_keys, DWORD prop_keys_len, + DWORD *required_prop_keys, DWORD flags ) +{ + FIXME( "%p, %p, %p, %lu, %p, %#lx stub!\n", devinfo, device_data, prop_keys, prop_keys_len, + required_prop_keys, flags); + SetLastError( ERROR_CALL_NOT_IMPLEMENTED ); + return FALSE; +} + /*********************************************************************** * SetupDiGetDevicePropertyW (SETUPAPI.@) */ diff --git a/dlls/setupapi/setupapi.spec b/dlls/setupapi/setupapi.spec index 84d008fe4d7..958e26235ea 100644 --- a/dlls/setupapi/setupapi.spec +++ b/dlls/setupapi/setupapi.spec @@ -357,6 +357,7 @@ @ stub SetupDiGetDeviceInterfaceAlias @ stdcall SetupDiGetDeviceInterfaceDetailA(long ptr ptr long ptr ptr) @ stdcall SetupDiGetDeviceInterfaceDetailW(long ptr ptr long ptr ptr) +@ stdcall SetupDiGetDevicePropertyKeys(ptr ptr ptr long ptr long) @ stdcall SetupDiGetDevicePropertyW(ptr ptr ptr ptr ptr long ptr long) @ stdcall SetupDiGetDeviceRegistryPropertyA(long ptr long ptr ptr long ptr) @ stdcall SetupDiGetDeviceRegistryPropertyW(long ptr long ptr ptr long ptr) diff --git a/include/setupapi.h b/include/setupapi.h index 831efdd4f50..74b5d003453 100644 --- a/include/setupapi.h +++ b/include/setupapi.h @@ -1573,6 +1573,7 @@ WINSETUPAPI BOOL WINAPI SetupDiGetDeviceInterfaceAlias(HDEVINFO, PSP_DEVICE_ WINSETUPAPI BOOL WINAPI SetupDiGetDeviceInterfaceDetailA(HDEVINFO, PSP_DEVICE_INTERFACE_DATA, PSP_DEVICE_INTERFACE_DETAIL_DATA_A, DWORD, PDWORD, PSP_DEVINFO_DATA); WINSETUPAPI BOOL WINAPI SetupDiGetDeviceInterfaceDetailW(HDEVINFO, PSP_DEVICE_INTERFACE_DATA, PSP_DEVICE_INTERFACE_DETAIL_DATA_W, DWORD, PDWORD, PSP_DEVINFO_DATA); #define SetupDiGetDeviceInterfaceDetail WINELIB_NAME_AW(SetupDiGetDeviceInterfaceDetail) +WINSETUPAPI BOOL WINAPI SetupDiGetDevicePropertyKeys(HDEVINFO, PSP_DEVINFO_DATA, DEVPROPKEY *, DWORD, DWORD *, DWORD); WINSETUPAPI BOOL WINAPI SetupDiGetDevicePropertyW(HDEVINFO, PSP_DEVINFO_DATA, const DEVPROPKEY *, DEVPROPTYPE *, BYTE *, DWORD, DWORD *, DWORD); #define SetupDiGetDeviceProperty WINELIB_NAME_AW(SetupDiGetDeviceProperty) /* note: A function doesn't exist */ WINSETUPAPI BOOL WINAPI SetupDiGetDeviceRegistryPropertyA(HDEVINFO, PSP_DEVINFO_DATA, DWORD, PDWORD, PBYTE, DWORD, PDWORD);
From: Vibhav Pant vibhavp@gmail.com
--- dlls/setupapi/tests/devinst.c | 82 +++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index cd05548870c..3ba71e86d3f 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -56,6 +56,7 @@ static HRESULT (WINAPI *pDriverStoreFindDriverPackageA)(const char *inf_path, vo static BOOL (WINAPI *pSetupDiSetDevicePropertyW)(HDEVINFO, SP_DEVINFO_DATA *, const DEVPROPKEY *, DEVPROPTYPE, const BYTE *, DWORD, DWORD); static BOOL (WINAPI *pSetupDiGetDevicePropertyW)(HDEVINFO, SP_DEVINFO_DATA *, const DEVPROPKEY *, DEVPROPTYPE *, BYTE *, DWORD, DWORD *, DWORD); static BOOL (WINAPI *pSetupQueryInfOriginalFileInformationA)(SP_INF_INFORMATION *, UINT, SP_ALTPLATFORM_INFO *, SP_ORIGINAL_FILE_INFO_A *); +static BOOL (WINAPI *pSetupDiGetDevicePropertyKeys)(HDEVINFO, PSP_DEVINFO_DATA, DEVPROPKEY *,DWORD, DWORD *, DWORD);
static BOOL wow64;
@@ -885,6 +886,7 @@ static void test_device_property(void) hmod = LoadLibraryA("setupapi.dll"); pSetupDiSetDevicePropertyW = (void *)GetProcAddress(hmod, "SetupDiSetDevicePropertyW"); pSetupDiGetDevicePropertyW = (void *)GetProcAddress(hmod, "SetupDiGetDevicePropertyW"); + pSetupDiGetDevicePropertyKeys = (void *)GetProcAddress(hmod, "SetupDiGetDevicePropertyKeys");
if (!pSetupDiSetDevicePropertyW || !pSetupDiGetDevicePropertyW) { @@ -1190,6 +1192,86 @@ static void test_device_property(void) ok(size == sizeof(valueW), "Got size %ld\n", size); ok(!lstrcmpW((WCHAR *)buffer, valueW), "Expect buffer %s, got %s\n", wine_dbgstr_w(valueW), wine_dbgstr_w((WCHAR *)buffer));
+ if (pSetupDiGetDevicePropertyKeys) + { + DWORD keys_len = 0, n, required_len, expected_keys = 1; + DEVPROPKEY *keys; + + ret = pSetupDiGetDevicePropertyKeys(NULL, NULL, NULL, 0, NULL, 0); + ok(!ret, "Expect failure\n"); + err = GetLastError(); + todo_wine ok(err == ERROR_INVALID_HANDLE, "Expect last error %#x, got %#lx\n", + ERROR_INVALID_HANDLE, err); + + SetLastError(0xdeadbeef); + ret = pSetupDiGetDevicePropertyKeys(set, NULL, NULL, 0, NULL, 0); + ok(!ret, "Expect failure\n"); + err = GetLastError(); + todo_wine ok(err == ERROR_INVALID_PARAMETER, "Expect last error %#x, got %#lx\n", + ERROR_INVALID_PARAMETER, err); + + SetLastError(0xdeadbeef); + ret = pSetupDiGetDevicePropertyKeys(set, &device_data, NULL, 10, NULL, 0); + ok(!ret, "Expect failure\n"); + err = GetLastError(); + todo_wine ok(err == ERROR_INVALID_USER_BUFFER, "Expect last error %#x, got %#lx\n", + ERROR_INVALID_USER_BUFFER, err); + + SetLastError(0xdeadbeef); + ret = pSetupDiGetDevicePropertyKeys(set, &device_data, NULL, 0, NULL, 0); + ok(!ret, "Expect failure\n"); + err = GetLastError(); + todo_wine ok(err == ERROR_INSUFFICIENT_BUFFER, "Expect last error %#x, got %#lx\n", + ERROR_INSUFFICIENT_BUFFER, err); + + SetLastError(0xdeadbeef); + ret = pSetupDiGetDevicePropertyKeys(set, &device_data, NULL, 0, &keys_len, 0xdeadbeef); + ok(!ret, "Expect failure\n"); + err = GetLastError(); + todo_wine ok(err == ERROR_INVALID_FLAGS, "Expect last error %#x, got %#lx\n", + ERROR_INVALID_FLAGS, err); + + SetLastError(0xdeadbeef); + ret = pSetupDiGetDevicePropertyKeys(set, &device_data, NULL, 0, &keys_len, 0); + ok(!ret, "Expect failure\n"); + err = GetLastError(); + todo_wine ok(err == ERROR_INSUFFICIENT_BUFFER, "Expect last error %#x, got %#lx\n", + ERROR_INSUFFICIENT_BUFFER, err); + + keys = calloc(keys_len, sizeof(*keys)); + todo_wine ok(keys_len && !!keys, "Failed to allocate buffer\n"); + SetLastError(0xdeadbeef); + + ret = pSetupDiGetDevicePropertyKeys(set, &device_data, keys, keys_len, &keys_len, 0xdeadbeef); + ok(!ret, "Expect failure\n"); + err = GetLastError(); + todo_wine ok(err == ERROR_INVALID_FLAGS, "Expect last error %#x, got %#lx\n", + ERROR_INVALID_FLAGS, err); + + required_len = 0xdeadbeef; + ret = SetupDiGetDevicePropertyKeys(set, &device_data, keys, keys_len, &required_len, 0); + todo_wine ok(ret, "Expect success\n"); + err = GetLastError(); + todo_wine ok(!err, "Expect last error %#x, got %#lx\n", ERROR_SUCCESS, err); + todo_wine ok(keys_len == required_len, "%lu != %lu\n", keys_len, required_len); + todo_wine ok(keys_len >= expected_keys, "Expected %lu >= %lu\n", keys_len, expected_keys); + + keys_len = 0; + if (keys) + { + for (n = 0; n < required_len; n++) + { + if (!memcmp(&keys[n], &DEVPKEY_Device_FriendlyName, sizeof(keys[n]))) + keys_len++; + } + + } + todo_wine ok(keys_len == expected_keys, "%lu != %lu\n", keys_len, expected_keys); + free(keys); + } + else + win_skip("SetupDiGetDevicePropertyKeys not available\n"); + ret = SetupDiRemoveDevice(set, &device_data); ok(ret, "Got unexpected error %#lx.\n", GetLastError());
From: Vibhav Pant vibhavp@gmail.com
--- dlls/setupapi/devinst.c | 110 +++++++++++++++++++++++++++++++++- dlls/setupapi/tests/devinst.c | 26 ++++---- 2 files changed, 120 insertions(+), 16 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index dc0e5ff5f2a..4e406fe700e 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -4499,10 +4499,114 @@ BOOL WINAPI SetupDiGetDevicePropertyKeys( HDEVINFO devinfo, PSP_DEVINFO_DATA dev DEVPROPKEY *prop_keys, DWORD prop_keys_len, DWORD *required_prop_keys, DWORD flags ) { - FIXME( "%p, %p, %p, %lu, %p, %#lx stub!\n", devinfo, device_data, prop_keys, prop_keys_len, + struct device *device; + DWORD count = 0, i; + HKEY hkey; + LSTATUS ls; + DEVPROPKEY *keys_buf = NULL; + + TRACE( "%p, %p, %p, %lu, %p, %#lx\n", devinfo, device_data, prop_keys, prop_keys_len, required_prop_keys, flags); - SetLastError( ERROR_CALL_NOT_IMPLEMENTED ); - return FALSE; + + if (flags) + { + SetLastError( ERROR_INVALID_FLAGS ); + return FALSE; + } + if (!prop_keys && prop_keys_len) + { + SetLastError( ERROR_INVALID_USER_BUFFER ); + return FALSE; + } + + device = get_device( devinfo, device_data ); + if (!device) + return FALSE; + + ls = RegOpenKeyExW( device->key, L"Properties", 0, KEY_ENUMERATE_SUB_KEYS, &hkey ); + if (ls) + { + SetLastError( ls ); + return FALSE; + } + + keys_buf = malloc( sizeof( *keys_buf ) * prop_keys_len ); + if (!keys_buf && prop_keys_len) + { + RegCloseKey( hkey ); + SetLastError( ERROR_NOT_ENOUGH_MEMORY ); + return FALSE; + } + + for (i = 0; ;i++) + { + WCHAR guid_str[39]; + HKEY propkey; + DWORD len, j; + GUID prop_guid; + + len = ARRAY_SIZE( guid_str ); + ls = RegEnumKeyExW( hkey, i, guid_str, &len, NULL, NULL, NULL, NULL ); + if (ls) + { + if (ls == ERROR_NO_MORE_ITEMS) + ls = ERROR_SUCCESS; + else + ERR( "Could not enumerate subkeys for device %s: %lu\n", + debugstr_w( device->instanceId ), ls ); + break; + } + ls = RegOpenKeyExW( hkey, guid_str, 0, KEY_ENUMERATE_SUB_KEYS, &propkey ); + if (ls) + break; + guid_str[37] = 0; + if (UuidFromStringW( &guid_str[1], &prop_guid )) + { + ERR( "Could not parse propkey GUID string %s\n", debugstr_w( &guid_str[1] ) ); + RegCloseKey( propkey ); + continue; + } + for (j = 0; ;j++) + { + DEVPROPID pid; + WCHAR key_name[6]; + + len = 5; + ls = RegEnumKeyExW( propkey, j, key_name, &len, NULL, NULL, NULL, NULL ); + if (ls) + { + if (ls != ERROR_NO_MORE_ITEMS) + ERR( "Could not enumerate subkeys for device %s under %s: %lu\n", debugstr_w( device->instanceId ), + debugstr_guid( &prop_guid ), ls ); + break; + } + swscanf( key_name, L"%04X", &pid ); + if (++count <= prop_keys_len) + { + keys_buf[count-1].fmtid = prop_guid; + keys_buf[count-1].pid = pid; + } + } + RegCloseKey( propkey ); + } + + RegCloseKey( hkey ); + if (!ls) + { + if (required_prop_keys) + *required_prop_keys = count; + + if (prop_keys_len < count) + { + free( keys_buf ); + SetLastError( ERROR_INSUFFICIENT_BUFFER ); + return FALSE; + } + memcpy( prop_keys, keys_buf, count * sizeof( *keys_buf ) ); + } + free( keys_buf ); + SetLastError( ls ); + return !ls; }
/*********************************************************************** diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 3ba71e86d3f..c5c0114b2b7 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -1200,61 +1200,61 @@ static void test_device_property(void) ret = pSetupDiGetDevicePropertyKeys(NULL, NULL, NULL, 0, NULL, 0); ok(!ret, "Expect failure\n"); err = GetLastError(); - todo_wine ok(err == ERROR_INVALID_HANDLE, "Expect last error %#x, got %#lx\n", + ok(err == ERROR_INVALID_HANDLE, "Expect last error %#x, got %#lx\n", ERROR_INVALID_HANDLE, err);
SetLastError(0xdeadbeef); ret = pSetupDiGetDevicePropertyKeys(set, NULL, NULL, 0, NULL, 0); ok(!ret, "Expect failure\n"); err = GetLastError(); - todo_wine ok(err == ERROR_INVALID_PARAMETER, "Expect last error %#x, got %#lx\n", + ok(err == ERROR_INVALID_PARAMETER, "Expect last error %#x, got %#lx\n", ERROR_INVALID_PARAMETER, err);
SetLastError(0xdeadbeef); ret = pSetupDiGetDevicePropertyKeys(set, &device_data, NULL, 10, NULL, 0); ok(!ret, "Expect failure\n"); err = GetLastError(); - todo_wine ok(err == ERROR_INVALID_USER_BUFFER, "Expect last error %#x, got %#lx\n", + ok(err == ERROR_INVALID_USER_BUFFER, "Expect last error %#x, got %#lx\n", ERROR_INVALID_USER_BUFFER, err);
SetLastError(0xdeadbeef); ret = pSetupDiGetDevicePropertyKeys(set, &device_data, NULL, 0, NULL, 0); ok(!ret, "Expect failure\n"); err = GetLastError(); - todo_wine ok(err == ERROR_INSUFFICIENT_BUFFER, "Expect last error %#x, got %#lx\n", + ok(err == ERROR_INSUFFICIENT_BUFFER, "Expect last error %#x, got %#lx\n", ERROR_INSUFFICIENT_BUFFER, err);
SetLastError(0xdeadbeef); ret = pSetupDiGetDevicePropertyKeys(set, &device_data, NULL, 0, &keys_len, 0xdeadbeef); ok(!ret, "Expect failure\n"); err = GetLastError(); - todo_wine ok(err == ERROR_INVALID_FLAGS, "Expect last error %#x, got %#lx\n", + ok(err == ERROR_INVALID_FLAGS, "Expect last error %#x, got %#lx\n", ERROR_INVALID_FLAGS, err);
SetLastError(0xdeadbeef); ret = pSetupDiGetDevicePropertyKeys(set, &device_data, NULL, 0, &keys_len, 0); ok(!ret, "Expect failure\n"); err = GetLastError(); - todo_wine ok(err == ERROR_INSUFFICIENT_BUFFER, "Expect last error %#x, got %#lx\n", + ok(err == ERROR_INSUFFICIENT_BUFFER, "Expect last error %#x, got %#lx\n", ERROR_INSUFFICIENT_BUFFER, err);
keys = calloc(keys_len, sizeof(*keys)); - todo_wine ok(keys_len && !!keys, "Failed to allocate buffer\n"); + ok(keys_len && !!keys, "Failed to allocate buffer\n"); SetLastError(0xdeadbeef);
ret = pSetupDiGetDevicePropertyKeys(set, &device_data, keys, keys_len, &keys_len, 0xdeadbeef); ok(!ret, "Expect failure\n"); err = GetLastError(); - todo_wine ok(err == ERROR_INVALID_FLAGS, "Expect last error %#x, got %#lx\n", + ok(err == ERROR_INVALID_FLAGS, "Expect last error %#x, got %#lx\n", ERROR_INVALID_FLAGS, err);
required_len = 0xdeadbeef; ret = SetupDiGetDevicePropertyKeys(set, &device_data, keys, keys_len, &required_len, 0); - todo_wine ok(ret, "Expect success\n"); + ok(ret, "Expect success\n"); err = GetLastError(); - todo_wine ok(!err, "Expect last error %#x, got %#lx\n", ERROR_SUCCESS, err); - todo_wine ok(keys_len == required_len, "%lu != %lu\n", keys_len, required_len); - todo_wine ok(keys_len >= expected_keys, "Expected %lu >= %lu\n", keys_len, expected_keys); + ok(!err, "Expect last error %#x, got %#lx\n", ERROR_SUCCESS, err); + ok(keys_len == required_len, "%lu != %lu\n", keys_len, required_len); + ok(keys_len >= expected_keys, "Expected %lu >= %lu\n", keys_len, expected_keys);
keys_len = 0; if (keys) @@ -1266,7 +1266,7 @@ static void test_device_property(void) }
} - todo_wine ok(keys_len == expected_keys, "%lu != %lu\n", keys_len, expected_keys); + ok(keys_len == expected_keys, "%lu != %lu\n", keys_len, expected_keys); free(keys); } else
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=149771
Your paranoid android.
=== debian11b (64 bit WoW report) ===
user32: win.c:4070: Test failed: Expected active window 0000000003B30144, got 0000000000000000. win.c:4071: Test failed: Expected focus window 0000000003B30144, got 0000000000000000.
wmp: oleobj: Timeout
Report validation errors: mshtml:dom has no test summary line (early exit of the main process?) mshtml:dom has unaccounted for todo messages mshtml:dom returned a non-zero exit code despite reporting no failures
This merge request was approved by Elizabeth Figura.