mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[0.4.7][WMISVC][SRVSVC][WKSSVC][DHCPSVC][RPCSS] Start/Stop behavior
by partially porting back: 0.4.15-dev-xxx [WMISVC] Fix DPRINT that lacks arguments 0.4.13-dev-684-geab73ad1a4
[SRVSVC] Make the server service stoppable 0.4.13-dev-683-g4073a8c58d
[WKSSVC] Make the workstation service stoppable 0.4.13-dev-680-geb532bc641
[WMISVC] Accept stop and shutdown commands when the service is running 0.4.12-dev-1063-g15a828c86d
[DHCPCSVC] Eliminate unused code and associated parameters 0.4.9-dev-547-g444338ae2e
[RPCSS] Sync with Wine Staging 3.3. CORE-14434 partially 0.4.9-dev-351-g9febc82acf
[DHCPCSVC] Add the ability to stop the DHCP client (first part of CORE-14390)
This commit is contained in:
parent
5be32e53ce
commit
1f2ecdf449
17 changed files with 143 additions and 324 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -75,9 +75,9 @@ dispatch(void)
|
|||
if (!Events[0])
|
||||
return;
|
||||
AdapterStateChangedEvent = Events[0];
|
||||
|
||||
|
||||
Events[1] = WSA_INVALID_EVENT;
|
||||
|
||||
|
||||
ApiLock();
|
||||
|
||||
do {
|
||||
|
@ -155,7 +155,7 @@ dispatch(void)
|
|||
else if (count == WAIT_OBJECT_0 + 1)
|
||||
{
|
||||
/* Packet received */
|
||||
|
||||
|
||||
/* WSA events are manual reset events */
|
||||
WSAResetEvent(Events[1]);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -328,7 +328,10 @@ UpdateServiceStatus(DWORD dwState)
|
|||
ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
|
||||
ServiceStatus.dwCurrentState = dwState;
|
||||
|
||||
ServiceStatus.dwControlsAccepted = 0;
|
||||
if (dwState == SERVICE_RUNNING)
|
||||
ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_SHUTDOWN | SERVICE_ACCEPT_STOP;
|
||||
else
|
||||
ServiceStatus.dwControlsAccepted = 0;
|
||||
|
||||
ServiceStatus.dwWin32ExitCode = 0;
|
||||
ServiceStatus.dwServiceSpecificExitCode = 0;
|
||||
|
@ -378,7 +381,7 @@ ServiceControlHandler(DWORD dwControl,
|
|||
UpdateServiceStatus(SERVICE_STOPPED);
|
||||
return ERROR_SUCCESS;
|
||||
|
||||
default :
|
||||
default:
|
||||
return ERROR_CALL_NOT_IMPLEMENTED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 *,
|
||||
|
|
|
@ -8,8 +8,7 @@ list(APPEND SOURCE
|
|||
epmp.c
|
||||
irotp.c
|
||||
rpcss_main.c
|
||||
service_main.c
|
||||
rpcss.h
|
||||
precomp.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/epm_s.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/irot_s.c)
|
||||
|
||||
|
@ -18,5 +17,5 @@ add_executable(rpcss ${SOURCE} rpcss.rc)
|
|||
target_link_libraries(rpcss ${PSEH_LIB} wine)
|
||||
set_module_type(rpcss win32cui UNICODE)
|
||||
add_importlibs(rpcss advapi32 rpcrt4 msvcrt kernel32 ntdll)
|
||||
add_pch(rpcss rpcss.h SOURCE)
|
||||
add_pch(rpcss precomp.h SOURCE)
|
||||
add_cd_file(TARGET rpcss DESTINATION reactos/system32 FOR all)
|
||||
|
|
|
@ -18,9 +18,10 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "rpcss.h"
|
||||
#include "epm_s.h"
|
||||
|
||||
#include <wine/debug.h>
|
||||
#include "wine/debug.h"
|
||||
#include "wine/list.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
||||
|
||||
|
|
|
@ -18,9 +18,17 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "rpcss.h"
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <wine/debug.h>
|
||||
#include "winerror.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
||||
#include "irot_s.h"
|
||||
|
||||
#include "wine/list.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(rpcss);
|
||||
|
||||
|
|
22
base/services/rpcss/precomp.h
Normal file
22
base/services/rpcss/precomp.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
#ifndef _RPCSS_PRECOMP_H_
|
||||
#define _RPCSS_PRECOMP_H_
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#define WIN32_NO_STATUS
|
||||
#define _INC_WINDOWS
|
||||
#define COM_NO_WINDOWS_H
|
||||
|
||||
#define NONAMELESSUNION
|
||||
#define NONAMELESSSTRUCT
|
||||
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
|
||||
#include <irot_s.h>
|
||||
#include <epm_s.h>
|
||||
|
||||
#include <wine/list.h>
|
||||
|
||||
#endif /* !_RPCSS_PRECOMP_H_ */
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* RPCSS definitions
|
||||
*
|
||||
* Copyright (C) 2002 Greg Turner
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef __WINE_RPCSS_H
|
||||
#define __WINE_RPCSS_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#define WIN32_NO_STATUS
|
||||
#define _INC_WINDOWS
|
||||
#define COM_NO_WINDOWS_H
|
||||
|
||||
#define NONAMELESSUNION
|
||||
#define NONAMELESSSTRUCT
|
||||
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
|
||||
#include <irot_s.h>
|
||||
#include <epm_s.h>
|
||||
|
||||
#include <wine/list.h>
|
||||
|
||||
#endif /* __WINE_RPCSS_H */
|
|
@ -15,45 +15,29 @@
|
|||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
* ---- rpcss_main.c:
|
||||
* Initialize and start serving requests. Bail if rpcss already is
|
||||
* running.
|
||||
*
|
||||
* ---- RPCSS.EXE:
|
||||
*
|
||||
* Wine needs a server whose role is somewhat like that
|
||||
* of rpcss.exe in windows. This is not a clone of
|
||||
* windows rpcss at all. It has been given the same name, however,
|
||||
* to provide for the possibility that at some point in the future,
|
||||
* it may become interface compatible with the "real" rpcss.exe on
|
||||
* Windows.
|
||||
*
|
||||
* ---- KNOWN BUGS / TODO:
|
||||
*
|
||||
* o Service hooks are unimplemented (if you bother to implement
|
||||
* these, also implement net.exe, at least for "net start" and
|
||||
* "net stop" (should be pretty easy I guess, assuming the rest
|
||||
* of the services API infrastructure works.
|
||||
*
|
||||
* o There is a looming problem regarding listening on privileged
|
||||
* ports. We will need to be able to coexist with SAMBA, and be able
|
||||
* to function without running winelib code as root. This may
|
||||
* take some doing, including significant reconceptualization of the
|
||||
* role of rpcss.exe in wine.
|
||||
*/
|
||||
|
||||
#include "rpcss.h"
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <wine/debug.h>
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winnt.h"
|
||||
#include "winsvc.h"
|
||||
#include "irot_s.h"
|
||||
#include "epm_s.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
||||
|
||||
HANDLE exit_event;
|
||||
static WCHAR rpcssW[] = {'R','p','c','S','s',0};
|
||||
static HANDLE exit_event;
|
||||
static SERVICE_STATUS_HANDLE service_handle;
|
||||
|
||||
//extern HANDLE __wine_make_process_system(void);
|
||||
|
||||
BOOL RPCSS_Initialize(void)
|
||||
static BOOL RPCSS_Initialize(void)
|
||||
{
|
||||
static unsigned short irot_protseq[] = IROT_PROTSEQ;
|
||||
static unsigned short irot_endpoint[] = IROT_ENDPOINT;
|
||||
|
@ -94,16 +78,6 @@ BOOL RPCSS_Initialize(void)
|
|||
if (status != RPC_S_OK)
|
||||
goto fail;
|
||||
|
||||
#ifndef __REACTOS__
|
||||
exit_event = __wine_make_process_system();
|
||||
#else
|
||||
exit_event = CreateEventW(NULL, FALSE, FALSE, NULL); // never fires
|
||||
{
|
||||
HANDLE hStartEvent = CreateEventW(NULL, TRUE, FALSE, L"ScmCreatedEvent");
|
||||
SetEvent(hStartEvent);
|
||||
}
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
|
||||
fail:
|
||||
|
@ -112,33 +86,71 @@ fail:
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* returns false if we discover at the last moment that we
|
||||
aren't ready to terminate */
|
||||
BOOL RPCSS_Shutdown(void)
|
||||
static DWORD WINAPI service_handler( DWORD ctrl, DWORD event_type, LPVOID event_data, LPVOID context )
|
||||
{
|
||||
RpcMgmtStopServerListening(NULL);
|
||||
RpcServerUnregisterIf(epm_v3_0_s_ifspec, NULL, TRUE);
|
||||
RpcServerUnregisterIf(Irot_v0_2_s_ifspec, NULL, TRUE);
|
||||
SERVICE_STATUS status;
|
||||
|
||||
CloseHandle(exit_event);
|
||||
status.dwServiceType = SERVICE_WIN32;
|
||||
status.dwControlsAccepted = SERVICE_ACCEPT_STOP;
|
||||
status.dwWin32ExitCode = 0;
|
||||
status.dwServiceSpecificExitCode = 0;
|
||||
status.dwCheckPoint = 0;
|
||||
status.dwWaitHint = 0;
|
||||
|
||||
return TRUE;
|
||||
switch (ctrl)
|
||||
{
|
||||
case SERVICE_CONTROL_STOP:
|
||||
case SERVICE_CONTROL_SHUTDOWN:
|
||||
RpcMgmtStopServerListening( NULL );
|
||||
RpcServerUnregisterIf( epm_v3_0_s_ifspec, NULL, TRUE );
|
||||
RpcServerUnregisterIf( Irot_v0_2_s_ifspec, NULL, TRUE );
|
||||
status.dwCurrentState = SERVICE_STOP_PENDING;
|
||||
status.dwControlsAccepted = 0;
|
||||
SetServiceStatus( service_handle, &status );
|
||||
SetEvent( exit_event );
|
||||
return NO_ERROR;
|
||||
default:
|
||||
status.dwCurrentState = SERVICE_RUNNING;
|
||||
SetServiceStatus( service_handle, &status );
|
||||
return NO_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __REACTOS__
|
||||
int main( int argc, char **argv )
|
||||
static void WINAPI ServiceMain( DWORD argc, LPWSTR *argv )
|
||||
{
|
||||
/*
|
||||
* We are invoked as a standard executable; we act in a
|
||||
* "lazy" manner. We register our interfaces and endpoints, and hang around
|
||||
* until we all user processes exit, and then silently terminate.
|
||||
*/
|
||||
SERVICE_STATUS status;
|
||||
|
||||
if (RPCSS_Initialize()) {
|
||||
WaitForSingleObject(exit_event, INFINITE);
|
||||
RPCSS_Shutdown();
|
||||
}
|
||||
if (!RPCSS_Initialize()) return;
|
||||
|
||||
return 0;
|
||||
exit_event = CreateEventW( NULL, TRUE, FALSE, NULL );
|
||||
|
||||
service_handle = RegisterServiceCtrlHandlerExW( rpcssW, service_handler, NULL );
|
||||
if (!service_handle) return;
|
||||
|
||||
status.dwServiceType = SERVICE_WIN32;
|
||||
status.dwCurrentState = SERVICE_RUNNING;
|
||||
status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
|
||||
status.dwWin32ExitCode = 0;
|
||||
status.dwServiceSpecificExitCode = 0;
|
||||
status.dwCheckPoint = 0;
|
||||
status.dwWaitHint = 10000;
|
||||
SetServiceStatus( service_handle, &status );
|
||||
|
||||
WaitForSingleObject( exit_event, INFINITE );
|
||||
|
||||
status.dwCurrentState = SERVICE_STOPPED;
|
||||
status.dwControlsAccepted = 0;
|
||||
SetServiceStatus( service_handle, &status );
|
||||
}
|
||||
|
||||
int wmain( int argc, WCHAR *argv[] )
|
||||
{
|
||||
static const SERVICE_TABLE_ENTRYW service_table[] =
|
||||
{
|
||||
{ rpcssW, ServiceMain },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
StartServiceCtrlDispatcherW( service_table );
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
Index: rpcss_main.c
|
||||
===================================================================
|
||||
--- rpcss_main.c
|
||||
+++ rpcss_main.c
|
||||
@@ -58,11 +58,11 @@
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
||||
|
||||
-static HANDLE exit_event;
|
||||
+HANDLE exit_event;
|
||||
|
||||
//extern HANDLE __wine_make_process_system(void);
|
||||
|
||||
-static BOOL RPCSS_Initialize(void)
|
||||
+BOOL RPCSS_Initialize(void)
|
||||
{
|
||||
static unsigned short irot_protseq[] = IROT_PROTSEQ;
|
||||
static unsigned short irot_endpoint[] = IROT_ENDPOINT;
|
||||
@@ -116,7 +116,7 @@
|
||||
|
||||
/* returns false if we discover at the last moment that we
|
||||
aren't ready to terminate */
|
||||
-static BOOL RPCSS_Shutdown(void)
|
||||
+BOOL RPCSS_Shutdown(void)
|
||||
{
|
||||
RpcMgmtStopServerListening(NULL);
|
||||
RpcServerUnregisterIf(epm_v3_0_s_ifspec, NULL, TRUE);
|
||||
@@ -127,6 +127,7 @@
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
+#if 0
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
/*
|
||||
@@ -142,3 +143,4 @@
|
||||
|
||||
return 0;
|
||||
}
|
||||
+#endif
|
|
@ -1,101 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Remote Procedure Call service
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: base/services/rpcss/service_main.c
|
||||
* PURPOSE: Service control code
|
||||
* COPYRIGHT: Copyright 2008 Ged Murphy <gedmurphy@reactos.org>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "rpcss.h"
|
||||
|
||||
#include <winsvc.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
extern BOOL RPCSS_Initialize(void);
|
||||
extern BOOL RPCSS_Shutdown(void);
|
||||
extern HANDLE exit_event;
|
||||
|
||||
static VOID WINAPI ServiceMain(DWORD, LPWSTR *);
|
||||
static WCHAR ServiceName[] = L"RpcSs";
|
||||
SERVICE_TABLE_ENTRYW ServiceTable[] =
|
||||
{
|
||||
{ ServiceName, ServiceMain },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static SERVICE_STATUS ServiceStatus;
|
||||
static SERVICE_STATUS_HANDLE ServiceStatusHandle;
|
||||
|
||||
DWORD WINAPI
|
||||
ServiceControlHandler(DWORD dwControl,
|
||||
DWORD dwEventType,
|
||||
LPVOID lpEventData,
|
||||
LPVOID lpContext)
|
||||
{
|
||||
switch (dwControl)
|
||||
{
|
||||
case SERVICE_CONTROL_SHUTDOWN:
|
||||
case SERVICE_CONTROL_STOP:
|
||||
SetEvent(exit_event);
|
||||
return NO_ERROR;
|
||||
|
||||
case SERVICE_CONTROL_INTERROGATE:
|
||||
return NO_ERROR;
|
||||
|
||||
default:
|
||||
return ERROR_CALL_NOT_IMPLEMENTED;
|
||||
}
|
||||
}
|
||||
|
||||
VOID WINAPI
|
||||
ServiceMain(DWORD argc, LPWSTR argv[])
|
||||
{
|
||||
DWORD dwError;
|
||||
|
||||
ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName,
|
||||
ServiceControlHandler,
|
||||
NULL);
|
||||
if (!ServiceStatusHandle)
|
||||
{
|
||||
dwError = GetLastError();
|
||||
DPRINT1("RegisterServiceCtrlHandlerW() failed! (Error %lu)\n", dwError);
|
||||
return;
|
||||
}
|
||||
|
||||
ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
|
||||
ServiceStatus.dwCurrentState = SERVICE_START_PENDING;
|
||||
ServiceStatus.dwControlsAccepted = 0;
|
||||
ServiceStatus.dwWin32ExitCode = NO_ERROR;
|
||||
ServiceStatus.dwServiceSpecificExitCode = 0;
|
||||
ServiceStatus.dwCheckPoint = 0;
|
||||
ServiceStatus.dwWaitHint = 1000;
|
||||
SetServiceStatus(ServiceStatusHandle, &ServiceStatus);
|
||||
|
||||
if (RPCSS_Initialize())
|
||||
{
|
||||
ServiceStatus.dwCurrentState = SERVICE_RUNNING;
|
||||
ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
|
||||
SetServiceStatus(ServiceStatusHandle, &ServiceStatus);
|
||||
|
||||
WaitForSingleObject(exit_event, INFINITE);
|
||||
|
||||
RPCSS_Shutdown();
|
||||
|
||||
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
|
||||
SetServiceStatus(ServiceStatusHandle, &ServiceStatus);
|
||||
}
|
||||
}
|
||||
|
||||
int wmain(int argc, LPWSTR argv[])
|
||||
{
|
||||
if (!StartServiceCtrlDispatcherW(ServiceTable))
|
||||
{
|
||||
DPRINT1("StartServiceCtrlDispatcherW() failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -241,7 +241,7 @@ reactos/base/applications/regedit # Out of sync
|
|||
reactos/base/applications/winhlp32 # Synced to WineStaging-1.9.16
|
||||
reactos/base/applications/wordpad # Synced to WineStaging-1.9.16
|
||||
reactos/base/applications/write # Synced to WineStaging-2.9
|
||||
reactos/base/services/rpcss # Synced to WineStaging-1.9.16
|
||||
reactos/base/services/rpcss # Synced to WineStaging-3.3
|
||||
reactos/base/system/expand # Synced to WineStaging-2.9
|
||||
reactos/base/system/msiexec # Synced to WineStaging-2.16
|
||||
reactos/modules/rosapps/winfile # Autosync
|
||||
|
|
Loading…
Reference in a new issue