From 95293779052dfd47d0c16a62725449fdbd1892f5 Mon Sep 17 00:00:00 2001 From: winesync Date: Fri, 5 Jan 2024 22:06:58 +0100 Subject: [PATCH] ****** Heavily adapted for ReactOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [WINESYNC] setupapi: Don't use SP_DEVINFO_DATA in internal structs. And especially don't use a pointer to one, since there's no guarantee it'll remain stable. Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard wine commit id 11d09c299e5df47cadda7473d03a49244c846634 by Zebediah Figura SYNC NOTE: Only changes applicable to ReactOS have been added: namely, the copy_device_data() inline helper. Co-authored-by: Hermès Bélusca-Maïto --- dll/win32/setupapi/devinst.c | 31 ++++++++++++------------------- sdk/tools/winesync/setupapi.cfg | 2 +- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/dll/win32/setupapi/devinst.c b/dll/win32/setupapi/devinst.c index 8596f1386c5..bafc2da1ae3 100644 --- a/dll/win32/setupapi/devinst.c +++ b/dll/win32/setupapi/devinst.c @@ -78,6 +78,13 @@ struct GetSectionCallbackInfo +static inline void copy_device_data(SP_DEVINFO_DATA *data, const struct DeviceInfo *devinfo) +{ + data->ClassGuid = devinfo->ClassGuid; + data->DevInst = devinfo->dnDevInst; + data->Reserved = (ULONG_PTR)devinfo; +} + static void SETUPDI_GuidToString(const GUID *guid, LPWSTR guidStr) { static const WCHAR fmt[] = {'{','%','0','8','X','-','%','0','4','X','-', @@ -1679,9 +1686,7 @@ BOOL WINAPI SetupDiCreateDeviceInfoW( } else { - DeviceInfoData->ClassGuid = *ClassGuid; - DeviceInfoData->DevInst = deviceInfo->dnDevInst; - DeviceInfoData->Reserved = (ULONG_PTR)deviceInfo; + copy_device_data(DeviceInfoData, deviceInfo); ret = TRUE; } } @@ -1849,9 +1854,7 @@ BOOL WINAPI SetupDiEnumDeviceInfo( else { struct DeviceInfo *DevInfo = CONTAINING_RECORD(ItemList, struct DeviceInfo, ListEntry); - info->ClassGuid = DevInfo->ClassGuid; - info->DevInst = DevInfo->dnDevInst; - info->Reserved = (ULONG_PTR)DevInfo; + copy_device_data(info, DevInfo); ret = TRUE; } } @@ -3109,11 +3112,7 @@ BOOL WINAPI SetupDiGetDeviceInterfaceDetailW( strcpyW(DeviceInterfaceDetailData->DevicePath, devName); TRACE("DevicePath is %s\n", debugstr_w(DeviceInterfaceDetailData->DevicePath)); if (DeviceInfoData) - { - DeviceInfoData->ClassGuid = deviceInterface->DeviceInfo->ClassGuid; - DeviceInfoData->DevInst = deviceInterface->DeviceInfo->dnDevInst; - DeviceInfoData->Reserved = (ULONG_PTR)deviceInterface->DeviceInfo; - } + copy_device_data(DeviceInfoData, deviceInterface->DeviceInfo); ret = TRUE; } } @@ -4934,11 +4933,7 @@ SetupDiOpenDeviceInfoW( } if (ret && deviceInfo && DeviceInfoData) - { - DeviceInfoData->ClassGuid = deviceInfo->ClassGuid; - DeviceInfoData->DevInst = deviceInfo->dnDevInst; - DeviceInfoData->Reserved = (ULONG_PTR)deviceInfo; - } + copy_device_data(DeviceInfoData, deviceInfo); } cleanup: @@ -4973,9 +4968,7 @@ SetupDiGetSelectedDevice( SetLastError(ERROR_INVALID_USER_BUFFER); else { - DeviceInfoData->ClassGuid = list->SelectedDevice->ClassGuid; - DeviceInfoData->DevInst = list->SelectedDevice->dnDevInst; - DeviceInfoData->Reserved = (ULONG_PTR)list->SelectedDevice; + copy_device_data(DeviceInfoData, list->SelectedDevice); ret = TRUE; } diff --git a/sdk/tools/winesync/setupapi.cfg b/sdk/tools/winesync/setupapi.cfg index 818d84cd7e9..cc4d6dde57a 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: 5d7b123d094ba2de40237f310ec43f4b06b560a3 + wine: 11d09c299e5df47cadda7473d03a49244c846634