Commit 72f298e3 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

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

parent 10fa32a3
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "wingdi.h" #include "wingdi.h"
#include "winuser.h" #include "winuser.h"
#include "winnls.h" #include "winnls.h"
#include "winsvc.h"
#include "setupapi.h" #include "setupapi.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h" #include "wine/heap.h"
...@@ -4694,9 +4695,12 @@ BOOL WINAPI SetupDiInstallDevice(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data) ...@@ -4694,9 +4695,12 @@ BOOL WINAPI SetupDiInstallDevice(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data)
static const WCHAR dothwW[] = {'.','H','W',0}; static const WCHAR dothwW[] = {'.','H','W',0};
static const WCHAR dotservicesW[] = {'.','S','e','r','v','i','c','e','s',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 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 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; UINT install_flags = SPINST_ALL;
HKEY driver_key, device_key; HKEY driver_key, device_key;
SC_HANDLE manager, service;
struct device *device; struct device *device;
struct driver *driver; struct driver *driver;
void *callback_ctx; void *callback_ctx;
...@@ -4757,6 +4761,7 @@ BOOL WINAPI SetupDiInstallDevice(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data) ...@@ -4757,6 +4761,7 @@ BOOL WINAPI SetupDiInstallDevice(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data)
strcatW(subsection, dotservicesW); strcatW(subsection, dotservicesW);
SetupInstallServicesFromInfSectionW(hinf, subsection, 0); SetupInstallServicesFromInfSectionW(hinf, subsection, 0);
svc_name[0] = 0;
if (SetupFindFirstLineW(hinf, subsection, addserviceW, &ctx)) if (SetupFindFirstLineW(hinf, subsection, addserviceW, &ctx))
{ {
do do
...@@ -4765,7 +4770,6 @@ BOOL WINAPI SetupDiInstallDevice(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data) ...@@ -4765,7 +4770,6 @@ BOOL WINAPI SetupDiInstallDevice(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data)
if (SetupGetIntField(&ctx, 2, &flags) && (flags & SPSVCINST_ASSOCSERVICE)) 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]) 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)); RegSetValueExW(device->key, Service, 0, REG_SZ, (BYTE *)svc_name, strlenW(svc_name) * sizeof(WCHAR));
break; break;
...@@ -4786,5 +4790,23 @@ BOOL WINAPI SetupDiInstallDevice(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data) ...@@ -4786,5 +4790,23 @@ BOOL WINAPI SetupDiInstallDevice(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data)
RegCloseKey(device_key); RegCloseKey(device_key);
RegCloseKey(driver_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; return TRUE;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment