From b667d82f0bd7a0be6c0e4ece3dd77f530976bee8 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Mon, 9 Dec 2024 21:53:08 +0100 Subject: [PATCH] [SETUPAPI] Implement CM_Set_Class_Registry_PropertyA() --- dll/win32/setupapi/cfgmgr.c | 71 +++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/dll/win32/setupapi/cfgmgr.c b/dll/win32/setupapi/cfgmgr.c index ffef4d5590c..bfd1da4a5f7 100644 --- a/dll/win32/setupapi/cfgmgr.c +++ b/dll/win32/setupapi/cfgmgr.c @@ -7843,10 +7843,77 @@ CM_Set_Class_Registry_PropertyA( _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine) { - FIXME("CM_Set_Class_Registry_PropertyA(%p %lx %p %lu %lx %p)\n", + LPWSTR lpBuffer; + ULONG ulType; + CONFIGRET ret; + + TRACE("CM_Set_Class_Registry_PropertyA(%p %lx %p %lu %lx %p)\n", ClassGuid, ulProperty, Buffer, ulLength, ulFlags, hMachine); - return CR_CALL_NOT_IMPLEMENTED; + if (ClassGuid == NULL) + return CR_INVALID_POINTER; + + if ((Buffer == NULL) && (ulLength != 0)) + return CR_INVALID_POINTER; + + if (ulFlags != 0) + return CR_INVALID_FLAG; + + if (Buffer == NULL) + { + ret = CM_Set_Class_Registry_PropertyW(ClassGuid, + ulProperty, + Buffer, + ulLength, + ulFlags, + hMachine); + } + else + { + /* Get property type */ + ulType = GetRegistryPropertyType(ulProperty); + + /* Allocate buffer if needed */ + if ((ulType == REG_SZ) || (ulType == REG_MULTI_SZ)) + { + lpBuffer = MyMalloc(ulLength * sizeof(WCHAR)); + if (lpBuffer == NULL) + { + ret = CR_OUT_OF_MEMORY; + } + else + { + if (!MultiByteToWideChar(CP_ACP, 0, Buffer, + ulLength, lpBuffer, ulLength)) + { + MyFree(lpBuffer); + ret = CR_FAILURE; + } + else + { + ret = CM_Set_Class_Registry_PropertyW(ClassGuid, + ulProperty, + lpBuffer, + ulLength * sizeof(WCHAR), + ulFlags, + hMachine); + MyFree(lpBuffer); + } + } + } + else + { + ret = CM_Set_Class_Registry_PropertyW(ClassGuid, + ulProperty, + Buffer, + ulLength, + ulFlags, + hMachine); + } + + } + + return ret; }