/// <summary> /// Constructor. /// </summary> /// <param name="stream">The stream to use to communicate with the transport.</param> /// <param name="max_recv_fragment">The initial maximum receive fragment length.</param> /// <param name="max_send_fragment">The initial maximum send fragment length.</param> /// <param name="transport_security">The transport security for the connection.</param> /// <param name="data_rep">The data representation.</param> protected RpcStreamClientTransport(Stream stream, ushort max_recv_fragment, ushort max_send_fragment, NdrDataRepresentation data_rep, RpcTransportSecurity transport_security) : base(max_recv_fragment, max_send_fragment, data_rep, transport_security) { _reader = new BinaryReader(stream, Encoding.ASCII, true); _writer = new BinaryWriter(stream, Encoding.ASCII, true); }
/// <summary> /// Send and receive an RPC message. /// </summary> /// <param name="proc_num">The procedure number.</param> /// <param name="objuuid">The object UUID for the call.</param> /// <param name="data_representation">NDR data representation.</param> /// <param name="ndr_buffer">Marshal NDR buffer for the call.</param> /// <param name="handles">List of handles marshaled into the buffer.</param> /// <returns>Client response from the send.</returns> public RpcClientResponse SendReceive(int proc_num, Guid objuuid, NdrDataRepresentation data_representation, byte[] ndr_buffer, IReadOnlyCollection <NtObject> handles) { if (ndr_buffer.Length > 0xF00) { return(SendAndReceiveLarge(proc_num, objuuid, ndr_buffer, handles)); } return(SendAndReceiveImmediate(proc_num, objuuid, ndr_buffer, handles)); }
/// <summary> /// Constructor. /// </summary> /// <param name="max_recv_fragment">The initial maximum receive fragment length.</param> /// <param name="max_send_fragment">The initial maximum send fragment length.</param> /// <param name="transport_security">The transport security for the connection.</param> /// <param name="data_rep">The data representation.</param> protected RpcConnectedClientTransport(ushort max_recv_fragment, ushort max_send_fragment, NdrDataRepresentation data_rep, RpcTransportSecurity transport_security) { _max_recv_fragment = max_recv_fragment; _max_send_fragment = max_send_fragment; _data_rep = data_rep; _transport_security = transport_security; _auth_context = transport_security.CreateClientContext(); }
public PDUHeader(PDUType type) { MajorVersion = RPC_VERSION_MAJOR; MinorVersion = RPC_VERSION_MINOR; Type = type; Flags = PDUFlags.None; DataRep = new NdrDataRepresentation(); FragmentLength = 0; AuthLength = 0; CallId = 0; }
/// <summary> /// Constructor. /// </summary> /// <param name="path">The NT pipe path to connect. e.g. \??\pipe\ABC.</param> /// <param name="security_quality_of_service">The security quality of service for the connection.</param> public RpcNamedPipeClientTransport(string path, SecurityQualityOfService security_quality_of_service) { if (string.IsNullOrEmpty(path)) { throw new ArgumentException("Must specify a path to connect to", nameof(path)); } _pipe = ConnectPipe(path, security_quality_of_service); _data_rep = new NdrDataRepresentation(); _max_recv_fragment = MaxRecvFrag; _max_send_fragment = MaxXmitFrag; Endpoint = path; }
/// <summary> /// Send and receive an RPC message. /// </summary> /// <param name="proc_num">The procedure number.</param> /// <param name="data_representation">The NDR data representation.</param> /// <param name="ndr_buffer">Marshal NDR buffer for the call.</param> /// <param name="handles">List of handles marshaled into the buffer.</param> /// <returns>Unmarshal NDR buffer for the result.</returns> protected RpcClientResponse SendReceive(int proc_num, NdrDataRepresentation data_representation, byte[] ndr_buffer, IReadOnlyCollection <NtObject> handles) { if (!Connected) { throw new InvalidOperationException("RPC client is not connected."); } DumpNdrBuffer("NDR Send Data", ndr_buffer); var resp = _transport.SendReceive(proc_num, ObjectUuid, data_representation, ndr_buffer, handles); DumpNdrBuffer("NDR Receive Data", resp.NdrBuffer); return(resp); }
/// <summary> /// Constructor. /// </summary> /// <param name="max_recv_fragment">The initial maximum receive fragment length.</param> /// <param name="max_send_fragment">The initial maximum send fragment length.</param> /// <param name="transport_security">The transport security for the connection.</param> /// <param name="data_rep">The data representation.</param> protected RpcConnectedClientTransport(ushort max_recv_fragment, ushort max_send_fragment, NdrDataRepresentation data_rep, RpcTransportSecurity transport_security) { _max_recv_fragment = max_recv_fragment; _max_send_fragment = max_send_fragment; _data_rep = data_rep; _security_context = new Dictionary <int, RpcTransportSecurityContext>(); _current_security_context = new RpcTransportSecurityContext(this, transport_security, _current_context_id++); _security_context[_current_security_context.ContextId] = _current_security_context; switch (transport_security.AuthenticationLevel) { case RpcAuthenticationLevel.PacketIntegrity: case RpcAuthenticationLevel.PacketPrivacy: _auth_data_required = true; break; } if (DisableBindTimeFeatureNegotiation) { _bind_time_features = BindTimeFeatureNegotiation.None; } }
/// <summary> /// Send and receive an RPC message. /// </summary> /// <param name="proc_num">The procedure number.</param> /// <param name="objuuid">The object UUID for the call.</param> /// <param name="data_representation">NDR data representation.</param> /// <param name="ndr_buffer">Marshal NDR buffer for the call.</param> /// <param name="handles">List of handles marshaled into the buffer.</param> /// <returns>Client response from the send.</returns> public RpcClientResponse SendReceive(int proc_num, Guid objuuid, NdrDataRepresentation data_representation, byte[] ndr_buffer, IReadOnlyCollection <NtObject> handles) { NdrUnmarshalBuffer.CheckDataRepresentation(data_representation); PDURequest request = new PDURequest { OpNum = (short)proc_num, ObjectUUID = objuuid, StubData = ndr_buffer }; var recv_pdu = SendReceivePDU(request); if (recv_pdu is PDUResponse pdu_respose) { return(new RpcClientResponse(pdu_respose.StubData, new NtObject[0])); } else { throw new RpcTransportException("Unexpected PDU from server."); } }
public RpcClientResponse SendReceive(int proc_num, Guid objuuid, NdrDataRepresentation data_representation, byte[] ndr_buffer, IReadOnlyCollection <NtObject> handles) { throw new NotImplementedException(); }
internal RpcClientResponse(byte[] ndr_buffer, IEnumerable <NtObject> handles) { NdrBuffer = ndr_buffer; Handles = new List <NtObject>(handles.Select(o => o.DuplicateObject())); DataRepresentation = new NdrDataRepresentation(); }
/// <summary> /// Send and receive an RPC message. /// </summary> /// <param name="proc_num">The procedure number.</param> /// <param name="objuuid">The object UUID for the call.</param> /// <param name="data_representation">NDR data representation.</param> /// <param name="ndr_buffer">Marshal NDR buffer for the call.</param> /// <param name="handles">List of handles marshaled into the buffer.</param> /// <returns>Client response from the send.</returns> public RpcClientResponse SendReceive(int proc_num, Guid objuuid, NdrDataRepresentation data_representation, byte[] ndr_buffer, IReadOnlyCollection <NtObject> handles) { NdrUnmarshalBuffer.CheckDataRepresentation(data_representation); return(new RpcClientResponse(SendReceiveRequestPDU(proc_num, objuuid, ndr_buffer), new NtObject[0])); }
/// <summary> /// Constructor. /// </summary> /// <param name="socket">The socket to use to communicate.</param> /// <param name="max_recv_fragment">The initial maximum receive fragment length.</param> /// <param name="max_send_fragment">The initial maximum send fragment length.</param> /// <param name="transport_security">The transport security for the connection.</param> /// <param name="data_rep">The data representation.</param> protected RpcStreamSocketClientTransport(Socket socket, ushort max_recv_fragment, ushort max_send_fragment, NdrDataRepresentation data_rep, RpcTransportSecurity transport_security) : base(new NetworkStream(socket), max_recv_fragment, max_send_fragment, data_rep, transport_security) { _socket = socket; }