[0.4.11][WMISVC][SRVSVC][WKSSVC][DHCPSVC][WUAUSERV] Start/Stop behavior

by partially porting back:
0.4.15-dev-xxx [WMISVC][WUAUSERV] Fix 2 DPRINTs that lack arguments
0.4.13-dev-684-g eab73ad1a4 [SRVSVC] Make the server service stoppable
0.4.13-dev-683-g 4073a8c58d [WKSSVC] Make the workstation service stoppable
0.4.13-dev-680-g eb532bc641 [WMISVC] Accept stop and shutdown commands when the service is running
0.4.12-dev-1063-g 15a828c86d [DHCPCSVC] Eliminate unused code and associated parameters

and revert 0.4.10-dev-558-g 55368bacc8 (#355) [WUAUSERV][WUSA]
on this branch as that Service stub does not even start in releases/0.4.10-0.4.12.
And it doesn't allow any application to run that wouldn't have run before.
Even with those changes the .NET4.5 and Python 3.5 mentioned in that PR don't work yet.
We postpone introduction of WUAUSERV to releases/0.4.13 therefore.
This commit is contained in:
Joachim Henze 2023-03-06 11:44:56 +01:00
parent ff024b30c3
commit 14e4939dc4
20 changed files with 22 additions and 279 deletions

View file

@ -43,4 +43,3 @@ add_subdirectory(winhlp32)
add_subdirectory(winver)
add_subdirectory(wordpad)
add_subdirectory(write)
add_subdirectory(wusa)

View file

@ -1,6 +0,0 @@
add_rc_deps(resource.rc ${CMAKE_CURRENT_SOURCE_DIR}/res/setup.ico)
add_executable(wusa wusa.c resource.rc)
set_module_type(wusa win32gui UNICODE)
add_importlibs(wusa shell32 msvcrt kernel32)
add_cd_file(TARGET wusa DESTINATION reactos/system32 FOR all)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

View file

@ -1,3 +0,0 @@
#pragma once
#define IDI_WUSA 101

View file

@ -1,14 +0,0 @@
#include <windef.h>
#include "resource.h"
/* Common resources */
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS WUSA stub"
#define REACTOS_STR_INTERNAL_NAME "wusa"
#define REACTOS_STR_ORIGINAL_FILENAME "wusa.exe"
#include <reactos/version.rc>
IDI_WUSA ICON "res/setup.ico"

View file

@ -1,19 +0,0 @@
/*
* PROJECT: ReactOS Update Service
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Windows Update Stand-Alone installer.
* Stub is required for some application at the installation phase.
* COPYRIGHT: Copyright 2018 Denis Malikov (filedem@gmail.com)
*/
#include "wusa.h"
int
WINAPI
wWinMain(HINSTANCE hCurInst,
HINSTANCE hPrevInst,
LPWSTR lpsCmdLine,
int nCmdShow)
{
return 0;
}

View file

@ -1,4 +0,0 @@
#define WIN32_NO_STATUS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <wchar.h>

View file

@ -15,4 +15,3 @@ add_subdirectory(umpnpmgr)
add_subdirectory(wkssvc)
add_subdirectory(wlansvc)
add_subdirectory(wmisvc)
add_subdirectory(wuauserv)

View file

@ -1288,7 +1288,7 @@ make_discover(struct interface_info *ip, struct client_lease *lease)
/* Set up the option buffer... */
ip->client->packet_length = cons_options(NULL, &ip->client->packet, 0,
options, 0, 0, 0, NULL, 0);
options);
if (ip->client->packet_length < BOOTP_MIN_LEN)
ip->client->packet_length = BOOTP_MIN_LEN;
@ -1380,7 +1380,7 @@ make_request(struct interface_info *ip, struct client_lease * lease)
/* Set up the option buffer... */
ip->client->packet_length = cons_options(NULL, &ip->client->packet, 0,
options, 0, 0, 0, NULL, 0);
options);
if (ip->client->packet_length < BOOTP_MIN_LEN)
ip->client->packet_length = BOOTP_MIN_LEN;
@ -1464,7 +1464,7 @@ make_decline(struct interface_info *ip, struct client_lease *lease)
/* Set up the option buffer... */
ip->client->packet_length = cons_options(NULL, &ip->client->packet, 0,
options, 0, 0, 0, NULL, 0);
options);
if (ip->client->packet_length < BOOTP_MIN_LEN)
ip->client->packet_length = BOOTP_MIN_LEN;

View file

@ -49,7 +49,7 @@ int bad_options_max = 5;
void parse_options(struct packet *);
void parse_option_buffer(struct packet *, unsigned char *, int);
int store_options(unsigned char *, int, struct tree_cache **,
unsigned char *, int, int, int, int);
unsigned char *, int, int, int);
/*
@ -197,12 +197,10 @@ parse_option_buffer(struct packet *packet,
*/
int
cons_options(struct packet *inpacket, struct dhcp_packet *outpacket,
int mms, struct tree_cache **options,
int overload, /* Overload flags that may be set. */
int terminate, int bootpp, u_int8_t *prl, int prl_len)
int mms, struct tree_cache **options)
{
unsigned char priority_list[300], buffer[4096];
int priority_len, main_buffer_size, mainbufix, bufix;
int priority_len, main_buffer_size, mainbufix;
int option_size, length;
/*
@ -223,8 +221,6 @@ cons_options(struct packet *inpacket, struct dhcp_packet *outpacket,
if (mms)
main_buffer_size = mms - DHCP_FIXED_LEN;
else if (bootpp)
main_buffer_size = 64;
else
main_buffer_size = 576 - DHCP_FIXED_LEN;
@ -254,14 +250,6 @@ cons_options(struct packet *inpacket, struct dhcp_packet *outpacket,
inpacket->options[DHO_DHCP_PARAMETER_REQUEST_LIST].data,
prlen);
priority_len += prlen;
prl = priority_list;
} else if (prl) {
if (prl_len + priority_len > sizeof(priority_list))
prl_len = sizeof(priority_list) - priority_len;
memcpy(&priority_list[priority_len], prl, prl_len);
priority_len += prl_len;
prl = priority_list;
} else {
memcpy(&priority_list[priority_len],
dhcp_option_default_priority_list,
@ -272,11 +260,9 @@ cons_options(struct packet *inpacket, struct dhcp_packet *outpacket,
/* Copy the options into the big buffer... */
option_size = store_options(
buffer,
(main_buffer_size - 7 + ((overload & 1) ? DHCP_FILE_LEN : 0) +
((overload & 2) ? DHCP_SNAME_LEN : 0)),
main_buffer_size - 7,
options, priority_list, priority_len, main_buffer_size,
(main_buffer_size + ((overload & 1) ? DHCP_FILE_LEN : 0)),
terminate);
main_buffer_size);
/* Put the cookie up front... */
memcpy(outpacket->options, DHCP_OPTIONS_COOKIE, 4);
@ -305,33 +291,7 @@ cons_options(struct packet *inpacket, struct dhcp_packet *outpacket,
memcpy(&outpacket->options[mainbufix],
buffer, main_buffer_size - mainbufix);
bufix = main_buffer_size - mainbufix;
length = DHCP_FIXED_NON_UDP + mainbufix;
if (overload & 1) {
if (option_size - bufix <= DHCP_FILE_LEN) {
memcpy(outpacket->file,
&buffer[bufix], option_size - bufix);
mainbufix = option_size - bufix;
if (mainbufix < DHCP_FILE_LEN)
outpacket->file[mainbufix++] = (char)DHO_END;
while (mainbufix < DHCP_FILE_LEN)
outpacket->file[mainbufix++] = (char)DHO_PAD;
} else {
memcpy(outpacket->file,
&buffer[bufix], DHCP_FILE_LEN);
bufix += DHCP_FILE_LEN;
}
}
if ((overload & 2) && option_size < bufix) {
memcpy(outpacket->sname,
&buffer[bufix], option_size - bufix);
mainbufix = option_size - bufix;
if (mainbufix < DHCP_SNAME_LEN)
outpacket->file[mainbufix++] = (char)DHO_END;
while (mainbufix < DHCP_SNAME_LEN)
outpacket->file[mainbufix++] = (char)DHO_PAD;
}
}
return (length);
}
@ -342,9 +302,9 @@ cons_options(struct packet *inpacket, struct dhcp_packet *outpacket,
int
store_options(unsigned char *buffer, int buflen, struct tree_cache **options,
unsigned char *priority_list, int priority_len, int first_cutoff,
int second_cutoff, int terminate)
int second_cutoff)
{
int bufix = 0, option_stored[256], i, ix, tto;
int bufix = 0, option_stored[256], i, ix;
/* Zero out the stored-lengths array. */
memset(option_stored, 0, sizeof(option_stored));
@ -380,13 +340,6 @@ store_options(unsigned char *buffer, int buflen, struct tree_cache **options,
/* We should now have a constant length for the option. */
length = options[code]->len;
/* Do we add a NUL? */
if (terminate && dhcp_options[code].format[0] == 't') {
length++;
tto = 1;
} else
tto = 0;
/* Try to store the option. */
/*
@ -426,13 +379,8 @@ store_options(unsigned char *buffer, int buflen, struct tree_cache **options,
/* Everything looks good - copy it in! */
buffer[bufix] = code;
buffer[bufix + 1] = incr;
if (tto && incr == length) {
memcpy(buffer + bufix + 2,
options[code]->value + ix, incr - 1);
buffer[bufix + 2 + incr - 1] = 0;
} else
memcpy(buffer + bufix + 2,
options[code]->value + ix, incr);
memcpy(buffer + bufix + 2,
options[code]->value + ix, incr);
length -= incr;
ix += incr;
bufix += 2 + incr;

View file

@ -282,7 +282,7 @@ struct hash_table {
/* options.c */
int cons_options(struct packet *, struct dhcp_packet *, int,
struct tree_cache **, int, int, int, u_int8_t *, int);
struct tree_cache **);
char *pretty_print_option(unsigned int,
unsigned char *, int, int, int);
void do_packet(struct interface_info *, struct dhcp_packet *,

View file

@ -60,6 +60,9 @@ UpdateServiceStatus(DWORD dwState)
else
ServiceStatus.dwWaitHint = 0;
if (dwState == SERVICE_RUNNING)
ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
SetServiceStatus(ServiceStatusHandle,
&ServiceStatus);
}

View file

@ -57,6 +57,9 @@ UpdateServiceStatus(DWORD dwState)
else
ServiceStatus.dwWaitHint = 0;
if (dwState == SERVICE_RUNNING)
ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
SetServiceStatus(ServiceStatusHandle,
&ServiceStatus);
}

View file

@ -65,6 +65,9 @@ UpdateServiceStatus(DWORD dwState)
else
ServiceStatus.dwWaitHint = 0;
if (dwState == SERVICE_RUNNING)
ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
SetServiceStatus(ServiceStatusHandle,
&ServiceStatus);
}
@ -106,7 +109,6 @@ ServiceControlHandler(DWORD dwControl,
return ERROR_SUCCESS;
default :
DPRINT1(" Control %lu received\n");
return ERROR_CALL_NOT_IMPLEMENTED;
}
}

View file

@ -1,7 +0,0 @@
add_library(wuauserv SHARED
wuauserv.c
wuauserv.rc)
set_module_type(wuauserv win32dll UNICODE)
add_importlibs(wuauserv advapi32 msvcrt kernel32 ntdll)
add_cd_file(TARGET wuauserv DESTINATION reactos/system32 FOR all)

View file

@ -1,128 +0,0 @@
/*
* PROJECT: ReactOS Update Service
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Automatic Updates service stub.
* Stub is required for some application at the installation phase.
* COPYRIGHT: Copyright 2018 Denis Malikov (filedem@gmail.com)
*/
#include "wuauserv.h"
/* GLOBALS ******************************************************************/
static WCHAR ServiceName[] = L"wuauserv";
static SERVICE_STATUS_HANDLE ServiceStatusHandle;
static SERVICE_STATUS ServiceStatus;
static HANDLE exitEvent = NULL;
/* FUNCTIONS *****************************************************************/
static VOID
UpdateServiceStatus(DWORD dwState)
{
ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
ServiceStatus.dwCurrentState = dwState;
ServiceStatus.dwControlsAccepted = 0;
ServiceStatus.dwWin32ExitCode = 0;
ServiceStatus.dwServiceSpecificExitCode = 0;
ServiceStatus.dwCheckPoint = 0;
if (dwState == SERVICE_START_PENDING ||
dwState == SERVICE_STOP_PENDING ||
dwState == SERVICE_PAUSE_PENDING ||
dwState == SERVICE_CONTINUE_PENDING)
ServiceStatus.dwWaitHint = 1000;
else
ServiceStatus.dwWaitHint = 0;
SetServiceStatus(ServiceStatusHandle,
&ServiceStatus);
DPRINT1("WU UpdateServiceStatus() called\n");
}
static DWORD WINAPI
ServiceControlHandler(DWORD dwControl,
DWORD dwEventType,
LPVOID lpEventData,
LPVOID lpContext)
{
switch (dwControl)
{
case SERVICE_CONTROL_STOP:
DPRINT1("WU ServiceControlHandler() SERVICE_CONTROL_STOP received\n");
UpdateServiceStatus(SERVICE_STOPPED);
SetEvent(exitEvent);
return ERROR_SUCCESS;
case SERVICE_CONTROL_PAUSE:
DPRINT1("WU ServiceControlHandler() SERVICE_CONTROL_PAUSE received\n");
UpdateServiceStatus(SERVICE_PAUSED);
return ERROR_SUCCESS;
case SERVICE_CONTROL_CONTINUE:
DPRINT1("WU ServiceControlHandler() SERVICE_CONTROL_CONTINUE received\n");
UpdateServiceStatus(SERVICE_RUNNING);
return ERROR_SUCCESS;
case SERVICE_CONTROL_INTERROGATE:
DPRINT1("WU ServiceControlHandler() SERVICE_CONTROL_INTERROGATE received\n");
SetServiceStatus(ServiceStatusHandle,
&ServiceStatus);
return ERROR_SUCCESS;
case SERVICE_CONTROL_SHUTDOWN:
DPRINT1("WU ServiceControlHandler() SERVICE_CONTROL_SHUTDOWN received\n");
UpdateServiceStatus(SERVICE_STOPPED);
return ERROR_SUCCESS;
default :
DPRINT1("WU ServiceControlHandler() Control %lu received\n");
return ERROR_CALL_NOT_IMPLEMENTED;
}
}
VOID WINAPI
ServiceMain(DWORD argc, LPTSTR *argv)
{
UNREFERENCED_PARAMETER(argc);
UNREFERENCED_PARAMETER(argv);
DPRINT("WU ServiceMain() called\n");
ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName,
ServiceControlHandler,
NULL);
if (!ServiceStatusHandle)
{
DPRINT1("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
return;
}
UpdateServiceStatus(SERVICE_RUNNING);
exitEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
WaitForSingleObject(exitEvent, INFINITE);
CloseHandle(exitEvent);
UpdateServiceStatus(SERVICE_STOPPED);
}
BOOL WINAPI
DllMain(HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

View file

@ -1,11 +0,0 @@
#define WIN32_NO_STATUS
#define _INC_WINDOWS
#define COM_NO_WINDOWS_H
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <winsvc.h>
#define NDEBUG
#include <debug.h>

View file

@ -1,5 +0,0 @@
#define REACTOS_VERSION_DLL
#define REACTOS_STR_FILE_DESCRIPTION "AutoUpdate Service Stub"
#define REACTOS_STR_INTERNAL_NAME "wuauserv"
#define REACTOS_STR_ORIGINAL_FILENAME "wuauserv.dll"
#include <reactos/version.rc>

View file

@ -1 +0,0 @@
@ stdcall ServiceMain(long ptr)

View file

@ -2047,16 +2047,6 @@ HKLM,"SYSTEM\CurrentControlSet\Services\winmgmt","Start",0x00010001,0x00000002
HKLM,"SYSTEM\CurrentControlSet\Services\winmgmt","Type",0x00010001,0x00000020
HKLM,"SYSTEM\CurrentControlSet\Services\winmgmt\Parameters","ServiceDll",0x00020000,"%SystemRoot%\system32\wbem\wmisvc.dll"
; AutoUpdate Service
HKLM,"SYSTEM\CurrentControlSet\Services\wuauserv","DisplayName",0x00000000,%WUAUSERV_SERVICE%
HKLM,"SYSTEM\CurrentControlSet\Services\wuauserv","Description",0x00000000,%WUAUSERV_SERVICE_DESCRIPTION%
HKLM,"SYSTEM\CurrentControlSet\Services\wuauserv","ErrorControl",0x00010001,0x00000001
HKLM,"SYSTEM\CurrentControlSet\Services\wuauserv","ImagePath",0x00020000,"%SystemRoot%\system32\svchost.exe -k netsvcs"
HKLM,"SYSTEM\CurrentControlSet\Services\wuauserv","ObjectName",0x00000000,"LocalSystem"
HKLM,"SYSTEM\CurrentControlSet\Services\wuauserv","Start",0x00010001,0x00000002
HKLM,"SYSTEM\CurrentControlSet\Services\wuauserv","Type",0x00010001,0x00000020
HKLM,"SYSTEM\CurrentControlSet\Services\wuauserv\Parameters","ServiceDll",0x00020000,"%SystemRoot%\system32\wuauserv.dll"
; Sound Blaster (NT4)
;HKLM,"SYSTEM\CurrentControlSet\Services\sndblst","Description",0x00000000,"Sound Blaster (NT4)"
;HKLM,"SYSTEM\CurrentControlSet\Services\sndblst","ErrorControl",0x00010001,0x00000001
@ -2213,9 +2203,6 @@ THEMES_SERVICE_DESCRIPTION="Themes support"
WINMGMT_SERVICE="ReactOS Management Infrastructure"
WINMGMT_SERVICE_DESCRIPTION="Provides interface to system management information."
WUAUSERV_SERVICE="Automatic Updates"
WUAUSERV_SERVICE_DESCRIPTION="AutoUpdate Service stub."
WLANSVC_SERVICE="WLAN Service"
WLANSVC_SERVICE_DESCRIPTION="WLAN Service"