/// <summary>
        /// Unmarshal and validate the descriptor type from the marshaler buffer.
        /// </summary>
        /// <param name="marshaler">The marshaler containing raw data.</param>
        /// <returns>true indicates that the field is decoded successfully and valid.</returns>
        protected bool ReadDescriptorType(PduMarshaler marshaler)
        {
            bDescriptorType = UsbDescriptorTypes.UNKNOWN;
            byte b = marshaler.ReadByte();
            // TODO: don't hard-code.
            if (b > 8 || b < 1)
            {
                return false;
            }

            bDescriptorType = (UsbDescriptorTypes)b;
            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
            {
                length = marshaler.ReadUInt16();
                interfaceNumber = marshaler.ReadByte();
                alternateSetting = marshaler.ReadByte();
                class_field = marshaler.ReadByte();
                subClass = marshaler.ReadByte();
                protocol = marshaler.ReadByte();
                padding = marshaler.ReadByte();
                interfaceHandle = marshaler.ReadUInt32();
                numberOfPipes = marshaler.ReadUInt32();

                if (numberOfPipes > 0)
                {
                    pipes = new TS_USBD_PIPE_INFORMATION_RESULT[numberOfPipes];

                    for (int i = 0; i < pipes.Length; i++)
                    {
                        pipes[i] = new TS_USBD_PIPE_INFORMATION_RESULT();
                        pipes[i].Decode(marshaler);
                    }
                }
                else
                {
                    pipes = null;
                }
            }
            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
     {
         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.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
     {
         maximumPacketSize = marshaler.ReadUInt16();
         endpointAddress = marshaler.ReadByte();
         interval = marshaler.ReadByte();
         pipeType = marshaler.ReadUInt32();
         pipeHandle = marshaler.ReadUInt32();
         maximumTransferSize = marshaler.ReadUInt32();
         pipeFlags = marshaler.ReadUInt32();
     }
     catch (Exception)
     {
         return false;
     }
     return true;
 }
Пример #6
0
 public bool Decode(PduMarshaler marshaler)
 {
     try
     {
         byte t = marshaler.ReadByte();
         c = (FOUR_BYTE_C_Values)(t >> 6);
         val1 = (byte)(t & 0x3F);
         if (c >= FOUR_BYTE_C_Values.TWO_BYTE_VAL)
         {
             val2 = marshaler.ReadByte();
         }
         if (c >= FOUR_BYTE_C_Values.THREE_BYTE_VAL)
         {
             val3 = marshaler.ReadByte();
         }
         if (c == FOUR_BYTE_C_Values.FOUR_BYTE_VAL)
         {
             val4 = marshaler.ReadByte();
         }
         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
            {
                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
            {
                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());
            }
        }
Пример #9
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; ;
            }
        }
 /// <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)
 {
     base.Decode(marshaler);
     bInterfaceNumber = marshaler.ReadByte();
     bAlternateSetting = marshaler.ReadByte();
     bNumEndpoints = marshaler.ReadByte();
     bInterfaceClass = marshaler.ReadByte();
     bInterfaceSubClass = marshaler.ReadByte();
     bInterfaceProtocol = marshaler.ReadByte();
     iInterface = marshaler.ReadByte();
     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
            {
                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());
            }
        }
 /// <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)
 {
     base.Decode(marshaler);
     bEndpointAddress = marshaler.ReadByte();
     bmAttributes = marshaler.ReadByte();
     wMaxPacketSize = marshaler.ReadByte();
     bInterval = marshaler.ReadByte();
     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)
 {
     base.Decode(marshaler);
     bcdUSB = marshaler.ReadUInt16();
     bDeviceClass = marshaler.ReadByte();
     bDeviceSubClass = marshaler.ReadByte();
     bDeviceProtocol = marshaler.ReadByte();
     bMaxPacketSize0 = marshaler.ReadByte();
     idVendor = marshaler.ReadUInt16();
     idProduct = marshaler.ReadUInt16();
     bcdDevice = marshaler.ReadUInt16();
     iManufacturer = marshaler.ReadByte();
     iProduct = marshaler.ReadByte();
     iSerialNumber = marshaler.ReadByte();
     bNumConfigurations = marshaler.ReadByte();
     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)
 {
     base.Decode(marshaler);
     wTotalLength = marshaler.ReadUInt16();
     bNumInterfaces = marshaler.ReadByte();
     bConfigurationValue = marshaler.ReadByte();
     iConfiguration = marshaler.ReadByte();
     bmAttributes = marshaler.ReadByte();
     MaxPower = marshaler.ReadByte();
     return true;
 }
Пример #15
0
 public bool Decode(PduMarshaler marshaler)
 {
     try
     {
         byte t = marshaler.ReadByte();
         c = (TWO_BYTE_C_Values)(t >> 7);
         val1 = (byte)(t & 0x7F);
         if (c == TWO_BYTE_C_Values.TWO_BYTE_VAL)
         {
             val2 = marshaler.ReadByte();
         }
         return true;
     }
     catch
     {
         return false;
     }
 }
Пример #16
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;
     }
 }
Пример #17
0
 public bool Decode(PduMarshaler marshaler)
 {
     try
     {
         byte t = marshaler.ReadByte();
         c = (EIGHT_BYTE_C_Values)(t >> 5);
         val1 = (byte)(t & 0x1F);
         if (c >= EIGHT_BYTE_C_Values.TWO_BYTE_VAL)
         {
             val2 = marshaler.ReadByte();
         }
         if (c >= EIGHT_BYTE_C_Values.THREE_BYTE_VAL)
         {
             val3 = marshaler.ReadByte();
         }
         if (c >= EIGHT_BYTE_C_Values.FOUR_BYTE_VAL)
         {
             val4 = marshaler.ReadByte();
         }
         if (c >= EIGHT_BYTE_C_Values.FIVE_BYTE_VAL)
         {
             val5 = marshaler.ReadByte();
         }
         if (c >= EIGHT_BYTE_C_Values.SIX_BYTE_VAL)
         {
             val6 = marshaler.ReadByte();
         }
         if (c >= EIGHT_BYTE_C_Values.SEVEN_BYTE_VAL)
         {
             val7 = marshaler.ReadByte();
         }
         if (c == EIGHT_BYTE_C_Values.EIGHT_BYTE_VAL)
         {
             val8 = marshaler.ReadByte();
         }
         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.surfaceId = marshaler.ReadUInt16();
                pduLen += 2;
                this.fillPixel.R = marshaler.ReadByte();
                this.fillPixel.G = marshaler.ReadByte();
                this.fillPixel.B = marshaler.ReadByte();
                this.fillPixel.XA = marshaler.ReadByte();
                pduLen += 4;
                this.fillRectCount = marshaler.ReadUInt16();
                pduLen += 2;

                for (int i = 0; i < this.fillRectCount; i++)
                {
                    RDPGFX_RECT16 rect;
                    rect.left = marshaler.ReadUInt16();
                    rect.top = marshaler.ReadUInt16();
                    rect.right = marshaler.ReadUInt16();
                    rect.bottom = marshaler.ReadUInt16();

                    fillRectList.Add(rect);
                    pduLen += (uint)Marshal.SizeOf(rect);
                }

                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
            {
                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;
                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);
                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());
            }
        }
Пример #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 decode the fields of this PDU.</param>
        public override bool Decode(PduMarshaler marshaler)
        {
            try
            {
                len = marshaler.ReadUInt16();
                numberOfPipes = marshaler.ReadUInt16();
                interfaceNumber = marshaler.ReadByte();
                alternateSetting = marshaler.ReadByte();
                padding = marshaler.ReadUInt16();
                numberOfPipes = marshaler.ReadUInt32();

                informations = new TS_USBD_PIPE_INFORMATION[numberOfPipes];
                for (int i = 0; i < numberOfPipes; i++)
                {
                    informations[i].Decode(marshaler);
                }
            }
            catch (Exception)
            {
                // TODO: All generic exceptions should be got rid of.
                return false;
            }
            return true;
        }
Пример #26
0
 public override bool Decode(PduMarshaler marshaler)
 {
     base.Decode(marshaler);
     contactId = marshaler.ReadByte();
     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());
     }
 }
Пример #28
0
        public override bool Decode(PduMarshaler marshaler)
        {
            try
            {
                if (!base.Decode(marshaler))
                {
                    return false;
                }
                encodeTime = new FOUR_BYTE_UNSIGNED_INTEGER();
                if (!encodeTime.Decode(marshaler))
                {
                    return false;
                }
                frameCount = new TWO_BYTE_UNSIGNED_INTEGER();
                if (!frameCount.Decode(marshaler))
                {
                    return false;
                }
                ushort count = frameCount.ToUShort();
                if (count > 0)
                {
                    frames = new RDPINPUT_TOUCH_FRAME[count];
                }
                for (int i = 0; i < count; i++)
                {
                    frames[i] = new RDPINPUT_TOUCH_FRAME();
                    if (!frames[i].contactCount.Decode(marshaler) || !frames[i].frameOffset.Decode(marshaler))
                    {
                        return false;
                    }
                    ushort contactCount = frames[i].contactCount.ToUShort();
                    if (contactCount > 0)
                    {
                        frames[i].contacts = new RDPINPUT_CONTACT_DATA[contactCount];
                    }
                    for (int j = 0; j < contactCount; j++)
                    {
                        frames[i].contacts[j] = new RDPINPUT_CONTACT_DATA();
                        frames[i].contacts[j].contactId = marshaler.ReadByte();
                        if (!frames[i].contacts[j].fieldsPresent.Decode(marshaler) || !frames[i].contacts[j].x.Decode(marshaler)
                            || !frames[i].contacts[j].y.Decode(marshaler) || !frames[i].contacts[j].contactFlags.Decode(marshaler))
                        {
                            return false;
                        }

                        ushort fieldsPresent = frames[i].contacts[j].fieldsPresent.ToUShort();
                        if ((ushort)(fieldsPresent & (ushort)(RDPINPUT_CONTACT_DATA_FieldsPresent.CONTACT_DATA_CONTACTRECT_PRESENT)) == (ushort)RDPINPUT_CONTACT_DATA_FieldsPresent.CONTACT_DATA_CONTACTRECT_PRESENT)
                        {
                            TWO_BYTE_SIGNED_INTEGER left = new TWO_BYTE_SIGNED_INTEGER();
                            if (!left.Decode(marshaler))
                            {
                                return false;
                            }
                            frames[i].contacts[j].contactRectLeft = left;
                            TWO_BYTE_SIGNED_INTEGER top = new TWO_BYTE_SIGNED_INTEGER();
                            if (!top.Decode(marshaler))
                            {
                                return false;
                            }
                            frames[i].contacts[j].contactRectTop = top;
                            TWO_BYTE_SIGNED_INTEGER right = new TWO_BYTE_SIGNED_INTEGER();
                            if (!right.Decode(marshaler))
                            {
                                return false;
                            }
                            frames[i].contacts[j].contactRectRight = right;
                            TWO_BYTE_SIGNED_INTEGER bottom = new TWO_BYTE_SIGNED_INTEGER();
                            if (!bottom.Decode(marshaler))
                            {
                                return false;
                            }
                            frames[i].contacts[j].contactRectBottom = bottom;
                        }
                        if ((ushort)(fieldsPresent & (ushort)(RDPINPUT_CONTACT_DATA_FieldsPresent.CONTACT_DATA_ORIENTATION_PRESENT)) == (ushort)RDPINPUT_CONTACT_DATA_FieldsPresent.CONTACT_DATA_ORIENTATION_PRESENT)
                        {
                            FOUR_BYTE_UNSIGNED_INTEGER orientation = new FOUR_BYTE_UNSIGNED_INTEGER();
                            if (!orientation.Decode(marshaler))
                            {
                                return false;
                            }
                            frames[i].contacts[j].orientation = orientation;
                        }
                        if ((ushort)(fieldsPresent & (ushort)(RDPINPUT_CONTACT_DATA_FieldsPresent.CONTACT_DATA_PRESSURE_PRESENT)) == (ushort)RDPINPUT_CONTACT_DATA_FieldsPresent.CONTACT_DATA_PRESSURE_PRESENT)
                        {
                            FOUR_BYTE_UNSIGNED_INTEGER pressure = new FOUR_BYTE_UNSIGNED_INTEGER();
                            if (!pressure.Decode(marshaler))
                            {
                                return false;
                            }
                            frames[i].contacts[j].pressure = pressure;
                        }
                    }
                }
                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
     {
         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)
 {
     bLength = marshaler.ReadByte();
     if (!ReadDescriptorType(marshaler))
     {
         return false;
     }
     return true;
 }