setupapi: Implement SetupDiDeleteDeviceInterfaceData().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2018-12-03 23:36:14 -06:00 committed by Alexandre Julliard
parent c05b54d9a9
commit d6a504eaf0
3 changed files with 53 additions and 8 deletions

View File

@ -576,6 +576,16 @@ static void remove_device_iface(struct device_iface *iface)
iface->flags |= SPINT_REMOVED; iface->flags |= SPINT_REMOVED;
} }
static void delete_device_iface(struct device_iface *iface)
{
list_remove(&iface->entry);
RegCloseKey(iface->refstr_key);
RegCloseKey(iface->class_key);
heap_free(iface->refstr);
heap_free(iface->symlink);
heap_free(iface);
}
static void remove_device(struct device *device) static void remove_device(struct device *device)
{ {
WCHAR id[MAX_DEVICE_ID_LEN], *p; WCHAR id[MAX_DEVICE_ID_LEN], *p;
@ -622,12 +632,7 @@ static void delete_device(struct device *device)
LIST_FOR_EACH_ENTRY_SAFE(iface, next, &device->interfaces, LIST_FOR_EACH_ENTRY_SAFE(iface, next, &device->interfaces,
struct device_iface, entry) struct device_iface, entry)
{ {
list_remove(&iface->entry); delete_device_iface(iface);
RegCloseKey(iface->refstr_key);
RegCloseKey(iface->class_key);
heap_free(iface->refstr);
heap_free(iface->symlink);
heap_free(iface);
} }
free_devnode(device->devnode); free_devnode(device->devnode);
list_remove(&device->entry); list_remove(&device->entry);
@ -1598,6 +1603,23 @@ BOOL WINAPI SetupDiRemoveDeviceInterface(HDEVINFO devinfo, SP_DEVICE_INTERFACE_D
return TRUE; return TRUE;
} }
/***********************************************************************
* SetupDiDeleteDeviceInterfaceData (SETUPAPI.@)
*/
BOOL WINAPI SetupDiDeleteDeviceInterfaceData(HDEVINFO devinfo, SP_DEVICE_INTERFACE_DATA *iface_data)
{
struct device_iface *iface;
TRACE("devinfo %p, iface_data %p.\n", devinfo, iface_data);
if (!(iface = get_device_iface(devinfo, iface_data)))
return FALSE;
delete_device_iface(iface);
return TRUE;
}
/*********************************************************************** /***********************************************************************
* SetupDiEnumDeviceInfo (SETUPAPI.@) * SetupDiEnumDeviceInfo (SETUPAPI.@)
*/ */

View File

@ -302,7 +302,7 @@
@ stdcall SetupDiCreateDeviceInterfaceRegKeyW(ptr ptr long long ptr wstr) @ stdcall SetupDiCreateDeviceInterfaceRegKeyW(ptr ptr long long ptr wstr)
@ stdcall SetupDiDeleteDevRegKey(ptr ptr long long long) @ stdcall SetupDiDeleteDevRegKey(ptr ptr long long long)
@ stdcall SetupDiDeleteDeviceInfo(ptr ptr) @ stdcall SetupDiDeleteDeviceInfo(ptr ptr)
@ stub SetupDiDeleteDeviceInterfaceData @ stdcall SetupDiDeleteDeviceInterfaceData(ptr ptr)
@ stdcall SetupDiDeleteDeviceInterfaceRegKey(ptr ptr long) @ stdcall SetupDiDeleteDeviceInterfaceRegKey(ptr ptr long)
@ stub SetupDiDeleteDeviceRegKey @ stub SetupDiDeleteDeviceRegKey
@ stdcall SetupDiDestroyClassImageList(ptr) @ stdcall SetupDiDestroyClassImageList(ptr)

View File

@ -650,6 +650,15 @@ static void test_device_iface(void)
check_device_iface(set, &device, &guid2, 0, SPINT_REMOVED, "\\\\?\\ROOT#LEGACY_BOGUS#0000#{6A55B5A5-3F65-11DB-B704-0011955C2BDB}"); check_device_iface(set, &device, &guid2, 0, SPINT_REMOVED, "\\\\?\\ROOT#LEGACY_BOGUS#0000#{6A55B5A5-3F65-11DB-B704-0011955C2BDB}");
check_device_iface(set, &device, &guid2, 1, 0, NULL); check_device_iface(set, &device, &guid2, 1, 0, NULL);
ret = SetupDiEnumDeviceInterfaces(set, &device, &guid, 0, &iface);
ok(ret, "Failed to enumerate interfaces, error %#x.\n", GetLastError());
ret = SetupDiDeleteDeviceInterfaceData(set, &iface);
ok(ret, "Failed to delete interface, error %#x.\n", GetLastError());
check_device_iface(set, &device, &guid, 0, 0, "\\\\?\\ROOT#LEGACY_BOGUS#0000#{6A55B5A4-3F65-11DB-B704-0011955C2BDB}\\Oogah");
check_device_iface(set, &device, &guid, 1, 0, "\\\\?\\ROOT#LEGACY_BOGUS#0000#{6A55B5A4-3F65-11DB-B704-0011955C2BDB}\\test");
check_device_iface(set, &device, &guid, 2, 0, NULL);
ret = SetupDiDestroyDeviceInfoList(set); ret = SetupDiDestroyDeviceInfoList(set);
ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError());
} }
@ -862,14 +871,28 @@ static void test_register_device_iface(void)
ok(ret, "Failed to create device, error %#x.\n", GetLastError()); ok(ret, "Failed to create device, error %#x.\n", GetLastError());
ret = SetupDiCreateDeviceInterfaceA(set, &device, &guid, NULL, 0, &iface); ret = SetupDiCreateDeviceInterfaceA(set, &device, &guid, NULL, 0, &iface);
ok(ret, "Failed to create interface, error %#x.\n", GetLastError()); ok(ret, "Failed to create interface, error %#x.\n", GetLastError());
ret = SetupDiCreateDeviceInterfaceA(set, &device, &guid, "removed", 0, &iface);
ok(ret, "Failed to create interface, error %#x.\n", GetLastError());
ret = SetupDiCreateDeviceInterfaceA(set, &device, &guid, "deleted", 0, &iface);
ok(ret, "Failed to create interface, error %#x.\n", GetLastError());
ret = SetupDiRegisterDeviceInfo(set, &device, 0, NULL, NULL, NULL); ret = SetupDiRegisterDeviceInfo(set, &device, 0, NULL, NULL, NULL);
ok(ret, "Failed to register device, error %#x.\n", GetLastError()); ok(ret, "Failed to register device, error %#x.\n", GetLastError());
ret = SetupDiEnumDeviceInterfaces(set, &device, &guid, 1, &iface);
ok(ret, "Failed to enumerate interfaces, error %#x.\n", GetLastError());
ret = SetupDiRemoveDeviceInterface(set, &iface);
ok(ret, "Failed to delete interface, error %#x.\n", GetLastError());
ret = SetupDiEnumDeviceInterfaces(set, &device, &guid, 2, &iface);
ok(ret, "Failed to enumerate interfaces, error %#x.\n", GetLastError());
ret = SetupDiDeleteDeviceInterfaceData(set, &iface);
ok(ret, "Failed to delete interface, error %#x.\n", GetLastError());
set2 = SetupDiGetClassDevsA(&guid, NULL, 0, DIGCF_DEVICEINTERFACE); set2 = SetupDiGetClassDevsA(&guid, NULL, 0, DIGCF_DEVICEINTERFACE);
ok(set2 != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); ok(set2 != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError());
check_device_iface(set2, NULL, &guid, 0, 0, "\\\\?\\root#legacy_bogus#0000#{6a55b5a4-3f65-11db-b704-0011955c2bdb}"); 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, NULL); 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 = SetupDiRemoveDevice(set, &device); ret = SetupDiRemoveDevice(set, &device);
ok(ret, "Failed to remove device, error %#x.\n", GetLastError()); ok(ret, "Failed to remove device, error %#x.\n", GetLastError());