Microsoft.Protocols.TestTools.StackSdk.RemoteDesktop.Rdpedyc.PduBuilder.CreateCompressedDataPdu C# (CSharp) Method

CreateCompressedDataPdu() public method

Create a DataCompressedDvcPdu
public CreateCompressedDataPdu ( uint channelId, byte data, int channelChunkLength = 1599 ) : Microsoft.Protocols.TestTools.StackSdk.RemoteDesktop.Rdpedyc.DataCompressedDvcPdu[]
channelId uint
data byte
channelChunkLength int
return Microsoft.Protocols.TestTools.StackSdk.RemoteDesktop.Rdpedyc.DataCompressedDvcPdu[]
        public DataCompressedDvcPdu[] CreateCompressedDataPdu(uint channelId, byte[] data, int channelChunkLength = 1599)
        {
            MemoryStream ms = new MemoryStream(data);
            List<DataCompressedDvcPdu> pdus = new List<DataCompressedDvcPdu>();

            //TODO: Here the compress algorithm has bug and cannot compress the data correctly. The size will become bigger than before comprssion
            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;

            //RDP8_BULK_ENCODED_DATA rdp8BulkEncodedData = new RDP8_BULK_ENCODED_DATA();
            //rdp8BulkEncodedData.descriptor = 0xE0; //Single
            //rdp8BulkEncodedData.header = 0x26;//PACKET_COMPRESSED (0x2), PACKET_CMPR_TYPE_RDP8_LITE (0x06)
            //rdp8BulkEncodedData.data = compressed;

            byte[] rdp8Header = new byte[] { 0xE0, 0x26 }; //0xE0; Single 0x26:PACKET_COMPRESSED (0x2), PACKET_CMPR_TYPE_RDP8_LITE (0x06)

            var s = new MemoryStream();
            s.Write(rdp8Header, 0, rdp8Header.Length);
            s.Write(compressed, 0, compressed.Length);
            byte[] rdp8BulkEncodedData = s.ToArray();
            pdu.Data = rdp8BulkEncodedData;
            pdus.Add(pdu);
            return pdus.ToArray();
        }

Usage Example

コード例 #1
0
        /// <summary>
        /// Send data using this DVC
        /// </summary>
        /// <param name="data"></param>
        public void Send(byte[] data, bool isCompressed = false)
        {
            DataDvcBasePdu[] dataPdus = null;
            if (isCompressed)
            {
                dataPdus = pduBuilder.CreateCompressedDataPdu(
                    channelId,
                    data);
            }
            else
            {
                dataPdus = pduBuilder.CreateDataPdu(channelId, data, ConstLength.MAX_CHUNK_LEN);
            }

            if (dataPdus != null)
            {
                foreach (DataDvcBasePdu pdu in dataPdus)
                {
                    transport.Send(pdu);
                }
            }
        }