Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=43211 Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/devinst.c | 17 ++++++++++++++ dlls/setupapi/stubs.c | 12 ---------- dlls/setupapi/tests/devinst.c | 52 +++++++++++++++++++++++++++++-------------- 3 files changed, 52 insertions(+), 29 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index db0b72fcb5..5685dc3bff 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -1574,6 +1574,23 @@ BOOL WINAPI SetupDiRemoveDevice(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data) return TRUE; }
+/*********************************************************************** + * SetupDiDeleteDeviceInfo (SETUPAPI.@) + */ +BOOL WINAPI SetupDiDeleteDeviceInfo(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data) +{ + struct device *device; + + TRACE("devinfo %p, device_data %p.\n", devinfo, device_data); + + if (!(device = get_device(devinfo, device_data))) + return FALSE; + + delete_device(device); + + return TRUE; +} + /*********************************************************************** * SetupDiRemoveDeviceInterface (SETUPAPI.@) */ diff --git a/dlls/setupapi/stubs.c b/dlls/setupapi/stubs.c index 7c3413a7cc..61ce005212 100644 --- a/dlls/setupapi/stubs.c +++ b/dlls/setupapi/stubs.c @@ -611,18 +611,6 @@ BOOL WINAPI SetupDiDestroyDriverInfoList(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DAT return FALSE; }
-/*********************************************************************** - * SetupDiDeleteDeviceInfo (SETUPAPI.@) - */ - -BOOL WINAPI SetupDiDeleteDeviceInfo(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData) - { - FIXME(": stub %p, %p\n", DeviceInfoSet, DeviceInfoData); - - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - /*********************************************************************** * SetupDiDrawMiniIcon (SETUPAPI.@) */ diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index edb660e106..55fe104b9b 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -337,13 +337,21 @@ static void test_device_info(void) check_device_info(set, 2, &guid, "ROOT\LEGACY_BOGUS\0002"); check_device_info(set, 3, &guid, NULL);
+ ret = SetupDiEnumDeviceInfo(set, 0, &ret_device); + ok(ret, "Failed to enumerate devices, error %#x.\n", GetLastError()); + ret = SetupDiDeleteDeviceInfo(set, &ret_device); + ok(ret, "Failed to delete device, error %#x.\n", GetLastError()); + + check_device_info(set, 0, &guid, "ROOT\LEGACY_BOGUS\0001"); + check_device_info(set, 1, &guid, "ROOT\LEGACY_BOGUS\0002"); + check_device_info(set, 2, &guid, NULL); + ret = SetupDiRemoveDevice(set, &device); ok(ret, "Got unexpected error %#x.\n", GetLastError());
- check_device_info(set, 0, &guid, "ROOT\LEGACY_BOGUS\0000"); - check_device_info(set, 1, &guid, "ROOT\LEGACY_BOGUS\0001"); + check_device_info(set, 0, &guid, "ROOT\LEGACY_BOGUS\0001");
- ret = SetupDiEnumDeviceInfo(set, 2, &ret_device); + ret = SetupDiEnumDeviceInfo(set, 1, &ret_device); ok(ret, "Got unexpected error %#x.\n", GetLastError()); ok(IsEqualGUID(&ret_device.ClassGuid, &guid), "Got unexpected class %s.\n", wine_dbgstr_guid(&ret_device.ClassGuid)); @@ -353,7 +361,7 @@ static void test_device_info(void) ok(ret_device.DevInst == device.DevInst, "Expected device node %#x, got %#x.\n", device.DevInst, ret_device.DevInst);
- check_device_info(set, 3, &guid, NULL); + check_device_info(set, 2, &guid, NULL);
SetupDiDestroyDeviceInfoList(set);
@@ -469,7 +477,7 @@ static void test_register_device_info(void) SP_DEVINFO_DATA device = {0}; BOOL ret; HDEVINFO set; - char id[30]; + int i = 0;
SetLastError(0xdeadbeef); ret = SetupDiRegisterDeviceInfo(NULL, NULL, 0, NULL, NULL, NULL); @@ -497,30 +505,40 @@ static void test_register_device_info(void)
ret = SetupDiCreateDeviceInfoA(set, "Root\LEGACY_BOGUS\0000", &guid, NULL, NULL, 0, &device); ok(ret, "Failed to create device, error %#x.\n", GetLastError()); - ret = SetupDiRegisterDeviceInfo(set, &device, 0, NULL, NULL, NULL); ok(ret, "Failed to register device, error %#x.\n", GetLastError());
ret = SetupDiCreateDeviceInfoA(set, "Root\LEGACY_BOGUS\0001", &guid, NULL, NULL, 0, &device); ok(ret, "Failed to create device, error %#x.\n", GetLastError()); + ret = SetupDiRegisterDeviceInfo(set, &device, 0, NULL, NULL, NULL); + ok(ret, "Failed to register device, error %#x.\n", GetLastError()); + ret = SetupDiRemoveDevice(set, &device); + ok(ret, "Failed to remove device, error %#x.\n", GetLastError()); + + ret = SetupDiCreateDeviceInfoA(set, "Root\LEGACY_BOGUS\0002", &guid, NULL, NULL, 0, &device); + ok(ret, "Failed to create device, error %#x.\n", GetLastError()); + ret = SetupDiRegisterDeviceInfo(set, &device, 0, NULL, NULL, NULL); + ok(ret, "Failed to register device, error %#x.\n", GetLastError()); + ret = SetupDiDeleteDeviceInfo(set, &device); + ok(ret, "Failed to remove device, error %#x.\n", GetLastError()); + + ret = SetupDiCreateDeviceInfoA(set, "Root\LEGACY_BOGUS\0003", &guid, NULL, NULL, 0, &device); + ok(ret, "Failed to create device, error %#x.\n", GetLastError());
SetupDiDestroyDeviceInfoList(set);
set = SetupDiGetClassDevsA(&guid, NULL, NULL, 0); ok(set != NULL, "Failed to create device list, error %#x.\n", GetLastError());
- ret = SetupDiEnumDeviceInfo(set, 0, &device); - ok(ret, "Failed to enumerate devices, error %#x.\n", GetLastError()); - ret = SetupDiGetDeviceInstanceIdA(set, &device, id, sizeof(id), NULL); - ok(ret, "Failed to get device id, error %#x.\n", GetLastError()); - ok(!strcasecmp(id, "Root\LEGACY_BOGUS\0000"), "Got unexpected id %s.\n", id); - - ret = SetupDiRemoveDevice(set, &device); - ok(ret, "Failed to remove device, error %#x.\n", GetLastError()); + check_device_info(set, 0, &guid, "Root\LEGACY_BOGUS\0000"); + check_device_info(set, 1, &guid, "Root\LEGACY_BOGUS\0002"); + check_device_info(set, 2, &guid, NULL);
- ret = SetupDiEnumDeviceInfo(set, 1, &device); - ok(!ret, "Expected failure.\n"); - ok(GetLastError() == ERROR_NO_MORE_ITEMS, "Got unexpected error %#x.\n", GetLastError()); + while (SetupDiEnumDeviceInfo(set, i++, &device)) + { + ret = SetupDiRemoveDevice(set, &device); + ok(ret, "Failed to remove device, error %#x.\n", GetLastError()); + }
SetupDiDestroyDeviceInfoList(set); }