ReactOS 0.4.15-dev-8241-g63935f8
rpcss_main.c
Go to the documentation of this file.
1/*
2 * Copyright 2001, Ove Kåven, TransGaming Technologies Inc.
3 * Copyright 2002 Greg Turner
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20#include <stdio.h>
21#include <stdarg.h>
22#include <limits.h>
23#include <assert.h>
24
25#include "windef.h"
26#include "winbase.h"
27#include "winnt.h"
28#include "winsvc.h"
29#include "irot_s.h"
30#include "epm_s.h"
31
32#include "wine/debug.h"
33
35
36static WCHAR rpcssW[] = {'R','p','c','S','s',0};
39
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
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
83fail:
84 RpcServerUnregisterIf(epm_v3_0_s_ifspec, NULL, FALSE);
85 RpcServerUnregisterIf(Irot_v0_2_s_ifspec, NULL, FALSE);
86 return FALSE;
87}
88
89static DWORD WINAPI service_handler( DWORD ctrl, DWORD event_type, LPVOID event_data, LPVOID context )
90{
92
93 status.dwServiceType = SERVICE_WIN32;
94#ifdef __REACTOS__
95 status.dwControlsAccepted = 0;
96#else
97 status.dwControlsAccepted = SERVICE_ACCEPT_STOP;
98#endif
99 status.dwWin32ExitCode = 0;
100 status.dwServiceSpecificExitCode = 0;
101 status.dwCheckPoint = 0;
102 status.dwWaitHint = 0;
103
104 switch (ctrl)
105 {
108 TRACE( "shutting down\n" );
110 RpcServerUnregisterIf( epm_v3_0_s_ifspec, NULL, TRUE );
111 RpcServerUnregisterIf( Irot_v0_2_s_ifspec, NULL, TRUE );
112 status.dwCurrentState = SERVICE_STOP_PENDING;
113 status.dwControlsAccepted = 0;
116 return NO_ERROR;
117 default:
118 FIXME( "got service ctrl %x\n", ctrl );
119 status.dwCurrentState = SERVICE_RUNNING;
121 return NO_ERROR;
122 }
123}
124
125#ifdef __REACTOS__
127#endif
128
130{
132
133 TRACE( "starting service\n" );
134
135 if (!RPCSS_Initialize()) return;
136
138
140 if (!service_handle) return;
141
142 status.dwServiceType = SERVICE_WIN32;
143 status.dwCurrentState = SERVICE_RUNNING;
144#ifdef __REACTOS__
145 status.dwControlsAccepted = 0;
146#else
148#endif
149 status.dwWin32ExitCode = 0;
150 status.dwServiceSpecificExitCode = 0;
151 status.dwCheckPoint = 0;
152#ifdef __REACTOS__
153 status.dwWaitHint = 0;
154#else
155 status.dwWaitHint = 10000;
156#endif
158
159#ifdef __REACTOS__
161#endif
162
164
165 status.dwCurrentState = SERVICE_STOPPED;
166 status.dwControlsAccepted = 0;
168 TRACE( "service stopped\n" );
169}
170
171int wmain( int argc, WCHAR *argv[] )
172{
173 static const SERVICE_TABLE_ENTRYW service_table[] =
174 {
175 { rpcssW, ServiceMain },
176 { NULL, NULL }
177 };
178
179 StartServiceCtrlDispatcherW( service_table );
180 return 0;
181}
static SERVICE_STATUS_HANDLE(WINAPI *pRegisterServiceCtrlHandlerExA)(LPCSTR
static int argc
Definition: ServiceArgs.c:12
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
VOID DoRpcSsSetupConfiguration(VOID)
Definition: setup.c:163
#define FIXME(fmt,...)
Definition: debug.h:114
#define NO_ERROR
Definition: dderror.h:5
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define INFINITE
Definition: serial.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ctrl
Definition: input.c:1756
#define argv
Definition: mplay32.c:18
int wmain()
RPC_STATUS WINAPI RpcServerListen(UINT MinimumCallThreads, UINT MaxCalls, UINT DontWait)
Definition: rpc_server.c:1520
RPC_STATUS WINAPI RpcServerRegisterIf(RPC_IF_HANDLE IfSpec, UUID *MgrTypeUuid, RPC_MGR_EPV *MgrEpv)
Definition: rpc_server.c:1116
RPC_STATUS WINAPI RpcServerUseProtseqEpW(RPC_WSTR Protseq, UINT MaxCalls, RPC_WSTR Endpoint, LPVOID SecurityDescriptor)
Definition: rpc_server.c:927
RPC_STATUS WINAPI RpcServerUnregisterIf(RPC_IF_HANDLE IfSpec, UUID *MgrTypeUuid, UINT WaitForCallsToComplete)
Definition: rpc_server.c:1202
RPC_STATUS WINAPI RpcMgmtStopServerListening(RPC_BINDING_HANDLE Binding)
Definition: rpc_server.c:1596
#define RPC_C_LISTEN_MAX_CALLS_DEFAULT
Definition: rpcdce.h:122
#define RPC_C_PROTSEQ_MAX_REQS_DEFAULT
Definition: rpcdce.h:123
#define RPC_S_OK
Definition: rpcnterr.h:22
static DWORD WINAPI service_handler(DWORD ctrl, DWORD event_type, LPVOID event_data, LPVOID context)
Definition: rpcss_main.c:89
static void WINAPI ServiceMain(DWORD argc, LPWSTR *argv)
Definition: rpcss_main.c:129
static WCHAR rpcssW[]
Definition: rpcss_main.c:36
static SERVICE_STATUS_HANDLE service_handle
Definition: rpcss_main.c:38
static BOOL RPCSS_Initialize(void)
Definition: rpcss_main.c:40
static HANDLE exit_event
Definition: rpcss_main.c:37
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext)
Definition: sctrl.c:812
BOOL WINAPI StartServiceCtrlDispatcherW(const SERVICE_TABLE_ENTRYW *lpServiceStartTable)
Definition: sctrl.c:1134
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:997
long RPC_STATUS
Definition: rpc.h:52
#define WINE_TRACE
Definition: debug.h:354
#define TRACE(s)
Definition: solgame.cpp:4
Definition: http.c:7252
Definition: ps.c:97
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
#define WINAPI
Definition: msvc.h:6
#define SERVICE_STOPPED
Definition: winsvc.h:21
#define SERVICE_ACCEPT_STOP
Definition: winsvc.h:28
#define SERVICE_STOP_PENDING
Definition: winsvc.h:23
#define SERVICE_CONTROL_SHUTDOWN
Definition: winsvc.h:40
#define SERVICE_RUNNING
Definition: winsvc.h:24
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36
#define SERVICE_ACCEPT_SHUTDOWN
Definition: winsvc.h:30
#define SERVICE_WIN32
Definition: cmtypes.h:964
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184