From: Vibhav Pant vibhavp@gmail.com
--- dlls/cfgmgr32/main.c | 44 +++++++++++++++++++++++++-- dlls/cfgmgr32/tests/cfgmgr32.c | 54 +++++++++++++++++----------------- 2 files changed, 69 insertions(+), 29 deletions(-)
diff --git a/dlls/cfgmgr32/main.c b/dlls/cfgmgr32/main.c index cf05c8d8758..a5d5c9046a7 100644 --- a/dlls/cfgmgr32/main.c +++ b/dlls/cfgmgr32/main.c @@ -829,9 +829,49 @@ HRESULT WINAPI DevGetObjectPropertiesEx( DEV_OBJECT_TYPE type, const WCHAR *id, const DEVPROPCOMPKEY *props, ULONG params_len, const DEV_QUERY_PARAMETER *params, ULONG *buf_len, const DEVPROPERTY **buf ) { - FIXME( "(%d, %s, %#lx, %lu, %p, %lu, %p, %p, %p): stub!\n", type, debugstr_w( id ), flags, props_len, props, + HRESULT hr; + ULONG valid_flags = DevQueryFlagAllProperties | DevQueryFlagLocalize; + + TRACE( "(%d, %s, %#lx, %lu, %p, %lu, %p, %p, %p)\n", type, debugstr_w( id ), flags, props_len, props, params_len, params, buf_len, buf ); - return E_NOTIMPL; + + if (flags & ~valid_flags) + return E_INVALIDARG; + if (type == DevObjectTypeUnknown || type > DevObjectTypeAEPProtocol) + return HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ); + if (!id || !!props_len != !!props || !!params_len != !!params + || (props_len && (flags & DevQueryFlagAllProperties))) + return E_INVALIDARG; + + switch (type) + { + case DevObjectTypeDeviceInterface: + case DevObjectTypeDeviceInterfaceDisplay: + { + SP_DEVICE_INTERFACE_DATA iface = {.cbSize = sizeof( iface )}; + DEV_OBJECT obj = {0}; + HDEVINFO set; + + set = SetupDiCreateDeviceInfoListExW( NULL, NULL, NULL, NULL ); + if (set == INVALID_HANDLE_VALUE) return HRESULT_FROM_WIN32( GetLastError() ); + if (!SetupDiOpenDeviceInterfaceW( set, id, 0, &iface )) + { + DWORD err = GetLastError(); + SetupDiDestroyDeviceInfoList( set ); + return HRESULT_FROM_WIN32(err == ERROR_NO_SUCH_DEVICE_INTERFACE ? ERROR_FILE_NOT_FOUND : err); + } + + hr = dev_object_iface_get_props( &obj, set, &iface, props_len, props, !!(flags & DevQueryFlagAllProperties) ); + *buf = obj.pProperties; + *buf_len = obj.cPropertyCount; + break; + } + default: + FIXME( "Unsupported DEV_OBJECT_TYPE: %d\n", type ); + hr = HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ); + } + + return hr; }
void WINAPI DevFreeObjectProperties( ULONG len, const DEVPROPERTY *props ) diff --git a/dlls/cfgmgr32/tests/cfgmgr32.c b/dlls/cfgmgr32/tests/cfgmgr32.c index 1cedd18c01a..f328da04200 100644 --- a/dlls/cfgmgr32/tests/cfgmgr32.c +++ b/dlls/cfgmgr32/tests/cfgmgr32.c @@ -600,25 +600,25 @@ static void test_DevGetObjectProperties( DEV_OBJECT_TYPE type, const WCHAR *id, }
hr = pDevGetObjectProperties( type, id, DevQueryFlagUpdateResults, 0, NULL, NULL, NULL ); - todo_wine ok( hr == E_INVALIDARG, "got hr %#lx\n", hr ); + ok( hr == E_INVALIDARG, "got hr %#lx\n", hr );
hr = pDevGetObjectProperties( type, id, DevQueryFlagAsyncClose, 0, NULL, &buf_len, &buf ); - todo_wine ok( hr == E_INVALIDARG, "got hr %#lx\n", hr ); + ok( hr == E_INVALIDARG, "got hr %#lx\n", hr );
hr = pDevGetObjectProperties( type, id, DevQueryFlagAsyncClose, 0, NULL, &buf_len, &buf ); - todo_wine ok( hr == E_INVALIDARG, "got hr %#lx\n", hr ); + ok( hr == E_INVALIDARG, "got hr %#lx\n", hr );
hr = pDevGetObjectProperties( type, id, DevQueryFlagNone, 1, NULL, &buf_len, &buf ); - todo_wine ok( hr == E_INVALIDARG, "got hr %#lx\n", hr ); + ok( hr == E_INVALIDARG, "got hr %#lx\n", hr );
hr = pDevGetObjectProperties( type, id, DevQueryFlagNone, 0, (DEVPROPCOMPKEY *)0xdeadbeef, &buf_len, &buf ); - todo_wine ok( hr == E_INVALIDARG, "got hr %#lx\n", hr ); + ok( hr == E_INVALIDARG, "got hr %#lx\n", hr );
buf = NULL; buf_len = 0; hr = pDevGetObjectProperties( type, id, DevQueryFlagAllProperties, 0, NULL, &buf_len, &buf ); - todo_wine ok( hr == S_OK, "got hr %#lx\n", hr ); - todo_wine ok( buf_len == props_len, "%lu != %lu\n", buf_len, props_len ); + ok( hr == S_OK, "got hr %#lx\n", hr ); + ok( buf_len == props_len, "%lu != %lu\n", buf_len, props_len ); for (i = 0; i < props_len; i++) { ULONG j; @@ -638,16 +638,16 @@ static void test_DevGetObjectProperties( DEV_OBJECT_TYPE type, const WCHAR *id, } } } - todo_wine ok( rem_props == 0, "got rem_props %lu\n", rem_props ); + ok( rem_props == 0, "got rem_props %lu\n", rem_props ); pDevFreeObjectProperties( buf_len, buf );
buf = (DEVPROPERTY *)0xdeadbeef; buf_len = 0xdeadbeef; rem_props = props_len; hr = pDevGetObjectProperties( type, id, DevQueryFlagNone, 0, NULL, &buf_len, &buf ); - todo_wine ok( hr == S_OK, "got hr %#lx\n", hr ); - todo_wine ok( buf_len == 0, "got buf_len %lu\n", buf_len ); - todo_wine ok( !buf, "got buf %p\n", buf ); + ok( hr == S_OK, "got hr %#lx\n", hr ); + ok( buf_len == 0, "got buf_len %lu\n", buf_len ); + ok( !buf, "got buf %p\n", buf );
buf = NULL; buf_len = 0; @@ -655,8 +655,8 @@ static void test_DevGetObjectProperties( DEV_OBJECT_TYPE type, const WCHAR *id, for (i = 0; i < props_len; i++) keys[i] = exp_props[i].CompKey; hr = pDevGetObjectProperties( type, id, DevQueryFlagNone, props_len, keys, &buf_len, &buf ); - todo_wine ok( hr == S_OK, "got hr %#lx\n", hr ); - todo_wine ok( buf_len == props_len, "%lu != %lu\n", buf_len, props_len ); + ok( hr == S_OK, "got hr %#lx\n", hr ); + ok( buf_len == props_len, "%lu != %lu\n", buf_len, props_len ); for (i = 0; i < props_len; i++) { ULONG j; @@ -669,15 +669,15 @@ static void test_DevGetObjectProperties( DEV_OBJECT_TYPE type, const WCHAR *id, } } } - todo_wine ok( rem_props == 0, "got rem_props %lu\n", rem_props ); + ok( rem_props == 0, "got rem_props %lu\n", rem_props ); pDevFreeObjectProperties( buf_len, buf );
buf_len = 0; buf = NULL; hr = pDevGetObjectProperties( type, id, DevQueryFlagNone, 1, &dummy_propcompkey, &buf_len, &buf ); - todo_wine ok( hr == S_OK, "got hr %#lx\n", hr ); - todo_wine ok( !!buf, "got buf %p", buf ); - todo_wine ok( buf_len == 1, "got buf_len %lu\n", buf_len ); + ok( hr == S_OK, "got hr %#lx\n", hr ); + ok( !!buf, "got buf %p", buf ); + ok( buf_len == 1, "got buf_len %lu\n", buf_len ); if (buf) { ok( IsEqualDevPropKey( buf[0].CompKey.Key, dummy_propkey ), "got propkey {%s, %#lx}\n", @@ -1085,34 +1085,34 @@ static void test_DevGetObjectProperties_invalid( void ) }
hr = pDevGetObjectProperties( DevObjectTypeUnknown, NULL, 0, 0, NULL, NULL, NULL ); - todo_wine ok( hr == HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ), "got hr %#lx\n", hr ); + ok( hr == HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ), "got hr %#lx\n", hr );
hr = pDevGetObjectProperties( DevObjectTypeUnknown, L"", 0, 0, NULL, NULL, NULL ); - todo_wine ok( hr == HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ), "got hr %#lx\n", hr ); + ok( hr == HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ), "got hr %#lx\n", hr );
hr = pDevGetObjectProperties( DevObjectTypeUnknown, NULL, DevQueryFlagAsyncClose, 0, NULL, NULL, NULL ); - todo_wine ok( hr == E_INVALIDARG, "got hr %#lx\n", hr ); + ok( hr == E_INVALIDARG, "got hr %#lx\n", hr );
hr = pDevGetObjectProperties( DevObjectTypeDeviceInterface, L"foobar", DevQueryFlagUpdateResults, 0, NULL, NULL, NULL ); - todo_wine ok( hr == E_INVALIDARG, "got hr %#lx\n", hr ); + ok( hr == E_INVALIDARG, "got hr %#lx\n", hr );
hr = pDevGetObjectProperties( DevObjectTypeDeviceInterface, L"foobar", 0xdeadbeef, 0, NULL, NULL, NULL ); - todo_wine ok( hr == E_INVALIDARG, "got hr %#lx\n", hr ); + ok( hr == E_INVALIDARG, "got hr %#lx\n", hr );
hr = pDevGetObjectProperties( DevObjectTypeUnknown, NULL, 0, 1, NULL, NULL, NULL ); - todo_wine ok( hr == HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ), "got hr %#lx\n", hr ); + ok( hr == HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ), "got hr %#lx\n", hr );
hr = pDevGetObjectProperties( DevObjectTypeUnknown, NULL, 0, 0, (DEVPROPCOMPKEY *)0xdeadbeef, NULL, NULL ); - todo_wine ok( hr == HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ), "got hr %#lx\n", hr ); + ok( hr == HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ), "got hr %#lx\n", hr );
hr = pDevGetObjectProperties( DevObjectTypeDeviceInterface, L"foobar", 0, 0, NULL, NULL, NULL ); - todo_wine ok( hr == HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ), "got hr %#lx\n", hr ); + ok( hr == HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ), "got hr %#lx\n", hr );
hr = pDevGetObjectProperties( DevObjectTypeDeviceInterfaceDisplay, L"foobar", 0, 0, NULL, NULL, NULL ); - todo_wine ok( hr == HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ), "got hr %#lx\n", hr ); + ok( hr == HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ), "got hr %#lx\n", hr );
hr = pDevGetObjectProperties( DevObjectTypeDeviceInterface, NULL, 0, 0, NULL, NULL, NULL ); - todo_wine ok( hr == E_INVALIDARG, "got hr %#lx\n", hr ); + ok( hr == E_INVALIDARG, "got hr %#lx\n", hr ); }
START_TEST(cfgmgr32)