From 85e90601e05bafc7fa709691cc6bf2e90ef03a6a Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sat, 21 Dec 2024 10:35:53 +0100 Subject: [PATCH] [SETUPAPI] Implement SetupDiGetCustomDevicePropertyA --- dll/win32/setupapi/devinst.c | 80 ++++++++++++++++++++++++++++++++ dll/win32/setupapi/setupapi.spec | 2 +- 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/dll/win32/setupapi/devinst.c b/dll/win32/setupapi/devinst.c index 53e99ba5d29..9dbabb48a32 100644 --- a/dll/win32/setupapi/devinst.c +++ b/dll/win32/setupapi/devinst.c @@ -6151,6 +6151,86 @@ SetupDiRestartDevices( return TRUE; } +/*********************************************************************** + * SetupDiGetCustomDevicePropertyA (SETUPAPI.@) + */ +BOOL +WINAPI +SetupDiGetCustomDevicePropertyA( + IN HDEVINFO DeviceInfoSet, + IN PSP_DEVINFO_DATA DeviceInfoData, + IN PCSTR CustomPropertyName, + IN DWORD Flags, + OUT PDWORD PropertyRegDataType OPTIONAL, + OUT PBYTE PropertyBuffer, + IN DWORD PropertyBufferSize, + OUT PDWORD RequiredSize OPTIONAL) +{ + struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet; + struct DeviceInfo *deviceInfo; + DWORD ConfigFlags = 0, PropertySize; + CONFIGRET cr; + + TRACE("%s(%p %p %s 0x%lx %p %p %lu %p)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData, + CustomPropertyName, Flags, PropertyRegDataType, PropertyBuffer, PropertyBufferSize, RequiredSize); + + if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (!DeviceInfoData || DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA) + || !DeviceInfoData->Reserved) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + if (Flags & ~DICUSTOMDEVPROP_MERGE_MULTISZ) + { + SetLastError(ERROR_INVALID_FLAGS); + return FALSE; + } + + deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved; + if (deviceInfo->set != set) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + if (Flags & DICUSTOMDEVPROP_MERGE_MULTISZ) + { + ConfigFlags |= CM_CUSTOMDEVPROP_MERGE_MULTISZ; + } + + PropertySize = PropertyBufferSize; + cr = CM_Get_DevInst_Custom_Property_ExA(deviceInfo->dnDevInst, + CustomPropertyName, + PropertyRegDataType, + PropertyBuffer, + &PropertySize, + ConfigFlags, + set->hMachine); + if ((cr == CR_SUCCESS) || (cr == CR_BUFFER_SMALL)) + { + if (RequiredSize) + *RequiredSize = PropertySize; + } + + if (cr != CR_SUCCESS) + { + SetLastError(GetErrorCodeFromCrCode(cr)); + return FALSE; + } + + return TRUE; +} + /*********************************************************************** * SetupDiGetCustomDevicePropertyW (SETUPAPI.@) */ diff --git a/dll/win32/setupapi/setupapi.spec b/dll/win32/setupapi/setupapi.spec index 3a15bffab48..c5d56635107 100644 --- a/dll/win32/setupapi/setupapi.spec +++ b/dll/win32/setupapi/setupapi.spec @@ -315,7 +315,7 @@ @ stdcall SetupDiGetClassInstallParamsW(ptr ptr ptr long ptr) @ stdcall SetupDiGetClassRegistryPropertyA(ptr long ptr ptr long ptr str ptr) @ stdcall SetupDiGetClassRegistryPropertyW(ptr long ptr ptr long ptr wstr ptr) -@ stub SetupDiGetCustomDevicePropertyA +@ stdcall SetupDiGetCustomDevicePropertyA(ptr ptr str long ptr ptr long ptr) @ stdcall SetupDiGetCustomDevicePropertyW(ptr ptr wstr long ptr ptr long ptr) @ stdcall SetupDiGetDeviceInfoListClass(ptr ptr) @ stdcall SetupDiGetDeviceInfoListDetailA(ptr ptr)