From 7cf6104d9458d921cf679a5067af003189835470 Mon Sep 17 00:00:00 2001 From: winesync Date: Thu, 14 Sep 2023 21:32:40 +0200 Subject: [PATCH] [WINESYNC] setupapi: Remove all device interfaces in SetupDiRemoveDevice(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard wine commit id 0b8c1d69e66094d72e00f30f370ec3f69fb43dfd by Zebediah Figura [WINESYNC] setupapi/tests: Add more driver / device id match tests. Signed-off-by: Rémi Bernon Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard wine commit id 9b2a25232312a073f288d683d48f9366d54654d3 by Rémi Bernon [WINESYNC] setupapi: Create only one driver per driver id match. Signed-off-by: Rémi Bernon Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard wine commit id eb94d7aea85b13197f8d678baeca414adc05aaed by Rémi Bernon [WINESYNC] setupapi: Rank drivers according to their id match. 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 Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard wine commit id cfddd2c1e24fc03ad570f771093fd08bbf8b9575 by Rémi Bernon --- modules/rostests/winetests/setupapi/devinst.c | 53 ++++++++++++++++--- sdk/tools/winesync/setupapi.cfg | 2 +- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/modules/rostests/winetests/setupapi/devinst.c b/modules/rostests/winetests/setupapi/devinst.c index 55dfc5ec128..db167fabbfa 100644 --- a/modules/rostests/winetests/setupapi/devinst.c +++ b/modules/rostests/winetests/setupapi/devinst.c @@ -1452,6 +1452,7 @@ static void test_register_device_iface(void) '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)}; + SP_DEVINFO_DATA device2 = {sizeof(device2)}; SP_DEVINFO_DATA device = {sizeof(device)}; HDEVINFO set, set2; BOOL ret; @@ -1491,11 +1492,40 @@ static void test_register_device_iface(void) check_device_iface(set2, NULL, &guid, 1, 0, "\\\\?\\root#legacy_bogus#0000#{6a55b5a4-3f65-11db-b704-0011955c2bdb}\\deleted"); check_device_iface(set2, NULL, &guid, 2, 0, NULL); + ret = SetupDiEnumDeviceInfo(set2, 0, &device2); + ok(ret, "Failed to enumerate devices, error %#x.\n", GetLastError()); + ret = SetupDiCreateDeviceInterfaceA(set2, &device2, &guid, "second", 0, NULL); + ok(ret, "Failed to create interface, error %#x.\n", GetLastError()); + ret = SetupDiRemoveDevice(set, &device); ok(ret, "Failed to remove device, error %#x.\n", GetLastError()); + check_device_iface(set, NULL, &guid, 0, SPINT_REMOVED, "\\\\?\\root#legacy_bogus#0000#{6a55b5a4-3f65-11db-b704-0011955c2bdb}"); + check_device_iface(set, NULL, &guid, 1, SPINT_REMOVED, "\\\\?\\root#legacy_bogus#0000#{6a55b5a4-3f65-11db-b704-0011955c2bdb}\\removed"); + check_device_iface(set, NULL, &guid, 2, 0, NULL); + + 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, "\\\\?\\root#legacy_bogus#0000#{6a55b5a4-3f65-11db-b704-0011955c2bdb}\\deleted"); + check_device_iface(set2, NULL, &guid, 2, 0, "\\\\?\\root#legacy_bogus#0000#{6a55b5a4-3f65-11db-b704-0011955c2bdb}\\second"); + check_device_iface(set2, NULL, &guid, 3, 0, NULL); + SetupDiDestroyDeviceInfoList(set); SetupDiDestroyDeviceInfoList(set2); + + /* make sure all interface keys are deleted when a device is removed */ + + set = SetupDiGetClassDevsA(&guid, NULL, 0, DIGCF_DEVICEINTERFACE); + ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + + ret = SetupDiCreateDeviceInfoA(set, "Root\\LEGACY_BOGUS\\0000", &guid, NULL, NULL, 0, &device); + ok(ret, "Failed to create device, error %#x.\n", GetLastError()); + + set2 = SetupDiGetClassDevsA(&guid, NULL, 0, DIGCF_DEVICEINTERFACE); + ok(set2 != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_iface(set2, NULL, &guid, 0, 0, NULL); + SetupDiDestroyDeviceInfoList(set2); + + SetupDiDestroyDeviceInfoList(set); } static void test_registry_property_a(void) @@ -2322,7 +2352,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)}; @@ -2331,6 +2361,7 @@ static void test_driver_list(void) FILETIME filetime; HDEVINFO set; HANDLE file; + DWORD idx; BOOL ret; static const char inf_data[] = "[Version]\n" @@ -2343,11 +2374,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" @@ -2418,7 +2451,15 @@ 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, "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); ok(!strcmp(driver.Description, "desc1"), "Got wrong description '%s'.\n", driver.Description); @@ -2489,14 +2530,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); @@ -2516,7 +2557,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); @@ -2524,7 +2565,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()); diff --git a/sdk/tools/winesync/setupapi.cfg b/sdk/tools/winesync/setupapi.cfg index 75c19eb52e5..a97e2d51cf2 100644 --- a/sdk/tools/winesync/setupapi.cfg +++ b/sdk/tools/winesync/setupapi.cfg @@ -10,4 +10,4 @@ files: dlls/setupapi/setupcab.c: dll/win32/setupapi/setupcab.c dlls/setupapi/stringtable.c: dll/win32/setupapi/stringtable_wine.c tags: - wine: 00b9c975d4bd3a24ae41c99057d7a1a32f329c00 + wine: cfddd2c1e24fc03ad570f771093fd08bbf8b9575