The RDP8_BULK_ENCODED_DATA structure contains a header byte and data that has been encoded using RDP 8.0 Bulk Compression techniques (section 3.1.9.1).
Exemplo n.º 1
0
        /// <summary>
        /// Create a DataCompressedDvcPdu
        /// </summary>
        /// <param name="channelId"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public DataCompressedDvcPdu[] CreateCompressedDataPdu(uint channelId, byte[] data)
        {
            MemoryStream ms = new MemoryStream(data);
            List <DataCompressedDvcPdu> pdus = new List <DataCompressedDvcPdu>();

            byte[] compressed = CompressDataToRdp8BulkEncodedData(data, PACKET_COMPR_FLAG.PACKET_COMPR_TYPE_LITE | PACKET_COMPR_FLAG.PACKET_COMPRESSED);

            DataCompressedDvcPdu pdu = new DataCompressedDvcPdu();

            pdu.HeaderBits.Cmd         = Cmd_Values.DataCompressed;
            pdu.HeaderBits.Sp          = 0x0;
            pdu.HeaderBits.CbChannelId = cbChId_Values.OneByte;
            pdu.ChannelId = channelId;

            RDP_SEGMENTED_DATA rdpSegmentedData = new RDP_SEGMENTED_DATA();

            rdpSegmentedData.descriptor = DescriptorTypes.SINGLE;

            RDP8_BULK_ENCODED_DATA rdp8BulkEncodedData = new RDP8_BULK_ENCODED_DATA();

            rdp8BulkEncodedData.header = (byte)(PACKET_COMPR_FLAG.PACKET_COMPR_TYPE_LITE | PACKET_COMPR_FLAG.PACKET_COMPRESSED);
            rdp8BulkEncodedData.data   = compressed;

            pdu.Data = PduMarshaler.Marshal(rdpSegmentedData);
            pdus.Add(pdu);
            return(pdus.ToArray());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Decode this PDU from the PduMarshaler.
        /// </summary>
        /// <param name="marshaler">This is used to decode the fields of this PDU.</param>
        public override bool Decode(PduMarshaler marshaler)
        {
            try
            {
                this.descriptor = (DescriptorTypes)marshaler.ReadByte();

                if (this.descriptor == DescriptorTypes.SINGLE)
                {
                    this.bulkData        = new RDP8_BULK_ENCODED_DATA();
                    this.bulkData.header = marshaler.ReadByte();
                    this.bulkData.data   = marshaler.ReadToEnd();
                }
                else
                {
                    this.segmentCount     = marshaler.ReadUInt16();
                    this.uncompressedSize = marshaler.ReadUInt32();
                    if (this.segmentCount > 0)
                    {
                        this.segmentArray = new RDP_DATA_SEGMENT[this.segmentCount];
                        for (int i = 0; i < this.segmentCount; i++)
                        {
                            this.segmentArray[i].size = marshaler.ReadUInt32();
                            if (this.segmentArray[i].size > 0)
                            {
                                this.segmentArray[i].bulkData        = new RDP8_BULK_ENCODED_DATA();
                                this.segmentArray[i].bulkData.header = marshaler.ReadByte();
                                this.segmentArray[i].bulkData.data   = marshaler.ReadBytes((int)this.segmentArray[i].size - 1);
                            }
                        }
                    }
                }

                return(true);
            }
            catch
            {
                marshaler.Reset();
                throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
            }
        }
        /// <summary>
        /// Decode this PDU from the PduMarshaler.
        /// </summary>
        /// <param name="marshaler">This is used to decode the fields of this PDU.</param>
        public override bool Decode(PduMarshaler marshaler)
        {
            try
            {
                this.descriptor = (DescriptorTypes)marshaler.ReadByte();

                if (this.descriptor == DescriptorTypes.SINGLE)
                {
                    this.bulkData = new RDP8_BULK_ENCODED_DATA();
                    this.bulkData.header = marshaler.ReadByte();
                    this.bulkData.data = marshaler.ReadToEnd();
                }
                else
                {
                    this.segmentCount = marshaler.ReadUInt16();
                    this.uncompressedSize = marshaler.ReadUInt32();
                    if (this.segmentCount > 0)
                    {
                        this.segmentArray = new RDP_DATA_SEGMENT[this.segmentCount];
                        for (int i = 0; i < this.segmentCount; i++)
                        {
                            this.segmentArray[i].size = marshaler.ReadUInt32();
                            if (this.segmentArray[i].size > 0)
                            {
                                this.segmentArray[i].bulkData = new RDP8_BULK_ENCODED_DATA();
                                this.segmentArray[i].bulkData.header = marshaler.ReadByte();
                                this.segmentArray[i].bulkData.data = marshaler.ReadBytes((int)this.segmentArray[i].size - 1);
                            }
                        }
                    }
                }

                return true;
            }
            catch
            {
                marshaler.Reset();
                throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
            }
        }