[SETUPAPI] Implement SetupDiGetClassRegistryPropertyA and SetupDiSetClassRegistryPropertyA

This commit is contained in:
Eric Kohl 2024-12-16 23:19:31 +01:00
parent f3dd15ad64
commit c10c5224ff
2 changed files with 164 additions and 4 deletions

View file

@ -1420,6 +1420,91 @@ cleanup:
return ret; return ret;
} }
/***********************************************************************
* SetupDiGetClassRegistryPropertyA(SETUPAPI.@)
*/
BOOL WINAPI
SetupDiGetClassRegistryPropertyA(
IN CONST GUID *ClassGuid,
IN DWORD Property,
OUT PDWORD PropertyRegDataType OPTIONAL,
OUT PBYTE PropertyBuffer,
IN DWORD PropertyBufferSize,
OUT PDWORD RequiredSize OPTIONAL,
IN PCSTR MachineName OPTIONAL,
IN PVOID Reserved)
{
HMACHINE hMachine = NULL;
DWORD PropLength = 0;
DWORD Error = ERROR_SUCCESS;
CONFIGRET cr;
TRACE("%s %lu %p %p %lu %p %s %p\n",
debugstr_guid(ClassGuid), Property, PropertyRegDataType, PropertyBuffer,
PropertyBufferSize, RequiredSize, MachineName, Reserved);
if (Reserved != NULL)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if (MachineName)
{
cr = CM_Connect_MachineA(MachineName, &hMachine);
if (cr != CR_SUCCESS)
goto done;
}
if (Property >= SPCRP_MAXIMUM_PROPERTY)
{
cr = CR_INVALID_PROPERTY;
goto done;
}
PropLength = PropertyBufferSize;
cr = CM_Get_Class_Registry_PropertyA((LPGUID)ClassGuid,
Property + (CM_DRP_DEVICEDESC - SPDRP_DEVICEDESC),
PropertyRegDataType,
PropertyBuffer,
&PropLength,
0,
hMachine);
if ((cr == CR_SUCCESS) || (cr == CR_BUFFER_SMALL))
{
if (RequiredSize)
*RequiredSize = PropLength;
}
done:
if (cr != CR_SUCCESS)
{
switch (cr)
{
case CR_INVALID_DEVINST :
Error = ERROR_NO_SUCH_DEVINST;
break;
case CR_INVALID_PROPERTY :
Error = ERROR_INVALID_REG_PROPERTY;
break;
case CR_BUFFER_SMALL :
Error = ERROR_INSUFFICIENT_BUFFER;
break;
default :
Error = GetErrorCodeFromCrCode(cr);
}
}
if (hMachine != NULL)
CM_Disconnect_Machine(hMachine);
SetLastError(Error);
return (cr == CR_SUCCESS);
}
/*********************************************************************** /***********************************************************************
* SetupDiGetClassRegistryPropertyW(SETUPAPI.@) * SetupDiGetClassRegistryPropertyW(SETUPAPI.@)
*/ */
@ -1451,7 +1536,7 @@ SetupDiGetClassRegistryPropertyW(
if (MachineName) if (MachineName)
{ {
cr = CM_Connect_Machine(MachineName, &hMachine); cr = CM_Connect_MachineW(MachineName, &hMachine);
if (cr != CR_SUCCESS) if (cr != CR_SUCCESS)
goto done; goto done;
} }
@ -1505,6 +1590,81 @@ done:
return (cr == CR_SUCCESS); return (cr == CR_SUCCESS);
} }
/***********************************************************************
* SetupDiSetClassRegistryPropertyA(SETUPAPI.@)
*/
BOOL WINAPI
SetupDiSetClassRegistryPropertyA(
IN CONST GUID *ClassGuid,
IN DWORD Property,
IN CONST BYTE *PropertyBuffer OPTIONAL,
IN DWORD PropertyBufferSize,
IN PCSTR MachineName OPTIONAL,
IN PVOID Reserved)
{
HMACHINE hMachine = NULL;
DWORD Error = ERROR_SUCCESS;
CONFIGRET cr;
TRACE("%s %lu %p %lu %s %p\n",
debugstr_guid(ClassGuid), Property, PropertyBuffer,
PropertyBufferSize, MachineName, Reserved);
if (Reserved != NULL)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if (MachineName)
{
cr = CM_Connect_MachineA(MachineName, &hMachine);
if (cr != CR_SUCCESS)
goto done;
}
if (Property >= SPCRP_MAXIMUM_PROPERTY)
{
cr = CR_INVALID_PROPERTY;
goto done;
}
cr = CM_Set_Class_Registry_PropertyA((LPGUID)ClassGuid,
Property + (CM_DRP_DEVICEDESC - SPDRP_DEVICEDESC),
PropertyBuffer,
PropertyBufferSize,
0,
hMachine);
done:
if (cr != CR_SUCCESS)
{
switch (cr)
{
case CR_INVALID_DEVINST:
Error = ERROR_NO_SUCH_DEVINST;
break;
case CR_INVALID_PROPERTY:
Error = ERROR_INVALID_REG_PROPERTY;
break;
case CR_BUFFER_SMALL:
Error = ERROR_INSUFFICIENT_BUFFER;
break;
default :
Error = GetErrorCodeFromCrCode(cr);
}
}
if (hMachine != NULL)
CM_Disconnect_Machine(hMachine);
SetLastError(Error);
return (cr == CR_SUCCESS);
}
/*********************************************************************** /***********************************************************************
* SetupDiSetClassRegistryPropertyW(SETUPAPI.@) * SetupDiSetClassRegistryPropertyW(SETUPAPI.@)
*/ */
@ -1533,7 +1693,7 @@ SetupDiSetClassRegistryPropertyW(
if (MachineName) if (MachineName)
{ {
cr = CM_Connect_Machine(MachineName, &hMachine); cr = CM_Connect_MachineW(MachineName, &hMachine);
if (cr != CR_SUCCESS) if (cr != CR_SUCCESS)
goto done; goto done;
} }

View file

@ -313,7 +313,7 @@
@ stdcall SetupDiGetClassImageListExW(ptr wstr ptr) @ stdcall SetupDiGetClassImageListExW(ptr wstr ptr)
@ stdcall SetupDiGetClassInstallParamsA(ptr ptr ptr long ptr) @ stdcall SetupDiGetClassInstallParamsA(ptr ptr ptr long ptr)
@ stdcall SetupDiGetClassInstallParamsW(ptr ptr ptr long ptr) @ stdcall SetupDiGetClassInstallParamsW(ptr ptr ptr long ptr)
@ stub SetupDiGetClassRegistryPropertyA @ stdcall SetupDiGetClassRegistryPropertyA(ptr long ptr ptr long ptr str ptr)
@ stdcall SetupDiGetClassRegistryPropertyW(ptr long ptr ptr long ptr wstr ptr) @ stdcall SetupDiGetClassRegistryPropertyW(ptr long ptr ptr long ptr wstr ptr)
@ stub SetupDiGetCustomDevicePropertyA @ stub SetupDiGetCustomDevicePropertyA
@ stub SetupDiGetCustomDevicePropertyW @ stub SetupDiGetCustomDevicePropertyW
@ -374,7 +374,7 @@
@ stub SetupDiSelectOEMDrv @ stub SetupDiSelectOEMDrv
@ stdcall SetupDiSetClassInstallParamsA(ptr ptr ptr long) @ stdcall SetupDiSetClassInstallParamsA(ptr ptr ptr long)
@ stdcall SetupDiSetClassInstallParamsW(ptr ptr ptr long) @ stdcall SetupDiSetClassInstallParamsW(ptr ptr ptr long)
@ stub SetupDiSetClassRegistryPropertyA @ stdcall SetupDiSetClassRegistryPropertyA(ptr long ptr long str ptr)
@ stdcall SetupDiSetClassRegistryPropertyW(ptr long ptr long wstr ptr) @ stdcall SetupDiSetClassRegistryPropertyW(ptr long ptr long wstr ptr)
@ stdcall SetupDiSetDeviceInstallParamsA(ptr ptr ptr) @ stdcall SetupDiSetDeviceInstallParamsA(ptr ptr ptr)
@ stdcall SetupDiSetDeviceInstallParamsW(ptr ptr ptr) @ stdcall SetupDiSetDeviceInstallParamsW(ptr ptr ptr)