/// <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)
 {
     bool fDecoded = base.Decode(marshaler);
     if (fDecoded)
     {
         return (this.Header.PacketType == PacketTypeValues.TSMM_PACKET_TYPE_CLIENT_NOTIFICATION || this.Header.PacketType == PacketTypeValues.TSMM_PACKET_TYPE_PRESENTATION_RESPONSE);
     }
     else
     {
         marshaler.Reset();
         throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
     }
 }
 /// <summary>
 /// Decode this PDU to the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to Decode the fields of this PDU.</param>
 /// <returns></returns>
 public override bool Decode(PduMarshaler marshaler)
 {
     try
     {
         base.Decode(marshaler);
         MaxNumMonitors = marshaler.ReadUInt32();
         MaxMonitorAreaFactorA = marshaler.ReadUInt32();
         MaxMonitorAreaFactorB = marshaler.ReadUInt32();
         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 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);
                this.surfaceIdSrc = marshaler.ReadUInt16();
                pduLen += 2;
                this.surfaceIdDest = marshaler.ReadUInt16();
                pduLen += 2;
                this.rectSrc.left = marshaler.ReadUInt16();
                pduLen += 2;
                this.rectSrc.top = marshaler.ReadUInt16();
                pduLen += 2;
                this.rectSrc.right = marshaler.ReadUInt16();
                pduLen += 2;
                this.rectSrc.bottom = marshaler.ReadUInt16();
                pduLen += 2;
                this.destPtsCount = marshaler.ReadUInt16();
                pduLen += 2;

                for (ushort i = 0; i < this.destPtsCount; i++)
                {
                    RDPGFX_POINT16 destPoint;
                    destPoint.x = marshaler.ReadUInt16();
                    destPoint.y = marshaler.ReadUInt16();
                    destPtsList.Add(destPoint);
                    pduLen += (uint)Marshal.SizeOf(destPoint);
                }

                return true;
            }
            catch
            {
                marshaler.Reset();
                throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
            }
        }
 /// <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.cbSize = marshaler.ReadUInt32();
         Header.PacketType = (PacketTypeValues)marshaler.ReadUInt32();
         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.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
            {
                this.blockType = (RFXProgCodecBlockType) marshaler.ReadUInt16();
                this.blockLen = marshaler.ReadUInt32();

                this.decodedLen = 6;
                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.magic = marshaler.ReadUInt32();
                this.version = marshaler.ReadUInt16();

                this.decodedLen += 6;
                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);
                cacheEntriesCount = marshaler.ReadUInt16();
                pduLen += 2;
                cacheEntries = new RDPGFX_CACHE_ENTRY_METADATA[cacheEntriesCount];
                totalCacheSize = 0;

                for (ushort i = 0; i < cacheEntriesCount; i++)
                {
                    cacheEntries[i].cacheKey = marshaler.ReadUInt64();
                    pduLen += 8;
                    cacheEntries[i].bitmapLength = marshaler.ReadUInt32();
                    pduLen += 4;
                    totalCacheSize += cacheEntries[i].bitmapLength;  // Calculate the summary of cache size in the request.
                }

                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);
                this.importedEntriesCount = marshaler.ReadUInt16();
                pduLen += 2;

                for (int i = 0; i < this.importedEntriesCount; i++)
                {
                    ushort slot = marshaler.ReadUInt16();
                    cacheSlotsList.Add(slot);
                    pduLen += 2;
                }
                return true;
            }
            catch
            {
                marshaler.Reset();
                throw new PDUDecodeException(this.GetType(), marshaler.ReadToEnd());
            }
        }
        public uint pduLen; // RDPEGFX command actual PDU length in bytes after successfully decode

        #endregion Fields

        #region Methods

        /// <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.cmdId = (PacketTypeValues)marshaler.ReadUInt16();
                Header.flags = marshaler.ReadUInt16();
                Header.pduLength = marshaler.ReadUInt32();
                pduLen = 8;   // 8 bytes common header.
                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)
        {
            bool fDecoded = base.Decode(marshaler);
            if (fDecoded)
            {
                return (this.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_WIRETOSURFACE_1 ||
                        this.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_WIRETOSURFACE_2 ||
                        this.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_DELETEENCODINGCONTEXT ||
                        this.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_SOLIDFILL ||
                        this.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_SURFACETOSURFACE ||

                        this.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_SURFACETOCACHE ||
                        this.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_CACHETOSURFACE ||
                        this.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_EVICTCACHEENTRY ||
                        this.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_CREATESURFACE ||
                        this.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_DELETESURFACE ||

                        this.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_STARTFRAME ||
                        this.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_ENDFRAME ||
                        this.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_RESETGRAPHICS ||
                        this.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_MAPSURFACETOOUTPUT ||
                        this.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_CACHEIMPORTREPLY ||

                        this.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_CAPSCONFIRM
                        );
            }
            else
            {
                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);
                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 encode the fields of this PDU.</param>
 public override bool Decode(PduMarshaler marshaler)
 {
     bool fDecoded = base.Decode(marshaler);
     if (fDecoded)
     {
         return (this.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_FRAMEACKNOWLEDGE ||
                 this.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_CACHEIMPORTOFFER ||
                 this.Header.cmdId == PacketTypeValues.RDPGFX_CMDID_CAPSADVERTISE);
     }
     else
     {
         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);
                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
     {
         //if (!base.Decode(marshaler)) return false;
         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);
                this.cacheSlot = marshaler.ReadUInt16();
                pduLen += 2;
                this.surfaceId = marshaler.ReadUInt16();
                pduLen += 2;
                this.destPtsCount = marshaler.ReadUInt16();
                pduLen += 2;

                for (int i = 0; i < this.destPtsCount; i++)
                {
                    RDPGFX_POINT16 destPoint;
                    destPoint.x = marshaler.ReadUInt16();
                    destPoint.y = marshaler.ReadUInt16();
                    destPtsList.Add(destPoint);

                    pduLen += 4;
                }

                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.ctxId = marshaler.ReadByte();
                this.tileSize = marshaler.ReadUInt16();
                this.flags = marshaler.ReadByte();

                this.decodedLen += 4;
                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());
            }
        }
        /// <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());
            }
        }
        /// <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());
            }
        }
Пример #23
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>
 /// Encode this PDU to 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.surfaceId = marshaler.ReadUInt16();
         pduLen += 2;
         this.width = marshaler.ReadUInt16();
         pduLen += 2;
         this.height = marshaler.ReadUInt16();
         pduLen += 2;
         this.pixFormat = (PixelFormat)(marshaler.ReadByte());
         pduLen++;
         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)
 {
     Data = marshaler.ReadToEnd();
     return Data != null;
 }
        /// <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.timeStamp = marshaler.ReadUInt32();
                pduLen += 4;
                this.frameId = marshaler.ReadUInt32();
                pduLen += 4;

                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.Header.cbSize = marshaler.ReadUInt32();
         this.Header.PacketType = (PacketTypeValues)marshaler.ReadUInt32();
         this.PresentatioinId = marshaler.ReadByte();
         this.ResponseFlags = marshaler.ReadByte();
         this.ResultFlags = marshaler.ReadUInt16();
         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.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
     {
         Data = marshaler.ReadToEnd();
     }
     catch (Exception)
     {
         Data = null;
         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.cacheKey = marshaler.ReadUInt64();
                pduLen += 8;
                this.cacheSlot = marshaler.ReadUInt16();
                pduLen += 2;
                this.rectSrc.left = marshaler.ReadUInt16();
                pduLen += 2;
                this.rectSrc.top = marshaler.ReadUInt16();
                pduLen += 2;
                this.rectSrc.right = marshaler.ReadUInt16();
                pduLen += 2;
                this.rectSrc.bottom = marshaler.ReadUInt16();
                pduLen += 2;

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