/// <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
     {
         base.Decode(marshaler);
         RequestId = marshaler.ReadUInt32();
         CbTsUrbResult = marshaler.ReadUInt32();
         TsUrbResult = marshaler.ReadBytes((int)CbTsUrbResult);
         HResult = marshaler.ReadUInt32();
         OutputBufferSize = marshaler.ReadUInt32();
         OutputBuffer = marshaler.ReadBytes((int)OutputBufferSize);
     }
     catch (Exception)
     {
         return false;
     }
     return true;
 }
 /// <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
     {
         base.Decode(marshaler);
         NumUsbDevice = marshaler.ReadUInt32();
         UsbDevice = marshaler.ReadUInt32();
         cchDeviceInstanceId = marshaler.ReadUInt32();
         DeviceInstanceId = marshaler.ReadUnicodeString((int)cchDeviceInstanceId);
         cchHwIds = marshaler.ReadUInt32();
         if (cchHwIds == 0)
         {
             HardwareIds = null;
         }
         else
         {
             HardwareIds = marshaler.ReadUnicodeString((int)cchHwIds);
         }
         cchCompatIds = marshaler.ReadUInt32();
         if (cchCompatIds == 0)
         {
             CompatibilityIds = null;
         }
         else
         {
             CompatibilityIds = marshaler.ReadUnicodeString((int)cchCompatIds);
         }
         cchContainerId = marshaler.ReadUInt32();
         ContainerId = marshaler.ReadUnicodeString((int)cchContainerId);
         UsbDeviceCapabilities = marshaler.ReadBytes(USB_DEVICE_CAPABILITIES.USB_DEVICE_CAPABILITIES_SIZE);
     }
     catch (Exception)
     {
         return false;
     }
     return true;
 }
 /// <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
     {
         base.Decode(marshaler);
         CbTsUrb = marshaler.ReadUInt32();
         TsUrb = marshaler.ReadBytes((int)CbTsUrb);
         OutputBufferSize = marshaler.ReadUInt32();
         // TODO: should fix ReadBytes method in the library
         if (OutputBufferSize > 0)
         {
             OutputBuffer = marshaler.ReadBytes((int)OutputBufferSize);
         }
     }
     catch (Exception)
     {
         return false;
     }
     return true;
 }
 /// <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 decode the fields of this PDU.</param>
 public override bool Decode(PduMarshaler marshaler)
 {
     try
     {
         base.Decode(marshaler);
         configurationDescriptorIsValid = marshaler.ReadByte();
         padding = marshaler.ReadBytes(PADDING_SIZE);
         numInterfaces = marshaler.ReadUInt32();
         for (int i = 0; i < intefaces.Length; i++)
         {
             intefaces[i].Decode(marshaler);
         }
         descriptor = marshaler.ReadToEnd();
     }
     catch (Exception)
     {
         return false;
     }
     return true;
 }
        /// <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;

                this.quantIdxY = marshaler.ReadByte();
                this.quantIdxCb = marshaler.ReadByte();
                this.quantIdxCr = marshaler.ReadByte();
                this.xIdx = marshaler.ReadUInt16();
                this.yIdx = marshaler.ReadUInt16();
                this.flags = marshaler.ReadBool();
                this.decodedLen += 8;

                this.yLen = marshaler.ReadUInt16();
                this.cbLen = marshaler.ReadUInt16();
                this.crLen = marshaler.ReadUInt16();
                this.tailLen = marshaler.ReadUInt16();
                this.decodedLen += 8;

                this.yData = marshaler.ReadBytes((int)this.yLen);
                this.decodedLen += this.yLen;
                this.cbData = marshaler.ReadBytes((int)this.cbLen);
                this.decodedLen += this.cbLen;
                this.crData = marshaler.ReadBytes((int)this.crLen);
                this.decodedLen += this.crLen;
                this.tailData = marshaler.ReadBytes((int)this.tailLen);
                this.decodedLen += this.tailLen;
                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
            {
                if (!base.Decode(marshaler)) return false;
                this.tileSize = marshaler.ReadByte();
                this.numRects = marshaler.ReadUInt16();
                this.numQuant = marshaler.ReadByte();
                this.numProgQuant = marshaler.ReadByte();
                this.flags = marshaler.ReadByte();
                this.decodedLen += 6;

                this.numTiles = marshaler.ReadUInt16();
                this.tileDataSize = marshaler.ReadUInt32();
                this.decodedLen += 6;

                this.rects = new TS_RFX_RECT[this.numRects];
                for (int i = 0; i < this.numRects; i++)
                {
                    this.rects[i].x = marshaler.ReadUInt16();
                    this.rects[i].y = marshaler.ReadUInt16();
                    this.rects[i].width = marshaler.ReadUInt16();
                    this.rects[i].height = marshaler.ReadUInt16();

                    this.decodedLen += (uint)Marshal.SizeOf(this.rects[i]);
                }

                this.quantVals = new TS_RFX_CODEC_QUANT[this.numQuant];
                for (int i = 0; i < this.numQuant; i++)
                {
                    this.quantVals[i].LL3_LH3 = marshaler.ReadByte();
                    this.quantVals[i].HL3_HH3 = marshaler.ReadByte();
                    this.quantVals[i].LH2_HL2 = marshaler.ReadByte();
                    this.quantVals[i].HH2_LH1 = marshaler.ReadByte();
                    this.quantVals[i].HL1_HH1 = marshaler.ReadByte();

                    this.decodedLen += 5;
                }

                this.quantProgVals = new RFX_PROGRESSIVE_CODEC_QUANT[this.numProgQuant];

                for (int i = 0; i < this.numProgQuant; i++)
                {
                    int quantProgSize = Marshal.SizeOf(this.quantProgVals[i]);
                    byte[] rawData = marshaler.ReadBytes(quantProgSize);
                    GCHandle handle = GCHandle.Alloc(rawData, GCHandleType.Pinned);
                    try
                    {
                        IntPtr rawDataPtr = handle.AddrOfPinnedObject();
                        this.quantProgVals[i] = (RFX_PROGRESSIVE_CODEC_QUANT)Marshal.PtrToStructure(rawDataPtr, typeof(RFX_PROGRESSIVE_CODEC_QUANT));
                    }
                    finally
                    {
                        handle.Free();
                    }
                    this.decodedLen += (uint)quantProgSize;
                }

                return true;
            }
            catch
            {
                marshaler.Reset();
                throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
            }
        }
Пример #8
0
 public override bool Decode(PduMarshaler marshaler)
 {
     try
     {
         this.SubHeaderLength = marshaler.ReadByte();
         this.SubHeaderType = (RDP_TUNNEL_SUBHEADER_TYPE_Values)marshaler.ReadByte();
         if (this.SubHeaderLength > 2)
         {
             this.SubHeaderData = marshaler.ReadBytes(this.SubHeaderLength - 2);
         }
         return true;
     }
     catch
     {
         return false;
     }
 }
        /// <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
            {
                base.Decode(marshaler);
                this.width = marshaler.ReadUInt32();
                pduLen += 4;
                this.height = marshaler.ReadUInt32();
                pduLen += 4;
                this.monitorCount = marshaler.ReadUInt32();
                pduLen += 4;

                for(int i=0; i < this.monitorCount; i++ )
                {
                    TS_MONITOR_DEF monitorDef;
                    monitorDef.left = marshaler.ReadUInt32();
                    monitorDef.top = marshaler.ReadUInt32();
                    monitorDef.right = marshaler.ReadUInt32();
                    monitorDef.bottom = marshaler.ReadUInt32();
                    monitorDef.flags = (Flags_TS_MONITOR_DEF) marshaler.ReadUInt32();

                    monitorDefArray.Add(monitorDef);
                    pduLen += (uint)Marshal.SizeOf(monitorDef);
                }
                if (pduLen < Header.pduLength)
                {
                    this.pad = marshaler.ReadBytes((int)(Header.pduLength - pduLen));
                    pduLen = Header.pduLength;
                }
                return true;
            }
            catch
            {
                marshaler.Reset();
                throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
            }
        }
Пример #10
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;
            }
        }
Пример #11
0
        public override bool Decode(PduMarshaler marshaler)
        {
            try
            {
                byte actionFlags = marshaler.ReadByte();
                this.Action = (RDP_TUNNEL_ACTION_Values)(byte)(actionFlags & 0xF);
                this.Flags = (byte)(actionFlags & 0xF0);
                this.PayloadLength = marshaler.ReadUInt16();
                this.HeaderLength = marshaler.ReadByte();
                if (this.HeaderLength > 4)
                {
                    int subHdTotalLen = this.HeaderLength - 4;
                    int curDecodedLen = 0;
                    List<RDP_TUNNEL_SUBHEADER> subHds = new List<RDP_TUNNEL_SUBHEADER>();
                    while (subHdTotalLen > curDecodedLen)
                    {

                        byte subHdLen = marshaler.ReadByte();
                        byte subHdType = marshaler.ReadByte();
                        byte[] subHdData = null;
                        if (subHdLen > 2)
                        {
                            subHdData = marshaler.ReadBytes(subHdLen - 2);
                        }
                        RDP_TUNNEL_SUBHEADER subHd = new RDP_TUNNEL_SUBHEADER();
                        subHd.SubHeaderLength = subHdLen;
                        subHd.SubHeaderType = (RDP_TUNNEL_SUBHEADER_TYPE_Values)subHdType;
                        subHd.SubHeaderData = subHdData;
                        subHds.Add(subHd);

                        curDecodedLen += subHdLen;
                    }
                    this.SubHeaders = subHds.ToArray();
                }
                return true;
            }
            catch
            {
                return false; ;
            }
        }
Пример #12
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;
            }
        }
        /// <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
     {
         base.Decode(marshaler);
         pipeHandle = marshaler.ReadUInt32();
         transferFlags = marshaler.ReadUInt32();
         timeout = marshaler.ReadUInt32();
         setupPacket = marshaler.ReadBytes(PACKET_SIZE);
     }
     catch (Exception)
     {
         return false;
     }
     return true;
 }
 /// <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
     {
         base.Decode(marshaler);
         RequestId = marshaler.ReadUInt32();
         HResult = marshaler.ReadUInt32();
         if (HResult == (uint)HRESULT_FROM_WIN32.ERROR_SUCCESS)
         {
             Information = marshaler.ReadUInt32();
             OutputBufferSize = marshaler.ReadUInt32();
             OutputBuffer = marshaler.ReadBytes((int)OutputBufferSize);
         }
         else if (HResult == (uint)HRESULT_FROM_WIN32.ERROR_INSUFFICIENT_BUFFER)
         {
             Information = marshaler.ReadUInt32();
             OutputBufferSize = marshaler.ReadUInt32();
             OutputBuffer = marshaler.ReadBytes((int)Information);
         }
         else
         {
             Information = marshaler.ReadUInt32();
             OutputBufferSize = marshaler.ReadUInt32();
             OutputBuffer = marshaler.ReadBytes((int)OutputBufferSize);
         }
     }
     catch (Exception)
     {
         return false;
     }
     return true;
 }
        /// <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
            {
                base.Decode(marshaler);
                this.surfaceId = marshaler.ReadUInt16();
                pduLen += 2;
                this.codecId = (CodecType)marshaler.ReadUInt16();
                pduLen += 2;
                this.pixelFormat = (PixelFormat)marshaler.ReadByte();
                pduLen ++;

                // Destination rectangle.
                this.destRect.left = marshaler.ReadUInt16();
                this.destRect.top = marshaler.ReadUInt16();
                this.destRect.right = marshaler.ReadUInt16();
                this.destRect.bottom = marshaler.ReadUInt16();
                pduLen += 8;

                // Bitmap.
                this.bitmapDataLength = marshaler.ReadUInt32();
                pduLen += 4;
                this.bitmapData = marshaler.ReadBytes((int)this.bitmapDataLength);
                pduLen += this.bitmapDataLength;

                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
     {
         base.Decode(marshaler);
         IoControlCode = (UsbIoControlCode)marshaler.ReadUInt32();
         InputBufferSize = marshaler.ReadUInt32();
         InputBuffer = marshaler.ReadBytes((int)InputBufferSize);
         OutputBufferSize = marshaler.ReadUInt32();
         RequestId = marshaler.ReadUInt32();
     }
     catch (Exception)
     {
         return false;
     }
     return true;
 }
        /// <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
            {
                base.Decode(marshaler);
                this.surfaceId = marshaler.ReadUInt16();
                pduLen += 2;
                this.codecId = (CodecType)marshaler.ReadUInt16();
                pduLen += 2;
                this.codecContextId = marshaler.ReadUInt32();
                pduLen += 4;
                this.pixelFormat = (PixelFormat)marshaler.ReadByte();
                pduLen++;

                // Bitmap.
                this.bitmapDataLength = marshaler.ReadUInt32();
                pduLen += 4;
                this.bitmapData = marshaler.ReadBytes((int)this.bitmapDataLength);
                pduLen += this.bitmapDataLength;

                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
            {
                if (!base.Decode(marshaler)) return false;

                this.quantIdxY = marshaler.ReadByte();
                this.quantIdxCb = marshaler.ReadByte();
                this.quantIdxCr = marshaler.ReadByte();
                this.xIdx = marshaler.ReadUInt16();
                this.yIdx = marshaler.ReadUInt16();
                this.progressiveQuality = marshaler.ReadByte();
                this.decodedLen += 8;

                this.ySrlLen = marshaler.ReadUInt16();
                this.yRawLen = marshaler.ReadUInt16();
                this.cbSrlLen = marshaler.ReadUInt16();
                this.cbRawLen = marshaler.ReadUInt16();
                this.crSrlLen = marshaler.ReadUInt16();
                this.crRawLen = marshaler.ReadUInt16();
                this.decodedLen += 12;

                this.ySrlData = marshaler.ReadBytes((int)this.ySrlLen);
                this.decodedLen += this.ySrlLen;
                this.yRawData = marshaler.ReadBytes((int)this.yRawLen);
                this.decodedLen += this.yRawLen;
                this.cbSrlData = marshaler.ReadBytes((int)this.cbSrlLen);
                this.decodedLen += this.cbSrlLen;
                this.cbRawData = marshaler.ReadBytes((int)this.cbRawLen);
                this.decodedLen += this.cbRawLen;
                this.crSrlData = marshaler.ReadBytes((int)this.crSrlLen);
                this.decodedLen += this.crSrlLen;
                this.crRawData = marshaler.ReadBytes((int)this.crRawLen);
                this.decodedLen += this.crRawLen;

                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
            {
                base.Decode(marshaler);
                capsSetCount = marshaler.ReadUInt16();
                pduLen += 2;
                capsSets = new RDPGFX_CAPSET[capsSetCount];

                for (ushort i = 0; i < capsSetCount; i++)
                {
                    CapsVersions version = (CapsVersions)marshaler.ReadUInt32();
                    capsSets[i].version = version;
                    pduLen += 4;
                    capsSets[i].capsDataLength = marshaler.ReadUInt32();
                    pduLen += 4;
                    capsSets[i].capsData = new byte[capsSets[i].capsDataLength];
                    capsSets[i].capsData = marshaler.ReadBytes((int)capsSets[i].capsDataLength);
                    pduLen += capsSets[i].capsDataLength;
                }

                return true;
            }
            catch
            {
                marshaler.Reset();
                throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
            }
        }
Пример #21
0
        public override bool Decode(PduMarshaler marshaler)
        {
            try
            {
                fecHeader.snSourceAck = marshaler.ReadUInt32();
                fecHeader.uReceiveWindowSize = marshaler.ReadUInt16();
                fecHeader.uFlags = (RDPUDP_FLAG)marshaler.ReadUInt16();

                if (fecHeader.uFlags.HasFlag(RDPUDP_FLAG.RDPUDP_FLAG_SYN))
                {
                    RDPUDP_SYNDATA_PAYLOAD synData = new RDPUDP_SYNDATA_PAYLOAD();
                    synData.snInitialSequenceNumber = marshaler.ReadUInt32();
                    synData.uUpStreamMtu = marshaler.ReadUInt16();
                    synData.uDownStreamMtu = marshaler.ReadUInt16();
                    // This datagram MUST be zero-padded to increase the size of this datagram to 1232 bytes.

                    if (fecHeader.uFlags.HasFlag(RDPUDP_FLAG.RDPUDP_FLAG_CORRELATION_ID))
                    {
                        RDPUDP_CORRELATION_ID_PAYLOAD correlationId = new RDPUDP_CORRELATION_ID_PAYLOAD();
                        correlationId.uCorrelationId = marshaler.ReadBytes(16);
                        this.CorrelationId = correlationId;
                        correlationId.uReserved = marshaler.ReadBytes(16);
                    }

                    this.padding = marshaler.ReadToEnd();
                    this.SynData = synData;
                    return true;
                }

                if (fecHeader.uFlags.HasFlag(RDPUDP_FLAG.RDPUDP_FLAG_ACK))
                {
                    // ACK.
                    RDPUDP_ACK_VECTOR_HEADER ackVector = new RDPUDP_ACK_VECTOR_HEADER();
                    ackVector.uAckVectorSize = marshaler.ReadUInt16();
                    ackVector.AckVectorElement = new AckVector[ackVector.uAckVectorSize];

                    List<byte> ackVecElementList = new List<byte>(marshaler.ReadBytes(ackVector.AckVectorElement.Length));
                    ackVecElementList.Reverse();

                    for (int i = 0; i < ackVector.AckVectorElement.Length; i++)
                    {
                        byte vecByte = ackVecElementList[i];
                        ackVector.AckVectorElement[i].Length = (byte)(0x3F & vecByte);
                        ackVector.AckVectorElement[i].State = (VECTOR_ELEMENT_STATE)(vecByte >> 6);
                    }

                    this.ackVectorHeader = ackVector;

                    // Padding (variable): A variable-sized array, of length zero or more,
                    // such that this structure ends on a DWORD ([MS-DTYP] section 2.2.9) boundary.
                    int padLen = 4 - (2 + ackVector.AckVectorElement.Length) % 4;
                    if (padLen > 0 && padLen != 4)
                    {
                        this.padding = marshaler.ReadBytes(padLen);
                    }

                    // Ack of Acks.
                    if (fecHeader.uFlags.HasFlag(RDPUDP_FLAG.RDPUDP_FLAG_ACK_OF_ACKS))
                    {
                        RDPUDP_ACK_OF_ACKVECTOR_HEADER aoaHeader = new RDPUDP_ACK_OF_ACKVECTOR_HEADER();
                        aoaHeader.snAckOfAcksSeqNum = marshaler.ReadUInt32();
                        this.ackOfAckVector = aoaHeader;
                    }
                }

                if (fecHeader.uFlags.HasFlag(RDPUDP_FLAG.RDPUDP_FLAG_DATA))
                {
                    if (!fecHeader.uFlags.HasFlag(RDPUDP_FLAG.RDPUDP_FLAG_FEC))
                    {
                        // Source Data.
                        RDPUDP_SOURCE_PAYLOAD_HEADER srcHeader = new RDPUDP_SOURCE_PAYLOAD_HEADER();
                        srcHeader.snCoded = marshaler.ReadUInt32();
                        srcHeader.snSourceStart = marshaler.ReadUInt32();
                        this.sourceHeader = srcHeader;
                    }
                    else
                    {
                        // FEC Data.
                        RDPUDP_FEC_PAYLOAD_HEADER fecDataHeader = new RDPUDP_FEC_PAYLOAD_HEADER();
                        fecDataHeader.snCoded =  marshaler.ReadUInt32();
                        fecDataHeader.snSourceStart = marshaler.ReadUInt32();
                        fecDataHeader.uRange = marshaler.ReadByte();
                        fecDataHeader.uFecIndex = marshaler.ReadByte();
                        fecDataHeader.uPadding = marshaler.ReadUInt16();
                        this.fecPayloadHeader = fecDataHeader;
                    }

                    this.payload = marshaler.ReadToEnd();
                }

                return true;
            }
            catch
            {
                return false;
            }
        }
        /// <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
            {
                base.Decode(marshaler);
                this.capsSet.version = (CapsVersions) marshaler.ReadUInt32();
                pduLen += 4;
                this.capsSet.capsDataLength = marshaler.ReadUInt32();
                pduLen += 4;

                this.capsSet.capsData = marshaler.ReadBytes((int)this.capsSet.capsDataLength);
                pduLen += this.capsSet.capsDataLength;

                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 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
     {
         base.Decode(marshaler);
         recipientAndPadding1 = marshaler.ReadByte();
         interfaceNumber = marshaler.ReadByte();
         msPageIndex = marshaler.ReadByte();
         msFeatureDescriptorIndex = marshaler.ReadUInt16();
         padding2 = marshaler.ReadBytes(PADDING_SIZE);
     }
     catch (Exception)
     {
         return false;
     }
     return true;
 }