[SETUPAPI] Fix a typo in CM_Query_Resource_Conflict_List.
[reactos.git] / dll / win32 / setupapi / cfgmgr.c
index 0a3035d..d33a649 100644 (file)
@@ -72,6 +72,7 @@ typedef struct _NOTIFY_DATA
 typedef struct _INTERNAL_RANGE
 {
     LIST_ENTRY ListEntry;
+    struct _INTERNAL_RANGE_LIST *pRangeList;
     DWORDLONG ullStart;
     DWORDLONG ullEnd;
 } INTERNAL_RANGE, *PINTERNAL_RANGE;
@@ -238,18 +239,43 @@ GetDeviceInstanceKeyPath(
 
         ulTransferLength = 300 * sizeof(WCHAR);
         ulLength = 300 * sizeof(WCHAR);
-        ret = PNP_GetDeviceRegProp(BindingHandle,
-                                   pszDeviceInst,
-                                   CM_DRP_DRIVER,
-                                   &ulType,
-                                   (PVOID)pszBuffer,
-                                   &ulTransferLength,
-                                   &ulLength,
-                                   0);
+
+        RpcTryExcept
+        {
+            ret = PNP_GetDeviceRegProp(BindingHandle,
+                                       pszDeviceInst,
+                                       CM_DRP_DRIVER,
+                                       &ulType,
+                                       (PVOID)pszBuffer,
+                                       &ulTransferLength,
+                                       &ulLength,
+                                       0);
+        }
+        RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+        {
+            ret = RpcStatusToCmStatus(RpcExceptionCode());
+        }
+        RpcEndExcept;
+
         if (ret != CR_SUCCESS)
         {
-            ERR("PNP_GetDeviceRegProp() failed (Error %lu)\n", ret);
-            goto done;
+            RpcTryExcept
+            {
+                ret = PNP_GetClassInstance(BindingHandle,
+                                           pszDeviceInst,
+                                           (PVOID)pszBuffer,
+                                           300);
+            }
+            RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+            {
+                ret = RpcStatusToCmStatus(RpcExceptionCode());
+            }
+            RpcEndExcept;
+
+            if (ret != CR_SUCCESS)
+            {
+                goto done;
+            }
         }
 
         TRACE("szBuffer: %S\n", pszBuffer);
@@ -808,7 +834,8 @@ CM_Add_Empty_Log_Conf(
  * CM_Add_Empty_Log_Conf_Ex [SETUPAPI.@]
  */
 CONFIGRET
-WINAPI CM_Add_Empty_Log_Conf_Ex(
+WINAPI
+CM_Add_Empty_Log_Conf_Ex(
     _Out_ PLOG_CONF plcLogConf,
     _In_ DEVINST dnDevInst,
     _In_ PRIORITY Priority,
@@ -1065,6 +1092,7 @@ CM_Add_Range(
         goto done;
     }
 
+    pRange->pRangeList = pRangeList;
     pRange->ullStart = ullStartValue;
     pRange->ullEnd = ullEndValue;
 
@@ -5900,10 +5928,51 @@ CM_Next_Range(
     _Out_ PDWORDLONG pullEnd,
     _In_ ULONG ulFlags)
 {
+    PINTERNAL_RANGE_LIST pRangeList;
+    PINTERNAL_RANGE pRange;
+    PLIST_ENTRY ListEntry;
+    CONFIGRET ret = CR_SUCCESS;
+
     FIXME("CM_Next_Range(%p %p %p %lx)\n",
           preElement, pullStart, pullEnd, ulFlags);
 
-    return CR_CALL_NOT_IMPLEMENTED;
+    pRange = (PINTERNAL_RANGE)preElement;
+
+    if (pRange == NULL || pRange->pRangeList == NULL)
+        return CR_FAILURE;
+
+    if (pullStart == NULL || pullEnd == NULL)
+        return CR_INVALID_POINTER;
+
+    if (ulFlags != 0)
+        return CR_INVALID_FLAG;
+
+    pRangeList = pRange->pRangeList;
+
+    /* Lock the range list */
+    WaitForSingleObject(pRangeList->hMutex, INFINITE);
+
+    /* Fail, if we reached the end of the list */
+    if (pRange->ListEntry.Flink == &pRangeList->ListHead)
+    {
+        ret = CR_FAILURE;
+        goto done;
+    }
+
+    /* Get the next range */
+    ListEntry = pRangeList->ListHead.Flink;
+    pRange = CONTAINING_RECORD(ListEntry, INTERNAL_RANGE, ListEntry);
+
+    /* Return the range data */
+    *pullStart = pRange->ullStart;
+    *pullEnd = pRange->ullEnd;
+    *preElement = (RANGE_ELEMENT)pRange;
+
+done:
+    /* Unlock the range list */
+    ReleaseMutex(pRangeList->hMutex);
+
+    return ret;
 }
 
 
@@ -6692,7 +6761,7 @@ CM_Query_Resource_Conflict_List(
     if (lpDevInst == NULL)
         return CR_INVALID_DEVNODE;
 
-    pConflictData = MyMalloc(sizeof(CONFLICT_DATA));
+    pConflictData = MyMalloc(sizeof(PCONFLICT_DATA));
     if (pConflictData == NULL)
     {
         ret = CR_OUT_OF_MEMORY;