[UMPNPMGR]
authorEric Kohl <eric.kohl@reactos.org>
Mon, 13 Feb 2017 22:59:40 +0000 (22:59 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Mon, 13 Feb 2017 22:59:40 +0000 (22:59 +0000)
PNP_GetDeviceList and PNP_GetDeviceListSize:
- Do not return CR_CALL_NOT_IMPLEMENTED by default.
- pulLength is counted in characters, not in bytes!
- Use the correct Relations value for PowerRelations.

[NDK]
Add the PowerRelations value to a comment.

[DEVMGR]
CM_Get_Device_ID_List_Size_ExW and CM_Get_Device_ID_List_ExW count the buffer length in characters, not in bytes!

svn path=/trunk/; revision=73796

reactos/base/services/umpnpmgr/umpnpmgr.c
reactos/dll/win32/devmgr/properties/advprop.cpp
reactos/sdk/include/ndk/cmtypes.h

index e1e7e5c..f64f3c5 100644 (file)
@@ -489,7 +489,7 @@ PNP_GetDeviceList(
     DWORD ulFlags)
 {
     PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA PlugPlayData;
-    CONFIGRET ret = CR_CALL_NOT_IMPLEMENTED;
+    CONFIGRET ret = CR_SUCCESS;
     NTSTATUS Status;
 
     DPRINT("PNP_GetDeviceList() called\n");
@@ -501,9 +501,7 @@ PNP_GetDeviceList(
         return CR_INVALID_POINTER;
 
 //    if (Buffer == NULL)
-//        return 
-
-    *pulLength = 0;
+//        return CR_INVALID_POINTER;
 
     if (ulFlags &
         (CM_GETIDLIST_FILTER_BUSRELATIONS |
@@ -519,8 +517,7 @@ PNP_GetDeviceList(
         }
         else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
         {
-            /* FIXME */
-            PlugPlayData.Relations = 0;
+            PlugPlayData.Relations = 2;
         }
         else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
         {
@@ -531,7 +528,7 @@ PNP_GetDeviceList(
             PlugPlayData.Relations = 0;
         }
 
-        PlugPlayData.BufferSize = *pulLength;
+        PlugPlayData.BufferSize = *pulLength * sizeof(WCHAR);
         PlugPlayData.Buffer = Buffer;
 
         Status = NtPlugPlayControl(PlugPlayControlQueryDeviceRelations,
@@ -539,7 +536,7 @@ PNP_GetDeviceList(
                                    sizeof(PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA));
         if (NT_SUCCESS(Status))
         {
-            *pulLength = PlugPlayData.BufferSize;
+            *pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
         }
         else
         {
@@ -548,15 +545,15 @@ PNP_GetDeviceList(
     }
     else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
     {
-
+        ret = CR_CALL_NOT_IMPLEMENTED;
     }
     else if (ulFlags & CM_GETIDLIST_FILTER_ENUMERATOR)
     {
-
+        ret = CR_CALL_NOT_IMPLEMENTED;
     }
     else /* CM_GETIDLIST_FILTER_NONE */
     {
-
+        ret = CR_CALL_NOT_IMPLEMENTED;
     }
 
     return ret;
@@ -573,7 +570,7 @@ PNP_GetDeviceListSize(
     DWORD ulFlags)
 {
     PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA PlugPlayData;
-    CONFIGRET ret = CR_CALL_NOT_IMPLEMENTED;
+    CONFIGRET ret = CR_SUCCESS;
     NTSTATUS Status;
 
     DPRINT("PNP_GetDeviceListSize() called\n");
@@ -600,8 +597,7 @@ PNP_GetDeviceListSize(
         }
         else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
         {
-            /* FIXME */
-            PlugPlayData.Relations = 0;
+            PlugPlayData.Relations = 2;
         }
         else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
         {
@@ -620,7 +616,7 @@ PNP_GetDeviceListSize(
                                    sizeof(PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA));
         if (NT_SUCCESS(Status))
         {
-            *pulLength = PlugPlayData.BufferSize;
+            *pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
         }
         else
         {
@@ -629,15 +625,15 @@ PNP_GetDeviceListSize(
     }
     else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
     {
-
+        ret = CR_CALL_NOT_IMPLEMENTED;
     }
     else if (ulFlags & CM_GETIDLIST_FILTER_ENUMERATOR)
     {
-
+        ret = CR_CALL_NOT_IMPLEMENTED;
     }
     else /* CM_GETIDLIST_FILTER_NONE */
     {
-
+        ret = CR_CALL_NOT_IMPLEMENTED;
     }
 
     return ret;
@@ -994,7 +990,7 @@ PNP_GetDeviceRegProp(
 
 done:
 
-    if(pulTransferLen)
+    if (pulTransferLen)
         *pulTransferLen = (ret == CR_SUCCESS) ? *pulLength : 0;
 
     if (hKey != NULL)
index 4386667..c2b79d5 100644 (file)
@@ -1339,7 +1339,6 @@ DisplayDeviceRelations(
     ULONG ulLength = 0;
     LPWSTR pszBuffer = NULL, pszStr;
     INT index = 0, len;
-
     CONFIGRET ret;
 
     ret = CM_Get_Device_ID_List_Size_ExW(&ulLength,
@@ -1351,7 +1350,7 @@ DisplayDeviceRelations(
 
     pszBuffer = (LPWSTR)HeapAlloc(GetProcessHeap(),
                                   HEAP_ZERO_MEMORY,
-                                  ulLength);
+                                  ulLength * sizeof(WCHAR));
     if (pszBuffer == NULL)
         return;
 
index 00554c9..2f2888a 100644 (file)
@@ -466,7 +466,7 @@ typedef struct _PLUGPLAY_CONTROL_DEPTH_DATA
 typedef struct _PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA
 {
     UNICODE_STRING DeviceInstance;
-    ULONG Relations; // 0:EjectRelations, 1:RemovalRelations, 3:BusRelations
+    ULONG Relations; // 0:EjectRelations, 1:RemovalRelations, 2:PowerRelations, 3:BusRelations
     ULONG BufferSize;
     PWCHAR Buffer;
 } PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA, *PPLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA;