- CFGMGR32.DLL: Forward implemented functions to SETUPAPI.DLL.
- SETUPAPI.DLL: Use PNP_EnumerateSubKeys to implement CM_Enumerate_Classes_Ex.
Modified: trunk/reactos/lib/cfgmgr32/cfgmgr32.def
Modified: trunk/reactos/lib/setupapi/cfgmgr.c

Modified: trunk/reactos/lib/cfgmgr32/cfgmgr32.def
--- trunk/reactos/lib/cfgmgr32/cfgmgr32.def	2005-09-11 13:55:23 UTC (rev 17800)
+++ trunk/reactos/lib/cfgmgr32/cfgmgr32.def	2005-09-11 14:38:57 UTC (rev 17801)
@@ -41,8 +41,8 @@
 ;CM_Create_DevNode_ExA
 ;CM_Create_DevNode_ExW
 ;CM_Create_Range_List
-;CM_Delete_Class_Key
-;CM_Delete_Class_Key_Ex
+CM_Delete_Class_Key@8=SETUPAPI.CM_Delete_Class_Key
+CM_Delete_Class_Key_Ex@12=SETUPAPI.CM_Delete_Class_Key_Ex
 ;CM_Delete_DevNode_Key
 ;CM_Delete_DevNode_Key_Ex
 ;CM_Delete_Range
@@ -56,10 +56,10 @@
 ;CM_Enable_DevNode_Ex
 CM_Enumerate_Classes@12=SETUPAPI.CM_Enumerate_Classes
 CM_Enumerate_Classes_Ex@16=SETUPAPI.CM_Enumerate_Classes_Ex
-;CM_Enumerate_EnumeratorsA
-;CM_Enumerate_EnumeratorsW
-;CM_Enumerate_Enumerators_ExA
-;CM_Enumerate_Enumerators_ExW
+CM_Enumerate_EnumeratorsA@16=SETUPAPI.CM_Enumerate_EnumeratorsA
+CM_Enumerate_EnumeratorsW@16=SETUPAPI.CM_Enumerate_EnumeratorsW
+CM_Enumerate_Enumerators_ExA@20=SETUPAPI.CM_Enumerate_Enumerators_ExA
+CM_Enumerate_Enumerators_ExW@20=SETUPAPI.CM_Enumerate_Enumerators_ExW
 ;CM_Find_Range
 ;CM_First_Range
 ;CM_Free_Log_Conf
@@ -71,14 +71,14 @@
 ;CM_Free_Res_Des_Handle
 CM_Get_Child@12=SETUPAPI.CM_Get_Child
 CM_Get_Child_Ex@16=SETUPAPI.CM_Get_ChildEx
-;CM_Get_Class_Key_NameA
-;CM_Get_Class_Key_NameW
-;CM_Get_Class_Key_Name_ExA
-;CM_Get_Class_Key_Name_ExW
-;CM_Get_Class_NameA
-;CM_Get_Class_NameW
-;CM_Get_Class_Name_ExA
-;CM_Get_Class_Name_ExW
+CM_Get_Class_Key_NameA@16=SETUPAPI.CM_Get_Class_Key_NameA
+CM_Get_Class_Key_NameW@16=SETUPAPI.CM_Get_Class_Key_NameW
+CM_Get_Class_Key_Name_ExA@20=SETUPAPI.CM_Get_Class_Key_Name_ExA
+CM_Get_Class_Key_Name_ExW@20=SETUPAPI.CM_Get_Class_Key_Name_ExW
+CM_Get_Class_NameA@16=SETUPAPI.CM_Get_Class_NameA
+CM_Get_Class_NameW@16=SETUPAPI.CM_Get_Class_NameW
+CM_Get_Class_Name_ExA@20=SETUPAPI.CM_Get_Class_Name_ExA
+CM_Get_Class_Name_ExW@20=SETUPAPI.CM_Get_Class_Name_ExW
 CM_Get_Depth@12=SETUPAPI.CM_Get_Depth
 CM_Get_Depth_Ex@16=SETUPAPI.CM_Get_Depth_Ex
 CM_Get_DevNode_Registry_PropertyA@24=SETUPAPI.CM_Get_DevNode_Registry_PropertyA
@@ -186,12 +186,12 @@
 ;CM_Reset_Children_Marks_Ex
 ;CM_Run_Detection
 ;CM_Run_Detection_Ex
-;CM_Set_DevNode_Problem
-;CM_Set_DevNode_Problem_Ex
-;CM_Set_DevNode_Registry_PropertyA
-;CM_Set_DevNode_Registry_PropertyW
-;CM_Set_DevNode_Registry_Property_ExA
-;CM_Set_DevNode_Registry_Property_ExW
+CM_Set_DevNode_Problem@12=SETUPAPI.CM_Set_DevNode_Problem
+CM_Set_DevNode_Problem_Ex@16=SETUPAPI.CM_Set_DevNode_Problem_Ex
+CM_Set_DevNode_Registry_PropertyA@20=SETUPAPI.CM_Set_DevNode_Registry_PropertyA
+CM_Set_DevNode_Registry_PropertyW@20=SETUPAPI.CM_Set_DevNode_Registry_PropertyW
+CM_Set_DevNode_Registry_Property_ExA@24=SETUPAPI.CM_Set_DevNode_Registry_Property_ExA
+CM_Set_DevNode_Registry_Property_ExW@24=SETUPAPI.CM_Set_DevNode_Registry_Property_ExW
 ;CM_Set_HW_Prof
 ;CM_Set_HW_Prof_Ex
 ;CM_Set_HW_Prof_FlagsA

Modified: trunk/reactos/lib/setupapi/cfgmgr.c
--- trunk/reactos/lib/setupapi/cfgmgr.c	2005-09-11 13:55:23 UTC (rev 17800)
+++ trunk/reactos/lib/setupapi/cfgmgr.c	2005-09-11 14:38:57 UTC (rev 17801)
@@ -226,46 +226,16 @@
 }
 
 
-static CONFIGRET GetCmCodeFromErrorCode(DWORD ErrorCode)
-{
-    switch (ErrorCode)
-    {
-        case ERROR_SUCCESS:
-            return CR_SUCCESS;
-
-        case ERROR_ACCESS_DENIED:
-            return CR_ACCESS_DENIED;
-
-        case ERROR_INSUFFICIENT_BUFFER:
-            return CR_BUFFER_SMALL;
-
-        case ERROR_INVALID_DATA:
-            return CR_INVALID_DATA;
-
-        case ERROR_INVALID_PARAMETER:
-            return CR_INVALID_DATA;
-
-        case ERROR_NO_MORE_ITEMS:
-            return CR_NO_SUCH_VALUE;
-
-        case ERROR_NO_SYSTEM_RESOURCES:
-            return CR_OUT_OF_MEMORY;
-
-        default:
-            return CR_FAILURE;
-    }
-}
-
-
 /***********************************************************************
  * CM_Enumerate_Classes_Ex [SETUPAPI.@]
  */
 CONFIGRET WINAPI CM_Enumerate_Classes_Ex(
     ULONG ulClassIndex, LPGUID ClassGuid, ULONG ulFlags, HMACHINE hMachine)
 {
-    HKEY hRelativeKey, hKey;
-    DWORD rc;
-    WCHAR Buffer[MAX_GUID_STRING_LEN];
+    WCHAR szBuffer[MAX_GUID_STRING_LEN];
+    RPC_BINDING_HANDLE BindingHandle = NULL;
+    CONFIGRET ret = CR_SUCCESS;
+    ULONG ulLength = MAX_GUID_STRING_LEN;
 
     TRACE("%lx %p %lx %p\n", ulClassIndex, ClassGuid, ulFlags, hMachine);
 
@@ -277,39 +247,34 @@
 
     if (hMachine != NULL)
     {
-        FIXME("hMachine argument ignored\n");
-        hRelativeKey = HKEY_LOCAL_MACHINE; /* FIXME: use here a field in hMachine */
+        BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
+        if (BindingHandle == NULL)
+            return CR_FAILURE;
     }
     else
-        hRelativeKey = HKEY_LOCAL_MACHINE;
+    {
+        if (!PnpGetLocalHandles(&BindingHandle, NULL))
+            return CR_FAILURE;
+    }
 
-    rc = RegOpenKeyExW(
-        hRelativeKey,
-        ControlClass,
-        0, /* options */
-        KEY_ENUMERATE_SUB_KEYS,
-        &hKey);
-    if (rc != ERROR_SUCCESS)
-        return GetCmCodeFromErrorCode(rc);
-
-    rc = RegEnumKeyW(
-        hKey,
-        ulClassIndex,
-        Buffer,
-        sizeof(Buffer) / sizeof(WCHAR));
-
-    RegCloseKey(hKey);
-
-    if (rc == ERROR_SUCCESS)
+    ret = PNP_EnumerateSubKeys(BindingHandle,
+                               PNP_BRANCH_CLASS,
+                               ulClassIndex,
+                               szBuffer,
+                               MAX_GUID_STRING_LEN,
+                               &ulLength,
+                               ulFlags);
+    if (ret == CR_SUCCESS)
     {
         /* Remove the {} */
-        Buffer[MAX_GUID_STRING_LEN - 2] = UNICODE_NULL;
+        szBuffer[MAX_GUID_STRING_LEN - 2] = UNICODE_NULL;
+
         /* Convert the buffer to a GUID */
-        if (UuidFromStringW(&Buffer[1], ClassGuid) != RPC_S_OK)
+        if (UuidFromStringW(&szBuffer[1], ClassGuid) != RPC_S_OK)
             return CR_FAILURE;
     }
 
-    return GetCmCodeFromErrorCode(rc);
+    return ret;
 }