static void test_RpcStringBindingFromBinding(void) { static unsigned char ncacn_np[] = "ncacn_np"; static unsigned char address[] = "."; static unsigned char endpoint[] = "\\pipe\\wine_rpc_test"; RPC_STATUS status; handle_t handle; RPC_CSTR binding; status = RpcStringBindingComposeA(NULL, ncacn_np, address, endpoint, NULL, &binding); ok(status == RPC_S_OK, "RpcStringBindingCompose failed (%u)\n", status); status = RpcBindingFromStringBindingA(binding, &handle); ok(status == RPC_S_OK, "RpcBindingFromStringBinding failed (%u)\n", status); RpcStringFreeA(&binding); status = RpcBindingToStringBindingA(handle, &binding); ok(status == RPC_S_OK, "RpcStringBindingFromBinding failed with error %u\n", status); ok(!strcmp((const char *)binding, "ncacn_np:.[\\\\pipe\\\\wine_rpc_test]"), "binding string didn't match what was expected: \"%s\"\n", binding); RpcStringFreeA(&binding); status = RpcBindingFree(&handle); ok(status == RPC_S_OK, "RpcBindingFree failed with error %u\n", status); }
void StartRpcClient() { unsigned char* rpcBinding = nullptr; ENSURE_SUCCESS(RpcStringBindingComposeA(nullptr, (unsigned char*)"ncacn_np", nullptr, (unsigned char*)"\\pipe\\resoel", nullptr, &rpcBinding)); ENSURE_SUCCESS(RpcBindingFromStringBindingA(rpcBinding, &resoel_IfHandle)); }
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); }
handle_t __RPC_USER EVENTLOG_HANDLE_A_bind(EVENTLOG_HANDLE_A UNCServerName) { handle_t hBinding = NULL; UCHAR *pszStringBinding; RPC_STATUS status; TRACE("EVENTLOG_HANDLE_A_bind() called\n"); status = RpcStringBindingComposeA(NULL, (UCHAR *)"ncacn_np", (UCHAR *)UNCServerName, (UCHAR *)"\\pipe\\EventLog", NULL, (UCHAR **)&pszStringBinding); if (status) { ERR("RpcStringBindingCompose returned 0x%x\n", status); return NULL; } /* Set the binding handle that will be used to bind to the server. */ status = RpcBindingFromStringBindingA(pszStringBinding, &hBinding); if (status) { ERR("RpcBindingFromStringBinding returned 0x%x\n", status); } status = RpcStringFreeA(&pszStringBinding); if (status) { ERR("RpcStringFree returned 0x%x\n", status); } return hBinding; }
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); }