SEH protect all calls to the UM-PNP-Manager.
authorEric Kohl <eric.kohl@reactos.org>
Mon, 27 Oct 2008 19:26:37 +0000 (19:26 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Mon, 27 Oct 2008 19:26:37 +0000 (19:26 +0000)
svn path=/trunk/; revision=37028

reactos/dll/win32/setupapi/cfgmgr.c

index adbc557..e53b02e 100644 (file)
@@ -76,6 +76,13 @@ static BOOL GuidToString(LPGUID Guid, LPWSTR String)
 }
 
 
+static CONFIGRET
+RpcStatusToCmStatus(RPC_STATUS Status)
+{
+    return CR_FAILURE;
+}
+
+
 /***********************************************************************
  * CMP_WaitNoPendingInstallEvents [SETUPAPI.@]
  */
@@ -102,6 +109,7 @@ CONFIGRET WINAPI CMP_Init_Detection(
     DWORD dwMagic)
 {
     RPC_BINDING_HANDLE BindingHandle = NULL;
+    CONFIGRET ret;
 
     TRACE("%lu\n", dwMagic);
 
@@ -111,7 +119,17 @@ CONFIGRET WINAPI CMP_Init_Detection(
     if (!PnpGetLocalHandles(&BindingHandle, NULL))
         return CR_FAILURE;
 
-    return PNP_InitDetection(BindingHandle);
+    _SEH_TRY
+    {
+        ret = PNP_InitDetection(BindingHandle);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -139,9 +157,18 @@ CONFIGRET WINAPI CMP_Report_LogOn(
 
     for (i = 0; i < 30; i++)
     {
-        ret = PNP_ReportLogOn(BindingHandle,
-                              bAdmin,
-                              dwProcessId);
+        _SEH_TRY
+        {
+            ret = PNP_ReportLogOn(BindingHandle,
+                                  bAdmin,
+                                  dwProcessId);
+        }
+        _SEH_HANDLE
+        {
+            ret = RpcStatusToCmStatus(RpcExceptionCode());
+        }
+        _SEH_END;
+
         if (ret == CR_SUCCESS)
             break;
 
@@ -217,7 +244,17 @@ CONFIGRET WINAPI CM_Add_Empty_Log_Conf_Ex(
     if (lpDevInst == NULL)
         return CR_INVALID_DEVNODE;
 
-    ret = PNP_AddEmptyLogConf(BindingHandle, lpDevInst, Priority, &ulLogConfTag, ulFlags);
+    _SEH_TRY
+    {
+        ret = PNP_AddEmptyLogConf(BindingHandle, lpDevInst, Priority,
+                                  &ulLogConfTag, ulFlags);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
     if (ret == CR_SUCCESS)
     {
         pLogConfInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(LOG_CONF_INFO));
@@ -295,6 +332,7 @@ CONFIGRET WINAPI CM_Add_ID_ExW(
     RPC_BINDING_HANDLE BindingHandle = NULL;
     HSTRING_TABLE StringTable = NULL;
     LPWSTR lpDevInst;
+    CONFIGRET ret;
 
     TRACE("%p %s %lx %p\n", dnDevInst, debugstr_w(pszID), ulFlags, hMachine);
 
@@ -330,10 +368,20 @@ CONFIGRET WINAPI CM_Add_ID_ExW(
     if (lpDevInst == NULL)
         return CR_INVALID_DEVNODE;
 
-    return PNP_AddID(BindingHandle,
-                     lpDevInst,
-                     pszID,
-                     ulFlags);
+    _SEH_TRY
+    {
+        ret = PNP_AddID(BindingHandle,
+                        lpDevInst,
+                        pszID,
+                        ulFlags);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -530,11 +578,20 @@ CONFIGRET WINAPI CM_Create_DevNode_ExW(
     if (lpParentDevInst == NULL)
         return CR_INVALID_DEVNODE;
 
-    ret = PNP_CreateDevInst(BindingHandle,
-                            pDeviceID,
-                            lpParentDevInst,
-                            MAX_DEVICE_ID_LEN,
-                            ulFlags);
+    _SEH_TRY
+    {
+        ret = PNP_CreateDevInst(BindingHandle,
+                                pDeviceID,
+                                lpParentDevInst,
+                                MAX_DEVICE_ID_LEN,
+                                ulFlags);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
     if (ret == CR_SUCCESS)
     {
         *pdnDevInst = StringTableAddString(StringTable, pDeviceID, 1);
@@ -565,6 +622,7 @@ CONFIGRET WINAPI CM_Delete_Class_Key_Ex(
 {
     WCHAR szGuidString[MAX_GUID_STRING_LEN];
     RPC_BINDING_HANDLE BindingHandle = NULL;
+    CONFIGRET ret;
 
     TRACE("%p %lx %lx\n", ClassGuid, ulFlags, hMachine);
 
@@ -589,11 +647,22 @@ CONFIGRET WINAPI CM_Delete_Class_Key_Ex(
             return CR_FAILURE;
     }
 
-    return PNP_DeleteClassKey(BindingHandle,
-                             szGuidString,
-                             ulFlags);
+    _SEH_TRY
+    {
+        ret = PNP_DeleteClassKey(BindingHandle,
+                                 szGuidString,
+                                 ulFlags);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
+
 /***********************************************************************
  * CM_Delete_DevNode_Key [SETUPAPI.@]
  */
@@ -605,6 +674,7 @@ CONFIGRET WINAPI CM_Delete_DevNode_Key(
                                     NULL);
 }
 
+
 /***********************************************************************
  * CM_Delete_DevNode_Key_Ex [SETUPAPI.@]
  */
@@ -639,6 +709,7 @@ CONFIGRET WINAPI CM_Disable_DevNode_Ex(
     RPC_BINDING_HANDLE BindingHandle = NULL;
     HSTRING_TABLE StringTable = NULL;
     LPWSTR lpDevInst;
+    CONFIGRET ret;
 
     FIXME("%p %lx %p\n", dnDevInst, ulFlags, hMachine);
 
@@ -671,11 +742,21 @@ CONFIGRET WINAPI CM_Disable_DevNode_Ex(
     if (lpDevInst == NULL)
         return CR_INVALID_DEVNODE;
 
-    return PNP_DeviceInstanceAction(BindingHandle,
-                                    5,
-                                    ulFlags,
-                                    lpDevInst,
-                                    NULL);
+    _SEH_TRY
+    {
+        ret = PNP_DeviceInstanceAction(BindingHandle,
+                                       5,
+                                       ulFlags,
+                                       lpDevInst,
+                                       NULL);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -727,6 +808,7 @@ CONFIGRET WINAPI CM_Enable_DevNode_Ex(
     RPC_BINDING_HANDLE BindingHandle = NULL;
     HSTRING_TABLE StringTable = NULL;
     LPWSTR lpDevInst;
+    CONFIGRET ret;
 
     FIXME("%p %lx %p\n", dnDevInst, ulFlags, hMachine);
 
@@ -759,11 +841,21 @@ CONFIGRET WINAPI CM_Enable_DevNode_Ex(
     if (lpDevInst == NULL)
         return CR_INVALID_DEVNODE;
 
-    return PNP_DeviceInstanceAction(BindingHandle,
-                                    4,
-                                    ulFlags,
-                                    lpDevInst,
-                                    NULL);
+    _SEH_TRY
+    {
+        ret = PNP_DeviceInstanceAction(BindingHandle,
+                                       4,
+                                       ulFlags,
+                                       lpDevInst,
+                                       NULL);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -809,13 +901,22 @@ CONFIGRET WINAPI CM_Enumerate_Classes_Ex(
             return CR_FAILURE;
     }
 
-    ret = PNP_EnumerateSubKeys(BindingHandle,
-                               PNP_CLASS_SUBKEYS,
-                               ulClassIndex,
-                               szBuffer,
-                               MAX_GUID_STRING_LEN,
-                               &ulLength,
-                               ulFlags);
+    _SEH_TRY
+    {
+        ret = PNP_EnumerateSubKeys(BindingHandle,
+                                   PNP_CLASS_SUBKEYS,
+                                   ulClassIndex,
+                                   szBuffer,
+                                   MAX_GUID_STRING_LEN,
+                                   &ulLength,
+                                   ulFlags);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
     if (ret == CR_SUCCESS)
     {
         /* Remove the {} */
@@ -908,6 +1009,7 @@ CONFIGRET WINAPI CM_Enumerate_Enumerators_ExW(
     HMACHINE hMachine)
 {
     RPC_BINDING_HANDLE BindingHandle = NULL;
+    CONFIGRET ret;
 
     TRACE("%lu %p %p %lx %lx\n", ulEnumIndex, Buffer, pulLength, ulFlags,
           hMachine);
@@ -932,13 +1034,23 @@ CONFIGRET WINAPI CM_Enumerate_Enumerators_ExW(
             return CR_FAILURE;
     }
 
-    return PNP_EnumerateSubKeys(BindingHandle,
-                                PNP_ENUMERATOR_SUBKEYS,
-                                ulEnumIndex,
-                                Buffer,
-                                *pulLength,
-                                pulLength,
-                                ulFlags);
+    _SEH_TRY
+    {
+        ret = PNP_EnumerateSubKeys(BindingHandle,
+                                   PNP_ENUMERATOR_SUBKEYS,
+                                   ulEnumIndex,
+                                   Buffer,
+                                   *pulLength,
+                                   pulLength,
+                                   ulFlags);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -963,6 +1075,7 @@ CONFIGRET WINAPI CM_Free_Log_Conf_Ex(
     HSTRING_TABLE StringTable = NULL;
     LPWSTR lpDevInst;
     PLOG_CONF_INFO pLogConfInfo;
+    CONFIGRET ret;
 
     TRACE("%lx %lx %lx\n", lcLogConfToBeFreed, ulFlags, hMachine);
 
@@ -996,8 +1109,18 @@ CONFIGRET WINAPI CM_Free_Log_Conf_Ex(
     if (lpDevInst == NULL)
         return CR_INVALID_DEVNODE;
 
-    return PNP_FreeLogConf(BindingHandle, lpDevInst, pLogConfInfo->ulFlags,
-                           pLogConfInfo->ulTag, 0);
+    _SEH_TRY
+    {
+        ret = PNP_FreeLogConf(BindingHandle, lpDevInst, pLogConfInfo->ulFlags,
+                              pLogConfInfo->ulTag, 0);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -1078,12 +1201,21 @@ CONFIGRET WINAPI CM_Get_Child_Ex(
     if (lpDevInst == NULL)
         return CR_INVALID_DEVNODE;
 
-    ret = PNP_GetRelatedDeviceInstance(BindingHandle,
-                                       PNP_GET_CHILD_DEVICE_INSTANCE,
-                                       lpDevInst,
-                                       szRelatedDevInst,
-                                       &dwLength,
-                                       0);
+    _SEH_TRY
+    {
+        ret = PNP_GetRelatedDeviceInstance(BindingHandle,
+                                           PNP_GET_CHILD_DEVICE_INSTANCE,
+                                           lpDevInst,
+                                           szRelatedDevInst,
+                                           &dwLength,
+                                           0);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
     if (ret != CR_SUCCESS)
         return ret;
 
@@ -1276,6 +1408,7 @@ CM_Get_Class_Name_ExW(
 {
     WCHAR szGuidString[MAX_GUID_STRING_LEN];
     RPC_BINDING_HANDLE BindingHandle = NULL;
+    CONFIGRET ret;
 
     TRACE("%p %p %p %lx %lx\n",
           ClassGuid, Buffer, pulLength, ulFlags, hMachine);
@@ -1303,11 +1436,21 @@ CM_Get_Class_Name_ExW(
             return CR_FAILURE;
     }
 
-    return PNP_GetClassName(BindingHandle,
-                            szGuidString,
-                            Buffer,
-                            pulLength,
-                            ulFlags);
+    _SEH_TRY
+    {
+        ret = PNP_GetClassName(BindingHandle,
+                               szGuidString,
+                               Buffer,
+                               pulLength,
+                               ulFlags);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -1331,6 +1474,7 @@ CONFIGRET WINAPI CM_Get_Depth_Ex(
     RPC_BINDING_HANDLE BindingHandle = NULL;
     HSTRING_TABLE StringTable = NULL;
     LPWSTR lpDevInst;
+    CONFIGRET ret;
 
     TRACE("%p %lx %lx %lx\n",
           pulDepth, dnDevInst, ulFlags, hMachine);
@@ -1364,10 +1508,20 @@ CONFIGRET WINAPI CM_Get_Depth_Ex(
     if (lpDevInst == NULL)
         return CR_INVALID_DEVNODE;
 
-    return PNP_GetDepth(BindingHandle,
-                        lpDevInst,
-                        pulDepth,
-                        ulFlags);
+    _SEH_TRY
+    {
+        ret = PNP_GetDepth(BindingHandle,
+                           lpDevInst,
+                           pulDepth,
+                           ulFlags);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -1532,14 +1686,24 @@ CONFIGRET WINAPI CM_Get_DevNode_Registry_Property_ExW(
         return CR_INVALID_DEVNODE;
 
     ulTransferLength = *pulLength;
-    ret = PNP_GetDeviceRegProp(BindingHandle,
-                               lpDevInst,
-                               ulProperty,
-                               &ulDataType,
-                               Buffer,
-                               &ulTransferLength,
-                               pulLength,
-                               ulFlags);
+
+    _SEH_TRY
+    {
+        ret = PNP_GetDeviceRegProp(BindingHandle,
+                                   lpDevInst,
+                                   ulProperty,
+                                   &ulDataType,
+                                   Buffer,
+                                   &ulTransferLength,
+                                   pulLength,
+                                   ulFlags);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
     if (ret == CR_SUCCESS)
     {
         if (pulRegDataType != NULL)
@@ -1575,6 +1739,7 @@ CM_Get_DevNode_Status_Ex(
     RPC_BINDING_HANDLE BindingHandle = NULL;
     HSTRING_TABLE StringTable = NULL;
     LPWSTR lpDevInst;
+    CONFIGRET ret;
 
     TRACE("%p %p %lx %lx %lx\n",
           pulStatus, pulProblemNumber, dnDevInst, ulFlags, hMachine);
@@ -1608,11 +1773,21 @@ CM_Get_DevNode_Status_Ex(
     if (lpDevInst == NULL)
         return CR_INVALID_DEVNODE;
 
-    return PNP_GetDeviceStatus(BindingHandle,
-                               lpDevInst,
-                               pulStatus,
-                               pulProblemNumber,
-                               ulFlags);
+    _SEH_TRY
+    {
+        ret = PNP_GetDeviceStatus(BindingHandle,
+                                  lpDevInst,
+                                  pulStatus,
+                                  pulProblemNumber,
+                                  ulFlags);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -1883,6 +2058,7 @@ CONFIGRET WINAPI CM_Get_Device_ID_List_Size_ExW(
     PULONG pulLen, PCWSTR pszFilter, ULONG ulFlags, HMACHINE hMachine)
 {
     RPC_BINDING_HANDLE BindingHandle = NULL;
+    CONFIGRET ret;
 
     FIXME("%p %s %ld %lx\n", pulLen, debugstr_w(pszFilter), ulFlags, hMachine);
 
@@ -1906,10 +2082,20 @@ CONFIGRET WINAPI CM_Get_Device_ID_List_Size_ExW(
 
     *pulLen = 0;
 
-    return PNP_GetDeviceListSize(BindingHandle,
-                                 (LPWSTR)pszFilter,
-                                 pulLen,
-                                 ulFlags);
+    _SEH_TRY
+    {
+        ret = PNP_GetDeviceListSize(BindingHandle,
+                                    (LPWSTR)pszFilter,
+                                    pulLen,
+                                    ulFlags);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -2024,11 +2210,20 @@ CONFIGRET WINAPI CM_Get_First_Log_Conf_Ex(
     if (lpDevInst == NULL)
         return CR_INVALID_DEVNODE;
 
-    ret = PNP_GetFirstLogConf(BindingHandle,
-                              lpDevInst,
-                              ulFlags,
-                              &ulTag,
-                              ulFlags);
+    _SEH_TRY
+    {
+        ret = PNP_GetFirstLogConf(BindingHandle,
+                                  lpDevInst,
+                                  ulFlags,
+                                  &ulTag,
+                                  ulFlags);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
     if (ret != CR_SUCCESS)
         return ret;
 
@@ -2065,6 +2260,7 @@ CONFIGRET WINAPI CM_Get_Global_State_Ex(
     PULONG pulState, ULONG ulFlags, HMACHINE hMachine)
 {
     RPC_BINDING_HANDLE BindingHandle = NULL;
+    CONFIGRET ret;
 
     TRACE("%p %lx %lx\n", pulState, ulFlags, hMachine);
 
@@ -2086,7 +2282,17 @@ CONFIGRET WINAPI CM_Get_Global_State_Ex(
             return CR_FAILURE;
     }
 
-    return PNP_GetGlobalState(BindingHandle, pulState, ulFlags);
+    _SEH_TRY
+    {
+        ret = PNP_GetGlobalState(BindingHandle, pulState, ulFlags);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -2157,6 +2363,7 @@ CONFIGRET WINAPI CM_Get_HW_Prof_Flags_ExW(
     ULONG ulFlags, HMACHINE hMachine)
 {
     RPC_BINDING_HANDLE BindingHandle = NULL;
+    CONFIGRET ret;
 
     FIXME("%s %lu %p %lx %lx\n", debugstr_w(szDevInstName),
           ulHardwareProfile, pulValue, ulFlags, hMachine);
@@ -2181,8 +2388,18 @@ CONFIGRET WINAPI CM_Get_HW_Prof_Flags_ExW(
             return CR_FAILURE;
     }
 
-    return PNP_HwProfFlags(BindingHandle, PNP_GET_HWPROFFLAGS, szDevInstName,
-                           ulHardwareProfile, pulValue, NULL, NULL, 0, 0);
+    _SEH_TRY
+    {
+        ret = PNP_HwProfFlags(BindingHandle, PNP_GET_HWPROFFLAGS, szDevInstName,
+                              ulHardwareProfile, pulValue, NULL, NULL, 0, 0);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -2208,6 +2425,7 @@ CONFIGRET WINAPI CM_Get_Log_Conf_Priority_Ex(
     HSTRING_TABLE StringTable = NULL;
     PLOG_CONF_INFO pLogConfInfo;
     LPWSTR lpDevInst;
+    CONFIGRET ret;
 
     FIXME("%p %p %lx %lx\n", lcLogConf, pPriority, ulFlags, hMachine);
 
@@ -2241,12 +2459,22 @@ CONFIGRET WINAPI CM_Get_Log_Conf_Priority_Ex(
     if (lpDevInst == NULL)
         return CR_INVALID_DEVNODE;
 
-    return PNP_GetLogConfPriority(BindingHandle,
-                                  lpDevInst,
-                                  pLogConfInfo->ulFlags,
-                                  pLogConfInfo->ulTag,
-                                  pPriority,
-                                  0);
+    _SEH_TRY
+    {
+        ret = PNP_GetLogConfPriority(BindingHandle,
+                                     lpDevInst,
+                                     pLogConfInfo->ulFlags,
+                                     pLogConfInfo->ulTag,
+                                     pPriority,
+                                     0);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -2308,12 +2536,21 @@ CONFIGRET WINAPI CM_Get_Next_Log_Conf_Ex(
     if (lpDevInst == NULL)
         return CR_INVALID_DEVNODE;
 
-    ret = PNP_GetNextLogConf(BindingHandle,
-                             lpDevInst,
-                             pLogConfInfo->ulFlags,
-                             pLogConfInfo->ulTag,
-                             &ulNewTag,
-                             0);
+    _SEH_TRY
+    {
+        ret = PNP_GetNextLogConf(BindingHandle,
+                                 lpDevInst,
+                                 pLogConfInfo->ulFlags,
+                                 pLogConfInfo->ulTag,
+                                 &ulNewTag,
+                                 0);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
     if (ret != CR_SUCCESS)
         return ret;
 
@@ -2392,12 +2629,21 @@ CONFIGRET WINAPI CM_Get_Parent_Ex(
     if (lpDevInst == NULL)
         return CR_INVALID_DEVNODE;
 
-    ret = PNP_GetRelatedDeviceInstance(BindingHandle,
-                                       PNP_GET_PARENT_DEVICE_INSTANCE,
-                                       lpDevInst,
-                                       szRelatedDevInst,
-                                       &dwLength,
-                                       0);
+    _SEH_TRY
+    {
+        ret = PNP_GetRelatedDeviceInstance(BindingHandle,
+                                           PNP_GET_PARENT_DEVICE_INSTANCE,
+                                           lpDevInst,
+                                           szRelatedDevInst,
+                                           &dwLength,
+                                           0);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
     if (ret != CR_SUCCESS)
         return ret;
 
@@ -2470,12 +2716,21 @@ CONFIGRET WINAPI CM_Get_Sibling_Ex(
     if (lpDevInst == NULL)
         return CR_INVALID_DEVNODE;
 
-    ret = PNP_GetRelatedDeviceInstance(BindingHandle,
-                                       PNP_GET_SIBLING_DEVICE_INSTANCE,
-                                       lpDevInst,
-                                       szRelatedDevInst,
-                                       &dwLength,
-                                       0);
+    _SEH_TRY
+    {
+        ret = PNP_GetRelatedDeviceInstance(BindingHandle,
+                                           PNP_GET_SIBLING_DEVICE_INSTANCE,
+                                           lpDevInst,
+                                           szRelatedDevInst,
+                                           &dwLength,
+                                           0);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
     if (ret != CR_SUCCESS)
         return ret;
 
@@ -2508,6 +2763,7 @@ WORD WINAPI CM_Get_Version_Ex(HMACHINE hMachine)
 {
     RPC_BINDING_HANDLE BindingHandle = NULL;
     WORD Version = 0;
+    CONFIGRET ret;
 
     TRACE("%lx\n", hMachine);
 
@@ -2523,7 +2779,17 @@ WORD WINAPI CM_Get_Version_Ex(HMACHINE hMachine)
             return CR_FAILURE;
     }
 
-    if (PNP_GetVersion(BindingHandle, &Version) != CR_SUCCESS)
+    _SEH_TRY
+    {
+        ret = PNP_GetVersion(BindingHandle, &Version);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    if (ret != CR_SUCCESS)
         return 0;
 
     return Version;
@@ -2548,6 +2814,7 @@ CONFIGRET WINAPI CM_Is_Dock_Station_Present_Ex(
     PBOOL pbPresent, HMACHINE hMachine)
 {
     RPC_BINDING_HANDLE BindingHandle = NULL;
+    CONFIGRET ret;
 
     TRACE("%p %lx\n", pbPresent, hMachine);
 
@@ -2568,8 +2835,18 @@ CONFIGRET WINAPI CM_Is_Dock_Station_Present_Ex(
             return CR_FAILURE;
     }
 
-    return PNP_IsDockStationPresent(BindingHandle,
-                                    pbPresent);
+    _SEH_TRY
+    {
+        ret = PNP_IsDockStationPresent(BindingHandle,
+                                       pbPresent);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -2662,19 +2939,37 @@ CONFIGRET WINAPI CM_Locate_DevNode_ExW(
     }
     else
     {
-        /* Get the root device ID */
-        ret = PNP_GetRootDeviceInstance(BindingHandle,
-                                        DeviceIdBuffer,
-                                        MAX_DEVICE_ID_LEN);
+        _SEH_TRY
+        {
+            /* Get the root device ID */
+            ret = PNP_GetRootDeviceInstance(BindingHandle,
+                                            DeviceIdBuffer,
+                                            MAX_DEVICE_ID_LEN);
+        }
+        _SEH_HANDLE
+        {
+            ret = RpcStatusToCmStatus(RpcExceptionCode());
+        }
+        _SEH_END;
+
         if (ret != CR_SUCCESS)
             return CR_FAILURE;
     }
     TRACE("DeviceIdBuffer: %s\n", debugstr_w(DeviceIdBuffer));
 
-    /* Validate the device ID */
-    ret = PNP_ValidateDeviceInstance(BindingHandle,
-                                     DeviceIdBuffer,
-                                     ulFlags);
+    _SEH_TRY
+    {
+        /* Validate the device ID */
+        ret = PNP_ValidateDeviceInstance(BindingHandle,
+                                         DeviceIdBuffer,
+                                         ulFlags);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
     if (ret == CR_SUCCESS)
     {
         *pdnDevInst = StringTableAddString(StringTable, DeviceIdBuffer, 1);
@@ -2708,6 +3003,7 @@ CONFIGRET WINAPI CM_Move_DevNode_Ex(
     HSTRING_TABLE StringTable = NULL;
     LPWSTR lpFromDevInst;
     LPWSTR lpToDevInst;
+    CONFIGRET ret;
 
     FIXME("%lx %lx %lx %lx\n",
           dnFromDevInst, dnToDevInst, ulFlags, hMachine);
@@ -2745,11 +3041,21 @@ CONFIGRET WINAPI CM_Move_DevNode_Ex(
     if (lpToDevInst == NULL)
         return CR_INVALID_DEVNODE;
 
-    return PNP_DeviceInstanceAction(BindingHandle,
-                                    2,
-                                    ulFlags,
-                                    lpFromDevInst,
-                                    lpToDevInst);
+    _SEH_TRY
+    {
+        ret = PNP_DeviceInstanceAction(BindingHandle,
+                                       2,
+                                       ulFlags,
+                                       lpFromDevInst,
+                                       lpToDevInst);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -2962,6 +3268,7 @@ CM_Reenumerate_DevNode_Ex(
     RPC_BINDING_HANDLE BindingHandle = NULL;
     HSTRING_TABLE StringTable = NULL;
     LPWSTR lpDevInst;
+    CONFIGRET ret;
 
     FIXME("%lx %lx %lx\n", dnDevInst, ulFlags, hMachine);
 
@@ -2991,11 +3298,21 @@ CM_Reenumerate_DevNode_Ex(
     if (lpDevInst == NULL)
         return CR_INVALID_DEVNODE;
 
-    return PNP_DeviceInstanceAction(BindingHandle,
-                                    7,
-                                    ulFlags,
-                                    lpDevInst,
-                                    NULL);
+    _SEH_TRY
+    {
+        ret = PNP_DeviceInstanceAction(BindingHandle,
+                                       7,
+                                       ulFlags,
+                                       lpDevInst,
+                                       NULL);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -3016,6 +3333,7 @@ CONFIGRET WINAPI CM_Request_Eject_PC_Ex(
     HMACHINE hMachine)
 {
     RPC_BINDING_HANDLE BindingHandle = NULL;
+    CONFIGRET ret;
 
     TRACE("%lx\n", hMachine);
 
@@ -3031,7 +3349,17 @@ CONFIGRET WINAPI CM_Request_Eject_PC_Ex(
             return CR_FAILURE;
     }
 
-    return PNP_RequestEjectPC(BindingHandle);
+    _SEH_TRY
+    {
+        ret = PNP_RequestEjectPC(BindingHandle);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -3053,6 +3381,7 @@ CONFIGRET WINAPI CM_Run_Detection_Ex(
     ULONG ulFlags, HMACHINE hMachine)
 {
     RPC_BINDING_HANDLE BindingHandle = NULL;
+    CONFIGRET ret;
 
     TRACE("%lx %lx\n", ulFlags, hMachine);
 
@@ -3074,8 +3403,18 @@ CONFIGRET WINAPI CM_Run_Detection_Ex(
             return CR_FAILURE;
     }
 
-    return PNP_RunDetection(BindingHandle,
-                            ulFlags);
+    _SEH_TRY
+    {
+        ret = PNP_RunDetection(BindingHandle,
+                               ulFlags);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -3099,6 +3438,7 @@ CONFIGRET WINAPI CM_Set_DevNode_Problem_Ex(
     RPC_BINDING_HANDLE BindingHandle = NULL;
     HSTRING_TABLE StringTable = NULL;
     LPWSTR lpDevInst;
+    CONFIGRET ret;
 
     TRACE("%lx %lx %lx %lx\n", dnDevInst, ulProblem, ulFlags, hMachine);
 
@@ -3128,10 +3468,20 @@ CONFIGRET WINAPI CM_Set_DevNode_Problem_Ex(
     if (lpDevInst == NULL)
         return CR_INVALID_DEVNODE;
 
-    return PNP_SetDeviceProblem(BindingHandle,
-                                lpDevInst,
-                                ulProblem,
-                                ulFlags);
+    _SEH_TRY
+    {
+        ret = PNP_SetDeviceProblem(BindingHandle,
+                                   lpDevInst,
+                                   ulProblem,
+                                   ulFlags);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -3309,6 +3659,7 @@ CONFIGRET WINAPI CM_Set_DevNode_Registry_Property_ExW(
     HSTRING_TABLE StringTable = NULL;
     LPWSTR lpDevInst;
     ULONG ulType;
+    CONFIGRET ret;
 
     TRACE("%lx %lu %p %lx %lx %lx\n",
           dnDevInst, ulProperty, Buffer, ulLength, ulFlags, hMachine);
@@ -3403,13 +3754,23 @@ CONFIGRET WINAPI CM_Set_DevNode_Registry_Property_ExW(
             return CR_INVALID_PROPERTY;
     }
 
-    return PNP_SetDeviceRegProp(BindingHandle,
-                                lpDevInst,
-                                ulProperty,
-                                ulType,
-                                (BYTE *)Buffer,
-                                ulLength,
-                                ulFlags);
+    _SEH_TRY
+    {
+        ret = PNP_SetDeviceRegProp(BindingHandle,
+                                   lpDevInst,
+                                   ulProperty,
+                                   ulType,
+                                   (BYTE *)Buffer,
+                                   ulLength,
+                                   ulFlags);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -3478,6 +3839,7 @@ CONFIGRET WINAPI CM_Set_HW_Prof_Flags_ExW(
     ULONG ulFlags, HMACHINE hMachine)
 {
     RPC_BINDING_HANDLE BindingHandle = NULL;
+    CONFIGRET ret;
 
     FIXME("%s %lu %lu %lx %lx\n", debugstr_w(szDevInstName),
           ulConfig, ulValue, ulFlags, hMachine);
@@ -3502,8 +3864,18 @@ CONFIGRET WINAPI CM_Set_HW_Prof_Flags_ExW(
             return CR_FAILURE;
     }
 
-    return PNP_HwProfFlags(BindingHandle, PNP_SET_HWPROFFLAGS, szDevInstName,
-                           ulConfig, &ulValue, NULL, NULL, 0, 0);
+    _SEH_TRY
+    {
+        ret = PNP_HwProfFlags(BindingHandle, PNP_SET_HWPROFFLAGS, szDevInstName,
+                              ulConfig, &ulValue, NULL, NULL, 0, 0);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -3527,6 +3899,7 @@ CONFIGRET WINAPI CM_Setup_DevNode_Ex(
     RPC_BINDING_HANDLE BindingHandle = NULL;
     HSTRING_TABLE StringTable = NULL;
     LPWSTR lpDevInst;
+    CONFIGRET ret;
 
     FIXME("%lx %lx %lx\n", dnDevInst, ulFlags, hMachine);
 
@@ -3559,11 +3932,21 @@ CONFIGRET WINAPI CM_Setup_DevNode_Ex(
     if (lpDevInst == NULL)
         return CR_INVALID_DEVNODE;
 
-    return PNP_DeviceInstanceAction(BindingHandle,
-                                    3,
-                                    ulFlags,
-                                    lpDevInst,
-                                    NULL);
+    _SEH_TRY
+    {
+        ret = PNP_DeviceInstanceAction(BindingHandle,
+                                       3,
+                                       ulFlags,
+                                       lpDevInst,
+                                       NULL);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }
 
 
@@ -3587,6 +3970,7 @@ CONFIGRET WINAPI CM_Uninstall_DevNode_Ex(
     RPC_BINDING_HANDLE BindingHandle = NULL;
     HSTRING_TABLE StringTable = NULL;
     LPWSTR lpDevInst;
+    CONFIGRET ret;
 
     TRACE("%lx %lx %lx\n", dnPhantom, ulFlags, hMachine);
 
@@ -3616,7 +4000,17 @@ CONFIGRET WINAPI CM_Uninstall_DevNode_Ex(
     if (lpDevInst == NULL)
         return CR_INVALID_DEVNODE;
 
-    return PNP_UninstallDevInst(BindingHandle,
-                                lpDevInst,
-                                ulFlags);
+    _SEH_TRY
+    {
+        ret = PNP_UninstallDevInst(BindingHandle,
+                                   lpDevInst,
+                                   ulFlags);
+    }
+    _SEH_HANDLE
+    {
+        ret = RpcStatusToCmStatus(RpcExceptionCode());
+    }
+    _SEH_END;
+
+    return ret;
 }