Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenrpcss_main.c
Go to the documentation of this file.
00001 /* 00002 * Copyright 2001, Ove Kåven, TransGaming Technologies Inc. 00003 * Copyright 2002 Greg Turner 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00018 * 00019 * ---- rpcss_main.c: 00020 * Initialize and start serving requests. Bail if rpcss already is 00021 * running. 00022 * 00023 * ---- RPCSS.EXE: 00024 * 00025 * Wine needs a server whose role is somewhat like that 00026 * of rpcss.exe in windows. This is not a clone of 00027 * windows rpcss at all. It has been given the same name, however, 00028 * to provide for the possibility that at some point in the future, 00029 * it may become interface compatible with the "real" rpcss.exe on 00030 * Windows. 00031 * 00032 * ---- KNOWN BUGS / TODO: 00033 * 00034 * o Service hooks are unimplemented (if you bother to implement 00035 * these, also implement net.exe, at least for "net start" and 00036 * "net stop" (should be pretty easy I guess, assuming the rest 00037 * of the services API infrastructure works. 00038 * 00039 * o There is a looming problem regarding listening on privileged 00040 * ports. We will need to be able to coexist with SAMBA, and be able 00041 * to function without running winelib code as root. This may 00042 * take some doing, including significant reconceptualization of the 00043 * role of rpcss.exe in wine. 00044 */ 00045 00046 #include <stdio.h> 00047 #include <limits.h> 00048 #include <assert.h> 00049 00050 #define NONAMELESSUNION 00051 #define NONAMELESSSTRUCT 00052 #include "rpcss.h" 00053 #include "winnt.h" 00054 #include "irot_s.h" 00055 #include "epm_s.h" 00056 00057 #include "wine/debug.h" 00058 00059 WINE_DEFAULT_DEBUG_CHANNEL(ole); 00060 00061 HANDLE exit_event; 00062 00063 //extern HANDLE __wine_make_process_system(void); 00064 00065 BOOL RPCSS_Initialize(void) 00066 { 00067 static unsigned short irot_protseq[] = IROT_PROTSEQ; 00068 static unsigned short irot_endpoint[] = IROT_ENDPOINT; 00069 static unsigned short epm_protseq[] = {'n','c','a','c','n','_','n','p',0}; 00070 static unsigned short epm_endpoint[] = {'\\','p','i','p','e','\\','e','p','m','a','p','p','e','r',0}; 00071 static unsigned short epm_protseq_lrpc[] = {'n','c','a','l','r','p','c',0}; 00072 static unsigned short epm_endpoint_lrpc[] = {'e','p','m','a','p','p','e','r',0}; 00073 RPC_STATUS status; 00074 00075 WINE_TRACE("\n"); 00076 00077 status = RpcServerRegisterIf(epm_v3_0_s_ifspec, NULL, NULL); 00078 if (status != RPC_S_OK) 00079 return status; 00080 status = RpcServerRegisterIf(Irot_v0_2_s_ifspec, NULL, NULL); 00081 if (status != RPC_S_OK) 00082 { 00083 RpcServerUnregisterIf(epm_v3_0_s_ifspec, NULL, FALSE); 00084 return FALSE; 00085 } 00086 00087 status = RpcServerUseProtseqEpW(epm_protseq, RPC_C_PROTSEQ_MAX_REQS_DEFAULT, 00088 epm_endpoint, NULL); 00089 if (status != RPC_S_OK) 00090 goto fail; 00091 00092 status = RpcServerUseProtseqEpW(epm_protseq_lrpc, RPC_C_PROTSEQ_MAX_REQS_DEFAULT, 00093 epm_endpoint_lrpc, NULL); 00094 if (status != RPC_S_OK) 00095 goto fail; 00096 00097 status = RpcServerUseProtseqEpW(irot_protseq, RPC_C_PROTSEQ_MAX_REQS_DEFAULT, 00098 irot_endpoint, NULL); 00099 if (status != RPC_S_OK) 00100 goto fail; 00101 00102 status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE); 00103 if (status != RPC_S_OK) 00104 goto fail; 00105 00106 //exit_event = __wine_make_process_system(); 00107 exit_event = CreateEventW(NULL, FALSE, FALSE, NULL); // never fires 00108 00109 return TRUE; 00110 00111 fail: 00112 RpcServerUnregisterIf(epm_v3_0_s_ifspec, NULL, FALSE); 00113 RpcServerUnregisterIf(Irot_v0_2_s_ifspec, NULL, FALSE); 00114 return FALSE; 00115 } 00116 00117 /* returns false if we discover at the last moment that we 00118 aren't ready to terminate */ 00119 BOOL RPCSS_Shutdown(void) 00120 { 00121 RpcMgmtStopServerListening(NULL); 00122 RpcServerUnregisterIf(epm_v3_0_s_ifspec, NULL, TRUE); 00123 RpcServerUnregisterIf(Irot_v0_2_s_ifspec, NULL, TRUE); 00124 00125 CloseHandle(exit_event); 00126 00127 return TRUE; 00128 } 00129 00130 #if 0 00131 int main( int argc, char **argv ) 00132 { 00133 /* 00134 * We are invoked as a standard executable; we act in a 00135 * "lazy" manner. We register our interfaces and endpoints, and hang around 00136 * until we all user processes exit, and then silently terminate. 00137 */ 00138 00139 if (RPCSS_Initialize()) { 00140 WaitForSingleObject(exit_event, INFINITE); 00141 RPCSS_Shutdown(); 00142 } 00143 00144 return 0; 00145 } 00146 #endif Generated on Sun May 27 2012 04:17:54 for ReactOS by
1.7.6.1
|