Fix GUID->String conversion.
Implement CM_Get_Class[_Ex]A/W.
Modified: trunk/reactos/include/wine/cfgmgr32.h
Modified: trunk/reactos/lib/setupapi/cfgmgr.c
Modified: trunk/reactos/lib/setupapi/setupapi.spec
Modified: trunk/reactos/w32api/include/ddk/cfgmgr32.h

Modified: trunk/reactos/include/wine/cfgmgr32.h
--- trunk/reactos/include/wine/cfgmgr32.h	2005-09-03 18:05:33 UTC (rev 17623)
+++ trunk/reactos/include/wine/cfgmgr32.h	2005-09-03 19:44:47 UTC (rev 17624)
@@ -139,6 +139,12 @@
 CONFIGRET WINAPI CM_Get_Class_Key_Name_ExA( LPGUID, LPSTR, PULONG, ULONG, HMACHINE );
 CONFIGRET WINAPI CM_Get_Class_Key_Name_ExW( LPGUID, LPWSTR, PULONG, ULONG, HMACHINE );
 #define     CM_Get_Class_Key_Name_Ex WINELIB_NAME_AW(CM_Get_Class_Key_Name_Ex)
+CONFIGRET WINAPI CM_Get_Class_NameA( LPGUID, PCHAR, PULONG, ULONG );
+CONFIGRET WINAPI CM_Get_Class_NameW( LPGUID, PWCHAR, PULONG, ULONG);
+#define     CM_Get_Class_Name WINELIB_NAME_AW(CM_Get_Class_Name)
+CONFIGRET WINAPI CM_Get_Class_Name_ExA( LPGUID, PCHAR, PULONG, ULONG, HMACHINE );
+CONFIGRET WINAPI CM_Get_Class_Name_ExW( LPGUID, PWCHAR, PULONG, ULONG, HMACHINE );
+#define     CM_Get_Class_Name_Ex WINELIB_NAME_AW(CM_Get_Class_Name_Ex)
 CONFIGRET WINAPI CM_Get_Depth( PULONG, DEVINST, ULONG );
 CONFIGRET WINAPI CM_Get_Depth_Ex( PULONG, DEVINST, ULONG, HMACHINE );
 CONFIGRET WINAPI CM_Get_DevNode_Registry_PropertyA( DEVINST, ULONG, PULONG, PVOID, PULONG, ULONG );

Modified: trunk/reactos/lib/setupapi/cfgmgr.c
--- trunk/reactos/lib/setupapi/cfgmgr.c	2005-09-03 18:05:33 UTC (rev 17623)
+++ trunk/reactos/lib/setupapi/cfgmgr.c	2005-09-03 19:44:47 UTC (rev 17624)
@@ -363,6 +363,21 @@
 }
 
 
+static BOOL GuidToString(LPGUID Guid, LPWSTR String)
+{
+    LPWSTR lpString;
+
+    if (UuidToStringW(Guid, &lpString) != RPC_S_OK)
+        return FALSE;
+
+    lstrcpyW(String, lpString);
+
+    RpcStringFree(&lpString);
+
+    return TRUE;
+}
+
+
 /***********************************************************************
  * CM_Get_Class_Key_Name_ExW [SETUPAPI.@]
  */
@@ -370,7 +385,7 @@
     LPGUID ClassGuid, LPWSTR pszKeyName, PULONG pulLength, ULONG ulFlags,
     HMACHINE hMachine)
 {
-    FIXME("%p %p %p %lx %lx\n",
+    TRACE("%p %p %p %lx %lx\n",
           ClassGuid, pszKeyName, pulLength, ulFlags, hMachine);
 
     if (ClassGuid == NULL || pszKeyName == NULL || pulLength == NULL)
@@ -385,7 +400,7 @@
         return CR_BUFFER_SMALL;
     }
 
-    if (UuidToStringW(ClassGuid, &pszKeyName) != RPC_S_OK)
+   if (!GuidToString(ClassGuid, pszKeyName))
         return CR_INVALID_DATA;
 
     *pulLength = MAX_GUID_STRING_LEN;
@@ -395,6 +410,88 @@
 
 
 /***********************************************************************
+ * CM_Get_Class_NameA [SETUPAPI.@]
+ */
+CONFIGRET WINAPI CM_Get_Class_NameA(
+    LPGUID ClassGuid, PCHAR Buffer, PULONG pulLength, ULONG ulFlags)
+{
+    TRACE("%p %p %p %lx\n", ClassGuid, Buffer, pulLength, ulFlags);
+    return CM_Get_Class_Name_ExA(ClassGuid, Buffer, pulLength, ulFlags,
+                                 NULL);
+}
+
+
+/***********************************************************************
+ * CM_Get_Class_NameW [SETUPAPI.@]
+ */
+CONFIGRET WINAPI CM_Get_Class_NameW(
+    LPGUID ClassGuid, PWCHAR Buffer, PULONG pulLength, ULONG ulFlags)
+{
+    TRACE("%p %p %p %lx\n", ClassGuid, Buffer, pulLength, ulFlags);
+    return CM_Get_Class_Name_ExW(ClassGuid, Buffer, pulLength, ulFlags,
+                                 NULL);
+}
+
+
+/***********************************************************************
+ * CM_Get_Class_Name_ExA [SETUPAPI.@]
+ */
+CONFIGRET WINAPI CM_Get_Class_Name_ExA(
+    LPGUID ClassGuid, PCHAR Buffer, PULONG pulLength, ULONG ulFlags,
+    HMACHINE hMachine)
+{
+    FIXME("%p %p %p %lx %lx\n",
+          ClassGuid, Buffer, pulLength, ulFlags, hMachine);
+    return CR_FAILURE;
+}
+
+
+/***********************************************************************
+ * CM_Get_Class_Name_ExW [SETUPAPI.@]
+ */
+CONFIGRET WINAPI
+CM_Get_Class_Name_ExW(
+    LPGUID ClassGuid, PWCHAR Buffer, PULONG pulLength, ULONG ulFlags,
+    HMACHINE hMachine)
+{
+    WCHAR szGuidString[MAX_GUID_STRING_LEN];
+    RPC_BINDING_HANDLE BindingHandle = NULL;
+
+    TRACE("%p %p %p %lx %lx\n",
+          ClassGuid, Buffer, pulLength, ulFlags, hMachine);
+
+    if (ClassGuid == NULL || Buffer == NULL || pulLength == NULL)
+        return CR_INVALID_POINTER;
+
+    if (ulFlags != 0)
+        return CR_INVALID_FLAG;
+
+    if (!GuidToString(ClassGuid, szGuidString))
+        return CR_INVALID_DATA;
+
+    TRACE("Guid %s\n", debugstr_w(szGuidString));
+
+    if (hMachine != NULL)
+    {
+        BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
+        if (BindingHandle == NULL)
+            return CR_FAILURE;
+    }
+    else
+    {
+        if (!PnpGetLocalHandles(&BindingHandle, NULL))
+            return CR_FAILURE;
+    }
+
+    return PNP_GetClassName(BindingHandle,
+                            szGuidString,
+                            Buffer,
+                            pulLength,
+                            ulFlags);
+}
+
+
+/***********************************************************************
  * CM_Get_Depth [SETUPAPI.@]
  */
 CONFIGRET WINAPI CM_Get_Depth(

Modified: trunk/reactos/lib/setupapi/setupapi.spec
--- trunk/reactos/lib/setupapi/setupapi.spec	2005-09-03 18:05:33 UTC (rev 17623)
+++ trunk/reactos/lib/setupapi/setupapi.spec	2005-09-03 19:44:47 UTC (rev 17624)
@@ -59,10 +59,10 @@
 @ stdcall CM_Get_Class_Key_NameW(ptr wstr ptr long)
 @ stdcall CM_Get_Class_Key_Name_ExA(ptr str ptr long long)
 @ stdcall CM_Get_Class_Key_Name_ExW(ptr wstr ptr long long)
-@ stub CM_Get_Class_NameA
-@ stub CM_Get_Class_NameW
-@ stub CM_Get_Class_Name_ExA
-@ stub CM_Get_Class_Name_ExW
+@ stdcall CM_Get_Class_NameA(ptr str ptr long)
+@ stdcall CM_Get_Class_NameW(ptr wstr ptr long)
+@ stdcall CM_Get_Class_Name_ExA(ptr str ptr long long)
+@ stdcall CM_Get_Class_Name_ExW(ptr wstr ptr long long)
 @ stdcall CM_Get_Depth(ptr long long)
 @ stdcall CM_Get_Depth_Ex(ptr long long long)
 @ stdcall CM_Get_DevNode_Registry_PropertyA(long long ptr ptr ptr long)
@@ -166,6 +166,7 @@
 @ stub CM_Request_Device_EjectA
 @ stub CM_Request_Device_EjectW
 @ stub CM_Request_Eject_PC
+@ stub CM_Request_Eject_PC_Ex
 @ stub CM_Reset_Children_Marks
 @ stub CM_Reset_Children_Marks_Ex
 @ stub CM_Run_Detection

Modified: trunk/reactos/w32api/include/ddk/cfgmgr32.h
--- trunk/reactos/w32api/include/ddk/cfgmgr32.h	2005-09-03 18:05:33 UTC (rev 17623)
+++ trunk/reactos/w32api/include/ddk/cfgmgr32.h	2005-09-03 19:44:47 UTC (rev 17624)
@@ -862,12 +862,55 @@
   IN ULONG  ulFlags,
   IN HMACHINE  hMachine);
 
-/* FIXME: Obsolete CM_Get_Class_Name */
-/* FIXME: Obsolete CM_Get_Class_Name_Ex */
+CMAPI
+CONFIGRET
+WINAPI
+CM_Get_Class_NameA(
+  IN LPGUID  ClassGuid,
+  OUT PCHAR  Buffer,
+  IN OUT PULONG  pulLength,
+  IN ULONG  ulFlags);
 
 CMAPI
 CONFIGRET
 WINAPI
+CM_Get_Class_NameW(
+  IN LPGUID  ClassGuid,
+  OUT PWCHAR  Buffer,
+  IN OUT PULONG  pulLength,
+  IN ULONG  ulFlags);
+
+CMAPI
+CONFIGRET
+WINAPI
+CM_Get_Class_Name_ExA(
+  IN LPGUID  ClassGuid,
+  OUT PCHAR  Buffer,
+  IN OUT PULONG  pulLength,
+  IN ULONG  ulFlags,
+  IN HMACHINE  hMachine);
+
+CMAPI
+CONFIGRET
+WINAPI
+CM_Get_Class_Name_ExW(
+  IN LPGUID  ClassGuid,
+  OUT PWCHAR  Buffer,
+  IN OUT PULONG  pulLength,
+  IN ULONG  ulFlags,
+  IN HMACHINE  hMachine);
+
+#ifdef UNICODE
+#define CM_Get_Class_Name CM_Get_Class_NameW
+#define CM_Get_Class_Name_Ex CM_Get_Class_Name_ExW
+#else
+#define CM_Get_Class_Name CM_Get_Class_NameA
+#define CM_Get_Class_Name_Ex CM_Get_Class_Name_ExA
+#endif /* UNICODE */
+
+CMAPI
+CONFIGRET
+WINAPI
 CM_Get_Class_Key_NameA(
   IN LPGUID  ClassGuid,
   OUT LPSTR  pszKeyName,