Fix GUID->String conversion.
authorEric Kohl <eric.kohl@reactos.org>
Sat, 3 Sep 2005 19:44:47 +0000 (19:44 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sat, 3 Sep 2005 19:44:47 +0000 (19:44 +0000)
Implement CM_Get_Class[_Ex]A/W.

svn path=/trunk/; revision=17624

reactos/include/wine/cfgmgr32.h
reactos/lib/setupapi/cfgmgr.c
reactos/lib/setupapi/setupapi.spec
reactos/w32api/include/ddk/cfgmgr32.h

index dc78f38..7622e76 100644 (file)
@@ -139,6 +139,12 @@ CONFIGRET WINAPI CM_Get_Class_Key_NameW( LPGUID, LPWSTR, PULONG, ULONG );
 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 );
index bc6068b..4c0cd07 100644 (file)
@@ -363,6 +363,21 @@ CONFIGRET WINAPI CM_Get_Class_Key_Name_ExA(
 }
 
 
+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 @@ CONFIGRET WINAPI CM_Get_Class_Key_Name_ExW(
     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 @@ CONFIGRET WINAPI CM_Get_Class_Key_Name_ExW(
         return CR_BUFFER_SMALL;
     }
 
-    if (UuidToStringW(ClassGuid, &pszKeyName) != RPC_S_OK)
+   if (!GuidToString(ClassGuid, pszKeyName))
         return CR_INVALID_DATA;
 
     *pulLength = MAX_GUID_STRING_LEN;
@@ -394,6 +409,88 @@ CONFIGRET WINAPI CM_Get_Class_Key_Name_ExW(
 }
 
 
+/***********************************************************************
+ * 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.@]
  */
index bd7c509..405f99e 100644 (file)
 @ 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)
 @ 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
index d8f802e..6784af3 100644 (file)
@@ -862,8 +862,51 @@ CM_Get_Child_Ex(
   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