Implement SetupDiGetDeviceInstanceIdW
authorHervé Poussineau <hpoussin@reactos.org>
Sat, 26 Nov 2005 08:13:04 +0000 (08:13 +0000)
committerHervé Poussineau <hpoussin@reactos.org>
Sat, 26 Nov 2005 08:13:04 +0000 (08:13 +0000)
Fix debug message

svn path=/trunk/; revision=19613

reactos/lib/devmgr/hwpage.c
reactos/lib/setupapi/devinst.c
reactos/lib/setupapi/stubs.c

index c96e48e..4dfe8d5 100644 (file)
@@ -143,7 +143,7 @@ DisplaySelectedDeviceProperties(IN PHARDWARE_PAGE_DATA hpd)
                                        0,
                                        &DeviceInstanceIdLen))
         {
-            DPRINT1("SetupDiGetDeviceInterfaceDetail unexpectedly returned TRUE!\n");
+            DPRINT1("SetupDiGetDeviceInstanceId unexpectedly returned TRUE!\n");
             goto Cleanup;
         }
 
index 149dd5e..2ef5d2d 100644 (file)
@@ -3004,7 +3004,7 @@ BOOL WINAPI SetupDiCallClassInstaller(
 {
     BOOL ret = FALSE;
 
-    TRACE("%ld %p %p\n", InstallFunction, DeviceInfoSet, DeviceInfoData);
+    TRACE("%u %p %p\n", InstallFunction, DeviceInfoSet, DeviceInfoData);
 
     if (!DeviceInfoSet)
         SetLastError(ERROR_INVALID_PARAMETER);
@@ -3063,7 +3063,7 @@ BOOL WINAPI SetupDiCallClassInstaller(
                 DefaultHandler = SetupDiSelectBestCompatDrv;
                 break;
             default:
-                ERR("Install function %lu not supported\n", InstallFunction);
+                ERR("Install function %u not supported\n", InstallFunction);
                 SetLastError(ERROR_NOT_SUPPORTED);
         }
 
@@ -3462,6 +3462,71 @@ BOOL WINAPI SetupDiSetDeviceInstallParamsW(
     return ret;
 }
 
+/***********************************************************************
+ *             SetupDiGetDeviceInstanceIdA(SETUPAPI.@)
+ */
+BOOL WINAPI SetupDiGetDeviceInstanceIdA(
+        IN HDEVINFO DeviceInfoSet,
+        IN PSP_DEVINFO_DATA DeviceInfoData,
+        OUT PSTR DeviceInstanceId,
+        IN DWORD DeviceInstanceIdSize,
+        OUT PDWORD RequiredSize)
+{
+    FIXME ("Stub %p %p %p %d %p\n",
+           DeviceInfoSet, DeviceInfoData, DeviceInstanceId, DeviceInstanceIdSize, RequiredSize);
+    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+    return FALSE;
+}
+
+/***********************************************************************
+ *             SetupDiGetDeviceInstanceIdW(SETUPAPI.@)
+ */
+BOOL WINAPI SetupDiGetDeviceInstanceIdW(
+        IN HDEVINFO DeviceInfoSet,
+        IN PSP_DEVINFO_DATA DeviceInfoData,
+        OUT PWSTR DeviceInstanceId,
+        IN DWORD DeviceInstanceIdSize,
+        OUT PDWORD RequiredSize)
+{
+    BOOL ret = FALSE;
+
+    TRACE("%p %p %p %lu %p\n", DeviceInfoSet, DeviceInfoData,
+          DeviceInstanceId, DeviceInstanceIdSize, RequiredSize);
+
+    if (!DeviceInfoSet)
+        SetLastError(ERROR_INVALID_HANDLE);
+    else if (((struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEV_INFO_SET_MAGIC)
+        SetLastError(ERROR_INVALID_HANDLE);
+    else if (!DeviceInfoData)
+        SetLastError(ERROR_INVALID_PARAMETER);
+    else if (DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
+        SetLastError(ERROR_INVALID_USER_BUFFER);
+    else if (!DeviceInstanceId && DeviceInstanceIdSize > 0)
+        SetLastError(ERROR_INVALID_PARAMETER);
+    else if (DeviceInstanceId && DeviceInstanceIdSize == 0)
+        SetLastError(ERROR_INVALID_PARAMETER);
+    else
+    {
+        struct DeviceInfoElement *DevInfo = (struct DeviceInfoElement *)DeviceInfoData->Reserved;
+        DWORD required;
+
+        required = (wcslen(DevInfo->DeviceName) + 1) * sizeof(WCHAR);
+        if (RequiredSize)
+            *RequiredSize = required;
+
+        if (required <= DeviceInstanceIdSize)
+        {
+            wcscpy(DeviceInstanceId, DevInfo->DeviceName);
+            ret = TRUE;
+        }
+        else
+            SetLastError(ERROR_INSUFFICIENT_BUFFER);
+    }
+
+    TRACE("Returning 0x%p\n", ret);
+    return ret;
+}
+
 /***********************************************************************
  *             SetupDiCreateDevRegKeyA (SETUPAPI.@)
  */
index 1891e69..fa05d73 100644 (file)
@@ -225,31 +225,6 @@ BOOL WINAPI SetupDiDestroyClassImageList(PSP_CLASSIMAGELIST_DATA ClassImageListD
     return TRUE;
 }
 
-/***********************************************************************
- *             SetupDiGetDeviceInstanceIdA(SETUPAPI.@)
- */
-BOOL WINAPI SetupDiGetDeviceInstanceIdA(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData,
-                                        PSTR DeviceInstanceId, DWORD DeviceInstanceIdSize,
-                                        PDWORD RequiredSize)
-{
-    FIXME ("Stub %p %p %p %d %p\n",
-           DeviceInfoSet, DeviceInfoData, DeviceInstanceId, DeviceInstanceIdSize, RequiredSize);
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return FALSE;
-}
-
-/***********************************************************************
- *             SetupDiGetDeviceInstanceIdW(SETUPAPI.@)
- */
-BOOL WINAPI SetupDiGetDeviceInstanceIdW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData,
-                                        PWSTR DeviceInstanceId, DWORD DeviceInstanceIdSize,
-                                        PDWORD RequiredSize)
-{
-    FIXME ("Stub %p %p %p %d %p\n",
-           DeviceInfoSet, DeviceInfoData, DeviceInstanceId, DeviceInstanceIdSize, RequiredSize);
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return FALSE;
-}
 
 /***********************************************************************
  *             SetupDiGetClassDevPropertySheetsA(SETUPAPI.@)