/// <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 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);
                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.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());
            }
        }
        /// <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.windowId = marshaler.ReadUInt64();
                pduLen += 8;
                this.mappedWidth = marshaler.ReadUInt32();
                pduLen += 4;
                this.mappedHeight = 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.cbGeometryData = marshaler.ReadUInt32();
                this.Version = (RdpegtVersionValues)marshaler.ReadUInt32();
                this.MappingId = marshaler.ReadUInt64();
                this.UpdateType = (UpdateTypeValues)marshaler.ReadUInt32();
                this.Flags = marshaler.ReadUInt32();
                this.TopLevelId = marshaler.ReadUInt64();
                this.Left = marshaler.ReadUInt32();
                this.Top = marshaler.ReadUInt32();
                this.Right = marshaler.ReadUInt32();
                this.Bottom = marshaler.ReadUInt32();
                this.TopLevelLeft = marshaler.ReadUInt32();
                this.TopLevelTop = marshaler.ReadUInt32();
                this.TopLevelRight = marshaler.ReadUInt32();
                this.TopLevelBottom = marshaler.ReadUInt32();
                this.GeometryType = (GeometryTypeValues)marshaler.ReadUInt32();
                this.cbGeometryBuffer = marshaler.ReadUInt32();

                //Decode RGNDATA
                this.pGeometryBuffer.rdh.dwSize = marshaler.ReadUInt32();
                this.pGeometryBuffer.rdh.iType = marshaler.ReadUInt32();
                this.pGeometryBuffer.rdh.nCount = marshaler.ReadUInt32();
                this.pGeometryBuffer.rdh.nRgnSize = marshaler.ReadUInt32();
                DecodeRect(marshaler, out this.pGeometryBuffer.rdh.rcBound);

                this.pGeometryBuffer.Buffer = new RECT[this.pGeometryBuffer.rdh.nCount];
                for (int i = 0; i < this.pGeometryBuffer.Buffer.Length; i++)
                {
                    DecodeRect(marshaler, out this.pGeometryBuffer.Buffer[i]);
                }

                this.Reserved2 = marshaler.ReadByte();

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