示例#1
0
        public virtual EusbPdu ParsePdu(byte[] data)
        {
            EusbPdu pdu = new EusbUnknownPdu();

            PduMarshaler.Unmarshal(data, pdu);
            return(pdu);
        }
        protected void ReadChannelId(PduMarshaler marshaler)
        {
            uint res = 0;

            switch (HeaderBits.CbChannelId)
            {
            case cbChId_Values.OneByte:
                res = Convert.ToUInt32(marshaler.ReadByte());
                break;

            case cbChId_Values.TwoBytes:
                res = Convert.ToUInt32(marshaler.ReadUInt16());
                break;

            case cbChId_Values.FourBytes:
                res = Convert.ToUInt32(marshaler.ReadUInt32());
                break;

            case cbChId_Values.Invalid:
            default:
                //TODO: handle errors.
                break;
            }

            //TODO: handle errors.
            ChannelId = res;
        }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     marshaler.WriteUInt16(maximumPacketSize);
     marshaler.WriteUInt16(padding);
     marshaler.WriteUInt32(maximumTransferSize);
     marshaler.WriteUInt32(pipeFlags);
 }
示例#4
0
        public override bool Decode(PduMarshaler marshaler)
        {
            try
            {
                byte[] data = new byte[marshaler.RawData.Length];
                Array.Copy(marshaler.RawData, data, data.Length);

                this.TunnelHeader = new RDP_TUNNEL_HEADER();
                bool bSuccessful = PduMarshaler.Unmarshal(data, this.TunnelHeader);
                if (bSuccessful)
                {
                    marshaler.ReadBytes(this.TunnelHeader.HeaderLength); // Move forward to payload data
                    if (this.TunnelHeader.PayloadLength > 0)
                    {
                        this.HigherLayerData = marshaler.ReadBytes(this.TunnelHeader.PayloadLength);
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
示例#5
0
        public override bool Decode(PduMarshaler marshaler)
        {
            try
            {
                byte[] data = new byte[marshaler.RawData.Length];
                Array.Copy(marshaler.RawData, data, data.Length);

                this.TunnelHeader = new RDP_TUNNEL_HEADER();
                bool bSuccessful = PduMarshaler.Unmarshal(data, this.TunnelHeader);
                if (bSuccessful)
                {
                    marshaler.ReadBytes(this.TunnelHeader.HeaderLength); // Move forward to payload data
                    this.RequestID      = marshaler.ReadUInt32();
                    this.Reserved       = marshaler.ReadUInt32();
                    this.SecurityCookie = marshaler.ReadBytes(16);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
        public override bool Decode(PduMarshaler marshaler)
        {
            HeaderBits = new Header(marshaler.ReadByte());

            Cmd_Values c = HeaderBits.Cmd;

            // TODO: Check this logic
            // Check in the special case that the Cmd bit field just
            // equals to Cmd_Values.Unknown
            if (c == Cmd_Values.Unknown)
            {
                return(false);
            }

            try
            {
                if (c == Cmd)
                {
                    DoUnmarshal(marshaler);
                    SetRawData(false, marshaler);
                    return(true);
                }
            }
            catch (OverflowException)
            {
                marshaler.Reset();
            }
            catch (RdpedycPduMismatchException)
            {
                marshaler.Reset();
            }

            return(false);
        }
        /// <summary>
        /// Submits data to the client USB device.
        /// </summary>
        /// <param name="device">The context of the device which is being operated.</param>
        /// <param name="tsUrb">A TS_URB structure.</param>
        /// <param name="outputBuffer">The raw data to be sent to the device.</param>
        public void TransferOutRequest(EusbDeviceContext device, TS_URB tsUrb, byte[] outputBuffer)
        {
            uint size = null == outputBuffer ? 0 : (uint)outputBuffer.Length;

            Site.Log.Add(
                LogEntryKind.Debug,
                "Sending TRANSFER_OUT_REQUEST. Device: {0}, URB: {1}, Output buffer size: {2}",
                device,
                tsUrb,
                size);

            EusbTransferOutRequestPdu requestPdu = new EusbTransferOutRequestPdu(device.UsbDeviceInterfaceId);

            byte[] buf = PduMarshaler.Marshal(tsUrb);
            requestPdu.CbTsUrb = (uint)buf.Length;

            // TODO: Need verify for negtive test cases?
            if (tsUrb.Header.Size != (ushort)requestPdu.CbTsUrb)
            {
                throw new ArgumentException(String.Format(
                                                "Header.Size ({0}) doesn't match the actual size ({1}).",
                                                tsUrb.Header.Size,
                                                requestPdu.CbTsUrb
                                                ));
            }

            requestPdu.TsUrb            = buf;
            requestPdu.OutputBuffer     = outputBuffer;
            requestPdu.OutputBufferSize = size;
            SendPdu(requestPdu, device.VirtualChannel);
        }
        /// <summary>
        /// Decode segment data to an array of server Pdus
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static RdpegfxPdu[] Decode(byte[] data)
        {
            RDP_SEGMENTED_DATA segData = new RDP_SEGMENTED_DATA();
            bool fResult = PduMarshaler.Unmarshal(data, segData);

            if (fResult)
            {
                if (segData.descriptor == DescriptorTypes.SINGLE)
                {
                    byte[] rawData = Compressor.Decompress(segData.bulkData.data, segData.bulkData.header);;


                    return(DecodePdus(rawData));
                }
                else
                {
                    List <byte>        dataList = new List <byte>();
                    byte[]             rawData  = null;
                    RDP_DATA_SEGMENT[] dataSegs = segData.segmentArray;
                    for (int i = 0; i < dataSegs.Length; i++)
                    {
                        RDP8_BULK_ENCODED_DATA bulkData = dataSegs[i].bulkData;
                        rawData = Compressor.Decompress(bulkData.data, bulkData.header);
                        dataList.AddRange(rawData);
                    }

                    if (segData.uncompressedSize == dataList.Count)
                    {
                        return(DecodePdus(dataList.ToArray()));
                    }
                }
            }

            return(null);
        }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     marshaler.WriteByte((byte)descriptor);
     if (descriptor == DescriptorTypes.SINGLE)
     {
         if (bulkData != null)
         {
             marshaler.WriteByte(bulkData.header);
             marshaler.WriteBytes(bulkData.data);
         }
     }
     else
     {
         marshaler.WriteUInt16(segmentCount);
         marshaler.WriteUInt32(uncompressedSize);
         if (segmentArray != null && segmentArray.Length > 0)
         {
             foreach (RDP_DATA_SEGMENT dataSeg in segmentArray)
             {
                 marshaler.WriteUInt32(dataSeg.size);
                 if (dataSeg.bulkData != null)
                 {
                     marshaler.WriteByte(bulkData.header);
                     marshaler.WriteBytes(bulkData.data);
                 }
             }
         }
     }
 }
 /// <summary>
 /// The callback method to receive data from transport layer.
 /// </summary>
 private void OnDataReceived(byte[] data, uint channelId)
 {
     lock (receivedList)
     {
         RdpegfxPdu pdu      = new RdpegfxPdu();
         bool       fSucceed = false;
         bool       fResult  = PduMarshaler.Unmarshal(data, pdu);
         if (fResult)
         {
             byte[] pduData = new byte[pdu.Header.pduLength];
             Array.Copy(data, pduData, pduData.Length);
             if (pdu.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_CAPSADVERTISE)
             {
                 RDPGFX_CAPS_ADVERTISE recv = new RDPGFX_CAPS_ADVERTISE();
                 fSucceed = AddToReceivedList(pduData, recv);
             }
             else if (pdu.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_FRAMEACKNOWLEDGE)
             {
                 RDPGFX_FRAME_ACK recv = new RDPGFX_FRAME_ACK();
                 fSucceed = AddToReceivedList(pduData, recv);
             }
             else if (pdu.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_CACHEIMPORTOFFER)
             {
                 RDPGFX_CACHE_IMPORT_OFFER recv = new RDPGFX_CACHE_IMPORT_OFFER();
                 fSucceed = AddToReceivedList(pduData, recv);
             }
         }
         if (!fResult || !fSucceed)
         {
             RdpegfxUnkownPdu unkown = new RdpegfxUnkownPdu();
             PduMarshaler.Unmarshal(data, unkown);
             receivedList.Add(unkown);
         }
     }
 }
 /// <summary>
 /// Encode a RECT.
 /// </summary>
 private void EncodeRect(RECT rct, PduMarshaler marshaler)
 {
     marshaler.WriteInt32(rct.left);
     marshaler.WriteInt32(rct.top);
     marshaler.WriteInt32(rct.right);
     marshaler.WriteInt32(rct.bottom);
 }
        private int GetMaxiumPayloadSizeForSourcePacket(int upStreamMtu)
        {
            // Create a fake empty RDPEUDP ACK+SOURCE packet.
            var packet = new RdpeudpPacket();

            packet.fecHeader.snSourceAck        = 0;
            packet.fecHeader.uReceiveWindowSize = 0;
            packet.fecHeader.uFlags             = RDPUDP_FLAG.RDPUDP_FLAG_DATA | RDPUDP_FLAG.RDPUDP_FLAG_ACK;

            var ackVectorHeader = new RDPUDP_ACK_VECTOR_HEADER();

            ackVectorHeader.uAckVectorSize   = 0;
            ackVectorHeader.AckVectorElement = null;
            ackVectorHeader.Padding          = null;
            packet.ackVectorHeader           = ackVectorHeader;

            var sourceHeader = new RDPUDP_SOURCE_PAYLOAD_HEADER();

            sourceHeader.snCoded       = 0;
            sourceHeader.snSourceStart = 0;
            packet.sourceHeader        = sourceHeader;

            var size = PduMarshaler.Marshal(packet).Length;

            // Maximum payload size = upstream MTU - empty ACK+SOURCE header size.
            return(upStreamMtu - size);
        }
示例#13
0
        public DynamicVCPDU ToPdu(byte[] data)
        {
            if (null == regsiteredPDUs)
            {
                regsiteredPDUs = new List <DynamicVCPDU>();
                RegisterDefaultPdus();
            }

            DynamicVCPDU res = null;

            foreach (DynamicVCPDU pdu in regsiteredPDUs)
            {
                if (PduMarshaler.Unmarshal(data, pdu))
                {
                    res = pdu;
                    break;
                }
            }

            if (res == null)
            {
                DynamicVCException.Throw("UnknownDynamicVCPDU was not registered.");
            }

            // Clear references in the list and register new PDUs.
            regsiteredPDUs.Clear();
            RegisterDefaultPdus();

            return(res);
        }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32(MaxNumMonitors);
     marshaler.WriteUInt32(MaxMonitorAreaFactorA);
     marshaler.WriteUInt32(MaxMonitorAreaFactorB);
 }
示例#15
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());
        }
        /// <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
            {
                if (!base.Decode(marshaler))
                {
                    return(false);
                }
                configurationHandle = marshaler.ReadUInt32();
                numInterfaces       = marshaler.ReadUInt32();

                if (numInterfaces == 0)
                {
                    interfaces = null;
                }
                else
                {
                    interfaces = new TS_USBD_INTERFACE_INFORMATION_RESULT[numInterfaces];
                    for (int i = 0; i < numInterfaces; i++)
                    {
                        interfaces[i] = new TS_USBD_INTERFACE_INFORMATION_RESULT();
                        if (!interfaces[i].Decode(marshaler))
                        {
                            return(false);
                        }
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
        /// <summary>
        /// Requests data from the client USB device.
        /// </summary>
        /// <param name="device">The context of the device which is being operated.</param>
        /// <param name="tsUrb">A TS_URB structure.</param>
        /// <param name="outputBufferSize">This value represents the maximum number of bytes of data that is requested from
        /// the USB device.</param>
        public void TransferInRequest(EusbDeviceContext device, TS_URB tsUrb, uint outputBufferSize)
        {
            // TODO: Check this verification.
            //Site.Assume.IsFalse(
            //    tsUrb is TS_URB_ISOCH_TRANSFER && device.NoAckIsochWriteJitterBufferSizeInMs,
            //    "The client does not support TS_URB_ISOCH_TRANSFER messages."
            //    );

            Site.Log.Add(
                LogEntryKind.Debug,
                "Sending TRANSFER_IN_REQUEST. Device: {0}, URB: {1}, Output buffer size: {2}",
                device,
                tsUrb,
                outputBufferSize);

            EusbTransferInRequestPdu requestPdu = new EusbTransferInRequestPdu(device.UsbDeviceInterfaceId);

            byte[] buf = PduMarshaler.Marshal(tsUrb);
            requestPdu.CbTsUrb = (uint)buf.Length;

            // TODO: Need verify for negtive test cases?
            if (tsUrb.Header.Size != (ushort)requestPdu.CbTsUrb)
            {
                throw new ArgumentException(String.Format(
                                                "Header.Size ({0}) doesn't match the actual size ({1}).",
                                                tsUrb.Header.Size,
                                                requestPdu.CbTsUrb
                                                ));
            }

            requestPdu.TsUrb            = buf;
            requestPdu.OutputBufferSize = outputBufferSize;
            SendPdu(requestPdu, device.VirtualChannel);
        }
        protected uint ReadLength(PduMarshaler marshaler)
        {
            uint res = 0;

            switch ((Len_Values)HeaderBits.Sp)
            {
            case Len_Values.OneByte:
                res = Convert.ToUInt32(marshaler.ReadByte());
                break;

            case Len_Values.TwoBytes:
                res = Convert.ToUInt32(marshaler.ReadUInt16());
                break;

            case Len_Values.FourBytes:
                res = Convert.ToUInt32(marshaler.ReadUInt32());
                break;

            case Len_Values.Invalid:
            default:
                //TODO: handle errors.
                break;
            }

            //TODO: handle errors.
            return(res);
        }
 /// <summary>
 /// Decode this PDU from the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override bool Decode(PduMarshaler marshaler)
 {
     try
     {
         this.Header.cbSize      = marshaler.ReadUInt32();
         this.Header.PacketType  = (PacketTypeValues)marshaler.ReadUInt32();
         this.PresentatioinId    = marshaler.ReadByte();
         this.Version            = (RdpevorVersionValues)marshaler.ReadByte();
         this.Command            = (CommandValues)marshaler.ReadByte();
         this.FrameRate          = marshaler.ReadByte();
         this.AverageBitrateKbps = marshaler.ReadUInt16();
         this.Reserved           = marshaler.ReadUInt16();
         this.SourceWidth        = marshaler.ReadUInt32();
         this.SourceHeight       = marshaler.ReadUInt32();
         this.ScaledWidth        = marshaler.ReadUInt32();
         this.ScaledHeight       = marshaler.ReadUInt32();
         this.hnsTimestampOffset = marshaler.ReadUInt64();
         this.GeometryMappingId  = marshaler.ReadUInt64();
         this.VideoSubtypeId     = marshaler.ReadBytes(16);
         this.cbExtra            = marshaler.ReadUInt32();
         this.pExtraData         = marshaler.ReadBytes((int)this.cbExtra);
         this.Reserved2          = marshaler.ReadByte();
         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 encode the fields of this PDU.</param>
 public override bool Decode(PduMarshaler marshaler)
 {
     try
     {
         this.Header.cbSize      = marshaler.ReadUInt32();
         this.Header.PacketType  = (PacketTypeValues)marshaler.ReadUInt32();
         this.PresentatioinId    = marshaler.ReadByte();
         this.Version            = (RdpevorVersionValues)marshaler.ReadByte();
         this.Flags              = (TsmmVideoData_FlagsValues)marshaler.ReadByte();
         this.Reserved           = marshaler.ReadByte();
         this.HnsTimestamp       = marshaler.ReadUInt64();
         this.HnsDuration        = marshaler.ReadUInt64();
         this.CurrentPacketIndex = marshaler.ReadUInt16();
         this.PacketsInSample    = marshaler.ReadUInt16();
         this.SampleNumber       = marshaler.ReadUInt32();
         this.cbSample           = marshaler.ReadUInt32();
         this.pSample            = marshaler.ReadBytes((int)this.cbSample);
         this.Reserved2          = marshaler.ReadByte();
         return(true);
     }
     catch
     {
         marshaler.Reset();
         throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
     }
 }
 /// <summary>
 /// Decode to a RECT.
 /// </summary>
 private void DecodeRect(PduMarshaler marshaler, out RECT rct)
 {
     rct        = new RECT();
     rct.left   = marshaler.ReadInt32();
     rct.top    = marshaler.ReadInt32();
     rct.right  = marshaler.ReadInt32();
     rct.bottom = marshaler.ReadInt32();
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     if (Data != null)
     {
         marshaler.WriteBytes(Data);
     }
     ;
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     marshaler.WriteUInt32(this.Header.cbSize);
     marshaler.WriteUInt32((uint)this.Header.PacketType);
     marshaler.WriteByte(this.PresentatioinId);
     marshaler.WriteByte(this.ResponseFlags);
     marshaler.WriteUInt16(this.ResultFlags);
 }
        private void SendPdu(EusbPdu pdu, DynamicVirtualChannel channel)
        {
            Site.Assume.IsNotNull(channel, "DynamicVirtualChannel must be initialized.");

            channel.Send(PduMarshaler.Marshal(pdu));

            Site.Log.Add(LogEntryKind.Debug, "Sending {0}: \r\n{1}\r\n", pdu.GetType().ToString(), pdu.ToString());
        }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteByte(bEndpointAddress);
     marshaler.WriteByte(bmAttributes);
     marshaler.WriteUInt16(wMaxPacketSize);
     marshaler.WriteByte(bInterval);
 }
        public void SendRdpInvalidPdu(RDPINPUT_INVALID_PDU pdu)
        {
            byte[] data = PduMarshaler.Marshal(pdu);

            //Sleep 100 millisecond to this packet to be merged with another packet in TCP channel.
            System.Threading.Thread.Sleep(100);

            rdpeiServer.RdpeiDVChannel.Send(data);
        }
 protected override void DoMarshal(PduMarshaler marshaler)
 {
     marshaler.WriteByte(Pad);
     marshaler.WriteUInt16(Version);
     marshaler.WriteUInt16(PriorityCharge0);
     marshaler.WriteUInt16(PriorityCharge1);
     marshaler.WriteUInt16(PriorityCharge2);
     marshaler.WriteUInt16(PriorityCharge3);
 }
 protected override void DoMarshal(PduMarshaler marshaler)
 {
     marshaler.WriteByte(Pad);
     marshaler.WriteUInt32(NumberOfTunnels);
     foreach (var tunnel in TunnelsToSwitch)
     {
         marshaler.WriteBytes(TypeMarshal.ToBytes <TunnelType_Value>(tunnel));
     }
 }
 public override void Encode(PduMarshaler marshaler)
 {
     marshaler.WriteUInt16(eventId);
     marshaler.WriteUInt32(pduLength);
     if (data != null)
     {
         marshaler.WriteBytes(data);
     }
 }
 /// <summary>
 /// Send a Pdu
 /// </summary>
 /// <param name="pdu"></param>
 public void SendRdpeiPdu(RDPINPUT_PDU pdu)
 {
     byte[] data = PduMarshaler.Marshal(pdu);
     if (rdpeiDVC == null)
     {
         throw new InvalidOperationException("DVC instance of RDPEI is null, Dynamic virtual channel must be created before sending data.");
     }
     rdpeiDVC.Send(data);
 }
 public bool Decode(PduMarshaler marshaler)
 {
     try
     {
         this.CapabilityType = (CapabilityType_Values)marshaler.ReadUInt16();
         this.CapabilityLength = marshaler.ReadUInt16();
         this.Version = (CAPABILITY_VERSION)marshaler.ReadUInt32();
         return true;
     }
     catch
     {
         marshaler.Reset();
         throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
     }
 }
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32(this.Length);
     marshaler.WriteByte(this.Padding);
 }
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32((uint)this.osType);
     marshaler.WriteUInt32((uint)this.osVersion);
     marshaler.WriteUInt16((ushort)this.protocolMajorVersion);
     marshaler.WriteUInt16((ushort)this.protocolMinorVersion);
     marshaler.WriteUInt32((uint)this.ioCode1);
     marshaler.WriteUInt32((uint)this.ioCode2);
     marshaler.WriteUInt32((uint)this.extendedPDU);
     marshaler.WriteUInt32((uint)this.extraFlags1);
     marshaler.WriteUInt32((uint)this.extraFlags2);
     marshaler.WriteUInt32(this.SpecialTypeDeviceCap);
 }
 /// <summary>
 /// Decode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to Decode the fields of this PDU.</param>
 public override bool Decode(PduMarshaler marshaler)
 {
     try
     {
         Header.Component = (Component_Values)marshaler.ReadUInt16();
         Header.PacketId = (PacketId_Values)marshaler.ReadUInt16();
         return true;
     }
     catch
     {
         marshaler.Reset();
         throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
     }
 }
 public override bool Decode(PduMarshaler marshaler)
 {
     Data = marshaler.ReadToEnd();
     return Data != null;
 }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     marshaler.WriteByte((byte)descriptor);
     if (descriptor == DescriptorTypes.SINGLE)
     {
         if (bulkData != null)
         {
             marshaler.WriteByte(bulkData.header);
             marshaler.WriteBytes(bulkData.data);
         }
     }
     else
     {
         marshaler.WriteUInt16(segmentCount);
         marshaler.WriteUInt32(uncompressedSize);
         if (segmentArray != null && segmentArray.Length > 0)
         {
             foreach (RDP_DATA_SEGMENT dataSeg in segmentArray)
             {
                 marshaler.WriteUInt32(dataSeg.size);
                 if (dataSeg.bulkData != null)
                 {
                     marshaler.WriteByte(bulkData.header);
                     marshaler.WriteBytes(bulkData.data);
                 }
             }
         }
     }
 }
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32(this.DeviceCount);
     foreach(var device in DeviceList)
     {
         device.Encode(marshaler);
     }
 }
 public override bool Decode(PduMarshaler marshaler)
 {
     try
     {
         base.Decode(marshaler);
         this.DeviceCount = marshaler.ReadUInt32();
         if(this.DeviceCount > 0)
         {
             this.DeviceList = new DEVICE_ANNOUNCE[this.DeviceCount];
             for(int i=0; i<this.DeviceCount; i++)
             {
                 DeviceList[i] = new DEVICE_ANNOUNCE();
                 DeviceList[i].Decode(marshaler);
             }
         }
         return true;
     }
     catch
     {
         marshaler.Reset();
         throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
     }
 }
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32((uint)this.UnicodeFlag);
     marshaler.WriteUInt32(this.CodePage);
     marshaler.WriteUInt32(this.ComputerNameLen);
     marshaler.WriteBytes(this.ComputerName);
 }
 public override bool Decode(PduMarshaler marshaler)
 {
     try
     {
         base.Decode(marshaler);
         this.UnicodeFlag = (UnicodeFlag_Values)(marshaler.ReadUInt32() & 0x1);
         this.CodePage = marshaler.ReadUInt32();
         this.ComputerNameLen = marshaler.ReadUInt32();
         this.ComputerName = marshaler.ReadBytes((int)this.ComputerNameLen);
         return true;
     }
     catch
     {
         marshaler.Reset();
         throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
     }
 }
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt16((ushort)this.VersionMajor);
     marshaler.WriteUInt16((ushort)this.VersionMinor);
     marshaler.WriteUInt32(this.ClientId);
 }
 public override bool Decode(PduMarshaler marshaler)
 {
     try
     {
         base.Decode(marshaler);
         this.VersionMajor = (DR_CORE_SERVER_ANNOUNCE_RSP_VersionMajor_Values)marshaler.ReadUInt16();
         this.VersionMinor = (DR_CORE_SERVER_ANNOUNCE_RSP_VersionMinor_Values)marshaler.ReadUInt16();
         this.ClientId = marshaler.ReadUInt32();
         return true;
     }
     catch
     {
         marshaler.Reset();
         throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
     }
 }
 public override bool Decode(PduMarshaler marshaler)
 {
     return base.Decode(marshaler);
 }
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt16(this.numCapabilities);
     marshaler.WriteUInt16(this.Padding);
     if(this.numCapabilities > 0 && this.CapabilityMessage.Length > 0)
     {
         foreach(var message in CapabilityMessage)
         {
             message.Encode(marshaler);
         }
     }
 }
 public override void Encode(PduMarshaler marshaler)
 {
     if (Data != null)
     {
         marshaler.WriteBytes(Data);
     };
 }
        public override bool Decode(PduMarshaler marshaler)
        {
            try
            {
                base.Decode(marshaler);
                this.numCapabilities = marshaler.ReadUInt16();
                this.Padding = marshaler.ReadUInt16();
                this.CapabilityMessage = new CAPABILITY_SET[numCapabilities];
                for (int i = 0; i < numCapabilities; i++ )
                {
                    CAPABILITY_HEADER header = new CAPABILITY_HEADER();
                    bool fsuccess = header.Decode(marshaler);
                    if(fsuccess)
                    {
                        switch (header.CapabilityType)
                        {
                            case CapabilityType_Values.CAP_GENERAL_TYPE:
                                CapabilityMessage[i] = new GENERAL_CAPS_SET(header);
                                CapabilityMessage[i].Decode(marshaler);
                                break;
                            case CapabilityType_Values.CAP_PRINTER_TYPE:
                                CapabilityMessage[i] = new PRINTER_CAPS_SET(header);
                                break;
                            case CapabilityType_Values.CAP_PORT_TYPE:
                                CapabilityMessage[i] = new PORT_CAPS_SET(header);
                                break;
                            case CapabilityType_Values.CAP_DRIVE_TYPE:
                                CapabilityMessage[i] = new DRIVE_CAPS_SET(header);
                                break;
                            case CapabilityType_Values.CAP_SMARTCARD_TYPE:
                                CapabilityMessage[i] = new SMARTCARD_CAPS_SET(header);
                                break;
                        }
                    }

                }
                return true;
            }
            catch
            {
                marshaler.Reset();
                throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
            }
        }
 /// <summary>
 /// Encode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to encode the fields of this PDU.</param>
 public override void Encode(PduMarshaler marshaler)
 {
     marshaler.WriteUInt16((ushort)Header.Component);
     marshaler.WriteUInt16((ushort)Header.PacketId);
 }
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32(this.OutputBufferLength);
     marshaler.WriteBytes(this.OutputBuffer);
 }
 public void Decode(PduMarshaler marshaler)
 {
     try
     {
         this.DeviceType = (DeviceType_Values)marshaler.ReadUInt32();
         this.DeviceId = marshaler.ReadUInt32();
         this.PreferredDosName = marshaler.ReadBytes(8);
         this.DeviceDataLength = marshaler.ReadUInt32();
         this.DeviceData = marshaler.ReadBytes((int)this.DeviceDataLength);
      }
     catch
     {
         marshaler.Reset();
         throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
     }
 }
 public override bool Decode(PduMarshaler marshaler)
 {
     try
     {
         base.Decode(marshaler);
         this.OutputBufferLength = marshaler.ReadUInt32();
         this.OutputBuffer = marshaler.ReadBytes((int)this.OutputBufferLength);
         return true;
     }
     catch
     {
         marshaler.Reset();
         throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
     }
 }
 public void Encode(PduMarshaler marshaler)
 {
     marshaler.WriteUInt16((UInt16)this.Component);
     marshaler.WriteUInt16((UInt16)this.PacketId);
 }
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteUInt32(this.OutputBufferLength);
     marshaler.WriteUInt32(this.InputBufferLength);
     marshaler.WriteUInt32(this.IoControlCode);
     marshaler.WriteBytes(this.Padding);
     marshaler.WriteBytes(this.InputBuffer);
 }
 public void Decode(PduMarshaler marshaler)
 {
     try
     {
         this.Component = (Component_Values)marshaler.ReadUInt16();
         this.PacketId = (PacketId_Values)marshaler.ReadUInt16();
     }
     catch
     {
         marshaler.Reset();
         throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
     }
 }
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
     marshaler.WriteBytes(this.Padding);
 }
 public override void Decode(PduMarshaler marshaler)
 {
     try
     {
         this.osType = (osType_Values)marshaler.ReadUInt32();
         this.osVersion = (osVersion_Values)marshaler.ReadUInt32();
         this.protocolMajorVersion = (protocolMajorVersion_Values)marshaler.ReadUInt16();
         this.protocolMinorVersion = (DR_CORE_SERVER_CLIENTID_CONFIRM_VersionMinor_Values)marshaler.ReadUInt16();
         this.ioCode1 = (ioCode1_Values)marshaler.ReadUInt32();
         this.ioCode2 = (ioCode2_Values)marshaler.ReadUInt32();
         this.extendedPDU = (extendedPDU_Values)marshaler.ReadUInt32();
         this.extraFlags1 = (extraFlags1_Values)marshaler.ReadUInt32();
         this.extraFlags2 = (extraFlags2_Values)marshaler.ReadUInt32();
         this.SpecialTypeDeviceCap = marshaler.ReadUInt32();
     }
     catch
     {
         marshaler.Reset();
         throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
     }
 }
 public override bool Decode(PduMarshaler marshaler)
 {
     try
     {
         base.Decode(marshaler);
         this.Padding = marshaler.ReadBytes(4);
         return true;
     }
     catch
     {
         marshaler.Reset();
         throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
     }
 }
 public void Encode(PduMarshaler marshaler)
 {
     marshaler.WriteUInt32((UInt32)this.DeviceType);
     marshaler.WriteUInt32(this.DeviceId);
     marshaler.WriteBytes(this.PreferredDosName);
     marshaler.WriteUInt32(this.DeviceDataLength);
     if (this.DeviceDataLength > 0)
         marshaler.WriteBytes(this.DeviceData);
 }
        /// <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());
            }
        }
 public void Encode(PduMarshaler marshaler)
 {
     marshaler.WriteUInt16((UInt16)this.CapabilityType);
     marshaler.WriteUInt16(this.CapabilityLength);
     marshaler.WriteUInt32((UInt32)this.Version);
 }
 public override void Encode(PduMarshaler marshaler)
 {
     base.Encode(marshaler);
 }