diff --git a/dll/win32/setupapi/devclass.c b/dll/win32/setupapi/devclass.c index ff3d7d9c070..c3bc47adb7c 100644 --- a/dll/win32/setupapi/devclass.c +++ b/dll/win32/setupapi/devclass.c @@ -1420,6 +1420,91 @@ cleanup: 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.@) */ @@ -1451,7 +1536,7 @@ SetupDiGetClassRegistryPropertyW( if (MachineName) { - cr = CM_Connect_Machine(MachineName, &hMachine); + cr = CM_Connect_MachineW(MachineName, &hMachine); if (cr != CR_SUCCESS) goto done; } @@ -1505,6 +1590,81 @@ done: 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.@) */ @@ -1533,7 +1693,7 @@ SetupDiSetClassRegistryPropertyW( if (MachineName) { - cr = CM_Connect_Machine(MachineName, &hMachine); + cr = CM_Connect_MachineW(MachineName, &hMachine); if (cr != CR_SUCCESS) goto done; } diff --git a/dll/win32/setupapi/setupapi.spec b/dll/win32/setupapi/setupapi.spec index 7a42afad98c..1c86bb655ac 100644 --- a/dll/win32/setupapi/setupapi.spec +++ b/dll/win32/setupapi/setupapi.spec @@ -313,7 +313,7 @@ @ stdcall SetupDiGetClassImageListExW(ptr wstr ptr) @ stdcall SetupDiGetClassInstallParamsA(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) @ stub SetupDiGetCustomDevicePropertyA @ stub SetupDiGetCustomDevicePropertyW @@ -374,7 +374,7 @@ @ stub SetupDiSelectOEMDrv @ stdcall SetupDiSetClassInstallParamsA(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 SetupDiSetDeviceInstallParamsA(ptr ptr ptr) @ stdcall SetupDiSetDeviceInstallParamsW(ptr ptr ptr)