https://git.reactos.org/?p=reactos.git;a=commitdiff;h=44564cb6828ba6e8549d211f06f5848005c3b0b5

commit 44564cb6828ba6e8549d211f06f5848005c3b0b5
Author:     Eric Kohl <[email protected]>
AuthorDate: Sun Dec 15 15:54:35 2024 +0100
Commit:     Eric Kohl <[email protected]>
CommitDate: Sun Dec 15 15:54:35 2024 +0100

    [SETUPAPI] Implement SetupDiGetClassRegistryPropertyW and 
SetupDiSetClassRegistryPropertyW
---
 dll/win32/setupapi/devclass.c    | 160 +++++++++++++++++++++++++++++++++++++++
 dll/win32/setupapi/setupapi.spec |   4 +-
 2 files changed, 162 insertions(+), 2 deletions(-)

diff --git a/dll/win32/setupapi/devclass.c b/dll/win32/setupapi/devclass.c
index b8f78401598..ff3d7d9c070 100644
--- a/dll/win32/setupapi/devclass.c
+++ b/dll/win32/setupapi/devclass.c
@@ -1419,3 +1419,163 @@ cleanup:
     TRACE("Returning %d\n", ret);
     return ret;
 }
+
+/***********************************************************************
+ *             SetupDiGetClassRegistryPropertyW(SETUPAPI.@)
+ */
+BOOL WINAPI
+SetupDiGetClassRegistryPropertyW(
+    IN CONST GUID *ClassGuid,
+    IN DWORD Property,
+    OUT PDWORD PropertyRegDataType OPTIONAL,
+    OUT PBYTE PropertyBuffer,
+    IN  DWORD PropertyBufferSize,
+    OUT PDWORD RequiredSize OPTIONAL,
+    IN PCWSTR 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, debugstr_w(MachineName), Reserved);
+
+    if (Reserved != NULL)
+    {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+
+    if (MachineName)
+    {
+        cr = CM_Connect_Machine(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_PropertyW((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);
+}
+
+/***********************************************************************
+ *             SetupDiSetClassRegistryPropertyW(SETUPAPI.@)
+ */
+BOOL WINAPI
+SetupDiSetClassRegistryPropertyW(
+    IN CONST GUID *ClassGuid,
+    IN DWORD Property,
+    IN CONST BYTE *PropertyBuffer OPTIONAL,
+    IN DWORD PropertyBufferSize,
+    IN PCWSTR 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, debugstr_w(MachineName), Reserved);
+
+    if (Reserved != NULL)
+    {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+
+    if (MachineName)
+    {
+        cr = CM_Connect_Machine(MachineName, &hMachine);
+        if (cr != CR_SUCCESS)
+           goto done;
+    }
+
+    if (Property >= SPCRP_MAXIMUM_PROPERTY)
+    {
+        cr = CR_INVALID_PROPERTY;
+        goto done;
+    }
+
+    cr = CM_Set_Class_Registry_PropertyW((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);
+}
diff --git a/dll/win32/setupapi/setupapi.spec b/dll/win32/setupapi/setupapi.spec
index cc849483b99..7a42afad98c 100644
--- a/dll/win32/setupapi/setupapi.spec
+++ b/dll/win32/setupapi/setupapi.spec
@@ -314,7 +314,7 @@
 @ stdcall SetupDiGetClassInstallParamsA(ptr ptr ptr long ptr)
 @ stdcall SetupDiGetClassInstallParamsW(ptr ptr ptr long ptr)
 @ stub SetupDiGetClassRegistryPropertyA
-@ stub SetupDiGetClassRegistryPropertyW
+@ stdcall SetupDiGetClassRegistryPropertyW(ptr long ptr ptr long ptr wstr ptr)
 @ stub SetupDiGetCustomDevicePropertyA
 @ stub SetupDiGetCustomDevicePropertyW
 @ stdcall SetupDiGetDeviceInfoListClass(ptr ptr)
@@ -375,7 +375,7 @@
 @ stdcall SetupDiSetClassInstallParamsA(ptr ptr ptr long)
 @ stdcall SetupDiSetClassInstallParamsW(ptr ptr ptr long)
 @ stub SetupDiSetClassRegistryPropertyA
-@ stub SetupDiSetClassRegistryPropertyW
+@ stdcall SetupDiSetClassRegistryPropertyW(ptr long ptr long wstr ptr)
 @ stdcall SetupDiSetDeviceInstallParamsA(ptr ptr ptr)
 @ stdcall SetupDiSetDeviceInstallParamsW(ptr ptr ptr)
 @ stub SetupDiSetDeviceInterfaceDefault

Reply via email to