/* returns false if we discover at the last moment that we aren't ready to terminate */ BOOL RPCSS_Shutdown(void) { RpcMgmtStopServerListening(NULL); RpcServerUnregisterIf(epm_v3_0_s_ifspec, NULL, TRUE); RpcServerUnregisterIf(Irot_v0_2_s_ifspec, NULL, TRUE); CloseHandle(exit_event); return TRUE; }
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; }
__declspec(dllexport) long UnregisterRpc( LPWSTR errorMessageBuffer , int errorMessageBufferLength ) { RPC_STATUS lStatus = -1; // The RpcMgmtStopServerListening function tells a server to stop listening for remote procedure calls. // lStatus = RpcMgmtStopServerListening( NULL ); if (0 != lStatus ) { return lStatus; } // The RpcServerUnregisterIf function removes an interface from the RPC run-time library registry. // lStatus = RpcServerUnregisterIf( NULL, NULL, TRUE ); if (0 != lStatus ) { return lStatus; } return 0; }
//------------------------------------------------------------------ bool AVEngine::CloseRPC() { RPC_STATUS status ; DWORD dwWaitStatus ; // Wait until thread have terminated. status = RpcMgmtStopServerListening(NULL); if (status != RPC_S_OK) { return false ; } status = RpcServerUnregisterIf(AVEngine_AsyncRPC_v1_0_s_ifspec, NULL, FALSE); if (status != RPC_S_OK) { return false ; } dwWaitStatus = WaitForSingleObject(hThread,2000); if ( dwWaitStatus == WAIT_FAILED || dwWaitStatus == WAIT_TIMEOUT ) { TerminateThread (hThread ,1); } // Close all thread handles and free memory allocation. CloseHandle(hThread); return true; }
void s_stop(void) { ok(RPC_S_OK == RpcMgmtStopServerListening(NULL), "RpcMgmtStopServerListening\n"); ok(RPC_S_OK == RpcServerUnregisterIf(NULL, NULL, FALSE), "RpcServerUnregisterIf\n"); ok(SetEvent(stop_event), "SetEvent\n"); }
HRESULT StopServer() { RpcServerUnregisterIf( MagoRemoteEvent_v1_0_s_ifspec, NULL, FALSE ); RpcMgmtStopServerListening( NULL ); RpcMgmtWaitServerListen(); return S_OK; }
RPC_STATUS SpoolerStopRpcServer( VOID ) /*++ Routine Description: Deletes the interface. Arguments: Return Value: NERR_Success, or any RPC error codes that can be returned from RpcServerUnregisterIf. --*/ { RPC_STATUS RpcStatus; RpcStatus = RpcServerUnregisterIf(winspool_ServerIfHandle, 0, 0); RpcMgmtStopServerListening(0); RpcMgmtWaitServerListen(); return (RpcStatus); }
void _BochsRpcServer::Stop() { if (!server_shutdown.exchange(true)) { RpcMgmtStopServerListening(NULL); RpcServerUnregisterIf(NULL, NULL, FALSE); SetEvent(WorkingItemReadyEvent.get()); //break the request processing wait } }
HRESULT ShutdownCommon() { HRESULT status = RpcMgmtStopServerListening(NULL); if (status != RPC_S_OK) { return status; } status = RpcServerUnregisterIf(ServerIChakraJIT_v0_0_s_ifspec, NULL, FALSE); return status; }
static void test_endpoint_mapper(RPC_CSTR protseq, RPC_CSTR address) { static unsigned char annotation[] = "Test annotation string."; RPC_STATUS status; RPC_BINDING_VECTOR *binding_vector; handle_t handle; unsigned char *binding; status = RpcServerRegisterIf(IFoo_v0_0_s_ifspec, NULL, NULL); ok(status == RPC_S_OK, "%s: RpcServerRegisterIf failed (%u)\n", protseq, status); status = RpcServerInqBindings(&binding_vector); ok(status == RPC_S_OK, "%s: RpcServerInqBindings failed with error %u\n", protseq, status); /* register endpoints created in test_RpcServerUseProtseq */ status = RpcEpRegisterA(IFoo_v0_0_s_ifspec, binding_vector, NULL, annotation); ok(status == RPC_S_OK, "%s: RpcEpRegisterA failed with error %u\n", protseq, status); /* reregister the same endpoint with no annotation */ status = RpcEpRegisterA(IFoo_v0_0_s_ifspec, binding_vector, NULL, NULL); ok(status == RPC_S_OK, "%s: RpcEpRegisterA failed with error %u\n", protseq, status); status = RpcStringBindingComposeA(NULL, protseq, address, NULL, NULL, &binding); ok(status == RPC_S_OK, "%s: RpcStringBindingCompose failed (%u)\n", protseq, status); status = RpcBindingFromStringBindingA(binding, &handle); ok(status == RPC_S_OK, "%s: RpcBindingFromStringBinding failed (%u)\n", protseq, status); RpcStringFreeA(&binding); status = RpcBindingReset(handle); ok(status == RPC_S_OK, "%s: RpcBindingReset failed with error %u\n", protseq, status); status = RpcEpResolveBinding(handle, IFoo_v0_0_s_ifspec); ok(status == RPC_S_OK || broken(status == RPC_S_SERVER_UNAVAILABLE), /* win9x */ "%s: RpcEpResolveBinding failed with error %u\n", protseq, status); status = RpcBindingReset(handle); ok(status == RPC_S_OK, "%s: RpcBindingReset failed with error %u\n", protseq, status); status = RpcBindingFree(&handle); ok(status == RPC_S_OK, "%s: RpcBindingFree failed with error %u\n", protseq, status); status = RpcServerUnregisterIf(NULL, NULL, FALSE); ok(status == RPC_S_OK, "%s: RpcServerUnregisterIf failed (%u)\n", protseq, status); status = RpcEpUnregister(IFoo_v0_0_s_ifspec, binding_vector, NULL); ok(status == RPC_S_OK, "%s: RpcEpUnregisterA failed with error %u\n", protseq, status); status = RpcBindingVectorFree(&binding_vector); ok(status == RPC_S_OK, "%s: RpcBindingVectorFree failed with error %u\n", protseq, status); }
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; }
/* add this function to hellop.c */ void HavokShutdown(void) { RPC_STATUS status; status = RpcMgmtStopServerListening(NULL); if (status) return; status = RpcServerUnregisterIf(NULL, NULL, FALSE); if (status) return; return; } //end Shutdown
void Shutdown(IN RPC_BINDING_HANDLE hBinding) { RPC_STATUS status; printf_s("Calling RpcMgmtStopServerListening\n"); status = RpcMgmtStopServerListening(NULL); printf_s("RpcMgmtStopServerListening returned: 0x%x\n", status); if (status) exit(status); printf_s("Calling RpcServerUnregisterIf\n"); status = RpcServerUnregisterIf(NULL, NULL, FALSE); printf_s("RpcServerUnregisterIf returned 0x%x\n", status); if (status) exit(status); }
void Shutdown(DATA_HANDLE_TYPE dh) { RPC_STATUS status; printf_s("Calling RpcMgmtStopServerListening\n"); status = RpcMgmtStopServerListening(NULL); printf_s("RpcMgmtStopServerListening returned: 0x%x\n", status); if (status) { exit(status); } printf_s("Calling RpcServerUnregisterIf\n"); status = RpcServerUnregisterIf(NULL, NULL, FALSE); printf_s("RpcServerUnregisterIf returned 0x%x\n", status); if (status) { exit(status); } }
void Shutdown() { RPC_STATUS status; status = RpcMgmtStopServerListening(NULL); if (status) { exit(status); } status = RpcServerUnregisterIf(NULL, NULL, FALSE); if (status) { exit(status); } }
NTSTATUS NTAPI RpcpStopRpcServer ( _In_ RPC_IF_HANDLE IfSpec ) { RPC_STATUS rpcStatus; /* Unregister the interface */ rpcStatus = RpcServerUnregisterIf(IfSpec, NULL, TRUE); /* Acquire the lock while we dereference the RPC services */ EnterCriticalSection(&RpcpCriticalSection); if (--RpcpNumInstances == 0) { /* All RPC services stopped, rundown the server */ RpcMgmtStopServerListening(NULL); RpcMgmtWaitServerListen(); } /* Release the lock and return the unregister result */ LeaveCriticalSection(&RpcpCriticalSection); return I_RpcMapWin32Status(rpcStatus); }
void RpcListen() { RPC_STATUS status; char *task; RPC_BINDING_VECTOR *ptrBindingVector = NULL; BOOLEAN ifaceRegistered = FALSE; BOOLEAN epRegistered = FALSE; #ifdef NOOSIDEBUGSERVER /* Use All Protseqs already done in OSI */ status = RpcServerUseAllProtseqs(1, NULL); if (status != RPC_S_OK) { task = "Use All Protocol Sequences"; goto cleanup; } #endif /* NOOSIDEBUGSERVER */ status = RpcServerRegisterIf(afsrpc_v1_0_s_ifspec, NULL, NULL); if (status != RPC_S_OK) { task = "Register Interface"; goto cleanup; } ifaceRegistered = TRUE; status = RpcServerInqBindings(&ptrBindingVector); if (status != RPC_S_OK) { task = "Inquire Bindings"; goto cleanup; } status = RpcServerRegisterAuthInfo(NULL, RPC_C_AUTHN_WINNT, NULL, NULL); if (status != RPC_S_OK) { task = "Register Authentication Info"; goto cleanup; } status = RpcEpRegister(afsrpc_v1_0_s_ifspec, ptrBindingVector, NULL, "AFS session key interface"); if (status != RPC_S_OK) { task = "Register Endpoints"; goto cleanup; } epRegistered = TRUE; afsi_log("RPC server listening"); status = RpcServerListen(OSI_MAXRPCCALLS, OSI_MAXRPCCALLS, 0); if (status != RPC_S_OK) { task = "Server Listen"; } cleanup: if (epRegistered) (void) RpcEpUnregister(afsrpc_v1_0_s_ifspec, ptrBindingVector, NULL); if (ptrBindingVector) (void) RpcBindingVectorFree(&ptrBindingVector); if (ifaceRegistered) (void) RpcServerUnregisterIf(afsrpc_v1_0_s_ifspec, NULL, FALSE); if (status != RPC_S_OK) afsi_log("RPC problem, code %d for %s", status, task); else afsi_log("RPC shutdown"); if (rpc_ShutdownEvent != NULL) thrd_SetEvent(rpc_ShutdownEvent); return; }
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); }
//------------------------------------------------------------------ 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; }
// // 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; }