Skip to content

Commit d44ed03

Browse files
committed
[SETUPAPI][PSDK] Implement SetupDiGetCustomDevicePropertyW
1 parent 1e06829 commit d44ed03

File tree

3 files changed

+82
-1
lines changed

3 files changed

+82
-1
lines changed

dll/win32/setupapi/devinst.c

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6150,3 +6150,83 @@ SetupDiRestartDevices(
61506150

61516151
return TRUE;
61526152
}
6153+
6154+
/***********************************************************************
6155+
* SetupDiGetCustomDevicePropertyW (SETUPAPI.@)
6156+
*/
6157+
BOOL
6158+
WINAPI
6159+
SetupDiGetCustomDevicePropertyW(
6160+
IN HDEVINFO DeviceInfoSet,
6161+
IN PSP_DEVINFO_DATA DeviceInfoData,
6162+
IN PCWSTR CustomPropertyName,
6163+
IN DWORD Flags,
6164+
OUT PDWORD PropertyRegDataType OPTIONAL,
6165+
OUT PBYTE PropertyBuffer,
6166+
IN DWORD PropertyBufferSize,
6167+
OUT PDWORD RequiredSize OPTIONAL)
6168+
{
6169+
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
6170+
struct DeviceInfo *deviceInfo;
6171+
DWORD ConfigFlags = 0, PropertySize;
6172+
CONFIGRET cr;
6173+
6174+
TRACE("%s(%p %p %s 0x%lx %p %p %lu %p)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData,
6175+
debugstr_w(CustomPropertyName), Flags, PropertyRegDataType, PropertyBuffer, PropertyBufferSize, RequiredSize);
6176+
6177+
if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
6178+
{
6179+
SetLastError(ERROR_INVALID_HANDLE);
6180+
return FALSE;
6181+
}
6182+
if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
6183+
{
6184+
SetLastError(ERROR_INVALID_HANDLE);
6185+
return FALSE;
6186+
}
6187+
if (!DeviceInfoData || DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA)
6188+
|| !DeviceInfoData->Reserved)
6189+
{
6190+
SetLastError(ERROR_INVALID_PARAMETER);
6191+
return FALSE;
6192+
}
6193+
if (Flags & ~DICUSTOMDEVPROP_MERGE_MULTISZ)
6194+
{
6195+
SetLastError(ERROR_INVALID_FLAGS);
6196+
return FALSE;
6197+
}
6198+
6199+
deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
6200+
if (deviceInfo->set != set)
6201+
{
6202+
SetLastError(ERROR_INVALID_PARAMETER);
6203+
return FALSE;
6204+
}
6205+
6206+
if (Flags & DICUSTOMDEVPROP_MERGE_MULTISZ)
6207+
{
6208+
ConfigFlags |= CM_CUSTOMDEVPROP_MERGE_MULTISZ;
6209+
}
6210+
6211+
PropertySize = PropertyBufferSize;
6212+
cr = CM_Get_DevInst_Custom_Property_ExW(deviceInfo->dnDevInst,
6213+
CustomPropertyName,
6214+
PropertyRegDataType,
6215+
PropertyBuffer,
6216+
&PropertySize,
6217+
ConfigFlags,
6218+
set->hMachine);
6219+
if ((cr == CR_SUCCESS) || (cr == CR_BUFFER_SMALL))
6220+
{
6221+
if (RequiredSize)
6222+
*RequiredSize = PropertySize;
6223+
}
6224+
6225+
if (cr != CR_SUCCESS)
6226+
{
6227+
SetLastError(GetErrorCodeFromCrCode(cr));
6228+
return FALSE;
6229+
}
6230+
6231+
return TRUE;
6232+
}

dll/win32/setupapi/setupapi.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@
316316
@ stdcall SetupDiGetClassRegistryPropertyA(ptr long ptr ptr long ptr str ptr)
317317
@ stdcall SetupDiGetClassRegistryPropertyW(ptr long ptr ptr long ptr wstr ptr)
318318
@ stub SetupDiGetCustomDevicePropertyA
319-
@ stub SetupDiGetCustomDevicePropertyW
319+
@ stdcall SetupDiGetCustomDevicePropertyW(ptr ptr wstr long ptr ptr long ptr)
320320
@ stdcall SetupDiGetDeviceInfoListClass(ptr ptr)
321321
@ stdcall SetupDiGetDeviceInfoListDetailA(ptr ptr)
322322
@ stdcall SetupDiGetDeviceInfoListDetailW(ptr ptr)

sdk/include/psdk/setupapi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ extern "C" {
117117
#define DICS_START 4
118118
#define DICS_FLAG_CONFIGGENERAL 4
119119
#define DICS_STOP 5
120+
#define DICUSTOMDEVPROP_MERGE_MULTISZ 0x00000001
120121
#define DIF_SELECTDEVICE 1
121122
#define DIF_INSTALLDEVICE 2
122123
#define DIF_ASSIGNRESOURCES 3

0 commit comments

Comments
 (0)