示例#1
0
        internal static RdpPacket ReceiveTPKTOrFastPath(out int type)
        {
            int       num  = 0;
            int       num2 = 0;
            RdpPacket p    = Tcp_Receive(null, 4);

            p.Position = 0L;
            if (p.Length == 0L)
            {
                type = -1;
                return(null);
            }
            num2 = p.ReadByte();
            if (num2 == 3)
            {
                p.ReadByte();
                num  = p.ReadBigEndian16();
                type = 0;
            }
            else
            {
                num = p.ReadByte();
                if ((num & 0x80) != 0)
                {
                    num &= -129;
                    num  = (num << 8) + p.ReadByte();
                }
                FastPath_EncryptionFlags flags = (FastPath_EncryptionFlags)(num2 >> 6);
                if ((flags & FastPath_EncryptionFlags.FASTPATH_OUTPUT_ENCRYPTED) != ((FastPath_EncryptionFlags)0))
                {
                    type = 0xfe;
                }
                else
                {
                    type = 0xff;
                }
            }
            long position = p.Position;

            p.Position = 4L;
            p          = Tcp_Receive(p, num - 4);
            p.Position = position;
            if ((type != 0xff) && (type != 0xfe))
            {
                p.Position = 4L;
                p.ReadByte();
                type = p.ReadByte();
                if (type == 240)
                {
                    p.ReadByte();
                    return(p);
                }
                p.ReadBigEndian16();
                p.ReadBigEndian16();
                p.ReadByte();
            }
            return(p);
        }
示例#2
0
        private static int receive_AttachUserConfirm()
        {
            int       num;
            int       num2   = 0;
            int       num3   = 0;
            int       num4   = 0;
            RdpPacket packet = ISO.ReceiveTPKTOrFastPath(out num);

            num2 = packet.ReadByte();
            if ((num2 >> 2) != AUCF)
            {
                throw new RDFatalException("Bad AUCF " + num2);
            }
            num3 = packet.ReadByte();
            if (num3 != 0)
            {
                throw new RDFatalException("Bad AURQ got " + num3);
            }
            if ((num2 & 2) != 0)
            {
                num4 = packet.ReadBigEndian16();
            }
            if (packet.Position != packet.Length)
            {
                throw new RDFatalException("Illegal Aucf packet length");
            }
            return(num4);
        }
示例#3
0
        internal static RdpPacket Receive()
        {
            byte[] buffer = new byte[0x3000];

            int       count  = Network.Receive(buffer);
            RdpPacket packet = new RdpPacket();

            packet.Write(buffer, 0, count);
            packet.Position = 0L;
            int num2 = 0;

            if (packet.ReadByte() == 3)
            {
                packet.ReadByte();
                num2 = packet.ReadBigEndian16();
                long position = packet.Position;
                while (num2 > count)
                {
                    int num4 = Network.Receive(buffer);
                    packet.Position = count;
                    packet.Write(buffer, 0, num4);
                    count += num4;
                }
                packet.Position = position;
                return(packet);
            }
            num2 = packet.ReadByte();
            if ((num2 & 0x80) != 0)
            {
                num2 &= -129;
                num2  = num2 << (8 + packet.ReadByte());
            }
            return(packet);
        }
示例#4
0
        private static int berParseHeader(RdpPacket data, BER_Header eTagVal)
        {
            int num  = 0;
            int num2 = 0;
            int num3 = 0;
            int num4 = (int)eTagVal;

            if (num4 > 0xff)
            {
                num = data.ReadBigEndian16();
            }
            else
            {
                num = data.ReadByte();
            }
            if (num != num4)
            {
                throw new RDFatalException("Bad tag " + num.ToString() + " but need " + eTagVal.ToString());
            }
            num3 = data.ReadByte();
            if (num3 <= 0x80)
            {
                return(num3);
            }
            num3 -= 0x80;
            num2  = 0;
            while (num3-- != 0)
            {
                num2 = (num2 << 8) + data.ReadByte();
            }
            return(num2);
        }
示例#5
0
        internal static RdpPacket ReceiveMCS(out int channel, out int type)
        {
            int       num    = 0;
            int       num2   = 0;
            RdpPacket packet = ReceiveTPKTOrFastPath(out type);

            if ((type == 0xff) || (type == 0xfe))
            {
                channel = MCS.MSC_GLOBAL_CHANNEL;
                return(packet);
            }
            if (type != 240)
            {
                throw new RDFatalException("Illegal data type " + ((int)type).ToString());
            }
            if (packet == null)
            {
                channel = -1;
                return(null);
            }
            num  = packet.ReadByte();
            num2 = num >> 2;
            if (num2 != MCS.SDIN)
            {
                if (num2 != MCS.DPUM)
                {
                    throw new RDFatalException("Illegal data opcode " + num.ToString());
                }
                throw new EndOfTransmissionException("End of transmission!");
            }
            packet.Position += 2L;
            channel          = packet.ReadBigEndian16();
            packet.ReadByte();
            if ((packet.ReadByte() & 0x80) != 0)
            {
                packet.Position += 1L;
            }
            return(packet);
        }