Ejemplo n.º 1
0
        private static bool parsePublicKey(RdpPacket data)
        {
            int num  = 0;
            int num2 = 0;

            num = data.ReadLittleEndian32();

            if (num != 0x31415352)
            {
                int num3 = 0x31415352;
                throw new RDFatalException("Bad magic header ! Need " + num3.ToString() + " but got " + num.ToString());
            }

            num2 = data.ReadLittleEndian32();

            if (num2 != (modulus_size + 8))
            {
                modulus_size = num2 - 8;
            }

            data.Position += 8L;
            m_Exponent     = new byte[4];
            data.Read(m_Exponent, 0, 4);
            m_Modulus = new byte[modulus_size];
            data.Read(m_Modulus, 0, modulus_size);

            return(data.Position <= data.Length);
        }
Ejemplo n.º 2
0
        protected static int ReadInteger(RdpPacket packet)
        {
            if (packet.ReadByte() != 2)
            {
                throw new Exception("Data Error!");
            }
            int num2 = packet.ReadByte();

            byte[] buffer = new byte[4];

            switch (num2)
            {
            case 4:
                packet.Read(buffer, 0, 4);
                return(BitConverter.ToInt32(buffer, 0));

            case 3:
                packet.Read(buffer, 0, 3);
                return(BitConverter.ToInt32(buffer, 0));

            case 2:
                packet.Read(buffer, 0, 2);
                return(BitConverter.ToInt32(buffer, 0));
            }

            packet.Read(buffer, 0, 1);

            return(BitConverter.ToInt32(buffer, 0));
        }
Ejemplo n.º 3
0
        private static void ProcesssResponse(RdpPacket packet, byte[] ServerPublicKey)
        {
            ASN1.ReadTag(packet, ASN1.SequenceTag(0), "TSRequest");
            ASN1.ReadTag(packet, ASN1.ContextTag(0), "CTX_Version");

            if (ASN1.ReadInteger(packet) < 2)
            {
                throw new Exception("TSRequest version not supported!");
            }

            ASN1.CloseTag(packet, "CTX_Version");
            byte[] buffer = null;
            int    num2   = ASN1.ReadTag(packet, "Tag");

            if (num2 == ASN1.ContextTag(1))
            {
                ASN1.ReadTag(packet, ASN1.SequenceTag(0), "NegTokens");
                ASN1.ReadTag(packet, ASN1.SequenceTag(0), "NegTokens2");
                ASN1.ReadTag(packet, ASN1.ContextTag(0), "CTX_OctetString");
                m_ChallengeMsg = new byte[ASN1.ReadTag(packet, ASN1.OctetStringTag(), "OctetString")];
                packet.Read(m_ChallengeMsg, 0, m_ChallengeMsg.Length);
                ASN1.CloseTag(packet, "OctetString");
                ASN1.CloseTag(packet, "CTX_OctetString");
                ASN1.CloseTag(packet, "NegTokens2");
                ASN1.CloseTag(packet, "NegTokens");
            }
            else if (num2 == ASN1.ContextTag(3))
            {
                buffer = new byte[ASN1.ReadTag(packet, ASN1.OctetStringTag(), "OctetString")];
                packet.Read(buffer, 0, buffer.Length);
                ASN1.CloseTag(packet, "OctetString");
            }

            ASN1.CloseTag(packet, "Tag");
            ASN1.CloseTag(packet, "TSRequest");

            if (buffer != null)
            {
                byte[] buffer2 = m_NTLMAuthenticate.DecryptMessage(buffer);
                buffer2[0] = (byte)(buffer2[0] - 1);
                if (!NTLM.CompareArray(buffer2, ServerPublicKey))
                {
                    throw new Exception("Unable to verify the server's public key!");
                }
                buffer2[0] = (byte)(buffer2[0] + 1);
                SendTSRequest(null, WriteTSCredentials(), null);
                m_bAuthenticated = true;
            }
            else
            {
                ReadNegoToken(m_ChallengeMsg, ServerPublicKey);
            }
        }
Ejemplo n.º 4
0
        private void send(RdpPacket data)
        {
            data.Position = 0L;
            int length = (int)data.Length;
            int count  = Math.Min(length, 1600);
            int num    = length - count;

            if (num == 0)
            {
                RdpPacket packet = new RdpPacket();
                packet.WriteLittleEndian32((int)length);
                packet.WriteLittleEndian32((int)(CHANNEL_FLAG.CHANNEL_FLAG_FIRST | CHANNEL_FLAG.CHANNEL_FLAG_LAST | CHANNEL_FLAG.CHANNEL_FLAG_SHOW_PROTOCOL));
                packet.copyToByteArray(data);

                IsoLayer.SendToCannel(packet, Secure.RDPEncrypted() ? (int)(MCS.TS_SECURITY_HEADER.SEC_ENCRYPT) : 0, this.ChannelID);
            }
            else
            {
                RdpPacket packet2 = new RdpPacket();
                packet2.WriteLittleEndian32((int)length);
                packet2.WriteLittleEndian32((int)(CHANNEL_FLAG.CHANNEL_FLAG_FIRST | CHANNEL_FLAG.CHANNEL_FLAG_SHOW_PROTOCOL));
                byte[] buffer = new byte[count];
                data.Read(buffer, 0, count);
                packet2.Write(buffer, 0, count);

                IsoLayer.SendToCannel(packet2, Secure.RDPEncrypted() ? (int)(MCS.TS_SECURITY_HEADER.SEC_ENCRYPT) : 0, this.ChannelID);
            }

            while (num > 0)
            {
                count = Math.Min(num, 1600);
                num  -= count;
                RdpPacket packet3 = new RdpPacket();
                packet3.WriteLittleEndian32((int)length);

                if (num == 0)
                {
                    packet3.WriteLittleEndian32((int)(CHANNEL_FLAG.CHANNEL_FLAG_LAST | CHANNEL_FLAG.CHANNEL_FLAG_SHOW_PROTOCOL));
                }
                else
                {
                    packet3.WriteLittleEndian32((int)(CHANNEL_FLAG.CHANNEL_FLAG_SHOW_PROTOCOL));
                }

                byte[] buffer2 = new byte[count];
                data.Read(buffer2, 0, count);
                packet3.Write(buffer2, 0, count);

                IsoLayer.SendToCannel(packet3, Secure.RDPEncrypted() ? (int)(MCS.TS_SECURITY_HEADER.SEC_ENCRYPT) : 0, this.ChannelID);
            }
        }
Ejemplo n.º 5
0
        private static void processColorCache(RdpPacket data)
        {
            byte[] buffer = null;
            byte[] r      = null;
            byte[] g      = null;
            byte[] b      = null;
            int    index  = 0;
            int    num2   = data.ReadByte();
            int    count  = data.ReadLittleEndian16();

            buffer = new byte[count * 4];
            r      = new byte[count];
            g      = new byte[count];
            b      = new byte[count];
            data.Read(buffer, 0, buffer.Length);

            for (int i = 0; i < count; i++)
            {
                b[i]   = buffer[index];
                g[i]   = buffer[index + 1];
                r[i]   = buffer[index + 2];
                index += 4;
            }

            Cache.put_colourmap(num2, new Palette(8, count, r, g, b));
        }
Ejemplo n.º 6
0
 public void Write(RdpPacket packet, int Length)
 {
     byte[] buffer = new byte[Length];
     packet.Read(buffer, 0, buffer.Length);
     this.Write(buffer, 0, Length);
     this.Position = 0L;
 }
Ejemplo n.º 7
0
 public void copyToByteArray(RdpPacket packet)
 {
     byte[] buffer = new byte[packet.Length];
     packet.Position = 0L;
     packet.Read(buffer, 0, (int)packet.Length);
     this.Write(buffer, 0, buffer.Length);
 }
Ejemplo n.º 8
0
        internal static void Write(RdpPacket data)
        {
            data.Position = 0L;
            byte[] buffer = new byte[data.Length];
            data.Read(buffer, 0, (int)data.Length);

            Network.Send(buffer);
        }
Ejemplo n.º 9
0
        private static void Send(RdpPacket packet)
        {
            packet.Position = 0L;
            byte[] buffer = new byte[packet.Length];
            packet.Read(buffer, 0, (int)packet.Length);
            NTLM.DumpHex(buffer, (int)packet.Length, "Send");

            Network.Send(buffer);
        }
Ejemplo n.º 10
0
        internal static void process_demand(RdpPacket data)
        {
            byte[] buffer   = new byte[Secure.modulus_size];
            byte[] bytes    = ASCIIEncoding.GetBytes(Options.hostname, true);
            byte[] username = ASCIIEncoding.GetBytes(Options.Username, true);
            data.Read(m_Server_Random, 0, m_Server_Random.Length);
            generate_keys(buffer, m_Server_Random, buffer);

            send_request(buffer, buffer, username, bytes);
        }
Ejemplo n.º 11
0
        internal static bool parse_authreq(RdpPacket data)
        {
            int count = 0;

            data.Position += 6L;
            count          = data.ReadLittleEndian16();

            if (count != 10)
            {
                throw new RDFatalException("Illegal length of license token!");
            }

            m_In_Token = new byte[count];
            data.Read(m_In_Token, 0, count);
            m_In_Sig = new byte[0x10];
            data.Read(m_In_Sig, 0, 0x10);

            return(data.Position == data.Length);
        }
Ejemplo n.º 12
0
        private static void processFontCache(RdpPacket data, int extraFlags)
        {
            int font      = 0;
            int num2      = 0;
            int character = 0;
            int offset    = 0;
            int baseline  = 0;
            int width     = 0;
            int height    = 0;
            int count     = 0;

            byte[] buffer = null;
            int    num9   = (extraFlags >> 4) & 15;

            if ((num9 & 2) != 0)
            {
                font = extraFlags & 15;
                num2 = extraFlags >> 8;
            }
            else
            {
                font = data.ReadByte();
                num2 = data.ReadByte();
            }

            for (int i = 0; i < num2; i++)
            {
                if ((num9 & 2) != 0)
                {
                    character = data.ReadByte();
                    offset    = data.ReadEncodedSigned16();
                    baseline  = data.ReadEncodedSigned16();
                    width     = data.ReadEncodedUnsigned16();
                    height    = data.ReadEncodedUnsigned16();
                }
                else
                {
                    character = data.ReadLittleEndian16();
                    offset    = data.ReadLittleEndian16();
                    baseline  = data.ReadLittleEndian16();
                    width     = data.ReadLittleEndian16();
                    height    = data.ReadLittleEndian16();
                }

                count  = ((height * ((width + 7) / 8)) + 3) & -4;
                buffer = new byte[count];
                data.Read(buffer, 0, count);
                Glyph glyph = new Glyph(font, character, offset, baseline, width, height, buffer);
                Cache.putFont(glyph);
            }
        }
Ejemplo n.º 13
0
        private static void processLogonInfo(RdpPacket data)
        {
            // Вызываем событие инициализации
            Options.OnAutorization();

            int num;

            switch (data.ReadLittleEndian32())
            {
            case 0:
            case 1:
            case 2:
                return;

            case 3:
                data.ReadLittleEndian16();
                num = data.ReadLittleEndian32();

                if ((num & 1) != 0)
                {
                    if (data.ReadLittleEndian32() != 0x1c)
                    {
                        throw new Exception("Invalid length for AutoReconnectCookie!");
                    }

                    data.ReadLittleEndian32();
                    Options.LogonID = data.ReadLittleEndian32();

                    if (Options.ReconnectCookie == null)
                    {
                        Options.ReconnectCookie = new byte[0x10];
                    }

                    data.Read(Options.ReconnectCookie, 0, 0x10);
                    break;
                }
                break;

            default:
                return;
            }

            if ((num & 2) != 0)
            {
                data.ReadLittleEndian32();
                data.ReadLittleEndian32();
            }
        }
Ejemplo n.º 14
0
        private static void process_bmpcache3(RdpPacket data, int flags)
        {
            ulong num3 = 0L;
            int   num  = flags & 7;

            if ((flags & 0x800) != 0)
            {
                throw new RDFatalException("DO_NOT_CACHE flag not supported!");
            }

            int num2 = data.ReadEncodedUnsigned16();

            byte[] buffer = new byte[8];
            data.Read(buffer, 0, buffer.Length);
            num3 = BitConverter.ToUInt64(buffer, 0);
            process_bmpdata(data, flags, num, num2, num3);
        }
Ejemplo n.º 15
0
        internal static void process_issue(RdpPacket data)
        {
            int count = 0;
            RC4 rc    = new RC4();

            byte[] destinationArray = new byte[m_LicenceKey.Length];
            Array.Copy(m_LicenceKey, 0, destinationArray, 0, m_LicenceKey.Length);
            data.ReadLittleEndian16();
            count = data.ReadLittleEndian16();

            if ((data.Position + count) <= data.Length)
            {
                rc.engineInitDecrypt(destinationArray);
                byte[] buffer = new byte[count];
                data.Read(buffer, 0, count);
                rc.crypt(buffer, 0, count, buffer, 0);
            }
        }
Ejemplo n.º 16
0
        private static void processPolyLine(RdpPacket data, int present, bool delta)
        {
            if ((present & 1) != 0)
            {
                PolylineOrder.X = setCoordinate(data, PolylineOrder.X, delta);
            }

            if ((present & 2) != 0)
            {
                PolylineOrder.Y = setCoordinate(data, PolylineOrder.Y, delta);
            }

            if ((present & 4) != 0)
            {
                PolylineOrder.Opcode = data.ReadByte();
            }

            if ((present & 8) != 0)
            {
                data.ReadLittleEndian16();
            }

            if ((present & 0x10) != 0)
            {
                PolylineOrder.PenColor = setColor(data);
            }

            if ((present & 0x20) != 0)
            {
                PolylineOrder.Lines = data.ReadByte();
            }

            if ((present & 0x40) != 0)
            {
                int num = data.ReadByte();
                PolylineOrder.DataSize = num;
                byte[] buffer = new byte[num];
                data.Read(buffer, 0, buffer.Length);
                PolylineOrder.Data = buffer;
            }

            PolylineOrder.drawPolyLineOrder();
        }
Ejemplo n.º 17
0
        internal static void SendToCannel(RdpPacket secData, int flags, int channel)
        {
            secData.Position = 0L;
            byte[] buffer = new byte[secData.Length];
            secData.Read(buffer, 0, buffer.Length);

            if ((Secure.enc_count == 0x1000) && Secure.RDPEncrypted())
            {
                Secure.m_Encrypt_Key = Secure.update(Secure.m_Encrypt_Key, Secure._r);
                byte[] destinationArray = new byte[Secure.m_KeyLength];
                Array.Copy(Secure.m_Encrypt_Key, 0, destinationArray, 0, Secure.m_KeyLength);
                Secure.m_RC4_Enc.engineInitEncrypt(destinationArray);
                Secure.enc_count = 0;
            }

            if (Secure.RDPEncrypted())
            {
                byte[] buffer1 = Secure.sign(Secure.m_Sec_Sign_Key, 8, Secure.m_KeyLength, buffer, buffer.Length);
                byte[] buffer2 = Secure.m_RC4_Enc.crypt(buffer);
                secData = new RdpPacket();
                secData.WriteLittleEndian32(flags);
                secData.Write(buffer1, 0, buffer1.Length);
                secData.Write(buffer2, 0, buffer2.Length);
            }
            else
            {
                flags  &= -9;
                secData = new RdpPacket();

                if (flags != 0)
                {
                    secData.WriteLittleEndian32(flags);
                }

                secData.Write(buffer, 0, buffer.Length);
            }

            SendMCS(secData, channel);

            Secure.enc_count++;
        }
Ejemplo n.º 18
0
        private static byte[] WriteTSCredentials()
        {
            RdpPacket packet = new RdpPacket();

            ASN1.WriteTag(packet, ASN1.SequenceTag(0), "SEQ_TSCRED");
            ASN1.WriteTag(packet, ASN1.ContextTag(0), "CTX_credType");
            ASN1.WriteInteger(packet, 1);
            ASN1.CloseTag(packet, "CTX_credType");
            ASN1.WriteTag(packet, ASN1.ContextTag(1), "CTX_credentials");
            ASN1.WriteTag(packet, ASN1.OctetStringTag(), "CTX_OctetString");
            ASN1.WriteTag(packet, ASN1.SequenceTag(0), "SEQ_Credentials");
            ASN1.WriteTag(packet, ASN1.ContextTag(0), "CTX_domain");
            ASN1.WriteTag(packet, ASN1.OctetStringTag(), "OctectString");
            byte[] bytes = Encoding.Unicode.GetBytes(Options.Domain);
            packet.Write(bytes, 0, bytes.Length);
            ASN1.CloseTag(packet, "OctectString");
            ASN1.CloseTag(packet, "CTX_domain");
            ASN1.WriteTag(packet, ASN1.ContextTag(1), "CTX_user");
            ASN1.WriteTag(packet, ASN1.OctetStringTag(), "OctectString");
            byte[] buffer = Encoding.Unicode.GetBytes(Options.Username);
            packet.Write(buffer, 0, buffer.Length);
            ASN1.CloseTag(packet, "OctectString");
            ASN1.CloseTag(packet, "CTX_user");
            ASN1.WriteTag(packet, ASN1.ContextTag(2), "CTX_password");
            ASN1.WriteTag(packet, ASN1.OctetStringTag(), "OctectString");
            byte[] buffer3 = Encoding.Unicode.GetBytes(Options.Password);
            packet.Write(buffer3, 0, buffer3.Length);
            ASN1.CloseTag(packet, "OctectString");
            ASN1.CloseTag(packet, "CTX_password");
            ASN1.CloseTag(packet, "SEQ_Credentials");
            ASN1.CloseTag(packet, "CTX_OctetString");
            ASN1.CloseTag(packet, "CTX_credentials");
            ASN1.CloseTag(packet, "SEQ_TSCRED");
            byte[] buffer4 = new byte[packet.Length];
            packet.Position = 0L;
            packet.Read(buffer4, 0, buffer4.Length);

            return(m_NTLMAuthenticate.EncryptMessage(buffer4));
        }
Ejemplo n.º 19
0
        public byte[] Negotiate()
        {
            RdpPacket packet   = new RdpPacket();
            uint      num      = (((((((0xe2000000 | NTLMSSP_NEGOTIATE_EXTENDED_SESSION_SECURITY) | NTLMSSP_NEGOTIATE_ALWAYS_SIGN) | NTLMSSP_NEGOTIATE_NTLM) | NTLMSSP_NEGOTIATE_SEAL) | NTLMSSP_NEGOTIATE_SIGN) | NTLMSSP_REQUEST_TARGET) | NTLMSSP_NEGOTIATE_OEM) | NTLMSSP_NEGOTIATE_UNICODE;
            int       position = (int)packet.Position;

            packet.WriteString("NTLMSSP", false);
            packet.WriteByte(0);
            packet.WriteLittleEndian32(1);
            packet.WriteLittleEndian32(num);
            int num3 = ((int)packet.Position) - position;

            num3 += 8;
            num3 += 8;

            if ((num & 0x2000000) != 0)
            {
                num3 += 8;
            }

            packet.WriteLittleEndian16((short)0);
            packet.WriteLittleEndian16((short)0);
            packet.WriteLittleEndian32(0);
            packet.WriteLittleEndian16((short)0);
            packet.WriteLittleEndian16((short)0);
            packet.WriteLittleEndian32(0);

            if ((num & 0x2000000) != 0)
            {
                this.WriteVersion(packet);
            }

            packet.Position     = 0L;
            this.m_NegotiateMsg = new byte[packet.Length];
            packet.Read(this.m_NegotiateMsg, 0, this.m_NegotiateMsg.Length);

            return(this.m_NegotiateMsg);
        }
Ejemplo n.º 20
0
        public static RdpPacket DecryptPacket(RdpPacket packet)
        {
            packet.Position += 8L;
            byte[] buffer = new byte[packet.Length - packet.Position];
            packet.Read(buffer, 0, buffer.Length);

            if (dec_count == 0x1000)
            {
                m_Decrypt_Key = update(m_Decrypt_Key, m_Sec_Decrypt_Update_Key);
                byte[] destinationArray = new byte[m_KeyLength];
                Array.Copy(m_Decrypt_Key, 0, destinationArray, 0, m_KeyLength);
                m_RC4_Dec.engineInitDecrypt(destinationArray);
                dec_count = 0;
            }

            dec_count++;
            byte[] buffer3 = m_RC4_Dec.crypt(buffer);
            packet = new RdpPacket();
            packet.Write(buffer3, 0, buffer3.Length);
            packet.Position = 0L;

            return(packet);
        }
Ejemplo n.º 21
0
        internal static void processPalette(RdpPacket data)
        {
            int num = 0;

            byte[] buffer = null;
            int    index  = 0;

            data.Position   += 2L;
            num              = data.ReadLittleEndian16();
            data.Position   += 2L;
            buffer           = new byte[num * 3];
            m_Global.m_Red   = new byte[num];
            m_Global.m_Green = new byte[num];
            m_Global.m_Blue  = new byte[num];
            data.Read(buffer, 0, buffer.Length);
            for (int i = 0; i < num; i++)
            {
                m_Global.m_Red[i]   = buffer[index];
                m_Global.m_Green[i] = buffer[index + 1];
                m_Global.m_Blue[i]  = buffer[index + 2];
                index += 3;
            }
        }
Ejemplo n.º 22
0
        internal static void processRedirection(RdpPacket data, bool bStdRedirect)
        {
            if (!bStdRedirect)
            {
                data.ReadLittleEndian16();
            }

            data.ReadLittleEndian16();
            data.ReadLittleEndian16();
            Options.sessionID = data.ReadLittleEndian32();
            int num = data.ReadLittleEndian32();

            if ((num & 1) != 0)
            {
                Options.Host = data.ReadUnicodeString();
            }

            byte[] buffer = null;

            if ((num & 2) != 0)
            {
                int count = data.ReadLittleEndian32();
                buffer = new byte[count];
                data.Read(buffer, 0, count);
            }

            if ((num & 4) != 0)
            {
                Options.Username = data.ReadUnicodeString();
            }

            if ((num & 8) != 0)
            {
                Options.Domain = data.ReadUnicodeString();
            }

            if ((num & 0x10) != 0)
            {
                Options.Password = data.ReadUnicodeString();
            }

            if ((num & 0x200) != 0)
            {
                Options.Host = data.ReadUnicodeString();
            }

            if ((num & 0x100) != 0)
            {
                Options.Host = data.ReadUnicodeString();
            }

            if (!string.IsNullOrEmpty(Options.Domain))
            {
                Options.DomainAndUsername = Options.Domain + @"\" + Options.Username;
            }
            else
            {
                Options.DomainAndUsername = Options.Username;
            }

            if ((num & 0x80) == 0)
            {
                Network.Close();
                Licence.Reset();
                Network.Connect(Options.Host, Options.Port);
                MCS.sendСonnectionRequest(buffer, false);
            }
        }
Ejemplo n.º 23
0
        public static byte[] decompress(int width, int height, int size, RdpPacket data, int Bpp)
        {
            byte[] buffer = new byte[size];
            data.Read(buffer, 0, size);
            int  startOffset   = 0;
            int  startlocation = 0;
            int  num3          = 0;
            int  num4          = 0;
            int  num5          = size;
            int  num6          = 0;
            int  num7          = 0;
            int  num8          = 0;
            int  offset        = width;
            int  num10         = -1;
            int  num11         = 0;
            int  num12         = 0;
            int  num13         = 0;
            int  num14         = 0;
            byte num15         = 0;
            int  num16         = 0;
            uint maxValue      = uint.MaxValue;
            bool flag          = false;
            bool flag2         = false;
            bool flag3         = false;

            byte[] input = new byte[width * height];
            while (num3 < num5)
            {
                num11 = 0;
                num12 = buffer[num3++] & 0xff;
                num6  = num12 >> 4;
                switch (num6)
                {
                case 12:
                case 13:
                case 14:
                    num6 -= 6;
                    num7  = num12 & 15;
                    num8  = 0x10;
                    goto Label_00F8;

                case 15:
                    num6 = num12 & 15;
                    if (num6 >= 9)
                    {
                        break;
                    }
                    num7  = buffer[num3++] & 0xff;
                    num7 |= (buffer[num3++] & 0xff) << 8;
                    goto Label_00F5;

                default:
                    num6 = num6 >> 1;
                    num7 = num12 & 0x1f;
                    num8 = 0x20;
                    goto Label_00F8;
                }
                num7 = (num6 < 11) ? 8 : 1;
Label_00F5:
                num8 = 0;
Label_00F8:
                if (num8 != 0)
                {
                    flag3 = (num6 == 2) || (num6 == 7);
                    if (num7 == 0)
                    {
                        if (flag3)
                        {
                            num7 = (buffer[num3++] & 0xff) + 1;
                        }
                        else
                        {
                            num7 = (buffer[num3++] & 0xff) + num8;
                        }
                    }
                    else if (flag3)
                    {
                        num7 = num7 << 3;
                    }
                }
                switch (num6)
                {
                case 0:
                    if ((num10 == num6) && ((offset != width) || (startOffset != 0)))
                    {
                        flag = true;
                    }
                    break;

                case 3:
                    num14 = buffer[num3++] & 0xff;
                    break;

                case 6:
                case 7:
                    maxValue = buffer[num3++];
                    num6    -= 5;
                    break;

                case 8:
                    num13 = buffer[num3++] & 0xff;
                    num14 = buffer[num3++] & 0xff;
                    break;

                case 9:
                    num16 = 3;
                    num6  = 2;
                    num11 = 3;
                    break;

                case 10:
                    num16 = 5;
                    num6  = 2;
                    num11 = 5;
                    break;
                }
                num10 = num6;
                num15 = 0;
                while (num7 > 0)
                {
                    int num18;
                    int num19;
                    int num20;
                    int num21;
                    int num22;
                    int num23;
                    int num24;
                    int num25;
                    int num26;
                    int num27;
                    int num28;
                    if (offset >= width)
                    {
                        if (height <= 0)
                        {
                            throw new RDFatalException("Decompressing bitmap failed! Height = " + height.ToString());
                        }
                        offset = 0;
                        height--;
                        startOffset   = startlocation;
                        startlocation = num4 + (height * width);
                    }
                    switch (num6)
                    {
                    case 0:
                        if (!flag)
                        {
                            goto Label_02CE;
                        }
                        if (startOffset != 0)
                        {
                            break;
                        }
                        input[startlocation + offset] = (byte)maxValue;
                        goto Label_02BF;

                    case 1:
                        if (startOffset == 0)
                        {
                            goto Label_03BC;
                        }
                        goto Label_0429;

                    case 2:
                        if (startOffset == 0)
                        {
                            goto Label_04C7;
                        }
                        goto Label_0596;

                    case 3:
                        goto Label_0634;

                    case 4:
                        goto Label_0696;

                    case 8:
                        goto Label_0714;

                    case 13:
                        goto Label_0790;

                    case 14:
                        goto Label_07E8;

                    default:
                        throw new RDFatalException("Incorrect decompress opcode " + num6.ToString());
                    }
                    input[startlocation + offset] = (byte)(input[startOffset + offset] ^ ((byte)maxValue));
Label_02BF:
                    flag = false;
                    num7--;
                    offset++;
Label_02CE:
                    if (startOffset == 0)
                    {
                        goto Label_02FA;
                    }
                    goto Label_035A;
Label_02D6:
                    num28 = 0;
                    while (num28 < 8)
                    {
                        input[startlocation + offset] = 0;
                        num7--;
                        offset++;
                        num28++;
                    }
Label_02FA:
                    if (((num7 & -8) != 0) && ((offset + 8) < width))
                    {
                        goto Label_02D6;
                    }
                    while ((num7 > 0) && (offset < width))
                    {
                        input[startlocation + offset] = 0;
                        num7--;
                        offset++;
                    }
                    continue;
Label_0330:
                    num18 = 0;
                    while (num18 < 8)
                    {
                        input[startlocation + offset] = input[startOffset + offset];
                        num7--;
                        offset++;
                        num18++;
                    }
Label_035A:
                    if (((num7 & -8) == 0) || ((offset + 8) >= width))
                    {
                        goto Label_0384;
                    }
                    goto Label_0330;
Label_036A:
                    input[startlocation + offset] = input[startOffset + offset];
                    num7--;
                    offset++;
Label_0384:
                    if ((num7 > 0) && (offset < width))
                    {
                        goto Label_036A;
                    }
                    continue;
Label_0396:
                    num19 = 0;
                    while (num19 < 8)
                    {
                        input[startlocation + offset] = (byte)maxValue;
                        num7--;
                        offset++;
                        num19++;
                    }
Label_03BC:
                    if (((num7 & -8) == 0) || ((offset + 8) >= width))
                    {
                        goto Label_03E2;
                    }
                    goto Label_0396;
Label_03CC:
                    input[startlocation + offset] = (byte)maxValue;
                    num7--;
                    offset++;
Label_03E2:
                    if ((num7 > 0) && (offset < width))
                    {
                        goto Label_03CC;
                    }
                    continue;
Label_03F4:
                    num20 = 0;
                    while (num20 < 8)
                    {
                        setli(input, startlocation, offset, getli(input, startOffset, offset, 1) ^ maxValue, 1);
                        num7--;
                        offset++;
                        num20++;
                    }
Label_0429:
                    if (((num7 & -8) == 0) || ((offset + 8) >= width))
                    {
                        goto Label_045E;
                    }
                    goto Label_03F4;
Label_0439:
                    setli(input, startlocation, offset, getli(input, startOffset, offset, 1) ^ maxValue, 1);
                    num7--;
                    offset++;
Label_045E:
                    if ((num7 > 0) && (offset < width))
                    {
                        goto Label_0439;
                    }
                    continue;
Label_0470:
                    num21 = 0;
                    while (num21 < 8)
                    {
                        num15 = (byte)(num15 << 1);
                        if (num15 == 0)
                        {
                            num16 = (num11 != 0) ? ((byte)num11) : buffer[num3++];
                            num15 = 1;
                        }
                        if ((num16 & num15) != 0)
                        {
                            input[startlocation + offset] = (byte)maxValue;
                        }
                        else
                        {
                            input[startlocation + offset] = 0;
                        }
                        num7--;
                        offset++;
                        num21++;
                    }
Label_04C7:
                    if (((num7 & -8) == 0) || ((offset + 8) >= width))
                    {
                        goto Label_051E;
                    }
                    goto Label_0470;
Label_04D7:
                    num15 = (byte)(num15 << 1);
                    if (num15 == 0)
                    {
                        num16 = (num11 != 0) ? ((byte)num11) : buffer[num3++];
                        num15 = 1;
                    }
                    if ((num16 & num15) != 0)
                    {
                        input[startlocation + offset] = (byte)maxValue;
                    }
                    else
                    {
                        input[startlocation + offset] = 0;
                    }
                    num7--;
                    offset++;
Label_051E:
                    if ((num7 > 0) && (offset < width))
                    {
                        goto Label_04D7;
                    }
                    continue;
Label_0530:
                    num22 = 0;
                    while (num22 < 8)
                    {
                        num15 = (byte)(num15 << 1);
                        if (num15 == 0)
                        {
                            num16 = (num11 != 0) ? ((byte)num11) : buffer[num3++];
                            num15 = 1;
                        }
                        if ((num16 & num15) != 0)
                        {
                            input[startlocation + offset] = (byte)(input[startOffset + offset] ^ ((byte)maxValue));
                        }
                        else
                        {
                            input[startlocation + offset] = input[startOffset + offset];
                        }
                        num7--;
                        offset++;
                        num22++;
                    }
Label_0596:
                    if (((num7 & -8) == 0) || ((offset + 8) >= width))
                    {
                        goto Label_05FC;
                    }
                    goto Label_0530;
Label_05A6:
                    num15 = (byte)(num15 << 1);
                    if (num15 == 0)
                    {
                        num16 = (num11 != 0) ? ((byte)num11) : buffer[num3++];
                        num15 = 1;
                    }
                    if ((num16 & num15) != 0)
                    {
                        input[startlocation + offset] = (byte)(input[startOffset + offset] ^ ((byte)maxValue));
                    }
                    else
                    {
                        input[startlocation + offset] = input[startOffset + offset];
                    }
                    num7--;
                    offset++;
Label_05FC:
                    if ((num7 > 0) && (offset < width))
                    {
                        goto Label_05A6;
                    }
                    continue;
Label_060E:
                    num23 = 0;
                    while (num23 < 8)
                    {
                        input[startlocation + offset] = (byte)num14;
                        num7--;
                        offset++;
                        num23++;
                    }
Label_0634:
                    if (((num7 & -8) == 0) || ((offset + 8) >= width))
                    {
                        goto Label_065A;
                    }
                    goto Label_060E;
Label_0644:
                    input[startlocation + offset] = (byte)num14;
                    num7--;
                    offset++;
Label_065A:
                    if ((num7 > 0) && (offset < width))
                    {
                        goto Label_0644;
                    }
                    continue;
Label_066C:
                    num24 = 0;
                    while (num24 < 8)
                    {
                        input[startlocation + offset] = buffer[num3++];
                        num7--;
                        offset++;
                        num24++;
                    }
Label_0696:
                    if (((num7 & -8) == 0) || ((offset + 8) >= width))
                    {
                        goto Label_06C0;
                    }
                    goto Label_066C;
Label_06A6:
                    input[startlocation + offset] = buffer[num3++];
                    num7--;
                    offset++;
Label_06C0:
                    if ((num7 > 0) && (offset < width))
                    {
                        goto Label_06A6;
                    }
                    continue;
Label_06D2:
                    num25 = 0;
                    while (num25 < 8)
                    {
                        if (flag2)
                        {
                            input[startlocation + offset] = (byte)num14;
                            flag2 = false;
                        }
                        else
                        {
                            input[startlocation + offset] = (byte)num13;
                            flag2 = true;
                            num7++;
                        }
                        num7--;
                        offset++;
                        num25++;
                    }
Label_0714:
                    if (((num7 & -8) == 0) || ((offset + 8) >= width))
                    {
                        goto Label_0756;
                    }
                    goto Label_06D2;
Label_0724:
                    if (flag2)
                    {
                        input[startlocation + offset] = (byte)num14;
                        flag2 = false;
                    }
                    else
                    {
                        input[startlocation + offset] = (byte)num13;
                        flag2 = true;
                        num7++;
                    }
                    num7--;
                    offset++;
Label_0756:
                    if ((num7 > 0) && (offset < width))
                    {
                        goto Label_0724;
                    }
                    continue;
Label_0768:
                    num26 = 0;
                    while (num26 < 8)
                    {
                        input[startlocation + offset] = 0xff;
                        num7--;
                        offset++;
                        num26++;
                    }
Label_0790:
                    if (((num7 & -8) == 0) || ((offset + 8) >= width))
                    {
                        goto Label_07B8;
                    }
                    goto Label_0768;
Label_07A0:
                    input[startlocation + offset] = 0xff;
                    num7--;
                    offset++;
Label_07B8:
                    if ((num7 > 0) && (offset < width))
                    {
                        goto Label_07A0;
                    }
                    continue;
Label_07C4:
                    num27 = 0;
                    while (num27 < 8)
                    {
                        input[startlocation + offset] = 0;
                        num7--;
                        offset++;
                        num27++;
                    }
Label_07E8:
                    if (((num7 & -8) == 0) || ((offset + 8) >= width))
                    {
                        goto Label_080C;
                    }
                    goto Label_07C4;
Label_07F8:
                    input[startlocation + offset] = 0;
                    num7--;
                    offset++;
Label_080C:
                    if ((num7 > 0) && (offset < width))
                    {
                        goto Label_07F8;
                    }
                }
            }
            _g++;
            return(input);
        }
Ejemplo n.º 24
0
        private static void processGlyphIndex(RdpPacket data, int present, bool delta)
        {
            if ((present & 1) != 0)
            {
                Text2Order.Font = data.ReadByte();
            }

            if ((present & 2) != 0)
            {
                Text2Order.Flags = data.ReadByte();
            }

            if ((present & 4) != 0)
            {
                Text2Order.Opcode = data.ReadByte();
            }

            if ((present & 8) != 0)
            {
                Text2Order.Mixmode = data.ReadByte();
            }

            if ((present & 0x10) != 0)
            {
                Text2Order.ForegroundColor = setColor(data);
            }

            if ((present & 0x20) != 0)
            {
                Text2Order.BackgroundColor = setColor(data);
            }

            if ((present & 0x40) != 0)
            {
                Text2Order.ClipLeft = data.ReadLittleEndian16();
            }

            if ((present & 0x80) != 0)
            {
                Text2Order.ClipTop = data.ReadLittleEndian16();
            }

            if ((present & 0x100) != 0)
            {
                Text2Order.ClipRight = data.ReadLittleEndian16();
            }

            if ((present & 0x200) != 0)
            {
                Text2Order.ClipBottom = data.ReadLittleEndian16();
            }

            if ((present & 0x400) != 0)
            {
                Text2Order.BoxLeft = data.ReadLittleEndian16();
            }

            if ((present & 0x800) != 0)
            {
                Text2Order.BoxTop = data.ReadLittleEndian16();
            }

            if ((present & 0x1000) != 0)
            {
                Text2Order.BoxRight = data.ReadLittleEndian16();
            }

            if ((present & 0x2000) != 0)
            {
                Text2Order.BoxBottom = data.ReadLittleEndian16();
            }

            parseBrush(data, Text2Order.Brush, present >> 14);

            if ((present & 0x80000) != 0)
            {
                Text2Order.X = data.ReadLittleEndian16();
            }

            if ((present & 0x100000) != 0)
            {
                Text2Order.Y = data.ReadLittleEndian16();
            }

            if ((present & 0x200000) != 0)
            {
                int num = data.ReadByte();
                Text2Order.GlyphLength = num;
                byte[] buffer = new byte[num];
                data.Read(buffer, 0, buffer.Length);
                Text2Order.GlyphIndices = buffer;
            }

            Text2Order.drawText();
        }
Ejemplo n.º 25
0
        public static uint[] decompressInt(int width, int height, int size, RdpPacket data, int Bpp)
        {
            byte[] buffer = new byte[size];
            data.Read(buffer, 0, size);
            int  num      = -1;
            int  num2     = 0;
            int  offset   = 0;
            int  num4     = 0;
            int  num5     = size;
            int  num6     = 0;
            uint num7     = 0;
            int  num8     = 0;
            int  num9     = width;
            int  num10    = -1;
            int  num11    = 0;
            int  num12    = 0;
            uint num13    = 0;
            uint num14    = 0;
            byte num15    = 0;
            int  num16    = 0;
            uint maxValue = uint.MaxValue;
            bool flag     = false;
            bool flag2    = false;
            bool flag3    = false;

            uint[] numArray = new uint[width * height];
            try
            {
                while (offset < num5)
                {
                    num11 = 0;
                    num12 = buffer[offset++] & 0xff;
                    num6  = num12 >> 4;
                    switch (num6)
                    {
                    case 12:
                    case 13:
                    case 14:
                        num6 -= 6;
                        num7  = (uint)(num12 & 15);
                        num8  = 0x10;
                        goto Label_00F8;

                    case 15:
                        num6 = num12 & 15;
                        if (num6 >= 9)
                        {
                            break;
                        }
                        num7  = (uint)(buffer[offset++] & 0xff);
                        num7 |= (uint)((buffer[offset++] & 0xff) << 8);
                        goto Label_00E2;

                    default:
                        num6 = num6 >> 1;
                        num7 = (uint)(num12 & 0x1f);
                        num8 = 0x20;
                        goto Label_00F8;
                    }
                    num7 = (uint)(num6 < 11 ? 8 : 1);
Label_00E2:
                    num8 = 0;
Label_00F8:
                    if (num8 != 0)
                    {
                        flag3 = (num6 == 2) || (num6 == 7);
                        if (num7 == 0)
                        {
                            if (flag3)
                            {
                                num7 = (uint)((buffer[offset++] & 0xff) + 1);
                            }
                            else
                            {
                                num7 = (uint)((buffer[offset++] & 0xff) + num8);
                            }
                        }
                        else if (flag3)
                        {
                            num7 = num7 << 3;
                        }
                    }
                    switch (num6)
                    {
                    case 0:
                        if ((num10 == num6) && ((num9 != width) || (num != -1)))
                        {
                            flag = true;
                        }
                        goto Label_01DF;

                    case 3:
                        break;

                    case 6:
                    case 7:
                        maxValue = cvalx(buffer, offset, Bpp);
                        offset  += Bpp;
                        num6    -= 5;
                        goto Label_01DF;

                    case 8:
                        num13   = cvalx(buffer, offset, Bpp);
                        offset += Bpp;
                        break;

                    case 9:
                        num16 = 3;
                        num6  = 2;
                        num11 = 3;
                        goto Label_01DF;

                    case 10:
                        num16 = 5;
                        num6  = 2;
                        num11 = 5;
                        goto Label_01DF;

                    default:
                        goto Label_01DF;
                    }
                    num14   = cvalx(buffer, offset, Bpp);
                    offset += Bpp;
Label_01DF:
                    num10 = num6;
                    num15 = 0;
                    while (num7 > 0)
                    {
                        int num19;
                        int num20;
                        int num21;
                        int num22;
                        int num23;
                        int num24;
                        int num25;
                        int num26;
                        int num27;
                        int num28;
                        if (num9 >= width)
                        {
                            if (height <= 0)
                            {
                                throw new RDFatalException("Illegal int bitmap height: " + height.ToString());
                            }
                            num9 = 0;
                            height--;
                            num  = num2;
                            num2 = num4 + (height * width);
                        }
                        switch (num6)
                        {
                        case 0:
                            if (!flag)
                            {
                                goto Label_029B;
                            }
                            if (num != -1)
                            {
                                break;
                            }
                            numArray[num2 + num9] = maxValue;
                            goto Label_028C;

                        case 1:
                            if (num != -1)
                            {
                                goto Label_0402;
                            }
                            goto Label_039A;

                        case 2:
                            if (num != -1)
                            {
                                goto Label_0571;
                            }
                            goto Label_04A3;

                        case 3:
                            goto Label_060F;

                        case 4:
                            goto Label_067B;

                        case 8:
                            goto Label_0702;

                        case 13:
                            goto Label_0780;

                        case 14:
                            goto Label_07DC;

                        default:
                            throw new RDFatalException("Illegal int bitmap opcode in " + num6.ToString());
                        }
                        numArray[num2 + num9] = numArray[num + num9] ^ maxValue;
Label_028C:
                        flag = false;
                        num7--;
                        num9++;
Label_029B:
                        if (num != -1)
                        {
                            goto Label_032C;
                        }
                        while (((num7 & 18446744073709551608L) != 0L) && ((num9 + 8) < width))
                        {
                            for (int i = 0; i < 8; i++)
                            {
                                numArray[num2 + num9] = 0;
                                num7--;
                                num9++;
                            }
                        }
                        while ((num7 > 0) && (num9 < width))
                        {
                            numArray[num2 + num9] = 0;
                            num7--;
                            num9++;
                        }
                        continue;
Label_0302:
                        num19 = 0;
                        while (num19 < 8)
                        {
                            numArray[num2 + num9] = numArray[num + num9];
                            num7--;
                            num9++;
                            num19++;
                        }
Label_032C:
                        if (((num7 & 18446744073709551608L) != 0L) && ((num9 + 8) < width))
                        {
                            goto Label_0302;
                        }
                        while ((num7 > 0) && (num9 < width))
                        {
                            numArray[num2 + num9] = numArray[num + num9];
                            num7--;
                            num9++;
                        }
                        continue;
Label_0375:
                        num20 = 0;
                        while (num20 < 8)
                        {
                            numArray[num2 + num9] = maxValue;
                            num7--;
                            num9++;
                            num20++;
                        }
Label_039A:
                        if (((num7 & 18446744073709551608L) != 0L) && ((num9 + 8) < width))
                        {
                            goto Label_0375;
                        }
                        while ((num7 > 0) && (num9 < width))
                        {
                            numArray[num2 + num9] = maxValue;
                            num7--;
                            num9++;
                        }
                        continue;
Label_03D5:
                        num21 = 0;
                        while (num21 < 8)
                        {
                            numArray[num2 + num9] = numArray[num + num9] ^ maxValue;
                            num7--;
                            num9++;
                            num21++;
                        }
Label_0402:
                        if (((num7 & 18446744073709551608L) != 0L) && ((num9 + 8) < width))
                        {
                            goto Label_03D5;
                        }
                        while ((num7 > 0) && (num9 < width))
                        {
                            numArray[num2 + num9] = numArray[num + num9] ^ maxValue;
                            num7--;
                            num9++;
                        }
                        continue;
Label_044E:
                        num22 = 0;
                        while (num22 < 8)
                        {
                            num15 = (byte)(num15 << 1);
                            if (num15 == 0)
                            {
                                num16 = (num11 != 0) ? num11 : buffer[offset++];
                                num15 = 1;
                            }
                            if ((num16 & num15) != 0)
                            {
                                numArray[num2 + num9] = maxValue;
                            }
                            else
                            {
                                numArray[num2 + num9] = 0;
                            }
                            num7--;
                            num9++;
                            num22++;
                        }
Label_04A3:
                        if (((num7 & 18446744073709551608L) != 0L) && ((num9 + 8) < width))
                        {
                            goto Label_044E;
                        }
                        while ((num7 > 0) && (num9 < width))
                        {
                            num15 = (byte)(num15 << 1);
                            if (num15 == 0)
                            {
                                num16 = (num11 != 0) ? num11 : buffer[offset++];
                                num15 = 1;
                            }
                            if ((num16 & num15) != 0)
                            {
                                numArray[num2 + num9] = maxValue;
                            }
                            else
                            {
                                numArray[num2 + num9] = 0;
                            }
                            num7--;
                            num9++;
                        }
                        continue;
Label_050E:
                        num23 = 0;
                        while (num23 < 8)
                        {
                            num15 = (byte)(num15 << 1);
                            if (num15 == 0)
                            {
                                num16 = (num11 != 0) ? num11 : buffer[offset++];
                                num15 = 1;
                            }
                            if ((num16 & num15) != 0)
                            {
                                numArray[num2 + num9] = numArray[num + num9] ^ maxValue;
                            }
                            else
                            {
                                numArray[num2 + num9] = numArray[num + num9];
                            }
                            num7--;
                            num9++;
                            num23++;
                        }
Label_0571:
                        if (((num7 & 18446744073709551608L) != 0L) && ((num9 + 8) < width))
                        {
                            goto Label_050E;
                        }
                        while ((num7 > 0) && (num9 < width))
                        {
                            num15 = (byte)(num15 << 1);
                            if (num15 == 0)
                            {
                                num16 = (num11 != 0) ? num11 : buffer[offset++];
                                num15 = 1;
                            }
                            if ((num16 & num15) != 0)
                            {
                                numArray[num2 + num9] = numArray[num + num9] ^ maxValue;
                            }
                            else
                            {
                                numArray[num2 + num9] = numArray[num + num9];
                            }
                            num7--;
                            num9++;
                        }
                        continue;
Label_05EA:
                        num24 = 0;
                        while (num24 < 8)
                        {
                            numArray[num2 + num9] = num14;
                            num7--;
                            num9++;
                            num24++;
                        }
Label_060F:
                        if (((num7 & 18446744073709551608L) != 0L) && ((num9 + 8) < width))
                        {
                            goto Label_05EA;
                        }
                        while ((num7 > 0) && (num9 < width))
                        {
                            numArray[num2 + num9] = num14;
                            num7--;
                            num9++;
                        }
                        continue;
Label_064A:
                        num25 = 0;
                        while (num25 < 8)
                        {
                            numArray[num2 + num9] = cvalx(buffer, offset, Bpp);
                            offset += Bpp;
                            num7--;
                            num9++;
                            num25++;
                        }
Label_067B:
                        if (((num7 & 18446744073709551608L) != 0L) && ((num9 + 8) < width))
                        {
                            goto Label_064A;
                        }
                        while ((num7 > 0) && (num9 < width))
                        {
                            numArray[num2 + num9] = cvalx(buffer, offset, Bpp);
                            offset += Bpp;
                            num7--;
                            num9++;
                        }
                        continue;
Label_06C2:
                        num26 = 0;
                        while (num26 < 8)
                        {
                            if (flag2)
                            {
                                numArray[num2 + num9] = num14;
                                flag2 = false;
                            }
                            else
                            {
                                numArray[num2 + num9] = num13;
                                flag2 = true;
                                num7++;
                            }
                            num7--;
                            num9++;
                            num26++;
                        }
Label_0702:
                        if (((num7 & 18446744073709551608L) != 0L) && ((num9 + 8) < width))
                        {
                            goto Label_06C2;
                        }
                        while ((num7 > 0) && (num9 < width))
                        {
                            if (flag2)
                            {
                                numArray[num2 + num9] = num14;
                                flag2 = false;
                            }
                            else
                            {
                                numArray[num2 + num9] = num13;
                                flag2 = true;
                                num7++;
                            }
                            num7--;
                            num9++;
                        }
                        continue;
Label_0758:
                        num27 = 0;
                        while (num27 < 8)
                        {
                            numArray[num2 + num9] = 0xffffff;
                            num7--;
                            num9++;
                            num27++;
                        }
Label_0780:
                        if (((num7 & 18446744073709551608L) != 0L) && ((num9 + 8) < width))
                        {
                            goto Label_0758;
                        }
                        while ((num7 > 0) && (num9 < width))
                        {
                            numArray[num2 + num9] = 0xffffff;
                            num7--;
                            num9++;
                        }
                        continue;
Label_07B8:
                        num28 = 0;
                        while (num28 < 8)
                        {
                            numArray[num2 + num9] = 0;
                            num7--;
                            num9++;
                            num28++;
                        }
Label_07DC:
                        if (((num7 & 18446744073709551608L) != 0L) && ((num9 + 8) < width))
                        {
                            goto Label_07B8;
                        }
                        while ((num7 > 0) && (num9 < width))
                        {
                            numArray[num2 + num9] = 0;
                            num7--;
                            num9++;
                        }
                    }
                }
            }
            catch
            {
            }
            return(numArray);
        }
Ejemplo n.º 26
0
        private static void processBitmapCache(RdpPacket data, bool bCompressed, bool bNoCompressionHdr)
        {
            int num2;
            int num  = num2 = 0;
            int num3 = data.ReadByte();

            data.ReadByte();
            int width  = data.ReadByte();
            int height = data.ReadByte();
            int bpp    = (data.ReadByte() + 7) / 8;

            num = data.ReadLittleEndian16();
            int num8 = data.ReadLittleEndian16();

            if (!bCompressed)
            {
                byte[] buffer = new byte[(width * height) * bpp];
                int    offset = (height - 1) * (width * bpp);

                for (int i = 0; i < height; i++)
                {
                    data.Read(buffer, offset, width * bpp);
                    offset -= width * bpp;
                }

                Cache.putBitmap(num3, num8, new RdpBitmap(buffer, width, height, bpp, 0, 0), 0);
            }
            else
            {
                if (!bNoCompressionHdr)
                {
                    data.ReadLittleEndian16();
                    num2 = data.ReadLittleEndian16();
                    data.ReadLittleEndian16();
                    data.ReadLittleEndian16();
                }
                else
                {
                    num2 = num;
                }

                if (bpp == 1)
                {
                    byte[] buffer2 = RdpBitmap.decompress(width, height, num2, data, bpp);

                    if (buffer2 != null)
                    {
                        Cache.putBitmap(num3, num8, new RdpBitmap(buffer2, width, height, bpp, 0, 0), 0);
                    }
                }
                else
                {
                    uint[] numArray = RdpBitmap.decompressInt(width, height, num2, data, bpp);

                    if (numArray != null)
                    {
                        Cache.putBitmap(num3, num8, new RdpBitmap(numArray, width, height, bpp, 0, 0), 0);
                    }
                }
            }
        }
Ejemplo n.º 27
0
        private static void process_bmpdata(RdpPacket data, int flags, int cache_id, int cache_idx, ulong persist_key)
        {
            RdpBitmap bitmap;

            byte[] buffer;
            int    bpp = data.ReadByte();

            data.ReadByte();
            data.ReadByte();
            int num2   = data.ReadByte();
            int width  = data.ReadLittleEndian16();
            int height = data.ReadLittleEndian16();
            int size   = data.ReadLittleEndian32();

            if (num2 == 1)
            {
                if (bpp == 1)
                {
                    buffer = RdpBitmap.decompress(width, height, size, data, bpp);

                    if (buffer == null)
                    {
                        return;
                    }

                    bitmap = new RdpBitmap(buffer, width, height, bpp, 0, 0);
                }
                else
                {
                    uint[] numArray = RdpBitmap.decompressInt(width, height, size, data, bpp);

                    if (numArray == null)
                    {
                        return;
                    }

                    bitmap = new RdpBitmap(numArray, width, height, bpp, 0, 0);
                }
            }
            else
            {
                buffer = new byte[(width * height) * bpp];

                for (int i = 0; i < height; i++)
                {
                    data.Read(buffer, ((height - i) - 1) * (width * bpp), width * bpp);
                }

                if (bpp == 1)
                {
                    bitmap = new RdpBitmap(buffer, width, height, bpp, 0, 0);
                }
                else
                {
                    bitmap = new RdpBitmap(RdpBitmap.convertImage(buffer, bpp), width, height, bpp, 0, 0);
                }
            }

            if (bitmap != null)
            {
                Cache.putBitmap(cache_id, cache_idx, bitmap, 0);

                if ((flags & 0x100) != 0)
                {
                    bitmap.PersistCache(persist_key);
                    Cache.m_BitmapCaches++;
                }
            }
        }
Ejemplo n.º 28
0
        private static void process_bmpcache2(RdpPacket data, int flags, bool compressed)
        {
            RdpBitmap bitmap;
            int       num3;
            int       num4;

            byte[] buffer;
            ulong  key  = 0L;
            int    num2 = flags & 7;
            int    bpp  = ((flags & 0x38) >> 3) - 2;

            if ((flags & 0x800) != 0)
            {
                throw new RDFatalException("DO_NOT_CACHE flag not supported!");
            }

            if ((flags & 0x100) != 0)
            {
                byte[] buffer2 = new byte[8];
                data.Read(buffer2, 0, buffer2.Length);
                key = BitConverter.ToUInt64(buffer2, 0);
            }

            if ((flags & 0x80) != 0)
            {
                num3 = data.ReadEncodedUnsigned16();
                num4 = num3;
            }
            else
            {
                num3 = data.ReadEncodedUnsigned16();
                num4 = data.ReadEncodedUnsigned16();
            }

            int size = data.ReadEncoded32();
            int num6 = data.ReadEncodedUnsigned16();

            if (compressed)
            {
                if ((flags & 0x400) == 0)
                {
                    data.Position += 8L;
                    size          -= 8;
                }

                if (bpp == 1)
                {
                    buffer = RdpBitmap.decompress(num3, num4, size, data, bpp);

                    if (buffer == null)
                    {
                        return;
                    }

                    bitmap = new RdpBitmap(buffer, num3, num4, bpp, 0, 0);
                }
                else
                {
                    uint[] numArray = RdpBitmap.decompressInt(num3, num4, size, data, bpp);

                    if (numArray == null)
                    {
                        return;
                    }

                    bitmap = new RdpBitmap(numArray, num3, num4, bpp, 0, 0);
                }
            }
            else
            {
                buffer = new byte[(num3 * num4) * bpp];

                for (int i = 0; i < num4; i++)
                {
                    data.Read(buffer, ((num4 - i) - 1) * (num3 * bpp), num3 * bpp);
                }
                if (bpp == 1)
                {
                    bitmap = new RdpBitmap(buffer, num3, num4, bpp, 0, 0);
                }
                else
                {
                    bitmap = new RdpBitmap(RdpBitmap.convertImage(buffer, bpp), num3, num4, bpp, 0, 0);
                }
            }

            if (bitmap != null)
            {
                Cache.putBitmap(num2, num6, bitmap, 0);

                if ((flags & 0x100) != 0)
                {
                    bitmap.PersistCache(key);
                    Cache.m_BitmapCaches++;
                }
            }
        }
Ejemplo n.º 29
0
        public void channel_process(RdpPacket data)
        {
            byte[] buffer = new byte[2];
            data.Read(buffer, 0, 2);
            var num = (MsgType)BitConverter.ToUInt16(buffer, 0);

            Debug.WriteLine(num);

            // Проверка, загружен ли файл
            if (!IsFileLoaded)
            {
                return;
            }

            switch (num)
            {
            case MsgType.CB_MONITOR_READY:
                serverMonitorReady(data);
                clientClipboardCapabilities();
                //clientTemporaryDirectory();
                clientFormatList();
                break;

            case MsgType.CB_FORMAT_LIST:
                break;

            case MsgType.CB_FORMAT_LIST_RESPONSE:
                serverFormatListResponse(data);
                break;

            case MsgType.CB_FORMAT_DATA_REQUEST:
                serverFormatDataRequest(data);
                clientFormatDataResponse();
                break;

            case MsgType.CB_FORMAT_DATA_RESPONSE:
                break;

            case MsgType.CB_TEMP_DIRECTORY:
                break;

            case MsgType.CB_CLIP_CAPS:
                serverClipboardCapabilities(data);
                break;

            case MsgType.CB_FILECONTENTS_REQUEST:
                serverFileContentsRequest(data);
                clientFileContentsResponse();
                break;

            case MsgType.CB_FILECONTENTS_RESPONSE:
                break;

            case MsgType.CB_LOCK_CLIPDATA:
                break;

            case MsgType.CB_UNLOCK_CLIPDATA:
                break;

            default:
                break;
            }
        }
Ejemplo n.º 30
0
        internal static void processBitmapUpdates(RdpPacket data)
        {
            int num   = 0;
            int x     = 0;
            int y     = 0;
            int num4  = 0;
            int num5  = 0;
            int cx    = 0;
            int cy    = 0;
            int num8  = 0;
            int num9  = 0;
            int num10 = 0;
            int num11 = 0;
            int size  = 0;

            byte[] buffer = null;
            num = data.ReadLittleEndian16();
            for (int i = 0; i < num; i++)
            {
                x    = data.ReadLittleEndian16();
                y    = data.ReadLittleEndian16();
                num4 = data.ReadLittleEndian16();
                num5 = data.ReadLittleEndian16();
                cx   = data.ReadLittleEndian16();
                cy   = data.ReadLittleEndian16();
                int bpp = (data.ReadLittleEndian16() + 7) / 8;
                num10 = data.ReadLittleEndian16();
                num11 = data.ReadLittleEndian16();
                num8  = (num4 - x) + 1;
                num9  = (num5 - y) + 1;
                if (num10 == 0)
                {
                    buffer = new byte[(cx * cy) * bpp];
                    for (int j = 0; j < cy; j++)
                    {
                        data.Read(buffer, ((cy - j) - 1) * (cx * bpp), cx * bpp);
                    }
                    uint[] src = RdpBitmap.convertImage(buffer, bpp);
                    ChangedRect.Invalidate(x, y, cx, cy);
                    Options.Canvas.SetPixels(x, y, num8, num9, src, 0, 0, cx);
                }
                else
                {
                    if ((num10 & 0x400) != 0)
                    {
                        size = num11;
                    }
                    else
                    {
                        data.Position += 2L;
                        size           = data.ReadLittleEndian16();
                        data.Position += 4L;
                    }
                    if (bpp == 1)
                    {
                        buffer = RdpBitmap.decompress(cx, cy, size, data, bpp);
                        ChangedRect.Invalidate(x, y, num8, num9);
                        for (int k = 0; k < num9; k++)
                        {
                            int index = k * cx;
                            int num18 = 0;
                            while (num18 < num8)
                            {
                                int num19 = buffer[index];
                                Options.Canvas.SetPixel(x + num18, y + k, RdpBitmap.convertFrom8bit(num19));
                                num18++;
                                index++;
                            }
                        }
                    }
                    else
                    {
                        uint[] numArray2 = RdpBitmap.decompressInt(cx, cy, size, data, bpp);
                        ChangedRect.Invalidate(x, y, num8, num9);
                        Options.Canvas.SetPixels(x, y, num8, num9, numArray2, 0, 0, cx);
                    }
                }
            }
        }