Zebediah Figura : setupapi: Also start newly installed root PnP services in SetupDiInstallDevice().

Alexandre Julliard julliard at winehq.org
Thu Jun 27 15:33:51 CDT 2019


Module: wine
Branch: master
Commit: 72f298e3f7eafecbbcb4d93156d8439a406c365d
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=72f298e3f7eafecbbcb4d93156d8439a406c365d

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Wed Jun 26 22:32:26 2019 -0500

setupapi: Also start newly installed root PnP services in SetupDiInstallDevice().

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/setupapi/devinst.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c
index 743999d..a684a6c 100644
--- a/dlls/setupapi/devinst.c
+++ b/dlls/setupapi/devinst.c
@@ -31,6 +31,7 @@
 #include "wingdi.h"
 #include "winuser.h"
 #include "winnls.h"
+#include "winsvc.h"
 #include "setupapi.h"
 #include "wine/debug.h"
 #include "wine/heap.h"
@@ -4694,9 +4695,12 @@ BOOL WINAPI SetupDiInstallDevice(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data)
     static const WCHAR dothwW[] = {'.','H','W',0};
     static const WCHAR dotservicesW[] = {'.','S','e','r','v','i','c','e','s',0};
     static const WCHAR addserviceW[] = {'A','d','d','S','e','r','v','i','c','e',0};
+    static const WCHAR rootW[] = {'r','o','o','t','\\',0};
     WCHAR section[LINE_LEN], section_ext[LINE_LEN], subsection[LINE_LEN], inf_path[MAX_PATH], *extptr, *filepart;
+    WCHAR svc_name[LINE_LEN];
     UINT install_flags = SPINST_ALL;
     HKEY driver_key, device_key;
+    SC_HANDLE manager, service;
     struct device *device;
     struct driver *driver;
     void *callback_ctx;
@@ -4757,6 +4761,7 @@ BOOL WINAPI SetupDiInstallDevice(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data)
     strcatW(subsection, dotservicesW);
     SetupInstallServicesFromInfSectionW(hinf, subsection, 0);
 
+    svc_name[0] = 0;
     if (SetupFindFirstLineW(hinf, subsection, addserviceW, &ctx))
     {
         do
@@ -4765,7 +4770,6 @@ BOOL WINAPI SetupDiInstallDevice(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data)
 
             if (SetupGetIntField(&ctx, 2, &flags) && (flags & SPSVCINST_ASSOCSERVICE))
             {
-                WCHAR svc_name[LINE_LEN];
                 if (SetupGetStringFieldW(&ctx, 1, svc_name, ARRAY_SIZE(svc_name), NULL) && svc_name[0])
                     RegSetValueExW(device->key, Service, 0, REG_SZ, (BYTE *)svc_name, strlenW(svc_name) * sizeof(WCHAR));
                 break;
@@ -4786,5 +4790,23 @@ BOOL WINAPI SetupDiInstallDevice(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data)
 
     RegCloseKey(device_key);
     RegCloseKey(driver_key);
+
+    if (!strncmpiW(device->instanceId, rootW, strlenW(rootW)) && svc_name[0]
+            && (manager = OpenSCManagerW(NULL, NULL, SC_MANAGER_CONNECT)))
+    {
+        if ((service = OpenServiceW(manager, svc_name, SERVICE_START)))
+        {
+            if (!StartServiceW(service, 0, NULL) && GetLastError() != ERROR_SERVICE_ALREADY_RUNNING)
+            {
+                ERR("Failed to start service %s for device %s, error %u.\n",
+                        debugstr_w(svc_name), debugstr_w(device->instanceId), GetLastError());
+            }
+            CloseServiceHandle(service);
+        }
+        else
+            ERR("Failed to open service %s for device %s.\n", debugstr_w(svc_name), debugstr_w(device->instanceId));
+        CloseServiceHandle(manager);
+    }
+
     return TRUE;
 }




More information about the wine-cvs mailing list