2 * Copyright 2001, Ove Kåven, TransGaming Technologies Inc.
3 * Copyright 2002 Greg Turner
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.
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.
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
20 * Initialize and start serving requests. Bail if rpcss already is
25 * Wine needs a server whose role is somewhat like that
26 * of rpcss.exe in windows. This is not a clone of
27 * windows rpcss at all. It has been given the same name, however,
28 * to provide for the possibility that at some point in the future,
29 * it may become interface compatible with the "real" rpcss.exe on
32 * ---- KNOWN BUGS / TODO:
34 * o Service hooks are unimplemented (if you bother to implement
35 * these, also implement net.exe, at least for "net start" and
36 * "net stop" (should be pretty easy I guess, assuming the rest
37 * of the services API infrastructure works.
39 * o There is a looming problem regarding listening on privileged
40 * ports. We will need to be able to coexist with SAMBA, and be able
41 * to function without running winelib code as root. This may
42 * take some doing, including significant reconceptualization of the
43 * role of rpcss.exe in wine.
51 #define NONAMELESSUNION
52 #define NONAMELESSSTRUCT
59 #include "wine/debug.h"
61 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
63 static HANDLE exit_event
;
65 extern HANDLE
__wine_make_process_system(void);
67 static BOOL
RPCSS_Initialize(void)
69 static unsigned short irot_protseq
[] = IROT_PROTSEQ
;
70 static unsigned short irot_endpoint
[] = IROT_ENDPOINT
;
71 static unsigned short epm_protseq
[] = {'n','c','a','c','n','_','n','p',0};
72 static unsigned short epm_endpoint
[] = {'\\','p','i','p','e','\\','e','p','m','a','p','p','e','r',0};
73 static unsigned short epm_protseq_lrpc
[] = {'n','c','a','l','r','p','c',0};
74 static unsigned short epm_endpoint_lrpc
[] = {'e','p','m','a','p','p','e','r',0};
79 status
= RpcServerRegisterIf(epm_v3_0_s_ifspec
, NULL
, NULL
);
80 if (status
!= RPC_S_OK
)
82 status
= RpcServerRegisterIf(Irot_v0_2_s_ifspec
, NULL
, NULL
);
83 if (status
!= RPC_S_OK
)
85 RpcServerUnregisterIf(epm_v3_0_s_ifspec
, NULL
, FALSE
);
89 status
= RpcServerUseProtseqEpW(epm_protseq
, RPC_C_PROTSEQ_MAX_REQS_DEFAULT
,
91 if (status
!= RPC_S_OK
)
94 status
= RpcServerUseProtseqEpW(epm_protseq_lrpc
, RPC_C_PROTSEQ_MAX_REQS_DEFAULT
,
95 epm_endpoint_lrpc
, NULL
);
96 if (status
!= RPC_S_OK
)
99 status
= RpcServerUseProtseqEpW(irot_protseq
, RPC_C_PROTSEQ_MAX_REQS_DEFAULT
,
100 irot_endpoint
, NULL
);
101 if (status
!= RPC_S_OK
)
104 status
= RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT
, TRUE
);
105 if (status
!= RPC_S_OK
)
108 exit_event
= __wine_make_process_system();
113 RpcServerUnregisterIf(epm_v3_0_s_ifspec
, NULL
, FALSE
);
114 RpcServerUnregisterIf(Irot_v0_2_s_ifspec
, NULL
, FALSE
);
118 /* returns false if we discover at the last moment that we
119 aren't ready to terminate */
120 static BOOL
RPCSS_Shutdown(void)
122 RpcMgmtStopServerListening(NULL
);
123 RpcServerUnregisterIf(epm_v3_0_s_ifspec
, NULL
, TRUE
);
124 RpcServerUnregisterIf(Irot_v0_2_s_ifspec
, NULL
, TRUE
);
126 CloseHandle(exit_event
);
131 int main( int argc
, char **argv
)
134 * We are invoked as a standard executable; we act in a
135 * "lazy" manner. We register our interfaces and endpoints, and hang around
136 * until we all user processes exit, and then silently terminate.
139 if (RPCSS_Initialize()) {
140 WaitForSingleObject(exit_event
, INFINITE
);