ReactOS  0.4.12-dev-43-g63b00d8
rpcss_main.c File Reference
#include <stdio.h>
#include <stdarg.h>
#include <limits.h>
#include <assert.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"
Include dependency graph for rpcss_main.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ole)
 
static BOOL RPCSS_Initialize (void)
 
static DWORD WINAPI service_handler (DWORD ctrl, DWORD event_type, LPVOID event_data, LPVOID context)
 
static void WINAPI ServiceMain (DWORD argc, LPWSTR *argv)
 
int wmain (int argc, WCHAR *argv[])
 

Variables

static WCHAR rpcssW [] = {'R','p','c','S','s',0}
 
static HANDLE exit_event
 
static SERVICE_STATUS_HANDLE service_handle
 

Function Documentation

◆ RPCSS_Initialize()

static BOOL RPCSS_Initialize ( void  )
static

Definition at line 40 of file rpcss_main.c.

Referenced by ServiceMain().

41 {
42  static unsigned short irot_protseq[] = IROT_PROTSEQ;
43  static unsigned short irot_endpoint[] = IROT_ENDPOINT;
44  static unsigned short epm_protseq[] = {'n','c','a','c','n','_','n','p',0};
45  static unsigned short epm_endpoint[] = {'\\','p','i','p','e','\\','e','p','m','a','p','p','e','r',0};
46  static unsigned short epm_protseq_lrpc[] = {'n','c','a','l','r','p','c',0};
47  static unsigned short epm_endpoint_lrpc[] = {'e','p','m','a','p','p','e','r',0};
49 
50  WINE_TRACE("\n");
51 
52  status = RpcServerRegisterIf(epm_v3_0_s_ifspec, NULL, NULL);
53  if (status != RPC_S_OK)
54  return status;
55  status = RpcServerRegisterIf(Irot_v0_2_s_ifspec, NULL, NULL);
56  if (status != RPC_S_OK)
57  {
58  RpcServerUnregisterIf(epm_v3_0_s_ifspec, NULL, FALSE);
59  return FALSE;
60  }
61 
63  epm_endpoint, NULL);
64  if (status != RPC_S_OK)
65  goto fail;
66 
67  status = RpcServerUseProtseqEpW(epm_protseq_lrpc, RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
68  epm_endpoint_lrpc, NULL);
69  if (status != RPC_S_OK)
70  goto fail;
71 
73  irot_endpoint, NULL);
74  if (status != RPC_S_OK)
75  goto fail;
76 
78  if (status != RPC_S_OK)
79  goto fail;
80 
81  return TRUE;
82 
83 fail:
84  RpcServerUnregisterIf(epm_v3_0_s_ifspec, NULL, FALSE);
85  RpcServerUnregisterIf(Irot_v0_2_s_ifspec, NULL, FALSE);
86  return FALSE;
87 }
#define TRUE
Definition: types.h:120
#define WINE_TRACE
Definition: debug.h:353
RPC_STATUS WINAPI RpcServerUnregisterIf(RPC_IF_HANDLE IfSpec, UUID *MgrTypeUuid, UINT WaitForCallsToComplete)
Definition: rpc_server.c:1209
long RPC_STATUS
Definition: rpc.h:52
RPC_STATUS WINAPI RpcServerListen(UINT MinimumCallThreads, UINT MaxCalls, UINT DontWait)
Definition: rpc_server.c:1527
#define RPC_C_LISTEN_MAX_CALLS_DEFAULT
Definition: rpcdce.h:122
smooth NULL
Definition: ftsmooth.c:416
RPC_STATUS WINAPI RpcServerRegisterIf(RPC_IF_HANDLE IfSpec, UUID *MgrTypeUuid, RPC_MGR_EPV *MgrEpv)
Definition: rpc_server.c:1123
RPC_STATUS WINAPI RpcServerUseProtseqEpW(RPC_WSTR Protseq, UINT MaxCalls, RPC_WSTR Endpoint, LPVOID SecurityDescriptor)
Definition: rpc_server.c:934
#define RPC_C_PROTSEQ_MAX_REQS_DEFAULT
Definition: rpcdce.h:123
static SERVICE_STATUS status
Definition: service.c:31
#define RPC_S_OK
Definition: rpcnterr.h:22

◆ service_handler()

static DWORD WINAPI service_handler ( DWORD  ctrl,
DWORD  event_type,
LPVOID  event_data,
LPVOID  context 
)
static

Definition at line 89 of file rpcss_main.c.

Referenced by ServiceMain().

90 {
92 
95  status.dwWin32ExitCode = 0;
96  status.dwServiceSpecificExitCode = 0;
97  status.dwCheckPoint = 0;
98  status.dwWaitHint = 0;
99 
100  switch (ctrl)
101  {
104  TRACE( "shutting down\n" );
106  RpcServerUnregisterIf( epm_v3_0_s_ifspec, NULL, TRUE );
107  RpcServerUnregisterIf( Irot_v0_2_s_ifspec, NULL, TRUE );
109  status.dwControlsAccepted = 0;
110  SetServiceStatus( service_handle, &status );
111  SetEvent( exit_event );
112  return NO_ERROR;
113  default:
114  FIXME( "got service ctrl %x\n", ctrl );
116  SetServiceStatus( service_handle, &status );
117  return NO_ERROR;
118  }
119 }
#define TRUE
Definition: types.h:120
RPC_STATUS WINAPI RpcMgmtStopServerListening(RPC_BINDING_HANDLE Binding)
Definition: rpc_server.c:1599
DWORD dwCurrentState
Definition: winsvc.h:100
#define SERVICE_ACCEPT_STOP
Definition: winsvc.h:28
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
DWORD dwServiceSpecificExitCode
Definition: winsvc.h:103
static SERVICE_STATUS_HANDLE service_handle
Definition: rpcss_main.c:38
#define NO_ERROR
Definition: dderror.h:5
RPC_STATUS WINAPI RpcServerUnregisterIf(RPC_IF_HANDLE IfSpec, UUID *MgrTypeUuid, UINT WaitForCallsToComplete)
Definition: rpc_server.c:1209
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:957
DWORD dwCheckPoint
Definition: winsvc.h:104
#define SERVICE_RUNNING
Definition: winsvc.h:24
#define FIXME(fmt,...)
Definition: debug.h:110
static HANDLE exit_event
Definition: rpcss_main.c:37
smooth NULL
Definition: ftsmooth.c:416
#define ctrl
Definition: input.c:1669
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwWaitHint
Definition: winsvc.h:105
DWORD dwWin32ExitCode
Definition: winsvc.h:102
DWORD dwServiceType
Definition: winsvc.h:99
DWORD dwControlsAccepted
Definition: winsvc.h:101
#define SERVICE_WIN32
Definition: cmtypes.h:962
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36
static SERVICE_STATUS status
Definition: service.c:31
#define SERVICE_STOP_PENDING
Definition: winsvc.h:23
#define SERVICE_CONTROL_SHUTDOWN
Definition: winsvc.h:40

◆ ServiceMain()

static void WINAPI ServiceMain ( DWORD  argc,
LPWSTR argv 
)
static

Definition at line 125 of file rpcss_main.c.

Referenced by wmain().

126 {
128 
129  TRACE( "starting service\n" );
130 
131  if (!RPCSS_Initialize()) return;
132 
134 
136  if (!service_handle) return;
137 
138  status.dwServiceType = SERVICE_WIN32;
141  status.dwWin32ExitCode = 0;
142  status.dwServiceSpecificExitCode = 0;
143  status.dwCheckPoint = 0;
144  status.dwWaitHint = 10000;
145  SetServiceStatus( service_handle, &status );
146 
147 #ifdef __REACTOS__
149 #endif
150 
152 
154  status.dwControlsAccepted = 0;
155  SetServiceStatus( service_handle, &status );
156  TRACE( "service stopped\n" );
157 }
#define TRUE
Definition: types.h:120
DWORD dwCurrentState
Definition: winsvc.h:100
#define SERVICE_ACCEPT_STOP
Definition: winsvc.h:28
static WCHAR rpcssW[]
Definition: rpcss_main.c:36
DWORD dwServiceSpecificExitCode
Definition: winsvc.h:103
static SERVICE_STATUS_HANDLE service_handle
Definition: rpcss_main.c:38
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:597
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:957
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
DWORD dwCheckPoint
Definition: winsvc.h:104
#define SERVICE_STOPPED
Definition: winsvc.h:21
#define SERVICE_RUNNING
Definition: winsvc.h:24
static HANDLE exit_event
Definition: rpcss_main.c:37
smooth NULL
Definition: ftsmooth.c:416
VOID DoRpcSsSetupConfiguration(VOID)
Definition: setup.c:163
#define SERVICE_ACCEPT_SHUTDOWN
Definition: winsvc.h:30
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwWaitHint
Definition: winsvc.h:105
DWORD dwWin32ExitCode
Definition: winsvc.h:102
DWORD dwServiceType
Definition: winsvc.h:99
static DWORD WINAPI service_handler(DWORD ctrl, DWORD event_type, LPVOID event_data, LPVOID context)
Definition: rpcss_main.c:89
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext)
Definition: sctrl.c:773
DWORD dwControlsAccepted
Definition: winsvc.h:101
#define SERVICE_WIN32
Definition: cmtypes.h:962
static BOOL RPCSS_Initialize(void)
Definition: rpcss_main.c:40
#define INFINITE
Definition: serial.h:102
static SERVICE_STATUS status
Definition: service.c:31

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( ole  )

◆ wmain()

int wmain ( int  argc,
WCHAR argv[] 
)

Definition at line 159 of file rpcss_main.c.

160 {
161  static const SERVICE_TABLE_ENTRYW service_table[] =
162  {
163  { rpcssW, ServiceMain },
164  { NULL, NULL }
165  };
166 
167  StartServiceCtrlDispatcherW( service_table );
168  return 0;
169 }
static WCHAR rpcssW[]
Definition: rpcss_main.c:36
BOOL WINAPI StartServiceCtrlDispatcherW(const SERVICE_TABLE_ENTRYW *lpServiceStartTable)
Definition: sctrl.c:1094
static void WINAPI ServiceMain(DWORD argc, LPWSTR *argv)
Definition: rpcss_main.c:125
smooth NULL
Definition: ftsmooth.c:416

Variable Documentation

◆ exit_event

HANDLE exit_event
static

Definition at line 37 of file rpcss_main.c.

◆ rpcssW

WCHAR rpcssW[] = {'R','p','c','S','s',0}
static

Definition at line 36 of file rpcss_main.c.

Referenced by ServiceMain(), start_rpcss(), and wmain().

◆ service_handle

SERVICE_STATUS_HANDLE service_handle
static

Definition at line 38 of file rpcss_main.c.

Referenced by RunTest(), service_handler(), and ServiceMain().