private static Win32Error ResolveBinding(SafeRpcBindingHandle binding, Guid interface_id, Version interface_version) { RPC_SERVER_INTERFACE ifspec = new RPC_SERVER_INTERFACE(); ifspec.Length = Marshal.SizeOf(ifspec); ifspec.InterfaceId.SyntaxGUID = interface_id; ifspec.InterfaceId.SyntaxVersion = interface_version.ToRpcVersion(); return(Win32NativeMethods.RpcEpResolveBinding(binding, ref ifspec)); }
/// <summary> /// Resolve the binding string for this service from the local Endpoint Mapper. /// </summary> /// <param name="binding">The binding handle.</param> /// <param name="interface_id">Interface UUID to lookup.</param> /// <param name="interface_version">Interface version lookup.</param> /// <remarks>This only will return a valid value if the service is running and registered with the Endpoint Mapper. It can also hang.</remarks> /// <returns>The RPC binding string. Empty string if it doesn't exist or the lookup failed.</returns> private static string MapBindingToBindingString(NtResult <SafeRpcBindingHandle> binding, Guid interface_id, Version interface_version) { if (!binding.IsSuccess) { return(string.Empty); } RPC_SERVER_INTERFACE ifspec = new RPC_SERVER_INTERFACE(); ifspec.Length = Marshal.SizeOf(ifspec); ifspec.InterfaceId.SyntaxGUID = interface_id; ifspec.InterfaceId.SyntaxVersion = interface_version.ToRpcVersion(); var result = Win32NativeMethods.RpcEpResolveBinding(binding.Result, ref ifspec); if (result != Win32Error.SUCCESS) { return(string.Empty); } return(binding.Result.ToString()); }
/// <summary> /// Resolve the binding string for this service from the the Endpoint Mapper. /// </summary> /// <param name="protocol_seq">The protocol sequence to lookup.</param> /// <param name="network_address">The network address to lookup the endpoint.</param> /// <param name="interface_id">Interface UUID to lookup.</param> /// <param name="interface_version">Interface version lookup.</param> /// <remarks>This only will return a valid value if the service is running and registered with the Endpoint Mapper. It can also hang.</remarks> /// <returns>The RPC binding string. Empty string if it doesn't exist or the lookup failed.</returns> public static string MapServerToBindingString(string protocol_seq, string network_address, Guid interface_id, Version interface_version) { using (var binding = SafeRpcBindingHandle.Create(null, protocol_seq, network_address, null, null, false)) { if (!binding.IsSuccess) { return(string.Empty); } RPC_SERVER_INTERFACE ifspec = new RPC_SERVER_INTERFACE(); ifspec.Length = Marshal.SizeOf(ifspec); ifspec.InterfaceId.SyntaxGUID = interface_id; ifspec.InterfaceId.SyntaxVersion = interface_version.ToRpcVersion(); var result = Win32NativeMethods.RpcEpResolveBinding(binding.Result, ref ifspec); if (result != Win32Error.SUCCESS) { return(string.Empty); } return(binding.Result.ToString()); } }
/// <summary> /// Resolve the binding string for this service from the local Endpoint Mapper. /// </summary> /// <param name="protocol_seq">The protocol sequence to lookup.</param> /// <param name="interface_id">Interface UUID to lookup.</param> /// <param name="interface_version">Interface version lookup.</param> /// <remarks>This only will return a valid value if the service is running and registered with the Endpoint Mapper. It can also hang.</remarks> /// <returns>The RPC binding string. Empty string if it doesn't exist or the lookup failed.</returns> public static string MapServerToBindingString(string protocol_seq, Guid interface_id, Version interface_version) { int result = Win32NativeMethods.RpcBindingFromStringBinding($"{protocol_seq}:", out SafeRpcBindingHandle binding); if (result != 0) { return(string.Empty); } using (binding) { RPC_SERVER_INTERFACE ifspec = new RPC_SERVER_INTERFACE(); ifspec.Length = Marshal.SizeOf(ifspec); ifspec.InterfaceId.SyntaxGUID = interface_id; ifspec.InterfaceId.SyntaxVersion = interface_version.ToRpcVersion(); result = Win32NativeMethods.RpcEpResolveBinding(binding, ref ifspec); if (result != 0) { return(string.Empty); } return(binding.ToString()); } }