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; }
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); }
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); } }
//------------------------------------------------------------------ DWORD WINAPI AVEngine::SetupRPCServer(void* lpParam) { RPC_STATUS status; PutLog(CALLING_RPCSERVERLISTEN); status = RpcMgmtWaitServerListen(); // wait operation if (status != RPC_S_OK) { PutLog(RPCMGMTWAITSERVERLISTEN_FAILD); return FALSE; } return TRUE; }
/* FUNCTION: main() PURPOSE: main() calls StartServiceCtrlDispatcher to register the main service thread. When this call returns, the service has stopped. PARAMETERS: dwArgc - number of command line arguments lpszArgv - array of command line arguments RETURN VALUE: none COMMENTS: */ VOID _cdecl main(int argc, char **argv){ RPC_STATUS status; int nNumArgs; LPWSTR *szArgList = CommandLineToArgvW(GetCommandLine(), &nNumArgs); if (NULL == szArgList) { _tprintf(TEXT("FileRep main: CommandLineToArgW failed")); exit(EXIT_FAILURE); } // Allow the user to override settings with command line switches. for (int i = 1; i < nNumArgs; i++) { // Well-formed argument switches start with '/' or '-' and are // two characters long. if (((*szArgList[i] == TEXT('-')) || (*szArgList[i] == TEXT('/'))) && _tcsclen(szArgList[i]) == 2) { switch (_totlower(*(szArgList[i]+1))) { case TEXT('f'): bNoFileIO = true; break; case TEXT('h'): case TEXT('?'): default: exit(EXIT_SUCCESS); } } else { _tprintf(TEXT("Bad arguments.\n\n")); exit(EXIT_FAILURE); } } // Service initialization if (!StartFileRepServer()) { return; } else { bServerListening = TRUE; // RpcMgmtWaitServerListen() will block until the server has // stopped listening. status = RpcMgmtWaitServerListen(); if (status != RPC_S_OK){ AddToMessageLogProcFailureEEInfo(TEXT("ServiceStart: RpcMgmtWaitServerListen"), status); return; } } return; }
ULONG VmDirRpcServerStopListen( VOID ) { ULONG dwError = 0; /* MSDN: If the server is not listening, the function fails. */ dwError = RpcMgmtStopServerListening(NULL); if(dwError == NO_ERROR) { // if we successfully called RpcMgmtStopServerListening // wait for rpc calls to complete.... dwError = RpcMgmtWaitServerListen(); } return dwError; }
NTSTATUS NTAPI RpcpStopRpcServerEx ( _In_ RPC_IF_HANDLE IfSpec ) { RPC_STATUS rpcStatus; /* Unregister the interface */ rpcStatus = RpcServerUnregisterIfEx(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); }
/* 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()
// // 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; }
/* 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()
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); }
void __cdecl main(int argc, char * argv[]) { unsigned char *pszProtocolSequence = DEFAULT_PROTOCOL_SEQUENCE; unsigned char *pszEndpoint = DEFAULT_ENDPOINT; unsigned char *pszSpn = NULL; unsigned int nMinCalls = DEFAULT_MIN_CALLS; unsigned int nMaxCalls = DEFAULT_MAX_CALLS; BOOL bDontWait = DEFAULT_WAIT_FLAG; PSECURITY_DESCRIPTOR pszSecurity = NULL; int i; RPC_STATUS status; // 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': pszProtocolSequence = argv[++i]; break; case 'e': pszEndpoint = argv[++i]; break; case 'a': pszSpn = argv[++i]; break; case 'm': nMaxCalls = (unsigned int) atoi(argv[++i]); break; case 'n': nMinCalls = (unsigned int) atoi(argv[++i]); break; case 'f': bDontWait = (unsigned int) atoi(argv[++i]); break; case 'h': case '?': default: Usage(argv[0]); } } else Usage(argv[0]); } if ((pszProtocolSequence == NULL) || (pszEndpoint == NULL) || (nMinCalls < 1) || (nMinCalls > nMaxCalls)) Usage(argv[0]); status = RpcServerUseProtseqEp(pszProtocolSequence, nMaxCalls, pszEndpoint, pszSecurity); printf_s("RpcServerUseProtseqEp returned 0x%x\n", status); if (status) Quit(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(AsyncRPC_ServerIfHandle, NULL, NULL, 0, RPC_C_LISTEN_MAX_CALLS_DEFAULT, NULL); printf_s("Calling RpcServerListen\n"); status = RpcServerListen(nMinCalls, nMaxCalls, bDontWait); printf_s("RpcServerListen returned: 0x%x\n", status); if (status) Quit(status); if (bDontWait) { printf_s("Calling RpcMgmtWaitServerListen\n"); status = RpcMgmtWaitServerListen(); // wait operation printf_s("RpcMgmtWaitServerListen returned: 0x%x\n", status); if (status) Quit(status); } free(pszSecurity); }