[RPCSS] Sync with Wine Staging 3.3. CORE-14434
authorAmine Khaldi <amine.khaldi@reactos.org>
Sun, 1 Apr 2018 12:11:47 +0000 (13:11 +0100)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sun, 1 Apr 2018 12:11:47 +0000 (13:11 +0100)
base/services/rpcss/CMakeLists.txt
base/services/rpcss/epmp.c
base/services/rpcss/irotp.c
base/services/rpcss/precomp.h [new file with mode: 0644]
base/services/rpcss/rpcss.h [deleted file]
base/services/rpcss/rpcss_main.c
base/services/rpcss/rpcss_ros.diff [deleted file]
base/services/rpcss/service_main.c [deleted file]
media/doc/README.WINE

index 1d42983..a7a31c5 100644 (file)
@@ -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)
index 5e2866e..58498b0 100644 (file)
  * 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);
 
index bf9c569..c73cb78 100644 (file)
  * 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);
 
diff --git a/base/services/rpcss/precomp.h b/base/services/rpcss/precomp.h
new file mode 100644 (file)
index 0000000..34be35b
--- /dev/null
@@ -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_ */
diff --git a/base/services/rpcss/rpcss.h b/base/services/rpcss/rpcss.h
deleted file mode 100644 (file)
index 347a5cf..0000000
+++ /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 <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 */
index adf0e7f..885726d 100644 (file)
  * 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"
 
-WINE_DEFAULT_DEBUG_CHANNEL(ole);
+#include "wine/debug.h"
 
-HANDLE exit_event;
+WINE_DEFAULT_DEBUG_CHANNEL(ole);
 
-//extern HANDLE __wine_make_process_system(void);
+static WCHAR rpcssW[] = {'R','p','c','S','s',0};
+static HANDLE exit_event;
+static SERVICE_STATUS_HANDLE service_handle;
 
-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;
+
+    status.dwServiceType             = SERVICE_WIN32;
+    status.dwControlsAccepted        = SERVICE_ACCEPT_STOP;
+    status.dwWin32ExitCode           = 0;
+    status.dwServiceSpecificExitCode = 0;
+    status.dwCheckPoint              = 0;
+    status.dwWaitHint                = 0;
+
+    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;
+    }
+}
 
-  CloseHandle(exit_event);
+static void WINAPI ServiceMain( DWORD argc, LPWSTR *argv )
+{
+    SERVICE_STATUS status;
 
-  return TRUE;
+    TRACE( "starting service\n" );
+
+    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" );
 }
 
-#ifndef __REACTOS__
-int main( int argc, char **argv )
+int wmain( int argc, WCHAR *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.
-   */
-
-  if (RPCSS_Initialize()) {
-    WaitForSingleObject(exit_event, INFINITE);
-    RPCSS_Shutdown();
-  }
-
-  return 0;
+    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 (file)
index f23583a..0000000
+++ /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 (file)
index 63be4e9..0000000
+++ /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 <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;
-}
index d6d104e..8f54e3b 100644 (file)
@@ -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