From 444338ae2e4ea1cdd5a9b8bc2f6a2481496d9b3c Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sun, 1 Apr 2018 13:11:47 +0100 Subject: [PATCH] [RPCSS] Sync with Wine Staging 3.3. CORE-14434 --- base/services/rpcss/CMakeLists.txt | 5 +- base/services/rpcss/epmp.c | 5 +- base/services/rpcss/irotp.c | 12 ++- base/services/rpcss/precomp.h | 22 +++++ base/services/rpcss/rpcss.h | 41 --------- base/services/rpcss/rpcss_main.c | 143 ++++++++++++++++------------- base/services/rpcss/rpcss_ros.diff | 40 -------- base/services/rpcss/service_main.c | 101 -------------------- media/doc/README.WINE | 2 +- 9 files changed, 118 insertions(+), 253 deletions(-) create mode 100644 base/services/rpcss/precomp.h delete mode 100644 base/services/rpcss/rpcss.h delete mode 100644 base/services/rpcss/rpcss_ros.diff delete mode 100644 base/services/rpcss/service_main.c diff --git a/base/services/rpcss/CMakeLists.txt b/base/services/rpcss/CMakeLists.txt index 1d429832a8f..a7a31c5dfef 100644 --- a/base/services/rpcss/CMakeLists.txt +++ b/base/services/rpcss/CMakeLists.txt @@ -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) @@ -23,5 +22,5 @@ endif() 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) diff --git a/base/services/rpcss/epmp.c b/base/services/rpcss/epmp.c index 5e2866e9af6..58498b0ee37 100644 --- a/base/services/rpcss/epmp.c +++ b/base/services/rpcss/epmp.c @@ -18,9 +18,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "rpcss.h" +#include "epm_s.h" -#include +#include "wine/debug.h" +#include "wine/list.h" WINE_DEFAULT_DEBUG_CHANNEL(ole); diff --git a/base/services/rpcss/irotp.c b/base/services/rpcss/irotp.c index bf9c5690eea..c73cb78476c 100644 --- a/base/services/rpcss/irotp.c +++ b/base/services/rpcss/irotp.c @@ -18,9 +18,17 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "rpcss.h" +#include +#include -#include +#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); diff --git a/base/services/rpcss/precomp.h b/base/services/rpcss/precomp.h new file mode 100644 index 00000000000..34be35b0681 --- /dev/null +++ b/base/services/rpcss/precomp.h @@ -0,0 +1,22 @@ + +#ifndef _RPCSS_PRECOMP_H_ +#define _RPCSS_PRECOMP_H_ + +#include + +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H + +#define NONAMELESSUNION +#define NONAMELESSSTRUCT + +#include +#include + +#include +#include + +#include + +#endif /* !_RPCSS_PRECOMP_H_ */ diff --git a/base/services/rpcss/rpcss.h b/base/services/rpcss/rpcss.h deleted file mode 100644 index 347a5cf9421..00000000000 --- a/base/services/rpcss/rpcss.h +++ /dev/null @@ -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 - -#define WIN32_NO_STATUS -#define _INC_WINDOWS -#define COM_NO_WINDOWS_H - -#define NONAMELESSUNION -#define NONAMELESSSTRUCT - -#include -#include - -#include -#include - -#include - -#endif /* __WINE_RPCSS_H */ diff --git a/base/services/rpcss/rpcss_main.c b/base/services/rpcss/rpcss_main.c index adf0e7f9ec4..885726dba18 100644 --- a/base/services/rpcss/rpcss_main.c +++ b/base/services/rpcss/rpcss_main.c @@ -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 +#include +#include +#include -#include +#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,76 @@ 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: + TRACE( "shutting down\n" ); + 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: + FIXME( "got service ctrl %x\n", ctrl ); + 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(); - } + TRACE( "starting service\n" ); - return 0; + if (!RPCSS_Initialize()) return; + + 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 ); + TRACE( "service stopped\n" ); +} + +int wmain( int argc, WCHAR *argv[] ) +{ + static const SERVICE_TABLE_ENTRYW service_table[] = + { + { rpcssW, ServiceMain }, + { NULL, NULL } + }; + + StartServiceCtrlDispatcherW( service_table ); + return 0; } -#endif diff --git a/base/services/rpcss/rpcss_ros.diff b/base/services/rpcss/rpcss_ros.diff deleted file mode 100644 index f23583afd7f..00000000000 --- a/base/services/rpcss/rpcss_ros.diff +++ /dev/null @@ -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 diff --git a/base/services/rpcss/service_main.c b/base/services/rpcss/service_main.c deleted file mode 100644 index 63be4e99297..00000000000 --- a/base/services/rpcss/service_main.c +++ /dev/null @@ -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 - * - */ - -#include "rpcss.h" - -#include - -#define NDEBUG -#include - -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; -} diff --git a/media/doc/README.WINE b/media/doc/README.WINE index d6d104ec63a..8f54e3b2bb4 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -241,7 +241,7 @@ reactos/base/applications/regedit # Out of sync reactos/base/applications/winhlp32 # Synced to WineStaging-3.3 reactos/base/applications/wordpad # Synced to WineStaging-1.9.16 reactos/base/applications/write # Synced to WineStaging-3.3 -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