DWORD WINAPI RpcThreadRoutine(LPVOID lpParameter) { RPC_STATUS Status; InitializeListHead(&LogHandleListHead); Status = RpcServerUseProtseqEpW(L"ncacn_np", 20, L"\\pipe\\EventLog", NULL); if (Status != RPC_S_OK) { DPRINT("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status); return 0; } Status = RpcServerRegisterIf(eventlog_v0_0_s_ifspec, NULL, NULL); if (Status != RPC_S_OK) { DPRINT("RpcServerRegisterIf() failed (Status %lx)\n", Status); return 0; } Status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, FALSE); if (Status != RPC_S_OK) { DPRINT("RpcServerListen() failed (Status %lx)\n", Status); } return 0; }
DWORD WINAPI start_gdipp_rpc_server(LPVOID lpParameter) { if (process_heap == NULL) return 1; //bool b_ret; RPC_STATUS rpc_status; scoped_rw_lock::initialize(); server_cache_size = min(config_instance.get_number(L"/gdipp/server/cache_size/text()", server_config::CACHE_SIZE), 24); glyph_cache_instance.initialize(); initialize_freetype(); //b_ret = rpc_index_initialize(); //if (!b_ret) // return 1; rpc_status = RpcServerUseProtseqEpW(reinterpret_cast<RPC_WSTR>(L"ncalrpc"), RPC_C_PROTSEQ_MAX_REQS_DEFAULT, reinterpret_cast<RPC_WSTR>(L"gdipp"), NULL); if (rpc_status != RPC_S_OK) return 1; rpc_status = RpcServerRegisterIf(gdipp_rpc_v1_0_s_ifspec, NULL, NULL); if (rpc_status != RPC_S_OK) return 1; rpc_status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE); if (rpc_status != RPC_S_OK) return 1; rpc_status = RpcMgmtWaitServerListen(); if (rpc_status != RPC_S_OK) return 1; return 0; }
// // RPC Server Init // static bool MidiRPC_InitServer() { RPC_STATUS status; // Initialize RPC protocol status = RpcServerUseProtseqEp ( (RPC_CSTR)("ncalrpc"), RPC_C_PROTSEQ_MAX_REQS_DEFAULT, (RPC_CSTR)("2d4dc2f9-ce90-4080-8a00-1cb819086970"), NULL ); if(status) return false; // Register server status = RpcServerRegisterIf(MidiRPC_v1_0_s_ifspec, NULL, NULL); if(status) return false; // Start listening status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, FALSE); return !status; }
void main() { RPC_STATUS status; /* unsigned char * pszProtocolSequence = "ncalrpc"; unsigned char * pszEndpoint = "hello";//"\\pipe\\hello"; */ unsigned int cMinCalls = 1; unsigned int fDontWait = FALSE; status = RpcServerUseProtseqEp((_TCHAR*)L"ncalrpc", RPC_C_LISTEN_MAX_CALLS_DEFAULT, (_TCHAR*)L"hello", NULL); if (status) exit(status); status = RpcServerRegisterIf(hello_v1_0_s_ifspec, NULL, NULL); if (status) exit(status); status = RpcServerListen(cMinCalls, RPC_C_LISTEN_MAX_CALLS_DEFAULT, fDontWait); if (status) exit(status); }
DWORD WINAPI LrpcThreadProc(LPVOID lpParameter) { RPC_STATUS Status; Status = RpcServerUseProtseqEpW(L"ncalrpc", 20, L"spoolss", NULL); if (Status != RPC_S_OK) { ERR("RpcServerUseProtseqEpW failed with status %ld!\n", Status); return 0; } Status = RpcServerRegisterIf(winspool_v1_0_s_ifspec, NULL, NULL); if (Status != RPC_S_OK) { ERR("RpcServerRegisterIf failed with status %ld!\n", Status); return 0; } Status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, 0); if (Status != RPC_S_OK) { ERR("RpcServerListen() failed with status %ld!\n", Status); } return 0; }
DWORD WINAPI RpcThreadRoutine( LPVOID lpParameter) { RPC_STATUS Status; Status = RpcServerUseProtseqEpW(L"ncacn_np", 20, L"\\pipe\\srvsvc", NULL); if (Status != RPC_S_OK) { ERR("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status); return 0; } Status = RpcServerRegisterIf(srvsvc_v3_0_s_ifspec, NULL, NULL); if (Status != RPC_S_OK) { ERR("RpcServerRegisterIf() failed (Status %lx)\n", Status); return 0; } Status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, FALSE); if (Status != RPC_S_OK) { ERR("RpcServerListen() failed (Status %lx)\n", Status); } return 0; }
/* FUNCTIONS *****************************************************************/ static DWORD WINAPI RpcThreadRoutine(LPVOID lpParameter) { RPC_STATUS Status; Status = RpcServerUseProtseqEpW(L"ncalrpc", 20, L"wlansvc", NULL); if (Status != RPC_S_OK) { DPRINT("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status); return 0; } Status = RpcServerRegisterIf(wlansvc_interface_v1_0_s_ifspec, NULL, NULL); if (Status != RPC_S_OK) { DPRINT("RpcServerRegisterIf() failed (Status %lx)\n", Status); return 0; } Status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, 0); if (Status != RPC_S_OK) { DPRINT("RpcServerListen() failed (Status %lx)\n", Status); } DPRINT("RpcServerListen finished\n"); return 0; }
NTSTATUS NTAPI RpcpStartRpcServer ( _In_ LPCWSTR IfName, _In_ RPC_IF_HANDLE IfSpec ) { NTSTATUS ntStatus; /* Acquire the lock while we instantiate a new interface */ EnterCriticalSection(&RpcpCriticalSection); /* Add this interface to the service */ ntStatus = RpcpAddInterface(IfName, IfSpec); if (!ntStatus) { /* Increment the reference count to see if this was the first interface */ if (++RpcpNumInstances == 1) { /* It was, so put the server into listening mode now */ ntStatus = RpcServerListen(1, 12345, TRUE); if (ntStatus == RPC_S_ALREADY_LISTENING) ntStatus = STATUS_SUCCESS; } } /* Release the lock and return back the result to the caller */ LeaveCriticalSection(&RpcpCriticalSection); return I_RpcMapWin32Status(ntStatus); }
DWORD WINAPI _BochsRpcServer::RpcListeningThreadProc(LPVOID pthis) { _BochsRpcServer* _this = reinterpret_cast<_BochsRpcServer*>(pthis); RPC_STATUS ret = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, 0); _this->CheckHeap(); //check if the heap is in a valid status and all memory allocated are freed return ret; }
static void server(void) { static unsigned char iptcp[] = "ncacn_ip_tcp"; static unsigned char port[] = PORT; static unsigned char np[] = "ncacn_np"; static unsigned char pipe[] = PIPE; RPC_STATUS status, iptcp_status, np_status; DWORD ret; iptcp_status = RpcServerUseProtseqEp(iptcp, 20, port, NULL); ok(iptcp_status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_ip_tcp) failed with status %d\n", iptcp_status); np_status = RpcServerUseProtseqEp(np, 0, pipe, NULL); if (np_status == RPC_S_PROTSEQ_NOT_SUPPORTED) skip("Protocol sequence ncacn_np is not supported\n"); else ok(np_status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_np) failed with status %d\n", np_status); if (pRpcServerRegisterIfEx) { trace("Using RpcServerRegisterIfEx\n"); status = pRpcServerRegisterIfEx(s_IServer_v0_0_s_ifspec, NULL, NULL, RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH, RPC_C_LISTEN_MAX_CALLS_DEFAULT, NULL); } else status = RpcServerRegisterIf(s_IServer_v0_0_s_ifspec, NULL, NULL); ok(status == RPC_S_OK, "RpcServerRegisterIf failed with status %d\n", status); status = RpcServerListen(1, 20, TRUE); ok(status == RPC_S_OK, "RpcServerListen failed with status %d\n", status); stop_event = CreateEvent(NULL, FALSE, FALSE, NULL); ok(stop_event != NULL, "CreateEvent failed with error %d\n", GetLastError()); if (iptcp_status == RPC_S_OK) run_client("tcp_basic"); else skip("tcp_basic tests skipped due to earlier failure\n"); if (np_status == RPC_S_OK) run_client("np_basic"); else { skip("np_basic tests skipped due to earlier failure\n"); /* np client is what signals stop_event, so bail out if we didn't run do it */ return; } ret = WaitForSingleObject(stop_event, 1000); ok(WAIT_OBJECT_0 == ret, "WaitForSingleObject\n"); /* if the stop event didn't fire then RpcMgmtWaitServerListen will wait * forever, so don't bother calling it in this case */ if (ret == WAIT_OBJECT_0) { status = RpcMgmtWaitServerListen(); todo_wine { ok(status == RPC_S_OK, "RpcMgmtWaitServerListening failed with status %d\n", status); } }
void RPCExecutor::Execute() { // tempting to throw an exception here if (!m_callObserver) { setExecutionStatus(waInitialiseFailed); return; } if (!m_winamp) { m_callObserver->notifyException("winamp implementation is not set"); setExecutionStatus(waInitialiseFailed); return; } std::string str; RPC_STATUS status; // "ncacn_np" for named pip // "ncacn_ip_tcp" for tcpip m_callObserver->notifyStatus("initialising..."); m_callObserver->notifyMessage(m_winamp->WinampVersion().c_str()); setExecutionStatus(waServerStarting); status = RpcServerUseProtseqEp((unsigned char *) m_protocolSequence.c_str(), 20, (unsigned char *) m_endPoint.c_str(), NULL); if (status == RPC_S_OK){ status = RpcServerRegisterIf(winamp_v1_0_s_ifspec, NULL, NULL); if (status == RPC_S_OK){ m_callObserver->notifyMessage("listening..."); setExecutionStatus(waListening); status = RpcServerListen(1, 20, FALSE); if (status != RPC_S_OK){ setExecutionStatus(waInitialiseFailed); m_callObserver->notifyException("error in listening"); m_callObserver->notifyException(RPCError(status)); } } else{ setExecutionStatus(waInitialiseFailed); m_callObserver->notifyException("failed to register interface"); m_callObserver->notifyException(RPCError(status)); m_callObserver->notifyException("initialise failed"); } } else{ setExecutionStatus(waInitialiseFailed); m_callObserver->notifyException("failed to create protocol sequence"); m_callObserver->notifyException(RPCError(status)); m_callObserver->notifyException("initialise failed"); } setExecutionStatus(waServerStopped); }
BOOL RPCSS_Initialize(void) { static unsigned short irot_protseq[] = IROT_PROTSEQ; static unsigned short irot_endpoint[] = IROT_ENDPOINT; static unsigned short epm_protseq[] = {'n','c','a','c','n','_','n','p',0}; static unsigned short epm_endpoint[] = {'\\','p','i','p','e','\\','e','p','m','a','p','p','e','r',0}; static unsigned short epm_protseq_lrpc[] = {'n','c','a','l','r','p','c',0}; static unsigned short epm_endpoint_lrpc[] = {'e','p','m','a','p','p','e','r',0}; RPC_STATUS status; WINE_TRACE("\n"); status = RpcServerRegisterIf(epm_v3_0_s_ifspec, NULL, NULL); if (status != RPC_S_OK) return status; status = RpcServerRegisterIf(Irot_v0_2_s_ifspec, NULL, NULL); if (status != RPC_S_OK) { RpcServerUnregisterIf(epm_v3_0_s_ifspec, NULL, FALSE); return FALSE; } status = RpcServerUseProtseqEpW(epm_protseq, RPC_C_PROTSEQ_MAX_REQS_DEFAULT, epm_endpoint, NULL); if (status != RPC_S_OK) goto fail; status = RpcServerUseProtseqEpW(epm_protseq_lrpc, RPC_C_PROTSEQ_MAX_REQS_DEFAULT, epm_endpoint_lrpc, NULL); if (status != RPC_S_OK) goto fail; status = RpcServerUseProtseqEpW(irot_protseq, RPC_C_PROTSEQ_MAX_REQS_DEFAULT, irot_endpoint, NULL); if (status != RPC_S_OK) goto fail; status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE); if (status != RPC_S_OK) goto fail; #ifndef __REACTOS__ exit_event = __wine_make_process_system(); #else exit_event = CreateEventW(NULL, FALSE, FALSE, NULL); // never fires #endif return TRUE; fail: RpcServerUnregisterIf(epm_v3_0_s_ifspec, NULL, FALSE); RpcServerUnregisterIf(Irot_v0_2_s_ifspec, NULL, FALSE); return FALSE; }
NTSTATUS LsapActivateRpcServer( VOID ) /*++ Routine Description: This function creates a thread for the RPC server. The new Thread then goes on to activate the RPC server, which causes RPC calls to be delivered when recieved. Arguments: None. Return Value: STATUS_SUCCESS - The thread was successfully created. Other status values that may be set by CreateThread(). --*/ { NTSTATUS Status; ULONG WaitCount = 0; // Start listening for remote procedure calls. The first // argument to RpcServerListen is the minimum number of call // threads to create; the second argument is the maximum number // of concurrent calls allowed. The final argument indicates that // this routine should not wait. After everything has been initialized, // we return. Status = I_RpcMapWin32Status(RpcServerListen(1, 1234, 1)); ASSERT( Status == RPC_S_OK ); // // Set event which signals that RPC server is available. // LsapSignalRpcIsActive(); return(STATUS_SUCCESS); }
void RPCServer::listen() { // Start to listen for remote procedure calls for all registered interfaces. // This call will not return until RpcMgmtStopServerListening is called. status = RpcServerListen( 1, // Recommended minimum number of threads. RPC_C_LISTEN_MAX_CALLS_DEFAULT, // Recommended maximum number of threads. FALSE); // Start listening now. if (status) exit(status); }
//Function to create a RPC server and wait, should be called using a worker thread. DWORD WINAPI PrtDistCreateRPCServerForEnqueueAndWait(LPVOID portNumber) { PrtDistLog("Creating RPC server for Enqueue at Port :"); RPC_STATUS status; char buffPort[100]; _itoa(*((PRT_INT32*)portNumber), buffPort, 10); PrtDistLog(buffPort); status = RpcServerUseProtseqEp( (unsigned char*)("ncacn_ip_tcp"), // Use TCP/IP protocol. RPC_C_PROTSEQ_MAX_REQS_DEFAULT, // Backlog queue length for TCP/IP. (RPC_CSTR)buffPort, // TCP/IP port to use. NULL); if (status) { PrtDistLog("Runtime reported exception in RpcServerUseProtseqEp"); exit(status); } status = RpcServerRegisterIf2( s_PrtDist_v1_0_s_ifspec, // Interface to register. NULL, // Use the MIDL generated entry-point vector. NULL, // Use the MIDL generated entry-point vector. RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH, // Forces use of security callback. RPC_C_LISTEN_MAX_CALLS_DEFAULT, // Use default number of concurrent calls. (unsigned)-1, // Infinite max size of incoming data blocks. NULL); // Naive security callback. if (status) { PrtDistLog("Runtime reported exception in RpcServerRegisterIf2"); exit(status); } PrtDistLog("Receiver listening ..."); // Start to listen for remote procedure calls for all registered interfaces. // This call will not return until RpcMgmtStopServerListening is called. status = RpcServerListen( 1, // Recommended minimum number of threads. RPC_C_LISTEN_MAX_CALLS_DEFAULT, // Recommended maximum number of threads. 0); if (status) { PrtDistLog("Runtime reported exception in RpcServerListen"); exit(status); } return -1; }
HRESULT StartServer( const wchar_t* sessionGuidStr ) { HRESULT hr = S_OK; RPC_STATUS rpcRet = RPC_S_OK; bool registered = false; std::wstring endpoint( AGENT_EVENT_IF_LOCAL_ENDPOINT_PREFIX ); endpoint.append( sessionGuidStr ); rpcRet = RpcServerUseProtseqEp( AGENT_LOCAL_PROTOCOL_SEQUENCE, RPC_C_PROTSEQ_MAX_REQS_DEFAULT, (RPC_WSTR) endpoint.c_str(), NULL ); if ( rpcRet != RPC_S_OK ) { hr = HRESULT_FROM_WIN32( rpcRet ); goto Error; } rpcRet = RpcServerRegisterIf2( MagoRemoteEvent_v1_0_s_ifspec, NULL, NULL, RPC_IF_ALLOW_LOCAL_ONLY, RPC_C_LISTEN_MAX_CALLS_DEFAULT, (unsigned int) -1, NULL ); if ( rpcRet != RPC_S_OK ) { hr = HRESULT_FROM_WIN32( rpcRet ); goto Error; } registered = true; rpcRet = RpcServerListen( 1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE ); if ( rpcRet != RPC_S_OK ) { hr = HRESULT_FROM_WIN32( rpcRet ); goto Error; } Error: if ( FAILED( hr ) ) { if ( registered ) RpcServerUnregisterIf( MagoRemoteEvent_v1_0_s_ifspec, NULL, FALSE ); } return hr; }
unsigned int __stdcall CUDA_WRAPPER::WinThreadListener(void * wrapper) { CUDA_WRAPPER * cu = (CUDA_WRAPPER *) wrapper; for (;;) { RPC_STATUS status; // Uses the protocol combined with the endpoint for receiving // remote procedure calls. status = RpcServerUseProtseqEp( (RPC_WSTR)_T("ncacn_ip_tcp"),// Use TCP/IP protocol RPC_C_PROTSEQ_MAX_REQS_DEFAULT, // Backlog q length for TCP/IP. (RPC_WSTR)_T("9191"), // TCP/IP port to use. NULL); // No security. if(status) { _endthreadex(status); return status; } // Registers the DoRPC interface. status = RpcServerRegisterIf( DoRPC_v1_0_s_ifspec, // Interface to register. NULL, // Use the MIDL generated entry-point vector. NULL); // Use the MIDL generated entry-point vector. if(status) { _endthreadex(status); return status; } // Start to listen for remote procedure calls for all registered interfaces. // This call will not return until RpcMgmtStopServerListening is called. status = RpcServerListen( 1, // Recommended minimum number of threads. RPC_C_LISTEN_MAX_CALLS_DEFAULT, // Recommended maximum number of threads. FALSE); // Start listening now. if(status) { _endthreadex(status); return status; } } return 0; }
int main() { // Create Handle RpcServerUseProtseqEpA(RPC_CSTR("ncacn_ip_tcp"),10, RPC_CSTR("8080"),NULL); // Register Server Inrerface RpcServerRegisterIf2( Server_v1_0_s_ifspec, NULL, NULL, RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH,10,(unsigned)-1,SecurityCallbackOK ); // Start Listening std::cout << "Listening on port 8080 ..." << std::endl; RpcServerListen(1,10,FALSE); }
ULONG VmDirRpcServerStartListen( VOID ) { DWORD dwError = 0; unsigned int cMinCalls = 1; unsigned int fDontWait = TRUE; dwError = RpcServerListen( cMinCalls, RPC_C_LISTEN_MAX_CALLS_DEFAULT, fDontWait ); BAIL_ON_VMDIR_ERROR(dwError); error: return dwError; }
DWORD WINAPI RpcThreadRoutine(LPVOID lpParameter) { RPC_STATUS Status; InitializeCriticalSection(&LogHandleListCs); InitializeListHead(&LogHandleListHead); Status = RpcServerUseProtseqEpW(L"ncacn_np", 20, L"\\pipe\\EventLog", NULL); if (Status != RPC_S_OK) { DPRINT("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status); goto Quit; } Status = RpcServerRegisterIf(eventlog_v0_0_s_ifspec, NULL, NULL); if (Status != RPC_S_OK) { DPRINT("RpcServerRegisterIf() failed (Status %lx)\n", Status); goto Quit; } Status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, FALSE); if (Status != RPC_S_OK) { DPRINT("RpcServerListen() failed (Status %lx)\n", Status); } EnterCriticalSection(&LogHandleListCs); while (!IsListEmpty(&LogHandleListHead)) { IELF_HANDLE LogHandle = (IELF_HANDLE)CONTAINING_RECORD(LogHandleListHead.Flink, LOGHANDLE, LogHandleListEntry); ElfDeleteEventLogHandle(&LogHandle); } LeaveCriticalSection(&LogHandleListCs); Quit: DeleteCriticalSection(&LogHandleListCs); return 0; }
int main() { RPC_STATUS status; // Uses the protocol combined with the endpoint for receiving // remote procedure calls. status = RpcServerUseProtseqEp( reinterpret_cast<unsigned char*>("ncacn_ip_tcp"), // Use TCP/IP protocol. RPC_C_PROTSEQ_MAX_REQS_DEFAULT, // Backlog queue length for TCP/IP. reinterpret_cast<unsigned char*>("4747"), // TCP/IP port to use. NULL); // No security. if (status) exit(status); // Registers the Example1Explicit interface. status = RpcServerRegisterIf2( Example1Explicit_v1_0_s_ifspec, // Interface to register. NULL, // Use the MIDL generated entry-point vector. NULL, // Use the MIDL generated entry-point vector. RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH, // Forces use of security callback. RPC_C_LISTEN_MAX_CALLS_DEFAULT, // Use default number of concurrent calls. (unsigned)-1, // Infinite max size of incoming data blocks. SecurityCallback); // Naive security callback. if (status) exit(status); // Start to listen for remote procedure calls for all registered interfaces. // This call will not return until RpcMgmtStopServerListening is called. status = RpcServerListen( 1, // Recommended minimum number of threads. RPC_C_LISTEN_MAX_CALLS_DEFAULT, // Recommended maximum number of threads. FALSE); // Start listening now. if (status) exit(status); }
bool HavokServer() { RPC_STATUS status; unsigned int cMinCalls = 1; unsigned int fDontWait = FALSE; /* 16MB stack per call status = RpcMgmtSetServerStackSize(16 * 1024 * 1024); if (status) return false; */ status = RpcServerUseProtseqEp(pszProtocolSequence, RPC_C_LISTEN_MAX_CALLS_DEFAULT, pszEndpoint, pszSecurity); if (status) return false; status = RpcServerRegisterIf(havok_v1_0_s_ifspec, NULL, NULL); if (status) return false; status = RpcServerListen(cMinCalls, RPC_C_LISTEN_MAX_CALLS_DEFAULT, fDontWait); if (status) return false; return true; }
static void test_rpc_ncacn_ip_tcp(void) { RPC_STATUS status; unsigned char *binding, *principal; handle_t IFoo_IfHandle; ULONG level, authnsvc, authzsvc; RPC_AUTH_IDENTITY_HANDLE identity; static unsigned char foo[] = "foo"; static unsigned char ncacn_ip_tcp[] = "ncacn_ip_tcp"; static unsigned char address[] = "127.0.0.1"; static unsigned char endpoint[] = "4114"; static unsigned char spn[] = "principal"; status = RpcNetworkIsProtseqValidA(foo); ok(status == RPC_S_INVALID_RPC_PROTSEQ, "return wrong\n"); status = RpcNetworkIsProtseqValidA(ncacn_ip_tcp); ok(status == RPC_S_OK, "return wrong\n"); status = RpcMgmtStopServerListening(NULL); todo_wine { ok(status == RPC_S_NOT_LISTENING, "wrong RpcMgmtStopServerListening error (%u)\n", status); } status = RpcMgmtWaitServerListen(); ok(status == RPC_S_NOT_LISTENING, "wrong RpcMgmtWaitServerListen error status (%u)\n", status); status = RpcServerListen(1, 20, FALSE); ok(status == RPC_S_NO_PROTSEQS_REGISTERED, "wrong RpcServerListen error (%u)\n", status); status = RpcServerUseProtseqEpA(ncacn_ip_tcp, 20, endpoint, NULL); ok(status == RPC_S_OK, "RpcServerUseProtseqEp failed (%u)\n", status); status = RpcServerRegisterIf(IFoo_v0_0_s_ifspec, NULL, NULL); ok(status == RPC_S_OK, "RpcServerRegisterIf failed (%u)\n", status); status = RpcServerListen(1, 20, TRUE); todo_wine { ok(status == RPC_S_OK, "RpcServerListen failed (%u)\n", status); } status = RpcServerListen(1, 20, TRUE); todo_wine { ok(status == RPC_S_ALREADY_LISTENING, "wrong RpcServerListen error (%u)\n", status); } status = RpcStringBindingComposeA(NULL, ncacn_ip_tcp, address, endpoint, NULL, &binding); ok(status == RPC_S_OK, "RpcStringBindingCompose failed (%u)\n", status); status = RpcBindingFromStringBindingA(binding, &IFoo_IfHandle); ok(status == RPC_S_OK, "RpcBindingFromStringBinding failed (%u)\n", status); status = RpcBindingSetAuthInfoA(IFoo_IfHandle, NULL, RPC_C_AUTHN_LEVEL_NONE, RPC_C_AUTHN_WINNT, NULL, RPC_C_AUTHZ_NAME); ok(status == RPC_S_OK, "RpcBindingSetAuthInfo failed (%u)\n", status); status = RpcBindingInqAuthInfoA(IFoo_IfHandle, NULL, NULL, NULL, NULL, NULL); ok(status == RPC_S_BINDING_HAS_NO_AUTH, "RpcBindingInqAuthInfo failed (%u)\n", status); status = RpcBindingSetAuthInfoA(IFoo_IfHandle, spn, RPC_C_AUTHN_LEVEL_PKT_PRIVACY, RPC_C_AUTHN_WINNT, NULL, RPC_C_AUTHZ_NAME); ok(status == RPC_S_OK, "RpcBindingSetAuthInfo failed (%u)\n", status); level = authnsvc = authzsvc = 0; principal = (unsigned char *)0xdeadbeef; identity = (RPC_AUTH_IDENTITY_HANDLE *)0xdeadbeef; status = RpcBindingInqAuthInfoA(IFoo_IfHandle, &principal, &level, &authnsvc, &identity, &authzsvc); ok(status == RPC_S_OK, "RpcBindingInqAuthInfo failed (%u)\n", status); ok(identity == NULL, "expected NULL identity, got %p\n", identity); ok(principal != (unsigned char *)0xdeadbeef, "expected valid principal, got %p\n", principal); ok(level == RPC_C_AUTHN_LEVEL_PKT_PRIVACY, "expected RPC_C_AUTHN_LEVEL_PKT_PRIVACY, got %d\n", level); ok(authnsvc == RPC_C_AUTHN_WINNT, "expected RPC_C_AUTHN_WINNT, got %d\n", authnsvc); todo_wine ok(authzsvc == RPC_C_AUTHZ_NAME, "expected RPC_C_AUTHZ_NAME, got %d\n", authzsvc); if (status == RPC_S_OK) RpcStringFreeA(&principal); status = RpcMgmtStopServerListening(NULL); ok(status == RPC_S_OK, "RpcMgmtStopServerListening failed (%u)\n", status); status = RpcMgmtStopServerListening(NULL); ok(status == RPC_S_OK, "RpcMgmtStopServerListening failed (%u)\n", status); status = RpcServerUnregisterIf(NULL, NULL, FALSE); ok(status == RPC_S_OK, "RpcServerUnregisterIf failed (%u)\n", status); status = RpcMgmtWaitServerListen(); todo_wine { ok(status == RPC_S_OK, "RpcMgmtWaitServerListen failed (%u)\n", status); } status = RpcStringFreeA(&binding); ok(status == RPC_S_OK, "RpcStringFree failed (%u)\n", status); status = RpcBindingFree(&IFoo_IfHandle); ok(status == RPC_S_OK, "RpcBindingFree failed (%u)\n", status); }
HRESULT JsInitializeJITServer( __in UUID* connectionUuid, __in_opt void* securityDescriptor, __in_opt void* alpcSecurityDescriptor) { RPC_STATUS status; RPC_BINDING_VECTOR* bindingVector = NULL; UUID_VECTOR uuidVector; uuidVector.Count = 1; uuidVector.Uuid[0] = connectionUuid; status = RpcServerUseProtseqW( (RPC_WSTR)L"ncalrpc", RPC_C_PROTSEQ_MAX_REQS_DEFAULT, alpcSecurityDescriptor); if (status != RPC_S_OK) { return status; } #ifndef NTBUILD status = RpcServerRegisterIf2( ServerIChakraJIT_v0_0_s_ifspec, NULL, NULL, RPC_IF_AUTOLISTEN, RPC_C_LISTEN_MAX_CALLS_DEFAULT, (ULONG)-1, NULL); #else status = RpcServerRegisterIf3( ServerIChakraJIT_v0_0_s_ifspec, NULL, NULL, RPC_IF_AUTOLISTEN, RPC_C_LISTEN_MAX_CALLS_DEFAULT, (ULONG)-1, NULL, securityDescriptor); #endif if (status != RPC_S_OK) { return status; } status = RpcServerInqBindings(&bindingVector); if (status != RPC_S_OK) { return status; } status = RpcEpRegister( ServerIChakraJIT_v0_0_s_ifspec, bindingVector, &uuidVector, NULL); RpcBindingVectorFree(&bindingVector); if (status != RPC_S_OK) { return status; } JITManager::GetJITManager()->SetIsJITServer(); status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, FALSE); return status; }
/* main: register the interface, start listening for clients */ void __cdecl main(int argc, char * argv[]) { RPC_STATUS status; unsigned char * pszProtocolSequence = "ncacn_ip_tcp"; unsigned char * pszSecurity = NULL; unsigned char * pszEndpoint = "8765"; unsigned char * pszSpn = NULL; unsigned int cMinCalls = 1; unsigned int cMaxCalls = 20; unsigned int fDontWait = FALSE; int i; /* allow the user to override settings with command line switches */ for (i = 1; i < argc; i++) { if ((*argv[i] == '-') || (*argv[i] == '/')) { switch (tolower(*(argv[i]+1))) { case 'p': // protocol sequence pszProtocolSequence = argv[++i]; break; case 'e': pszEndpoint = argv[++i]; break; case 'a': pszSpn = argv[++i]; break; case 'm': cMaxCalls = (unsigned int) atoi(argv[++i]); break; case 'n': cMinCalls = (unsigned int) atoi(argv[++i]); break; case 'f': fDontWait = (unsigned int) atoi(argv[++i]); break; /* case 'i': if(!_stricmp(argv[++i],"No_Authenticate")) ifFlag = RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH; break;*/ case 'h': case '?': default: Usage(argv[0]); } } else Usage(argv[0]); } status = RpcServerUseProtseqEp(pszProtocolSequence, cMaxCalls, pszEndpoint, pszSecurity); // Security descriptor printf_s("RpcServerUseProtseqEp returned 0x%x\n", status); if (status) { exit(status); } /* User did not specify spn, construct one. */ if (pszSpn == NULL) { MakeSpn(&pszSpn); } /* Using Negotiate as security provider */ status = RpcServerRegisterAuthInfo(pszSpn, RPC_C_AUTHN_GSS_NEGOTIATE, NULL, NULL); printf_s("RpcServerRegisterAuthInfo returned 0x%x\n", status); if (status) { exit(status); } status = RpcServerRegisterIfEx(umarsh_ServerIfHandle, NULL, NULL, 0, RPC_C_LISTEN_MAX_CALLS_DEFAULT, NULL ); printf_s("Calling RpcServerListen\n"); status = RpcServerListen(cMinCalls, cMaxCalls, fDontWait); printf_s("RpcServerListen returned: 0x%x\n", status); if (status) { exit(status); } if (fDontWait) { printf_s("Calling RpcMgmtWaitServerListen\n"); status = RpcMgmtWaitServerListen(); // wait operation printf_s("RpcMgmtWaitServerListen returned: 0x%x\n", status); if (status) { exit(status); } } } // end main()
RPC_STATUS SpoolerStartRpcServer( VOID) /*++ Routine Description: Arguments: Return Value: NERR_Success, or any RPC error codes that can be returned from RpcServerUnregisterIf. --*/ { unsigned char * InterfaceAddress; RPC_STATUS status; PSECURITY_DESCRIPTOR SecurityDescriptor = NULL; BOOL Bool; HKEY hKey; DWORD cbData; DWORD dwSerializeRpc = 0; DWORD dwType; InterfaceAddress = "\\pipe\\spoolss"; // Croft up a security descriptor that will grant everyone // all access to the object (basically, no security) // // We do this by putting in a NULL Dacl. // // BUGBUG: rpc should copy the security descriptor, // Since it currently doesn't, simply allocate it for now and // leave it around forever. // SecurityDescriptor = LocalAlloc( LMEM_FIXED, sizeof( SECURITY_DESCRIPTOR )); if (SecurityDescriptor == 0) { DBGMSG(DBG_ERROR, ("Spoolss: out of memory\n")); return FALSE; } InitializeSecurityDescriptor( SecurityDescriptor, SECURITY_DESCRIPTOR_REVISION ); Bool = SetSecurityDescriptorDacl ( SecurityDescriptor, TRUE, // Dacl present NULL, // NULL Dacl FALSE // Not defaulted ); // // There's no way the above call can fail. But check anyway. // if (!Bool) { DBGMSG(DBG_ERROR, ("Spoolss: SetSecurityDescriptorDacl failed\n")); return FALSE; } // // For now, ignore the second argument. // status = RpcServerUseProtseqEpA("ncacn_np", 10, InterfaceAddress, SecurityDescriptor); if (status) { DBGMSG(DBG_ERROR, ("RpcServerUseProtseqEpA = %u\n",status)); return FALSE; } // // For now, ignore the second argument. // status = RpcServerUseProtseqEpA("ncalrpc", 10, "spoolss", SecurityDescriptor); if (status) { DBGMSG(DBG_ERROR, ("RpcServerUseProtseqEpA = %u\n",status)); return FALSE; } // // Now we need to add the interface. We can just use the winspool_ServerIfHandle // specified by the MIDL compiler in the stubs (winspl_s.c). // status = RpcServerRegisterIf(winspool_ServerIfHandle, 0, 0); if (status) { DBGMSG(DBG_ERROR, ("RpcServerRegisterIf = %u\n",status)); return FALSE; } if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, szPrintKey, 0, KEY_READ, &hKey)) { cbData = sizeof(dwSerializeRpc); // // Ignore failure case since we can use the default // RegQueryValueEx(hKey, szSerializeRpc, NULL, &dwType, (LPBYTE)&dwSerializeRpc, &cbData); cbData = sizeof(dwCallExitProcessOnShutdown); // // This value can be used to control if spooler controls ExitProcess // on shutdown // RegQueryValueEx(hKey, szCallExitProcessOnShutdown, NULL, &dwType, (LPBYTE)&dwCallExitProcessOnShutdown, &cbData); RegCloseKey(hKey); } if (dwSerializeRpc) { // By default, rpc will serialize access to context handles. Since // the spooler needs to be able to have two threads access a context // handle at once, and it knows what it is doing, we will tell rpc // not to serialize access to context handles. I_RpcSsDontSerializeContext(); } status = RpcMgmtSetServerStackSize(16384); if (status != RPC_S_OK) { DBGMSG(DBG_ERROR, ("Spoolss : RpcMgmtSetServerStackSize = %d\n", status)); } // The first argument specifies the minimum number of threads to // create to handle calls; the second argument specifies the maximum // concurrent calls to handle. The third argument indicates that // the routine should not wait. status = RpcServerListen(1,12345,1); // DaveSn was 0 if ( status != RPC_S_OK ) { DBGMSG(DBG_ERROR, ("Spoolss : RpcServerListen = %d\n", status)); } return (status); }
__declspec(dllexport) long RegisterRpc( LPWSTR pszProtocolSequence , LPWSTR pszEndpoint , LPWSTR pszServiceClass , LPWSTR pszNetworkAddress , LPWSTR psErrorMessageBuffer , int errorMessageBufferLength ) { LPWSTR pszSpn = NULL; long lStatus; // The RpcServerUseProtseqEp function tells the RPC run-time library to // use the specified protocol sequence combined with the specified // endpoint for receiving remote procedure calls. // lStatus = RpcServerUseProtseqEp( ( RPC_WSTR ) pszProtocolSequence, RPC_C_PROTSEQ_MAX_REQS_DEFAULT, ( RPC_WSTR ) pszEndpoint, NULL ); if ( lStatus ) { swprintf_s(psErrorMessageBuffer, errorMessageBufferLength, L"RpcServerUseProtseqEp returned 0x%x", lStatus ); return KEYPROVIDER_FAILED; } // User did not specify spn, construct one. if ( NULL == pszSpn ) { // Add 2 for the slash character and null terminator. INT nSpnLength = wcslen( pszServiceClass ) + wcslen( pszNetworkAddress ) + 2; pszSpn = ( LPWSTR ) malloc( nSpnLength * sizeof( wchar_t ) ); if ( !pszSpn ) { return KEYPROVIDER_NOT_ENOUGH_MEMORY; } wcscpy_s( pszSpn, nSpnLength, pszServiceClass ); wcscat_s( pszSpn, nSpnLength, L"/" ); wcscat_s( pszSpn, nSpnLength, pszNetworkAddress ); } // The RpcServerRegisterIfEx function registers an interface with // the RPC run-time library. // lStatus = RpcServerRegisterIfEx( KeyProviderListener_v1_0_s_ifspec, NULL, NULL, RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH, RPC_C_LISTEN_MAX_CALLS_DEFAULT, NULL ); if ( lStatus ) { swprintf_s(psErrorMessageBuffer, errorMessageBufferLength, L"RpcServerRegisterIfEx returned 0x%x", lStatus ); return KEYPROVIDER_FAILED; } // The RpcServerRegisterAuthInfo function registers authentication // information with the RPC run-time library. // // Using Negotiate as security provider. lStatus = RpcServerRegisterAuthInfo( ( RPC_WSTR ) pszSpn, RPC_C_AUTHN_GSS_NEGOTIATE, NULL, NULL ); if ( lStatus ) { swprintf_s(psErrorMessageBuffer, errorMessageBufferLength, L"RpcServerRegisterAuthInfo returned 0x%x", lStatus ); return KEYPROVIDER_FAILED; } // The RpcServerListen function signals the RPC run-time library to listen // for remote procedure calls. // lStatus = RpcServerListen( 1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE ); if ( lStatus ) { swprintf_s(psErrorMessageBuffer, errorMessageBufferLength, L"RpcServerListen returned: 0x%x", lStatus ); return KEYPROVIDER_FAILED; } return 0; }
// // FUNCTION: ServiceStart // // PURPOSE: Actual code of the service // that does the work. // // PARAMETERS: // dwArgc - number of command line arguments // lpszArgv - array of command line arguments // // RETURN VALUE: // none // // COMMENTS: // Starts the service listening for RPC requests. // VOID ServiceStart (HWND NotifyWindow) { UINT i; RPC_BINDING_VECTOR *pbindingVector = 0; RPC_STATUS status; BOOL fListening = FALSE; /////////////////////////////////////////////////// // // Service initialization // // // Use protocol sequences (protseqs) specified in ProtocolArray. // if(NotifyWindow) PostMessage(NotifyWindow,MPM_SERVER_STARTING,0,0); for(i = 0; i < sizeof(ProtocolArray)/sizeof(TCHAR *); i++) { status = RpcServerUseProtseq(ProtocolArray[i], ProtocolBuffer, 0); if (status == RPC_S_OK) { if(NotifyWindow) PostMessage(NotifyWindow,MPM_SERVER_PENDING,0,0); fListening = TRUE; } } if (!fListening) { // Unable to listen to any protocol! // if(NotifyWindow) PostMessage(NotifyWindow,MPM_SERVER_STOPPED,0,status); dwErr = status; return; } // // Register the services interface(s). // status = RpcServerRegisterIf(R_MPE_v1_0_s_ifspec,0,0); if (status != RPC_S_OK) { if(NotifyWindow) PostMessage(NotifyWindow,MPM_SERVER_STOPPED,0,status); dwErr = status; hMainThread = 0; return; } if(NotifyWindow) PostMessage(NotifyWindow,MPM_SERVER_PENDING,0,0); // Register interface(s) and binding(s) (endpoints) with // the endpoint mapper. // status = RpcServerInqBindings(&pbindingVector); if (status != RPC_S_OK) { if(NotifyWindow) PostMessage(NotifyWindow,MPM_SERVER_STOPPED,0,status); dwErr = status; hMainThread = 0; return; } if(NotifyWindow) PostMessage(NotifyWindow,MPM_SERVER_PENDING,0,0); status = RpcEpRegister(R_MPE_v1_0_s_ifspec,pbindingVector,0,0); if (status != RPC_S_OK) { dwErr = status; if(NotifyWindow) PostMessage(NotifyWindow,MPM_SERVER_STOPPED,0,status); hMainThread = 0; return; } if(NotifyWindow) PostMessage(NotifyWindow,MPM_SERVER_PENDING,0,0); // Enable NT LM Security Support Provider (NtLmSsp service) // status = RpcServerRegisterAuthInfo(0, RPC_C_AUTHN_WINNT, 0, 0 ); if (status != RPC_S_OK){ dwErr = status; if(NotifyWindow) PostMessage(NotifyWindow,MPM_SERVER_STOPPED,0,status); hMainThread = 0; return; } if(NotifyWindow) PostMessage(NotifyWindow,MPM_SERVER_PENDING,0,0); // Start accepting client calls. // status = RpcServerListen(MinimumThreads, RPC_C_LISTEN_MAX_CALLS_DEFAULT, // rpcdce.h TRUE); // don't block. if (status != RPC_S_OK) { dwErr = status; PostMessage(NotifyWindow,MPM_SERVER_STOPPED,0,status); hMainThread = 0; return; } // // End of initialization // //////////////////////////////////////////////////////////// if(NotifyWindow) PostMessage(NotifyWindow,MPM_SERVER_STARTED,0,status); else SetEvent(StartEvent); //////////////////////////////////////////////////////////// // // Cleanup // // RpcMgmtWaitServerListen() will block until the server has // stopped listening. If this service had something better to // do with this thread, it would delay this call until // ServiceStop() had been called. (Set an event in ServiceStop()). // status = RpcMgmtWaitServerListen(); if (status != RPC_S_OK) { dwErr = status; PostMessage(NotifyWindow,MPM_SERVER_STOPPED,0,status); hMainThread = 0; return; } NotifyWindow = g_hNotifyWindow; if(NotifyWindow) PostMessage(NotifyWindow,MPM_SERVER_PENDING,0,0); // ASSERT(status == RPC_S_OK) status = RpcServerUnregisterIf(R_MPE_v1_0_s_ifspec,0,TRUE); if(NotifyWindow) PostMessage(NotifyWindow,MPM_SERVER_PENDING,0,0); // Remove entries from the endpoint mapper database. // RpcEpUnregister(R_MPE_v1_0_s_ifspec, // from rpcsvc.h pbindingVector, 0); if(NotifyWindow) PostMessage(NotifyWindow,MPM_SERVER_PENDING,0,0); // Delete the binding vector // status = RpcBindingVectorFree(&pbindingVector); if(NotifyWindow) PostMessage(NotifyWindow,MPM_SERVER_STOPPED,0,status); // //////////////////////////////////////////////////////////// return; }
//------------------------------------------------------------------ bool AVEngine::Start() { RPC_STATUS status; unsigned int nMinCalls = DEFAULT_MIN_CALLS ; unsigned int nMaxCalls = DEFAULT_MAX_CALLS ; wchar_t *pszProtocolSequence = DEFAULT_PROTOCOL_SEQUENCE ; // for "RpcServerUseProtseqEp" proper work, we change it's declaration from " unsigned char *" to "wchar_t *" wchar_t *pszEndpoint = DEFAULT_ENDPOINT ; //tells the RPC run-time library to use the specified protocol sequence combined with the specified endpoint for receiving remote procedure calls. status = RpcServerUseProtseqEp((RPC_WSTR)pszProtocolSequence,nMaxCalls,(RPC_WSTR)pszEndpoint,NULL); if (status != RPC_S_OK) { PutLog(RPCSERVERUSEPROTSEQEP_FAILD); return false ; } status = RpcServerRegisterIf2(AVEngine_AsyncRPC_v1_0_s_ifspec, // interface to register NULL, // MgrTypeUuid NULL,// MgrEpv; null means use default RPC_IF_ALLOW_LOCAL_ONLY, //the RPC runtime rejects calls made by remote clients. All local calls using ncadg_* and ncacn_* protocol sequences are also rejected, with the exception of ncacn_np. nMaxCalls,//Maximum number of concurrent remote procedure call requests the server can accept on an auto-listen interface. NULL,//Maximum size of incoming data blocks, in bytes. * This parameter has no effect on calls made over the ncalrpc protocol. NULL);//Security-callback function, or NULL for no callback. // Create new thread for listen to client requests if (status != RPC_S_OK) { PutLog(RPCSERVERREGISTERIF2_FAILD); return false ; } PutLog(CALLING_RPCSERVERLISTEN); //signals the RPC run-time library to listen for remote procedure calls. status = RpcServerListen(nMinCalls, //Hint to the RPC run time that specifies the minimum number of call threads that should be created and maintained in the given server. nMaxCalls, //Recommended maximum number of concurrent remote procedure calls the server can execute. 1 //A value of nonzero indicates that RpcServerListen should return immediately after completing function processing. ); if (status != RPC_S_OK) { RpcServerUnregisterIf(AVEngine_AsyncRPC_v1_0_s_ifspec, NULL, FALSE); PutLog(RPCSERVERLISTEN_FAILD); return false ; } PutLog(CALLING_RPCSERVERLISTEN); hThread = CreateThread( NULL, // default security attributes 0, // use default stack size SetupRPCServer, // thread function NULL, // argument to thread function 0, // use default creation flags &dwThreadId ); // returns the thread identifier // Check the return value for success. if (hThread == NULL) { PutLog(CREATELISTENTHREAD_FAILD); return false; } return true; }
/* main: register the interface, start listening for clients */ void __cdecl main(int argc, char * argv[]) { RPC_STATUS status; UUID MgrTypeUuid, ClientUuid; unsigned char * pszProtocolSequence = "ncacn_ip_tcp"; unsigned char * pszSecurity = NULL; unsigned char * pszClientUuid = NULL_UUID_STRING; unsigned char * pszMgrTypeUuid = "11111111-1111-1111-1111-111111111111"; unsigned char * pszEndpoint = "8765"; unsigned char * pszSpn = NULL; unsigned int cMinCalls = 1; unsigned int cMaxCalls = 20; unsigned int fDontWait = FALSE; int i; cluuid_SERVER_EPV epv2; // the mgr_epv for the 2nd implementation /* allow the user to override settings with command line switches */ for (i = 1; i < argc; i++) { if ((*argv[i] == '-') || (*argv[i] == '/')) { switch (tolower(*(argv[i]+1))) { case 'p': // protocol sequence pszProtocolSequence = argv[++i]; break; case 'e': pszEndpoint = argv[++i]; break; case 'a': pszSpn = argv[++i]; break; case 'm': cMaxCalls = (unsigned int) atoi(argv[++i]); break; case 'n': cMinCalls = (unsigned int) atoi(argv[++i]); break; case 'f': fDontWait = (unsigned int) atoi(argv[++i]); break; case '1': pszMgrTypeUuid = argv[++i]; break; case '2': pszClientUuid = argv[++i]; break; case 'h': case '?': default: Usage(argv[0]); } } else Usage(argv[0]); } status = RpcServerUseProtseqEp(pszProtocolSequence, cMaxCalls, pszEndpoint, pszSecurity); // Security descriptor printf_s("RpcServerUseProtseqEp returned 0x%x\n", status); if (status) { exit(status); } status = UuidFromString(pszClientUuid, &ClientUuid); printf_s("UuidFromString returned 0x%x = %d\n", status, status); if (status) { exit(status); } status = UuidFromString(pszMgrTypeUuid, &MgrTypeUuid); printf_s("UuidFromString returned 0x%x = %d\n", status, status); if (status) { exit(status); } if (strcmp (pszMgrTypeUuid, NULL_UUID_STRING) == 0) { printf_s("Register object using non-null uuid %s\n", pszMgrTypeUuid); exit(1); } if (strcmp (pszClientUuid, NULL_UUID_STRING) == 0) { printf_s("Register object using non-null uuid %s\n", pszMgrTypeUuid); ClientUuid = MgrTypeUuid; } RpcObjectSetType(&ClientUuid, &MgrTypeUuid); // associate type UUID with nil UUID printf_s("RpcObjectSetType returned 0x%x\n", status); if (status) { exit(status); } /* User did not specify spn, construct one. */ if (pszSpn == NULL) { MakeSpn(&pszSpn); } /* Using Negotiate as security provider. */ status = RpcServerRegisterAuthInfo(pszSpn, RPC_C_AUTHN_GSS_NEGOTIATE, NULL, NULL); printf_s("RpcServerRegisterAuthInfo returned 0x%x\n", status); if (status) { exit(status); } status = RpcServerRegisterIfEx(cluuid_ServerIfHandle, NULL, NULL, 0, RPC_C_LISTEN_MAX_CALLS_DEFAULT, NULL ); /* register the second manager epv and associate it with the specified uuid. the second uuid must be non-null so that it will not conflict with the NULL uuid already registered for this interface */ epv2.HelloProc = HelloProc2; epv2.Shutdown = Shutdown; status = RpcServerRegisterIfEx(cluuid_ServerIfHandle, &MgrTypeUuid, &epv2, 0, RPC_C_LISTEN_MAX_CALLS_DEFAULT, NULL ); printf_s("RpcServerRegisterIfEx returned 0x%x\n", status); if (status) { exit(status); } printf_s("Calling RpcServerListen\n"); status = RpcServerListen(cMinCalls, cMaxCalls, fDontWait); printf_s("RpcServerListen returned: 0x%x\n", status); if (status) { exit(status); } if (fDontWait) { printf_s("Calling RpcMgmtWaitServerListen\n"); status = RpcMgmtWaitServerListen(); // wait operation printf_s("RpcMgmtWaitServerListen returned: 0x%x\n", status); if (status) { exit(status); } } } // end main()