Skip to content

Commit

Permalink
[SETUPAPI][PSDK] Implement SetupDiGetCustomDevicePropertyW
Browse files Browse the repository at this point in the history
  • Loading branch information
EricKohl committed Dec 18, 2024
1 parent 1e06829 commit d44ed03
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 1 deletion.
80 changes: 80 additions & 0 deletions dll/win32/setupapi/devinst.c
Original file line number Diff line number Diff line change
Expand Up @@ -6150,3 +6150,83 @@ SetupDiRestartDevices(

return TRUE;
}

/***********************************************************************
* SetupDiGetCustomDevicePropertyW (SETUPAPI.@)
*/
BOOL
WINAPI
SetupDiGetCustomDevicePropertyW(
IN HDEVINFO DeviceInfoSet,
IN PSP_DEVINFO_DATA DeviceInfoData,
IN PCWSTR 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,
debugstr_w(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_ExW(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;
}
2 changes: 1 addition & 1 deletion dll/win32/setupapi/setupapi.spec
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
@ stdcall SetupDiGetClassRegistryPropertyA(ptr long ptr ptr long ptr str ptr)
@ stdcall SetupDiGetClassRegistryPropertyW(ptr long ptr ptr long ptr wstr ptr)
@ stub SetupDiGetCustomDevicePropertyA
@ stub SetupDiGetCustomDevicePropertyW
@ stdcall SetupDiGetCustomDevicePropertyW(ptr ptr wstr long ptr ptr long ptr)
@ stdcall SetupDiGetDeviceInfoListClass(ptr ptr)
@ stdcall SetupDiGetDeviceInfoListDetailA(ptr ptr)
@ stdcall SetupDiGetDeviceInfoListDetailW(ptr ptr)
Expand Down
1 change: 1 addition & 0 deletions sdk/include/psdk/setupapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ extern "C" {
#define DICS_START 4
#define DICS_FLAG_CONFIGGENERAL 4
#define DICS_STOP 5
#define DICUSTOMDEVPROP_MERGE_MULTISZ 0x00000001
#define DIF_SELECTDEVICE 1
#define DIF_INSTALLDEVICE 2
#define DIF_ASSIGNRESOURCES 3
Expand Down

0 comments on commit d44ed03

Please sign in to comment.