From: Vibhav Pant vibhavp@gmail.com
--- dlls/cfgmgr32/main.c | 13 +++++++++++-- dlls/cfgmgr32/tests/cfgmgr32.c | 12 ++++++------ include/devpropdef.h | 9 +++++++++ 3 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/dlls/cfgmgr32/main.c b/dlls/cfgmgr32/main.c index a9a899cfdb8..053a657d381 100644 --- a/dlls/cfgmgr32/main.c +++ b/dlls/cfgmgr32/main.c @@ -1109,15 +1109,24 @@ HRESULT WINAPI DevGetObjectPropertiesEx( DEV_OBJECT_TYPE type, const WCHAR *id,
static const char *debugstr_DEVPROPERTY( const DEVPROPKEY *key ) { - if (!key) return wine_dbg_sprintf("(null)"); return wine_dbg_sprintf( "{%s, %04lx}", debugstr_guid( &key->fmtid ), key->pid ); }
const DEVPROPERTY *WINAPI DevFindProperty( const DEVPROPKEY *key, DEVPROPSTORE store, const WCHAR *locale, ULONG props_len, const DEVPROPERTY *props ) { - FIXME( "(%s, %d, %s, %lu, %p): stub!\n", debugstr_DEVPROPERTY( key ), store, debugstr_w( locale ), props_len, + /* Windows does not validate parameters here. */ + const DEVPROPCOMPKEY comp_key = { *key, store, locale }; + ULONG i; + + TRACE( "(%s, %d, %s, %lu, %p)\n", debugstr_DEVPROPERTY( key ), store, debugstr_w( locale ), props_len, props ); + + for (i = 0; i < props_len; i++) + { + if (IsEqualDevPropCompKey( comp_key, props[i].CompKey )) + return &props[i]; + } return NULL; }
diff --git a/dlls/cfgmgr32/tests/cfgmgr32.c b/dlls/cfgmgr32/tests/cfgmgr32.c index 2d06e8dcacc..07551133283 100644 --- a/dlls/cfgmgr32/tests/cfgmgr32.c +++ b/dlls/cfgmgr32/tests/cfgmgr32.c @@ -641,7 +641,7 @@ static void test_DevGetObjectProperties( DEV_OBJECT_TYPE type, const WCHAR *id, ok( dev_property_val_equal( &exp_props[i], &buf[j] ), "%s != %s\n", debugstr_DEVPROP_val( &buf[j] ), debugstr_DEVPROP_val( &exp_props[i] ) ); found_prop = pDevFindProperty( &exp_props[i].CompKey.Key, DEVPROP_STORE_SYSTEM, NULL, buf_len, buf ); - todo_wine ok( found_prop == &buf[i], "got found_prop %p != %p\n", found_prop, &buf[i] ); + ok( found_prop == &buf[i], "got found_prop %p != %p\n", found_prop, &buf[i] ); } winetest_pop_context(); rem_props--; @@ -679,7 +679,7 @@ static void test_DevGetObjectProperties( DEV_OBJECT_TYPE type, const WCHAR *id, winetest_push_context( "%s", debugstr_DEVPROPKEY( &exp_props[i].CompKey.Key ) ); rem_props--; found_prop = pDevFindProperty( &exp_props[i].CompKey.Key, DEVPROP_STORE_SYSTEM, NULL, buf_len, buf ); - todo_wine ok( found_prop == &buf[j], "got found_prop %p != %p\n", found_prop, &buf[j] ); + ok( found_prop == &buf[j], "got found_prop %p != %p\n", found_prop, &buf[j] ); winetest_pop_context(); break; } @@ -702,7 +702,7 @@ static void test_DevGetObjectProperties( DEV_OBJECT_TYPE type, const WCHAR *id, debugstr_guid( &buf[0].CompKey.Key.fmtid ), buf[0].CompKey.Key.pid ); ok( buf[0].Type == DEVPROP_TYPE_EMPTY, "got Type %#lx\n", buf[0].Type ); found_prop = pDevFindProperty( &DEVPKEY_dummy, DEVPROP_STORE_SYSTEM, NULL, buf_len, buf ); - todo_wine ok( found_prop == &buf[0], "got found_prop %p != %p\n", found_prop, &buf[0] ); + ok( found_prop == &buf[0], "got found_prop %p != %p\n", found_prop, &buf[0] ); pDevFreeObjectProperties( buf_len, buf ); } free( keys ); @@ -775,7 +775,7 @@ static void test_dev_object_iface_props( int line, const DEV_OBJECT *obj, const
found_prop = pDevFindProperty( &property->CompKey.Key, DEVPROP_STORE_SYSTEM, NULL, obj->cPropertyCount, obj->pProperties ); - todo_wine ok( found_prop == property, "got found_prop %p != %p\n", found_prop, property ); + ok( found_prop == property, "got found_prop %p != %p\n", found_prop, property ); free( buf ); winetest_pop_context(); break; @@ -921,7 +921,7 @@ static void test_DevGetObjects( void ) debugstr_guid( &obj->pProperties[0].CompKey.Key.fmtid ), obj->pProperties[0].CompKey.Key.pid, debugstr_guid( &prop->key.fmtid ), prop->key.pid ); found_prop = pDevFindProperty( &prop->key, DEVPROP_STORE_SYSTEM, NULL, obj->cPropertyCount, obj->pProperties ); - todo_wine ok( found_prop == &obj->pProperties[0], "got found_prop %p != %p\n", found_prop, &obj->pProperties[0] ); + ok( found_prop == &obj->pProperties[0], "got found_prop %p != %p\n", found_prop, &obj->pProperties[0] ); } /* Search for a property not in obj->pProperties, we should get NULL, as we haven't requested this * property in the DevGetObjects call. */ @@ -960,7 +960,7 @@ static void test_DevGetObjects( void ) ok( obj->pProperties[0].Type == DEVPROP_TYPE_EMPTY, "got Type %#lx != %#x", obj->pProperties[0].Type, DEVPROP_TYPE_EMPTY ); found_prop = pDevFindProperty( &DEVPKEY_dummy, DEVPROP_STORE_SYSTEM, NULL, obj->cPropertyCount, obj->pProperties ); - todo_wine ok( found_prop == &obj->pProperties[0], "got found_prop %p != %p\n", found_prop, &obj->pProperties[0] ); + ok( found_prop == &obj->pProperties[0], "got found_prop %p != %p\n", found_prop, &obj->pProperties[0] ); } winetest_pop_context(); } diff --git a/include/devpropdef.h b/include/devpropdef.h index de82648e661..b654425dd91 100644 --- a/include/devpropdef.h +++ b/include/devpropdef.h @@ -114,6 +114,15 @@ typedef struct _DEVPROPCOMPKEY PCWSTR LocaleName; } DEVPROPCOMPKEY, *PDEVPROPCOMPKEY;
+#ifndef IsEqualLocaleName +#define IsEqualLocaleName(a,b) ((a) == (b) || ((a) && (b) && !wcsicmp((a),(b)))) +#endif + +#ifndef IsEqualDevPropCompKey +#define IsEqualDevPropCompKey(a,b) (IsEqualDevPropKey((a).Key,(b).Key) && (a).Store == (b).Store && \ + IsEqualLocaleName((a).LocaleName,(b).LocaleName)) +#endif + typedef struct _DEVPROPERTY { DEVPROPCOMPKEY CompKey;