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 Is supposed to use RPC, not random kludges, to map endpoints.
41 * o Probably name services should be implemented here as well.
43 * o Wine's named pipes (in general) may not interoperate with those of
46 * o There is a looming problem regarding listening on privileged
47 * ports. We will need to be able to coexist with SAMBA, and be able
48 * to function without running winelib code as root. This may
49 * take some doing, including significant reconceptualization of the
50 * role of rpcss.exe in wine.
52 * o Who knows? Whatever rpcss does, we ought to at
53 * least think about doing... but what /does/ it do?
60 #define NONAMELESSUNION
61 #define NONAMELESSSTRUCT
65 #include "wine/debug.h"
67 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
69 static HANDLE master_mutex
;
70 static HANDLE exit_event
;
72 extern HANDLE
__wine_make_process_system(void);
74 HANDLE
RPCSS_GetMasterMutex(void)
79 static BOOL
RPCSS_work(HANDLE exit_event
)
81 return RPCSS_NPDoWork(exit_event
);
84 static BOOL
RPCSS_Initialize(void)
88 exit_event
= __wine_make_process_system();
90 master_mutex
= CreateMutexA( NULL
, FALSE
, RPCSS_MASTER_MUTEX_NAME
);
92 WINE_ERR("Failed to create master mutex\n");
96 if (!RPCSS_BecomePipeServer()) {
97 WINE_WARN("Server already running: exiting.\n");
99 CloseHandle(master_mutex
);
108 /* returns false if we discover at the last moment that we
109 aren't ready to terminate */
110 static BOOL
RPCSS_Shutdown(void)
112 if (!RPCSS_UnBecomePipeServer())
115 if (!CloseHandle(master_mutex
))
116 WINE_WARN("Failed to release master mutex\n");
120 CloseHandle(exit_event
);
125 static void RPCSS_MainLoop(void)
129 while ( RPCSS_work(exit_event
) )
133 int main( int argc
, char **argv
)
136 * We are invoked as a standard executable; we act in a
137 * "lazy" manner. We open up our pipe, and hang around until we all
138 * user processes exit, and then silently terminate.
141 if (RPCSS_Initialize()) {