public Virtual_Channel_RAW_Pdu_Ex(Virtual_Channel_RAW_Pdu originalPacket, RdpbcgrClientContext clientContext)
     : base(clientContext)
 {
     this.commonHeader       = originalPacket.commonHeader;
     this.channelPduHeader   = originalPacket.channelPduHeader;
     this.virtualChannelData = originalPacket.virtualChannelData;
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="context"></param>
        public Rdpbcgr_DVCClientTransport(RdpbcgrClientContext context)
        {
            this.context = context;

            if (context.SVCManager == null)
            {
                throw new NotSupportedException("Cannot get SVC from RDPBCGR connection for RDPEDYC, this transport must be created after RDPBCGR connection established.");
            }

            channel = context.SVCManager.GetChannelByName(StaticVirtualChannelName.RDPEDYC);
            if (channel == null)
            {
                throw new NotSupportedException("Cannot get SVC from RDPBCGR connection for RDPEDYC, the static virtual channel is not created.");
            }

            channel.Received += ReceivedBytes;
            if (!context.SVCManager.IsRunning)
            {
                // Must start the SVC manager here, so as to make sure the first packet of RDPEDYC can be processed
                context.SVCManager.Start();
            }

            decoder    = new ClientDecodingPduBuilder();
            pduBuilder = new PduBuilder();
        }
 public TS_INPUT_PDU_Ex(TS_INPUT_PDU originalPacket, RdpbcgrClientContext clientContext)
     : base(clientContext)
 {
     this.commonHeader        = originalPacket.commonHeader;
     this.shareDataHeader     = originalPacket.shareDataHeader;
     this.numberEvents        = originalPacket.numberEvents;
     this.pad2Octets          = originalPacket.pad2Octets;
     this.slowPathInputEvents = originalPacket.slowPathInputEvents;
 }
        /// <summary>
        /// Construcotr
        /// </summary>
        /// <param name="clientSessionContext"></param>
        /// <param name="transportType"></param>
        public Rdpemt_DVCClientTransport(RdpbcgrClientContext clientSessionContext, DynamicVC_TransportType transportType)
        {
            this.clientSessionContext = clientSessionContext;
            this.transportProtocol    = Multitransport_Protocol_value.INITITATE_REQUEST_PROTOCOL_UDPFECR;
            if (transportType == DynamicVC_TransportType.RDP_UDP_Lossy)
            {
                this.transportProtocol = Multitransport_Protocol_value.INITITATE_REQUEST_PROTOCOL_UDPFECL;
            }

            decoder    = new ClientDecodingPduBuilder();
            pduBuilder = new PduBuilder();
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="context"></param>
        /// <param name="autoCreateChannel"></param>
        /// <param name="callBackMethodsDic"></param>
        public RdpedycClient(RdpbcgrClientContext context, bool autoCreateChannel = true)
        {
            this.clientSessionContext = context;
            transportDic = new Dictionary <DynamicVC_TransportType, IDVCTransport>();
            unprocessedDVCPacketBuffer = new List <UnprocessedDVCPDUInfo>();
            Rdpbcgr_DVCClientTransport transport = new Rdpbcgr_DVCClientTransport(context);

            channelDicbyId = new Dictionary <uint, DynamicVirtualChannel>();

            this.autoCreateChannel = autoCreateChannel;

            pduBuilder = new PduBuilder();

            transport.Received += ProcessPacketFromTCP;
            transportDic.Add(DynamicVC_TransportType.RDP_TCP, transport);
        }
        /// <summary>
        /// Encode slow path pdu to a byte list.
        /// </summary>
        /// <param name="sendBuffer">The buffer list to contain the PDU.
        /// This argument cannot be null. It may throw ArgumentNullException if it is null.</param>
        /// <param name="commonHeader">The common header of the PDU including tpktHeader, X224, security header,
        /// user channel Id and I/O channel Id.</param>
        /// <param name="dataBody">The data following the common header.
        /// This argument can be null. If it is null, the method will encode commonHeader only.</param>
        /// <param name="context">The context used to encrypt the data body.
        /// If the securityHeader is the type of TS_SECURITY_HEADER, then this argument can be null.
        /// Otherwise, this argument can not be null, the dataBody will not be encrypted.</param>
        public static void EncodeSlowPathPdu(List <byte> sendBuffer,
                                             SlowPathPduCommonHeader commonHeader,
                                             byte[] dataBody,
                                             RdpbcgrClientContext context)
        {
            EncodeStructure(sendBuffer, commonHeader.tpktHeader);
            EncodeStructure(sendBuffer, commonHeader.x224Data);

            List <byte> securityBuffer = new List <byte>();

            EncodeSecurityData(securityBuffer, commonHeader.securityHeader, dataBody, context);

            SendDataRequest securityExchange = new SendDataRequest(new UserId(commonHeader.initiator),
                                                                   new ChannelId(commonHeader.channelId),
                                                                   new DataPriority(ConstValue.SEND_DATA_REQUEST_PRIORITY),
                                                                   ConstValue.SEND_DATA_REQUEST_SEGMENTATION,
                                                                   new Asn1OctetString(securityBuffer.ToArray()));
            DomainMCSPDU mcsDomain = new DomainMCSPDU(DomainMCSPDU.sendDataRequest, securityExchange);

            EncodeDomainMcsPdu(sendBuffer, mcsDomain);
        }
Esempio n. 7
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="context"></param>
        public ClientStaticVirtualChannelManager(RdpbcgrClientContext context)
        {
            this.context          = context;
            this.channelDicById   = new Dictionary <ushort, StaticVirtualChannel>();
            this.channelDicByName = new Dictionary <string, StaticVirtualChannel>();
            ushort[]      virtualChannelIds     = context.VirtualChannelIdStore;
            CHANNEL_DEF[] virtualChannelDefines = context.VirtualChannelDefines;
            if (virtualChannelIds != null && virtualChannelDefines != null &&
                virtualChannelIds.Length == virtualChannelDefines.Length)
            {
                CompressionType compressType = context.VirtualChannelSCCompressionType;
                if (context.CompressionTypeSupported == CompressionType.PACKET_COMPR_TYPE_NONE)
                {
                    compressType = CompressionType.PACKET_COMPR_TYPE_NONE;
                }
                else if (context.CompressionTypeSupported == CompressionType.PACKET_COMPR_TYPE_RDP6 ||
                         context.CompressionTypeSupported == CompressionType.PACKET_COMPR_TYPE_RDP61)
                {
                    compressType = CompressionType.PACKET_COMPR_TYPE_64K;
                }

                for (int i = 0; i < virtualChannelIds.Length; ++i)
                {
                    string name = virtualChannelDefines[i].name;
                    if (name != null)
                    {
                        name = name.Replace("\0", string.Empty).ToUpper();
                    }
                    StaticVirtualChannel channel = new ClientStaticVirtualChannel(virtualChannelIds[i],
                                                                                  name,
                                                                                  virtualChannelDefines[i].options,
                                                                                  context.VCChunkSize,
                                                                                  compressType,
                                                                                  context.VirtualChannelCSCompressionType,
                                                                                  SendPacket);
                    channelDicById.Add(virtualChannelIds[i], channel);
                    channelDicByName.Add(name, channel);
                }
            }
        }
        /// <summary>
        /// Encode security header and its body to a byte list.
        /// </summary>
        /// <param name="buffer">The buffer list to contain the PDU.
        /// This argument cannot be null. It may throw ArgumentNullException if it is null.</param>
        /// <param name="securityHeader">The security header to be encoded.
        /// This argument can be null. If it is null, the method will encode dataBody only.
        /// Then it is the same as EncodeBytes.</param>
        /// <param name="dataBody">The data following the security header.
        /// This argument can be null. If it is null, the method will encode securityHeader only.</param>
        /// <param name="context">The context used to encrypt the data body.
        /// If the securityHeader is the type of TS_SECURITY_HEADER, then this argument can be null.
        /// Otherwise, this argument can not be null, it will not encrypt the dataBody.</param>
        internal static void EncodeSecurityData(List <byte> buffer,
                                                TS_SECURITY_HEADER securityHeader,
                                                byte[] dataBody,
                                                RdpbcgrClientContext context)
        {
            if (securityHeader != null)       // have a security header
            {
                EncodeStructure(buffer, (ushort)securityHeader.flags);
                EncodeStructure(buffer, securityHeader.flagsHi);

                if (securityHeader.GetType() == typeof(TS_SECURITY_HEADER1))   // non-fips security header
                {
                    if (dataBody != null && context != null)
                    {
                        TS_SECURITY_HEADER1 nonFipsHeader = securityHeader as TS_SECURITY_HEADER1;
                        byte[] dataSignature = null;

                        bool isSalted = (nonFipsHeader.flags & TS_SECURITY_HEADER_flags_Values.SEC_SECURE_CHECKSUM)
                                        == TS_SECURITY_HEADER_flags_Values.SEC_SECURE_CHECKSUM;
                        context.Encrypt(dataBody, isSalted, out dataBody, out dataSignature);

                        // If the data signature has not been set, generate it.
                        // Otherwise, keep the old value.
                        if (nonFipsHeader.dataSignature == null)
                        {
                            nonFipsHeader.dataSignature = dataSignature;
                        }

                        EncodeBytes(buffer, nonFipsHeader.dataSignature);
                    }
                }
                else if (securityHeader.GetType() == typeof(TS_SECURITY_HEADER2))   // fips security header
                {
                    if (dataBody != null && context != null)
                    {
                        TS_SECURITY_HEADER2 fipsHeader = securityHeader as TS_SECURITY_HEADER2;
                        byte[] dataSignature           = null;
                        EncodeStructure(buffer, (ushort)fipsHeader.length);
                        EncodeStructure(buffer, fipsHeader.version);

                        // If the padlen equals 0, calculate it.
                        // Otherwise, keep the old value.
                        if (fipsHeader.padlen == 0)
                        {
                            fipsHeader.padlen = (byte)(ConstValue.TRIPLE_DES_PAD
                                                       - (dataBody.Length % ConstValue.TRIPLE_DES_PAD));
                        }

                        EncodeStructure(buffer, fipsHeader.padlen);
                        context.Encrypt(dataBody, false, out dataBody, out dataSignature);

                        // If the data signature has not been set, generate it.
                        // Otherwise, keep the old value.
                        if (fipsHeader.dataSignature == null)
                        {
                            fipsHeader.dataSignature = dataSignature;
                        }

                        EncodeBytes(buffer, fipsHeader.dataSignature);
                    }
                }
                // else do not do encryption
            }

            EncodeBytes(buffer, dataBody);
        }
 public Client_Confirm_Active_Pdu_Ex(Client_Confirm_Active_Pdu originalPacket, RdpbcgrClientContext clientContext)
     : base(clientContext)
 {
     this.commonHeader         = originalPacket.commonHeader;
     this.confirmActivePduData = originalPacket.confirmActivePduData;
 }
 public Client_Info_Pdu_Ex(Client_Info_Pdu originalPacket, RdpbcgrClientContext clientContext)
     : base(clientContext)
 {
     this.commonHeader = originalPacket.commonHeader;
     this.infoPacket   = originalPacket.infoPacket;
 }
 public Client_MCS_Erect_Domain_Request_Ex(Client_MCS_Erect_Domain_Request originalPacket, RdpbcgrClientContext clientContext, NegativeType invalidType)
     : base(clientContext)
 {
     this.tpktHeader  = originalPacket.tpktHeader;
     this.x224Data    = originalPacket.x224Data;
     this.subHeight   = originalPacket.subHeight;
     this.subInterval = originalPacket.subInterval;
     this.invalidType = invalidType;
 }
 public Client_MCS_Connect_Initial_Pdu_with_GCC_Conference_Create_Request_Ex(Client_MCS_Connect_Initial_Pdu_with_GCC_Conference_Create_Request originalPacket, RdpbcgrClientContext clientContext)
     : base(clientContext)
 {
     this.tpktHeader = originalPacket.tpktHeader;
     this.x224Data   = originalPacket.x224Data;
     this.mcsCi      = originalPacket.mcsCi;
 }
Esempio n. 13
0
 public TS_LICENSE_PDU(RdpbcgrClientContext clientContext)
     : base(clientContext)
 {
 }