[PATCH v2 4/6] setupapi: Reënumerate root PnP devices in SetupDiInstallDevice().

Zebediah Figura z.figura12 at gmail.com
Thu Apr 1 20:51:28 CDT 2021


If the service is already running, starting it has no effect.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/setupapi/devinst.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c
index de0413e74f5..0a396cc8464 100644
--- a/dlls/setupapi/devinst.c
+++ b/dlls/setupapi/devinst.c
@@ -104,6 +104,8 @@ static const WCHAR AddInterface[] = {'A','d','d','I','n','t','e','r','f','a','c'
 static const WCHAR backslashW[] = {'\\',0};
 static const WCHAR emptyW[] = {0};
 
+#define SERVICE_CONTROL_REENUMERATE_ROOT_DEVICES 128
+
 struct driver
 {
     WCHAR inf_path[MAX_PATH];
@@ -5123,13 +5125,20 @@ BOOL WINAPI SetupDiInstallDevice(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data)
     if (!wcsnicmp(device->instanceId, rootW, lstrlenW(rootW)) && svc_name[0]
             && (manager = OpenSCManagerW(NULL, NULL, SC_MANAGER_CONNECT)))
     {
-        if ((service = OpenServiceW(manager, svc_name, SERVICE_START)))
+        if ((service = OpenServiceW(manager, svc_name, SERVICE_START | SERVICE_USER_DEFINED_CONTROL)))
         {
+            SERVICE_STATUS status;
+
             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());
             }
+            if (!ControlService(service, SERVICE_CONTROL_REENUMERATE_ROOT_DEVICES, &status))
+            {
+                ERR("Failed to control service %s for device %s, error %u.\n",
+                        debugstr_w(svc_name), debugstr_w(device->instanceId), GetLastError());
+            }
             CloseServiceHandle(service);
         }
         else
-- 
2.30.2




More information about the wine-devel mailing list