From 334d17330525e2a480ffe3796dd3caf04fbf1997 Mon Sep 17 00:00:00 2001 From: winesync Date: Fri, 5 Jan 2024 22:41:08 +0100 Subject: [PATCH] ****** Heavily adapted for ReactOS -- TODO: Investigate: Code around copy_device_iface_data may be simplified? MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [WINESYNC] setupapi: Merge the InterfaceInfo and InterfaceInstances structs. It seems the original motivation for separating these was to facilitate easy enumeration of specific classes using SetupDiEnumDeviceInterfaces(), but it makes other things unnecessarily complex [including an eventual implementation of SetupDiRemoveDeviceInterface()] and the implementation provided here seems quite simple enough. Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard wine commit id 86d26dded5560d6d8adb195372f0676d1f7229b0 by Zebediah Figura SYNC NOTE: Only changes applicable to ReactOS have been added: namely, the copy_device_iface_data() inline helper. Co-authored-by: Hermès Bélusca-Maïto --- dll/win32/setupapi/devinst.c | 32 +++++++++++++------------------- dll/win32/setupapi/interface.c | 3 ++- sdk/tools/winesync/setupapi.cfg | 2 +- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/dll/win32/setupapi/devinst.c b/dll/win32/setupapi/devinst.c index bafc2da1ae3..c19180f0d1e 100644 --- a/dll/win32/setupapi/devinst.c +++ b/dll/win32/setupapi/devinst.c @@ -85,6 +85,14 @@ static inline void copy_device_data(SP_DEVINFO_DATA *data, const struct DeviceIn data->Reserved = (ULONG_PTR)devinfo; } +static inline void copy_device_iface_data(SP_DEVICE_INTERFACE_DATA *data, + const struct DeviceInterface *iface) +{ + data->InterfaceClassGuid = iface->InterfaceClassGuid; + data->Flags = iface->Flags; + data->Reserved = (ULONG_PTR)iface; +} + static void SETUPDI_GuidToString(const GUID *guid, LPWSTR guidStr) { static const WCHAR fmt[] = {'{','%','0','8','X','-','%','0','4','X','-', @@ -2866,9 +2874,7 @@ BOOL WINAPI SetupDiEnumDeviceInterfaces( if (MemberIndex-- == 0) { /* return this item */ - DeviceInterfaceData->InterfaceClassGuid = DevItf->InterfaceClassGuid; - DeviceInterfaceData->Flags = DevItf->Flags; - DeviceInterfaceData->Reserved = (ULONG_PTR)DevItf; + copy_device_iface_data(DeviceInterfaceData, DevItf); found = TRUE; ret = TRUE; } @@ -2898,9 +2904,7 @@ BOOL WINAPI SetupDiEnumDeviceInterfaces( if (MemberIndex-- == 0) { /* return this item */ - DeviceInterfaceData->InterfaceClassGuid = DevItf->InterfaceClassGuid; - DeviceInterfaceData->Flags = DevItf->Flags; - DeviceInterfaceData->Reserved = (ULONG_PTR)DevItf; + copy_device_iface_data(DeviceInterfaceData, DevItf); found = TRUE; ret = TRUE; } @@ -3910,19 +3914,13 @@ BOOL WINAPI SetupDiOpenDeviceInterfaceW( if (!wcsicmp(deviceInterface->SymbolicLink, DevicePath)) { if (DeviceInterfaceData) - { - DeviceInterfaceData->Reserved = (ULONG_PTR)deviceInterface; - DeviceInterfaceData->Flags = deviceInterface->Flags; - CopyMemory(&DeviceInterfaceData->InterfaceClassGuid, &ClassId, sizeof(GUID)); - } + copy_device_iface_data(DeviceInterfaceData, deviceInterface); return TRUE; } - } } - dwIndex = 0; do { @@ -3978,8 +3976,7 @@ BOOL WINAPI SetupDiOpenDeviceInterfaceW( deviceInterface = HeapAlloc(GetProcessHeap(), 0, sizeof(struct DeviceInterface) + (wcslen(SymBuffer) + 1) * sizeof(WCHAR)); if (deviceInterface) { - - CopyMemory(&deviceInterface->InterfaceClassGuid, &ClassId, sizeof(GUID)); + deviceInterface->InterfaceClassGuid = ClassId; deviceInterface->DeviceInfo = deviceInfo; deviceInterface->Flags = SPINT_ACTIVE; //FIXME @@ -3988,12 +3985,9 @@ BOOL WINAPI SetupDiOpenDeviceInterfaceW( InsertTailList(&deviceInfo->InterfaceListHead, &deviceInterface->ListEntry); InsertTailList(&list->ListHead, &deviceInfo->ListEntry); - if (DeviceInterfaceData) { - DeviceInterfaceData->Reserved = (ULONG_PTR)deviceInterface; - DeviceInterfaceData->Flags = deviceInterface->Flags; - CopyMemory(&DeviceInterfaceData->InterfaceClassGuid, &ClassId, sizeof(GUID)); + copy_device_iface_data(DeviceInterfaceData, deviceInterface); } else { diff --git a/dll/win32/setupapi/interface.c b/dll/win32/setupapi/interface.c index 0eaf400e258..c6d112d8e56 100644 --- a/dll/win32/setupapi/interface.c +++ b/dll/win32/setupapi/interface.c @@ -363,8 +363,9 @@ InstallOneInterface( return FALSE; } + DeviceInterfaceData.cbSize = sizeof(DeviceInterfaceData); + // copy_device_iface_data(&DeviceInterfaceData, DevItf); DeviceInterfaceData.InterfaceClassGuid = DevItf->InterfaceClassGuid; - DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); DeviceInterfaceData.Flags = DevItf->Flags; DeviceInterfaceData.Reserved = (ULONG_PTR)DevItf; diff --git a/sdk/tools/winesync/setupapi.cfg b/sdk/tools/winesync/setupapi.cfg index ec1a3f9be1e..f0c30de2a2f 100644 --- a/sdk/tools/winesync/setupapi.cfg +++ b/sdk/tools/winesync/setupapi.cfg @@ -5,4 +5,4 @@ files: dlls/setupapi/misc.c: dll/win32/setupapi/misc.c dlls/setupapi/stubs.c: dll/win32/setupapi/stubs.c tags: - wine: ad9e1883ef558886607037592f48e6c5d216d4e1 + wine: 86d26dded5560d6d8adb195372f0676d1f7229b0