Наследование: System.IO.BinaryWriter
Пример #1
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
     serializer.Write(this.Unknown0);
     serializer.WriteVarint(this.Unknown1);
     serializer.Write(this.Unknown2);
     serializer.WriteVarint(this.Unknown3);
     serializer.Write((byte)Unknown4.Length);
     for (int i = 0; i < Unknown4.Length; i++)
     {
         serializer.Write(Unknown4[i]);
     }
     serializer.Write(this.Unknown5);
     serializer.WriteVarint(this.Unknown6);
     serializer.Write(this.Unknown7.IsPresent ? (byte) 1 : (byte) 0);
     if (this.Unknown7.IsPresent)
     {
         serializer.Write(this.Unknown7.Value);
     }
     serializer.Write(this.Unknown8);
     serializer.Write(this.Unknown9);
     serializer.Write(this.Unknown10);
     serializer.Write(this.Unknown11);
     serializer.Write(this.Unknown12);
     serializer.Write(this.Unknown13);
 }
Пример #2
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
     serializer.Write(this.Unknown0);
     serializer.WriteVarint(this.Unknown1);
     serializer.Write(this.Unknown2);
     serializer.WriteVarint(this.Unknown3);
     serializer.Write((byte)Unknown4.Length);
     for (int i = 0; i < Unknown4.Length; i++)
     {
         serializer.Write(Unknown4[i]);
     }
     serializer.Write(this.Unknown5);
     serializer.WriteVarint(this.Unknown6);
     serializer.Write(this.Unknown7);
     serializer.Write(this.Unknown8);
     serializer.Write(this.Unknown9);
     serializer.Write(this.Unknown10);
     serializer.Write(this.Unknown11);
     for (int i = 0; i < this.Unknown12.Length; i++)
     {
         serializer.Write(this.Unknown12[i]);
     }
     serializer.Write(this.Unknown13);
 }
Пример #3
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
     serializer.WriteVarint(this.Unknown0);
     serializer.WriteVarint(this.Unknown1);
     serializer.WriteVarint(this.Unknown2);
     serializer.WriteUtf16String(this.Unknown3);
     serializer.Write(this.Unknown4);
     serializer.Write(this.Unknown5);
     serializer.Write(this.Unknown6);
     serializer.WriteUtf16String(this.Unknown7);
     for (int i = 0; i < this.Unknown8.Length; i++)
     {
         serializer.WriteVarint(this.Unknown8[i]);
     }
     serializer.Write((byte)Unknown9.Length);
     for (int i = 0; i < Unknown9.Length; i++)
     {
         serializer.WriteVarint(Unknown9[i]);
     }
     serializer.Write((byte)Unknown10.Length);
     for (int i = 0; i < Unknown10.Length; i++)
     {
         serializer.Write(Unknown10[i]);
     }
     serializer.Write((byte)Unknown11.Length);
     for (int i = 0; i < Unknown11.Length; i++)
     {
         serializer.WriteVarint(Unknown11[i]);
     }
 }
Пример #4
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
     serializer.Write(this.Unknown0);
     serializer.WriteVarint(this.Unknown1);
     serializer.Write(this.Unknown2);
     serializer.Write(this.Unknown3);
     serializer.Write(this.Unknown4);
     serializer.Write(this.Unknown5);
     serializer.Write(this.Unknown6);
     serializer.Write(this.Unknown7);
     serializer.Write(this.Unknown8);
     serializer.Write((byte)Unknown9.Length);
     for (int i = 0; i < Unknown9.Length; i++)
     {
         serializer.WriteVarint(Unknown9[i]);
     }
     serializer.WriteUtf16String(this.Unknown10);
     serializer.WriteUtf16String(this.Unknown11);
     serializer.Write(this.Unknown12);
     serializer.Write(this.Unknown13);
     serializer.Write((byte)Unknown25.Length);
     for (int i = 0; i < Unknown25.Length; i++)
     {
         Unknown25[i].Serialize(serializer);
     }
     serializer.Write(this.Unknown26);
     serializer.Write(this.Unknown27);
 }
Пример #5
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
     serializer.Write(this.Unknown0);
     serializer.WriteUtf16String(this.Unknown1);
     serializer.WriteUtf16String(this.Unknown2);
 }
Пример #6
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
     serializer.Write(this.Unknown0);
     serializer.Write(this.Unknown1);
     serializer.WriteVarint(this.Unknown2);
 }
Пример #7
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
     serializer.WriteVarint(this.Unknown0);
     serializer.Write(this.Unknown1);
     serializer.Write(this.Unknown2);
     serializer.WriteVarint(this.Unknown3);
     serializer.WriteVarint(this.Unknown4);
     serializer.WriteVarint(this.Unknown5);
     serializer.WriteVarint(this.Unknown6);
     serializer.WriteVarint(this.Unknown7);
     serializer.WriteVarint(this.Unknown8);
     for (int i = 0; i < this.Unknown9.Length; i++)
     {
         serializer.Write(this.Unknown9[i]);
     }
     serializer.Write((byte)Unknown16.Length);
     for (int i = 0; i < Unknown16.Length; i++)
     {
         Unknown16[i].Serialize(serializer);
     }
     for (int i = 0; i < this.Unknown17.Length; i++)
     {
         serializer.Write(this.Unknown17[i]);
     }
 }
Пример #8
0
 public void Serialize(Serializer serializer)
 {
     serializer.WriteVarint(this.Unknown1);
     serializer.WriteVarint(this.Unknown2);
     serializer.Write(this.Unknown3);
     serializer.Write(this.Unknown4);
     serializer.Write(this.Unknown5);
 }
Пример #9
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
     serializer.WriteVarint(this.Unknown0);
     for (int i = 0; i < this.Unknown1.Length; i++)
     {
         serializer.Write(this.Unknown1[i]);
     }
 }
Пример #10
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
     serializer.Write((byte)Unknown0.Length);
     for (int i = 0; i < Unknown0.Length; i++)
     {
         serializer.Write(Unknown0[i]);
     }
 }
Пример #11
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
     serializer.WriteVarint(this.Unknown0);
     serializer.Write(this.Unknown1);
     serializer.WriteVarint(this.Unknown2);
     serializer.WriteVarint(this.Unknown3);
     serializer.WriteVarint(this.Unknown4);
     serializer.WriteVarint(this.Unknown5);
     serializer.WriteVarint(this.Unknown6);
     serializer.Write((byte)Unknown10.Length);
     for (int i = 0; i < Unknown10.Length; i++)
     {
         Unknown10[i].Serialize(serializer);
     }
     serializer.Write(this.Unknown11.IsPresent ? (byte) 1 : (byte) 0);
     if (this.Unknown11.IsPresent)
     {
         serializer.WriteVarint(this.Unknown11.Value);
     }
     serializer.Write(this.Unknown12.IsPresent ? (byte) 1 : (byte) 0);
     if (this.Unknown12.IsPresent)
     {
         serializer.Write(this.Unknown12.Value);
     }
     serializer.Write(this.Unknown13.IsPresent ? (byte) 1 : (byte) 0);
     if (this.Unknown13.IsPresent)
     {
         serializer.Write(this.Unknown13.Value);
     }
     serializer.Write(this.Unknown14.IsPresent ? (byte) 1 : (byte) 0);
     if (this.Unknown14.IsPresent)
     {
         serializer.WriteVarint(this.Unknown14.Value);
     }
     serializer.Write(this.Unknown15.IsPresent ? (byte) 1 : (byte) 0);
     if (this.Unknown15.IsPresent)
     {
         serializer.Write(this.Unknown15.Value);
     }
     serializer.Write(this.Unknown22.IsPresent ? (byte) 1 : (byte) 0);
     if (this.Unknown22.IsPresent)
     {
         this.Unknown22.Value.Serialize(serializer);
     }
     serializer.Write(this.Unknown23.IsPresent ? (byte) 1 : (byte) 0);
     if (this.Unknown23.IsPresent)
     {
         serializer.WriteVarint(this.Unknown23.Value);
     }
     serializer.Write(this.Unknown24.IsPresent ? (byte) 1 : (byte) 0);
     if (this.Unknown24.IsPresent)
     {
         serializer.WriteVarint(this.Unknown24.Value);
     }
 }
Пример #12
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
     serializer.WriteVarint(this.Unknown0);
     serializer.Write((byte)Unknown5.Length);
     for (int i = 0; i < Unknown5.Length; i++)
     {
         Unknown5[i].Serialize(serializer);
     }
 }
Пример #13
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
     serializer.Write(this.Unknown0);
     serializer.Write(this.Unknown1);
     serializer.Write(this.Unknown2);
     serializer.Write(this.Unknown3);
     serializer.Write(this.Unknown4);
     serializer.Write(this.Unknown5);
 }
Пример #14
0
        public static byte[] ToBytes(uint[] uints)
        {
            Serializer serializer = new Serializer();
            serializer.Write(uints[0]);
            serializer.Write(uints[1]);
            serializer.Write(uints[2]);
            serializer.Write(uints[3]);
            serializer.Write(uints[4]);

            return serializer.GetBytes();
        }
Пример #15
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
     serializer.WriteVarint(this.Unknown0);
     serializer.WriteVarint(this.Unknown1);
     serializer.WriteUtf16String(this.Unknown2);
     serializer.WriteUtf16String(this.Unknown3);
     serializer.WriteUtf16String(this.Unknown4);
     serializer.WriteUtf16String(this.Unknown5);
     serializer.WriteUtf16String(this.Unknown6);
 }
Пример #16
0
        public byte[] Compress(byte[] buffer)
        {
            byte[] compressed = compressor.Compress(buffer);

            Serializer serializer = new Serializer();
            serializer.Write((short)compressed.Length);
            serializer.Write((short)buffer.Length);
            serializer.Write(compressed);

            return serializer.GetBytes();
        }
Пример #17
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
     serializer.Write(this.Unknown0);
     serializer.Write(this.Unknown1);
     serializer.Write(this.Unknown2);
     for (int i = 0; i < this.Unknown3.Length; i++)
     {
         serializer.Write(this.Unknown3[i]);
     }
     serializer.Write(this.Unknown4);
 }
Пример #18
0
        public byte[] Serialize(ISession session, IMessage message)
        {
            // serialize the data into a bytestream
            Serializer serializer = new Serializer();
            message.Serialize(serializer);

            // postprocessing...
            byte[] compressed = this.compressor.Compress(serializer.GetBytes());
            byte[] encrypted = this.encryptor.Encrypt(compressed);

            return encrypted;
        }
Пример #19
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
     serializer.WriteVarint(this.Unknown0);
     serializer.Write(this.Unknown1);
     serializer.Write(this.Unknown2);
     serializer.Write((byte)Unknown3.Length);
     for (int i = 0; i < Unknown3.Length; i++)
     {
         serializer.WriteVarint(Unknown3[i]);
     }
 }
Пример #20
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
     serializer.WriteVarint(this.Unknown0);
     serializer.Write(this.Unknown1);
     serializer.WriteVarint(this.Unknown2);
     serializer.WriteUtf16String(this.Unknown3);
     serializer.Write((ushort)Unknown4.Length);
     for (int i = 0; i < Unknown4.Length; i++)
     {
         serializer.Write(Unknown4[i]);
     }
 }
Пример #21
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
     serializer.Write(this.Unknown0);
     serializer.WriteVarint(this.Unknown1);
     serializer.Write(this.Unknown2);
     serializer.Write(this.Unknown3);
     serializer.Write(this.Unknown4);
     serializer.Write(this.Unknown5);
     serializer.Write(this.Unknown6);
     serializer.Write(this.Unknown7);
     serializer.Write(this.Unknown8);
     serializer.Write(this.Unknown9);
 }
Пример #22
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
     serializer.Write(this.Unknown0);
     serializer.WriteVarint(this.Unknown1);
     serializer.Write(this.Unknown2);
     serializer.WriteVarint(this.Unknown3);
     serializer.Write((byte)Unknown4.Length);
     for (int i = 0; i < Unknown4.Length; i++)
     {
         serializer.Write(Unknown4[i]);
     }
     serializer.Write(this.Unknown5);
     serializer.WriteVarint(this.Unknown6);
     serializer.Write(this.Unknown7);
     serializer.Write(this.Unknown8);
     serializer.Write(this.Unknown9.IsPresent ? (byte) 1 : (byte) 0);
     if (this.Unknown9.IsPresent)
     {
         serializer.Write(this.Unknown9.Value);
     }
     serializer.Write(this.Unknown10);
     serializer.WriteVarint(this.Unknown11);
     serializer.Write(this.Unknown17.IsPresent ? (byte) 1 : (byte) 0);
     if (this.Unknown17.IsPresent)
     {
         this.Unknown17.Value.Serialize(serializer);
     }
     serializer.Write(this.Unknown18.IsPresent ? (byte) 1 : (byte) 0);
     if (this.Unknown18.IsPresent)
     {
         serializer.Write(this.Unknown18.Value);
     }
     serializer.Write(this.Unknown19.IsPresent ? (byte) 1 : (byte) 0);
     if (this.Unknown19.IsPresent)
     {
         serializer.Write(this.Unknown19.Value);
     }
     serializer.Write(this.Unknown23.IsPresent ? (byte) 1 : (byte) 0);
     if (this.Unknown23.IsPresent)
     {
         this.Unknown23.Value.Serialize(serializer);
     }
     serializer.WriteUtf16String(this.Unknown24);
     serializer.Write(this.Unknown25.IsPresent ? (byte) 1 : (byte) 0);
     if (this.Unknown25.IsPresent)
     {
         serializer.Write(this.Unknown25.Value);
     }
 }
Пример #23
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
     serializer.WriteVarint(this.Unknown0);
     serializer.WriteUtf16String(this.Unknown1);
     serializer.Write(this.Unknown2);
     serializer.Write(this.Unknown7.IsPresent ? (byte) 1 : (byte) 0);
     if (this.Unknown7.IsPresent)
     {
         this.Unknown7.Value.Serialize(serializer);
     }
     serializer.Write(this.Unknown13.IsPresent ? (byte) 1 : (byte) 0);
     if (this.Unknown13.IsPresent)
     {
         this.Unknown13.Value.Serialize(serializer);
     }
 }
Пример #24
0
        public IEnumerable<IMessage> Deserialize(ISession session, byte[] data)
        {
            Deserializer deserializer = new Deserializer(data);

            while (deserializer.BaseStream.Position < deserializer.BaseStream.Length)
            {
                byte header = deserializer.ReadByte();
                byte length = deserializer.ReadByte();

                switch (length)
                {
                    case 0x05: // Version
                        deserializer.BaseStream.Position += 2;
                        /*this.clientVersion = */deserializer.ReadUInt32();
                        deserializer.BaseStream.Position += 56; // Probably wrong offset
                        break;

                    case 0x42: // PublicKey
                        byte[] publicKey = deserializer.ReadBytes(64);
                        byte[] sharedKey = DiffieHellman.GenerateSharedKey(publicKey, Keys.PrivateKey, Keys.Prime);
                        byte[] randomBytes = CryptoUtils.GetRandomBytes();
                        byte[] hashedRandomBytes = CryptoUtils.Hash(randomBytes);
                        byte[] xoredRandomBytes = CryptoUtils.XOR(randomBytes, sharedKey);
                        this.key = hashedRandomBytes;

                        Serializer serializer = new Serializer();
                        serializer.Write((byte)0x01); // RC4Seed Header
                        serializer.Write((byte)0x16); // RC4Seed Length
                        serializer.Write(xoredRandomBytes); // xored RC4Key

                        session.Send(serializer.GetBytes());

                        session.State = prepareNewState();

                        break;

                    default:
                        Console.WriteLine("Unhandled packet, header: {0}, length: {1}", header, length);
                        break;
                }
            }

            // mock up, since we return the byte-encoded messages directly
            return new IMessage[] {};
        }
Пример #25
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
     serializer.WriteVarint(this.Unknown0);
     for (int i = 0; i < this.Unknown1.Length; i++)
     {
         serializer.Write(this.Unknown1[i]);
     }
     serializer.Write(this.Unknown2);
     serializer.Write(this.Unknown3);
     serializer.Write(this.Unknown4);
     serializer.WriteVarint(this.Unknown5);
     serializer.WriteVarint(this.Unknown6);
     for (int i = 0; i < this.Unknown11.Length; i++)
     {
         this.Unknown11[i].Serialize(serializer);
     }
     serializer.Write(this.Unknown12);
     serializer.Write(this.Unknown13);
     serializer.Write(this.Unknown14);
 }
Пример #26
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(this.Unknown11);
     serializer.Write(this.Unknown12);
     serializer.WriteVarint(this.Unknown13);
     serializer.WriteVarint(this.Unknown14);
     serializer.WriteVarint(this.Unknown15);
 }
Пример #27
0
 public void Serialize(Serializer serializer)
 {
 }
Пример #28
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(Header);
 }
Пример #29
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(this.Unknown13);
     serializer.Write(this.Unknown14);
     serializer.Write(this.Unknown15);
     serializer.Write(this.Unknown16);
 }
Пример #30
0
 public void Serialize(Serializer serializer)
 {
     serializer.Write(this.Unknown21);
     serializer.Write(this.Unknown22);
 }