Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/setupapi/tests/devinst.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index de302d21660..73e0086081d 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -2348,7 +2348,7 @@ static void test_driver_list(void) char detail_buffer[1000]; SP_DRVINFO_DETAIL_DATA_A *detail = (SP_DRVINFO_DETAIL_DATA_A *)detail_buffer; char short_path[MAX_PATH], inf_dir[MAX_PATH], inf_path[MAX_PATH + 10], inf_path2[MAX_PATH + 10]; - static const char hardware_id[] = "bogus_hardware_id\0"; + static const char hardware_id[] = "bogus_hardware_id\0other_hardware_id\0"; static const char compat_id[] = "bogus_compat_id\0"; SP_DEVINSTALL_PARAMS_A params = {sizeof(params)}; SP_DRVINFO_DATA_A driver = {sizeof(driver)}; @@ -2357,6 +2357,7 @@ static void test_driver_list(void) FILETIME filetime; HDEVINFO set; HANDLE file; + DWORD idx; BOOL ret;
static const char inf_data[] = "[Version]\n" @@ -2369,11 +2370,13 @@ static void test_driver_list(void) "mfg2_wow=mfg2_key,NT" WOWEXT "\n" "mfg3=mfg3_key,NT" WRONGEXT "\n" "[mfg1_key.nt" MYEXT "]\n" + "desc0=,other_hardware_id,bogus_compat_id\n" "desc1=install1,bogus_hardware_id\n" "desc2=,bogus_hardware_id\n" "desc3=,wrong_hardware_id\n" "desc4=,wrong_hardware_id,bogus_compat_id\n" "[mfg1_key.nt" WOWEXT "]\n" + "desc0=,other_hardware_id,bogus_compat_id\n" "desc1=install1,bogus_hardware_id\n" "desc2=,bogus_hardware_id\n" "desc3=,wrong_hardware_id\n" @@ -2444,10 +2447,25 @@ static void test_driver_list(void) ret = SetupDiBuildDriverInfoList(set, &device, SPDIT_COMPATDRIVER); ok(ret, "Failed to build driver list, error %#x.\n", GetLastError());
- ret = SetupDiEnumDriverInfoA(set, &device, SPDIT_COMPATDRIVER, 0, &driver); + idx = 0; + ret = SetupDiEnumDriverInfoA(set, &device, SPDIT_COMPATDRIVER, idx++, &driver); ok(ret, "Failed to enumerate drivers, error %#x.\n", GetLastError()); ok(driver.DriverType == SPDIT_COMPATDRIVER, "Got wrong type %#x.\n", driver.DriverType); - ok(!strcmp(driver.Description, "desc1"), "Got wrong description '%s'.\n", driver.Description); + ok(!strcmp(driver.Description, "desc0"), "Got wrong description '%s'.\n", driver.Description); + ok(!strcmp(driver.MfgName, wow64 ? "mfg1_wow" : "mfg1"), "Got wrong manufacturer '%s'.\n", driver.MfgName); + ok(!strcmp(driver.ProviderName, ""), "Got wrong provider '%s'.\n", driver.ProviderName); + + ret = SetupDiEnumDriverInfoA(set, &device, SPDIT_COMPATDRIVER, idx++, &driver); + ok(ret, "Failed to enumerate drivers, error %#x.\n", GetLastError()); + ok(driver.DriverType == SPDIT_COMPATDRIVER, "Got wrong type %#x.\n", driver.DriverType); + todo_wine ok(!strcmp(driver.Description, "desc1"), "Got wrong description '%s'.\n", driver.Description); + if (strcmp(driver.Description, "desc1")) + { + ret = SetupDiEnumDriverInfoA(set, &device, SPDIT_COMPATDRIVER, idx++, &driver); + ok(ret, "Failed to enumerate drivers, error %#x.\n", GetLastError()); + ok(driver.DriverType == SPDIT_COMPATDRIVER, "Got wrong type %#x.\n", driver.DriverType); + ok(!strcmp(driver.Description, "desc1"), "Got wrong description '%s'.\n", driver.Description); + } ok(!strcmp(driver.MfgName, wow64 ? "mfg1_wow" : "mfg1"), "Got wrong manufacturer '%s'.\n", driver.MfgName); ok(!strcmp(driver.ProviderName, ""), "Got wrong provider '%s'.\n", driver.ProviderName);
@@ -2515,14 +2533,14 @@ static void test_driver_list(void) ok(!detail->CompatIDsLength, "Got wrong compat IDs length %u.\n", detail->CompatIDsLength); ok(!memcmp(detail->HardwareID, "bogus_hardware_id\0", sizeof("bogus_hardware_id\0")), "Got wrong ID list.\n");
- ret = SetupDiEnumDriverInfoA(set, &device, SPDIT_COMPATDRIVER, 1, &driver); + ret = SetupDiEnumDriverInfoA(set, &device, SPDIT_COMPATDRIVER, idx++, &driver); ok(ret, "Failed to enumerate drivers, error %#x.\n", GetLastError()); ok(driver.DriverType == SPDIT_COMPATDRIVER, "Got wrong type %#x.\n", driver.DriverType); ok(!strcmp(driver.Description, "desc2"), "Got wrong description '%s'.\n", driver.Description); ok(!strcmp(driver.MfgName, wow64 ? "mfg1_wow" : "mfg1"), "Got wrong manufacturer '%s'.\n", driver.MfgName); ok(!strcmp(driver.ProviderName, ""), "Got wrong provider '%s'.\n", driver.ProviderName);
- ret = SetupDiEnumDriverInfoA(set, &device, SPDIT_COMPATDRIVER, 2, &driver); + ret = SetupDiEnumDriverInfoA(set, &device, SPDIT_COMPATDRIVER, idx++, &driver); ok(ret, "Failed to enumerate drivers, error %#x.\n", GetLastError()); ok(driver.DriverType == SPDIT_COMPATDRIVER, "Got wrong type %#x.\n", driver.DriverType); ok(!strcmp(driver.Description, "desc4"), "Got wrong description '%s'.\n", driver.Description); @@ -2542,7 +2560,7 @@ static void test_driver_list(void) ok(!memcmp(detail->HardwareID, "wrong_hardware_id\0bogus_compat_id\0", sizeof("wrong_hardware_id\0bogus_compat_id\0")), "Got wrong ID list.\n");
- ret = SetupDiEnumDriverInfoA(set, &device, SPDIT_COMPATDRIVER, 3, &driver); + ret = SetupDiEnumDriverInfoA(set, &device, SPDIT_COMPATDRIVER, idx++, &driver); ok(ret, "Failed to enumerate drivers, error %#x.\n", GetLastError()); ok(driver.DriverType == SPDIT_COMPATDRIVER, "Got wrong type %#x.\n", driver.DriverType); ok(!strcmp(driver.Description, "desc5"), "Got wrong description '%s'.\n", driver.Description); @@ -2550,7 +2568,7 @@ static void test_driver_list(void) ok(!strcmp(driver.ProviderName, ""), "Got wrong provider '%s'.\n", driver.ProviderName);
SetLastError(0xdeadbeef); - ret = SetupDiEnumDriverInfoA(set, &device, SPDIT_COMPATDRIVER, 4, &driver); + ret = SetupDiEnumDriverInfoA(set, &device, SPDIT_COMPATDRIVER, idx++, &driver); ok(!ret, "Expected failure.\n"); ok(GetLastError() == ERROR_NO_MORE_ITEMS, "Got unexpected error %#x.\n", GetLastError());
@@ -2564,7 +2582,7 @@ static void test_driver_list(void) ret = SetupDiGetSelectedDriverA(set, &device, &driver); ok(ret, "Failed to get selected driver, error %#x.\n", GetLastError()); ok(driver.DriverType == SPDIT_COMPATDRIVER, "Got wrong type %#x.\n", driver.DriverType); - ok(!strcmp(driver.Description, "desc1"), "Got wrong description '%s'.\n", driver.Description); + todo_wine ok(!strcmp(driver.Description, "desc1"), "Got wrong description '%s'.\n", driver.Description); ok(!strcmp(driver.MfgName, wow64 ? "mfg1_wow" : "mfg1"), "Got wrong manufacturer '%s'.\n", driver.MfgName); ok(!strcmp(driver.ProviderName, ""), "Got wrong provider '%s'.\n", driver.ProviderName);
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/setupapi/devinst.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index 91001976edd..baef28ac130 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -4644,9 +4644,10 @@ static BOOL version_is_compatible(const WCHAR *version) static void enum_compat_drivers_from_file(struct device *device, const WCHAR *path) { static const WCHAR manufacturerW[] = {'M','a','n','u','f','a','c','t','u','r','e','r',0}; - WCHAR mfg_name[LINE_LEN], mfg_key[LINE_LEN], mfg_key_ext[LINE_LEN], id[MAX_DEVICE_ID_LEN], version[MAX_DEVICE_ID_LEN]; + WCHAR mfg_key[LINE_LEN], id[MAX_DEVICE_ID_LEN], version[MAX_DEVICE_ID_LEN]; + DWORD i, j, k, driver_count = device->driver_count; + struct driver driver, *drivers = device->drivers; INFCONTEXT ctx; - DWORD i, j, k; HINF hinf;
TRACE("Enumerating drivers from %s.\n", debugstr_w(path)); @@ -4654,11 +4655,13 @@ static void enum_compat_drivers_from_file(struct device *device, const WCHAR *pa if ((hinf = SetupOpenInfFileW(path, NULL, INF_STYLE_WIN4, NULL)) == INVALID_HANDLE_VALUE) return;
+ lstrcpyW(driver.inf_path, path); + for (i = 0; SetupGetLineByIndexW(hinf, manufacturerW, i, &ctx); ++i) { - SetupGetStringFieldW(&ctx, 0, mfg_name, ARRAY_SIZE(mfg_name), NULL); + SetupGetStringFieldW(&ctx, 0, driver.manufacturer, ARRAY_SIZE(driver.manufacturer), NULL); if (!SetupGetStringFieldW(&ctx, 1, mfg_key, ARRAY_SIZE(mfg_key), NULL)) - lstrcpyW(mfg_key, mfg_name); + lstrcpyW(mfg_key, driver.manufacturer);
if (SetupGetFieldCount(&ctx) >= 2) { @@ -4675,37 +4678,37 @@ static void enum_compat_drivers_from_file(struct device *device, const WCHAR *pa continue; }
- if (!SetupDiGetActualSectionToInstallW(hinf, mfg_key, mfg_key_ext, ARRAY_SIZE(mfg_key_ext), NULL, NULL)) + if (!SetupDiGetActualSectionToInstallW(hinf, mfg_key, driver.mfg_key, + ARRAY_SIZE(driver.mfg_key), NULL, NULL)) { WARN("Failed to find section for %s, skipping.\n", debugstr_w(mfg_key)); continue; }
- for (j = 0; SetupGetLineByIndexW(hinf, mfg_key_ext, j, &ctx); ++j) + for (j = 0; SetupGetLineByIndexW(hinf, driver.mfg_key, j, &ctx); ++j) { for (k = 2; SetupGetStringFieldW(&ctx, k, id, ARRAY_SIZE(id), NULL); ++k) { if (device_matches_id(device, HardwareId, id) || device_matches_id(device, CompatibleIDs, id)) { - unsigned int count = ++device->driver_count; - - device->drivers = heap_realloc(device->drivers, count * sizeof(*device->drivers)); - lstrcpyW(device->drivers[count - 1].inf_path, path); - lstrcpyW(device->drivers[count - 1].manufacturer, mfg_name); - lstrcpyW(device->drivers[count - 1].mfg_key, mfg_key_ext); - SetupGetStringFieldW(&ctx, 0, device->drivers[count - 1].description, - ARRAY_SIZE(device->drivers[count - 1].description), NULL); - SetupGetStringFieldW(&ctx, 1, device->drivers[count - 1].section, - ARRAY_SIZE(device->drivers[count - 1].section), NULL); + SetupGetStringFieldW(&ctx, 0, driver.description, ARRAY_SIZE(driver.description), NULL); + SetupGetStringFieldW(&ctx, 1, driver.section, ARRAY_SIZE(driver.section), NULL);
TRACE("Found compatible driver: manufacturer %s, desc %s.\n", - debugstr_w(mfg_name), debugstr_w(device->drivers[count - 1].description)); + debugstr_w(driver.manufacturer), debugstr_w(driver.description)); + + driver_count++; + drivers = heap_realloc(drivers, driver_count * sizeof(*drivers)); + drivers[driver_count - 1] = driver; } } } }
SetupCloseInfFile(hinf); + + device->drivers = drivers; + device->driver_count = driver_count; }
/***********************************************************************
I don't really like the patch subject—it's not nearly specific enough—but the content of this patch looks sensible to me.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/setupapi/devinst.c | 26 +++++++++++++++----------- dlls/setupapi/tests/devinst.c | 9 +-------- 2 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index baef28ac130..13e52f4534a 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -4648,6 +4648,7 @@ static void enum_compat_drivers_from_file(struct device *device, const WCHAR *pa DWORD i, j, k, driver_count = device->driver_count; struct driver driver, *drivers = device->drivers; INFCONTEXT ctx; + BOOL found; HINF hinf;
TRACE("Enumerating drivers from %s.\n", debugstr_w(path)); @@ -4687,20 +4688,23 @@ static void enum_compat_drivers_from_file(struct device *device, const WCHAR *pa
for (j = 0; SetupGetLineByIndexW(hinf, driver.mfg_key, j, &ctx); ++j) { - for (k = 2; SetupGetStringFieldW(&ctx, k, id, ARRAY_SIZE(id), NULL); ++k) + for (k = 2, found = FALSE; SetupGetStringFieldW(&ctx, k, id, ARRAY_SIZE(id), NULL); ++k) { - if (device_matches_id(device, HardwareId, id) || device_matches_id(device, CompatibleIDs, id)) - { - SetupGetStringFieldW(&ctx, 0, driver.description, ARRAY_SIZE(driver.description), NULL); - SetupGetStringFieldW(&ctx, 1, driver.section, ARRAY_SIZE(driver.section), NULL); + if ((found = device_matches_id(device, HardwareId, id))) break; + if ((found = device_matches_id(device, CompatibleIDs, id))) break; + }
- TRACE("Found compatible driver: manufacturer %s, desc %s.\n", - debugstr_w(driver.manufacturer), debugstr_w(driver.description)); + if (found) + { + SetupGetStringFieldW(&ctx, 0, driver.description, ARRAY_SIZE(driver.description), NULL); + SetupGetStringFieldW(&ctx, 1, driver.section, ARRAY_SIZE(driver.section), NULL);
- driver_count++; - drivers = heap_realloc(drivers, driver_count * sizeof(*drivers)); - drivers[driver_count - 1] = driver; - } + TRACE("Found compatible driver: manufacturer %s, desc %s.\n", + debugstr_w(driver.manufacturer), debugstr_w(driver.description)); + + driver_count++; + drivers = heap_realloc(drivers, driver_count * sizeof(*drivers)); + drivers[driver_count - 1] = driver; } } } diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 73e0086081d..677d6bda02a 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -2458,14 +2458,7 @@ static void test_driver_list(void) ret = SetupDiEnumDriverInfoA(set, &device, SPDIT_COMPATDRIVER, idx++, &driver); ok(ret, "Failed to enumerate drivers, error %#x.\n", GetLastError()); ok(driver.DriverType == SPDIT_COMPATDRIVER, "Got wrong type %#x.\n", driver.DriverType); - todo_wine ok(!strcmp(driver.Description, "desc1"), "Got wrong description '%s'.\n", driver.Description); - if (strcmp(driver.Description, "desc1")) - { - ret = SetupDiEnumDriverInfoA(set, &device, SPDIT_COMPATDRIVER, idx++, &driver); - ok(ret, "Failed to enumerate drivers, error %#x.\n", GetLastError()); - ok(driver.DriverType == SPDIT_COMPATDRIVER, "Got wrong type %#x.\n", driver.DriverType); - ok(!strcmp(driver.Description, "desc1"), "Got wrong description '%s'.\n", driver.Description); - } + ok(!strcmp(driver.Description, "desc1"), "Got wrong description '%s'.\n", driver.Description); ok(!strcmp(driver.MfgName, wow64 ? "mfg1_wow" : "mfg1"), "Got wrong manufacturer '%s'.\n", driver.MfgName); ok(!strcmp(driver.ProviderName, ""), "Got wrong provider '%s'.\n", driver.ProviderName);
On 8/17/21 9:39 AM, Rémi Bernon wrote:
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
dlls/setupapi/devinst.c | 26 +++++++++++++++----------- dlls/setupapi/tests/devinst.c | 9 +-------- 2 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index baef28ac130..13e52f4534a 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -4648,6 +4648,7 @@ static void enum_compat_drivers_from_file(struct device *device, const WCHAR *pa DWORD i, j, k, driver_count = device->driver_count; struct driver driver, *drivers = device->drivers; INFCONTEXT ctx;
BOOL found; HINF hinf;
TRACE("Enumerating drivers from %s.\n", debugstr_w(path));
@@ -4687,20 +4688,23 @@ static void enum_compat_drivers_from_file(struct device *device, const WCHAR *pa
for (j = 0; SetupGetLineByIndexW(hinf, driver.mfg_key, j, &ctx); ++j) {
for (k = 2; SetupGetStringFieldW(&ctx, k, id, ARRAY_SIZE(id), NULL); ++k)
for (k = 2, found = FALSE; SetupGetStringFieldW(&ctx, k, id, ARRAY_SIZE(id), NULL); ++k) {
if (device_matches_id(device, HardwareId, id) || device_matches_id(device, CompatibleIDs, id))
{
SetupGetStringFieldW(&ctx, 0, driver.description, ARRAY_SIZE(driver.description), NULL);
SetupGetStringFieldW(&ctx, 1, driver.section, ARRAY_SIZE(driver.section), NULL);
if ((found = device_matches_id(device, HardwareId, id))) break;
if ((found = device_matches_id(device, CompatibleIDs, id))) break;
}
TRACE("Found compatible driver: manufacturer %s, desc %s.\n",
debugstr_w(driver.manufacturer), debugstr_w(driver.description));
if (found)
{
SetupGetStringFieldW(&ctx, 0, driver.description, ARRAY_SIZE(driver.description), NULL);
SetupGetStringFieldW(&ctx, 1, driver.section, ARRAY_SIZE(driver.section), NULL);
driver_count++;
drivers = heap_realloc(drivers, driver_count * sizeof(*drivers));
drivers[driver_count - 1] = driver;
}
TRACE("Found compatible driver: manufacturer %s, desc %s.\n",
debugstr_w(driver.manufacturer), debugstr_w(driver.description));
driver_count++;
drivers = heap_realloc(drivers, driver_count * sizeof(*drivers));
drivers[driver_count - 1] = driver; } } }
I must be missing something; wouldn't it be simpler and functionally equivalent just to put a "break" at the end of the inner "if"?
On 8/17/21 6:53 PM, Zebediah Figura (she/her) wrote:
I must be missing something; wouldn't it be simpler and functionally equivalent just to put a "break" at the end of the inner "if"?
Sure but it didn't look as nice, and especially for the next patch.
On 8/17/21 11:55 AM, Rémi Bernon wrote:
On 8/17/21 6:53 PM, Zebediah Figura (she/her) wrote:
I must be missing something; wouldn't it be simpler and functionally equivalent just to put a "break" at the end of the inner "if"?
Sure but it didn't look as nice, and especially for the next patch.
Okay, I see the bind.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
And as described on MSDN "Driver Rank Example".
In order to safely remove the hardcoded XBox gamepad ID list from winebus.sys, and list their hardware IDs in the (future) xinput.sys driver INF.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/setupapi/devinst.c | 33 ++++++++++++++++++++++++--------- dlls/setupapi/tests/devinst.c | 2 +- 2 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index 13e52f4534a..29cfbbeb87f 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -109,6 +109,7 @@ static const WCHAR emptyW[] = {0};
struct driver { + DWORD rank; WCHAR inf_path[MAX_PATH]; WCHAR manufacturer[LINE_LEN]; WCHAR mfg_key[LINE_LEN]; @@ -4588,21 +4589,23 @@ BOOL WINAPI SetupDiRegisterCoDeviceInstallers(HDEVINFO devinfo, SP_DEVINFO_DATA
/* Check whether the given hardware or compatible ID matches any of the device's * own hardware or compatible IDs. */ -static BOOL device_matches_id(const struct device *device, const WCHAR *id_type, const WCHAR *id) +static BOOL device_matches_id(const struct device *device, const WCHAR *id_type, const WCHAR *id, + DWORD *driver_rank) { WCHAR *device_ids; const WCHAR *p; - DWORD size; + DWORD i, size;
if (!RegGetValueW(device->key, NULL, id_type, RRF_RT_REG_MULTI_SZ, NULL, NULL, &size)) { device_ids = heap_alloc(size); if (!RegGetValueW(device->key, NULL, id_type, RRF_RT_REG_MULTI_SZ, NULL, device_ids, &size)) { - for (p = device_ids; *p; p += lstrlenW(p) + 1) + for (p = device_ids, i = 0; *p; p += lstrlenW(p) + 1, i++) { if (!wcsicmp(p, id)) { + *driver_rank += min(i, 0xff); heap_free(device_ids); return TRUE; } @@ -4688,10 +4691,13 @@ static void enum_compat_drivers_from_file(struct device *device, const WCHAR *pa
for (j = 0; SetupGetLineByIndexW(hinf, driver.mfg_key, j, &ctx); ++j) { + driver.rank = 0; for (k = 2, found = FALSE; SetupGetStringFieldW(&ctx, k, id, ARRAY_SIZE(id), NULL); ++k) { - if ((found = device_matches_id(device, HardwareId, id))) break; - if ((found = device_matches_id(device, CompatibleIDs, id))) break; + if ((found = device_matches_id(device, HardwareId, id, &driver.rank))) break; + driver.rank += 0x2000; + if ((found = device_matches_id(device, CompatibleIDs, id, &driver.rank))) break; + driver.rank = 0x1000 + min(0x0100 * (k - 2), 0xf00); }
if (found) @@ -4699,8 +4705,8 @@ static void enum_compat_drivers_from_file(struct device *device, const WCHAR *pa SetupGetStringFieldW(&ctx, 0, driver.description, ARRAY_SIZE(driver.description), NULL); SetupGetStringFieldW(&ctx, 1, driver.section, ARRAY_SIZE(driver.section), NULL);
- TRACE("Found compatible driver: manufacturer %s, desc %s.\n", - debugstr_w(driver.manufacturer), debugstr_w(driver.description)); + TRACE("Found compatible driver: rank %#x manufacturer %s, desc %s.\n", + driver.rank, debugstr_w(driver.manufacturer), debugstr_w(driver.description));
driver_count++; drivers = heap_realloc(drivers, driver_count * sizeof(*drivers)); @@ -4867,6 +4873,8 @@ BOOL WINAPI SetupDiEnumDriverInfoA(HDEVINFO devinfo, SP_DEVINFO_DATA *device_dat BOOL WINAPI SetupDiSelectBestCompatDrv(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data) { struct device *device; + struct driver *best; + DWORD i;
TRACE("devinfo %p, device_data %p.\n", devinfo, device_data);
@@ -4880,10 +4888,17 @@ BOOL WINAPI SetupDiSelectBestCompatDrv(HDEVINFO devinfo, SP_DEVINFO_DATA *device return FALSE; }
- WARN("Semi-stub, selecting the first available driver.\n"); + best = device->drivers; + for (i = 1; i < device->driver_count; ++i) + { + if (device->drivers[i].rank >= best->rank) continue; + best = device->drivers + i; + }
- device->selected_driver = &device->drivers[0]; + TRACE("selected driver: rank %#x manufacturer %s, desc %s.\n", + best->rank, debugstr_w(best->manufacturer), debugstr_w(best->description));
+ device->selected_driver = best; return TRUE; }
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 677d6bda02a..6f02acb9589 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -2575,7 +2575,7 @@ static void test_driver_list(void) ret = SetupDiGetSelectedDriverA(set, &device, &driver); ok(ret, "Failed to get selected driver, error %#x.\n", GetLastError()); ok(driver.DriverType == SPDIT_COMPATDRIVER, "Got wrong type %#x.\n", driver.DriverType); - todo_wine ok(!strcmp(driver.Description, "desc1"), "Got wrong description '%s'.\n", driver.Description); + ok(!strcmp(driver.Description, "desc1"), "Got wrong description '%s'.\n", driver.Description); ok(!strcmp(driver.MfgName, wow64 ? "mfg1_wow" : "mfg1"), "Got wrong manufacturer '%s'.\n", driver.MfgName); ok(!strcmp(driver.ProviderName, ""), "Got wrong provider '%s'.\n", driver.ProviderName);
Signed-off-by: Zebediah Figura zfigura@codeweavers.com