[WUAUSERV] Make the wuauserv service startable and stoppable.

This commit is contained in:
Eric Kohl 2019-07-20 19:27:22 +02:00
parent ae99df1675
commit 8a631c8455
3 changed files with 13 additions and 5 deletions

View File

@ -1,6 +1,9 @@
spec2def(wuauserv.dll wuauserv.spec ADD_IMPORTLIB)
add_library(wuauserv MODULE
wuauserv.c
wuauserv.rc)
wuauserv.rc
${CMAKE_CURRENT_BINARY_DIR}/wuauserv.def)
set_module_type(wuauserv win32dll UNICODE)
add_importlibs(wuauserv advapi32 msvcrt kernel32 ntdll)

View File

@ -37,6 +37,9 @@ UpdateServiceStatus(DWORD dwState)
else
ServiceStatus.dwWaitHint = 0;
if (dwState == SERVICE_RUNNING)
ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
SetServiceStatus(ServiceStatusHandle,
&ServiceStatus);
DPRINT1("WU UpdateServiceStatus() called\n");
@ -52,8 +55,8 @@ ServiceControlHandler(DWORD dwControl,
{
case SERVICE_CONTROL_STOP:
DPRINT1("WU ServiceControlHandler() SERVICE_CONTROL_STOP received\n");
UpdateServiceStatus(SERVICE_STOPPED);
SetEvent(exitEvent);
UpdateServiceStatus(SERVICE_STOP_PENDING);
return ERROR_SUCCESS;
case SERVICE_CONTROL_PAUSE:
@ -74,7 +77,8 @@ ServiceControlHandler(DWORD dwControl,
case SERVICE_CONTROL_SHUTDOWN:
DPRINT1("WU ServiceControlHandler() SERVICE_CONTROL_SHUTDOWN received\n");
UpdateServiceStatus(SERVICE_STOPPED);
SetEvent(exitEvent);
UpdateServiceStatus(SERVICE_STOP_PENDING);
return ERROR_SUCCESS;
default :
@ -100,9 +104,10 @@ ServiceMain(DWORD argc, LPTSTR *argv)
return;
}
exitEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
UpdateServiceStatus(SERVICE_RUNNING);
exitEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
WaitForSingleObject(exitEvent, INFINITE);
CloseHandle(exitEvent);

View File

@ -1781,7 +1781,7 @@ HKLM,"SOFTWARE\Microsoft\Ole","EnableRemoteConnect",0x00000000,"N"
; SvcHost services
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost",,0x00000012
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost","DcomLaunch",0x00010000,"DcomLaunch","PlugPlay"
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost","netsvcs",0x00010000,"DHCP","BITS","lanmanserver","lanmanworkstation","Schedule","Themes","winmgmt","W32Time"
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost","netsvcs",0x00010000,"DHCP","BITS","lanmanserver","lanmanworkstation","Schedule","Themes","W32Time","winmgmt","wuauserv"
; Win32 config
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows",,0x00000012