当前位置: 首页>>代码示例>>C#>>正文


C# StreamHandler.ReadBytes方法代码示例

本文整理汇总了C#中StreamHandler.ReadBytes方法的典型用法代码示例。如果您正苦于以下问题:C# StreamHandler.ReadBytes方法的具体用法?C# StreamHandler.ReadBytes怎么用?C# StreamHandler.ReadBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StreamHandler的用法示例。


在下文中一共展示了StreamHandler.ReadBytes方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Read

 public override void Read(StreamHandler Reader)
 {
     this.Count = Reader.ReadByte();
     this.Seed = Reader.ReadUInt32();
     this.ClientSeed = Reader.ReadBytes(16);
     this.ServerSeed = Reader.ReadBytes(16);
 }
开发者ID:CarlosX,项目名称:Kamilla.Wow,代码行数:7,代码来源:Authentication.cs

示例2: ElementRead

 protected override void ElementRead(StreamHandler reader, int index)
 {
     if (index == -5)
         this.Unk = reader.ReadUInt32();
     else
         this.Data[-index - 1] = reader.ReadBytes(reader.ReadInt32());
 }
开发者ID:CarlosX,项目名称:Kamilla.Wow,代码行数:7,代码来源:SetPhaseShift.cs

示例3: GetNetworkLog

        public static NetworkLog GetNetworkLog(string filename)
        {
            if (!s_initialized)
                Initialize();

            var ext = Path.GetExtension(filename);

            var extFittingDumps = new List<NetworkLogWrapper>();
            foreach (var info in s_logs)
            {
                if (info.FileExtension == ext)
                    extFittingDumps.Add(info);
            }

            if (extFittingDumps.Count == 0)
                extFittingDumps = s_logs;
            else if (extFittingDumps.Count == 1)
                return extFittingDumps[0].Activate(NetworkLogMode.Reading);

            byte[] header;
            using (var sh = new StreamHandler(filename, FileMode.Open))
                header = sh.ReadBytes(Math.Min((int)sh.Length, s_maxHeaderLength));

            foreach (var wrapper in extFittingDumps)
            {
                if (wrapper.Fits(header))
                    return wrapper.Activate(NetworkLogMode.Reading);
            }

            return null;
        }
开发者ID:CarlosX,项目名称:Kamilla,代码行数:31,代码来源:NetworkLogFactory.cs

示例4: Read

        public override void Read(StreamHandler Reader)
        {
            byte[] blob = Reader.ReadBytes(256);
            Token = Reader.ReadUInt32();
            UnknownULong = Reader.ReadUInt64();
            ConnectionIndex = Reader.ReadByte();

            // hardcoded in client
            byte[] modulus1 = {
                    0x91, 0xD5, 0x9B, 0xB7, 0xD4, 0xE1, 0x83, 0xA5, 0x22, 0x2B, 0x5F, 0x38, 0xF4, 0xB8, 0x86, 0xFF, 
                    0x32, 0x84, 0x38, 0x2D, 0x99, 0x38, 0x8F, 0xBA, 0xF3, 0xC9, 0x22, 0x5D, 0x51, 0x73, 0x1E, 0x28, 
                    0x87, 0x24, 0x8F, 0xB5, 0xC9, 0xB0, 0x7C, 0x95, 0xD0, 0x6B, 0x5B, 0xF4, 0x94, 0xC5, 0x94, 0x9D, 
                    0xFA, 0x6F, 0x47, 0x3A, 0xA3, 0x86, 0xC0, 0xA8, 0x37, 0xF3, 0x9B, 0xEF, 0x2F, 0xC1, 0xFB, 0xB3, 
                    0xF4, 0x1C, 0x2B, 0x0E, 0xD3, 0x6D, 0x88, 0xBB, 0x02, 0xE0, 0x4E, 0x63, 0xFA, 0x76, 0xE3, 0x43, 
                    0xF9, 0x01, 0xFD, 0x23, 0x5E, 0x6A, 0x0B, 0x14, 0xEC, 0x5E, 0x91, 0x34, 0x0D, 0x0B, 0x4F, 0xA3, 
                    0x5A, 0x46, 0xC5, 0x5E, 0xDC, 0xB5, 0xCD, 0xC1, 0x47, 0x6B, 0x59, 0xCA, 0xFA, 0xA9, 0xBE, 0x24, 
                    0x9F, 0xF5, 0x05, 0x6B, 0xBB, 0x67, 0x8B, 0xB7, 0xE4, 0x3A, 0x43, 0x00, 0x5C, 0x1C, 0xB7, 0xCA, 
                    0x98, 0x90, 0x79, 0x77, 0x6D, 0x05, 0x4F, 0x83, 0xCC, 0xAC, 0x06, 0x2E, 0x50, 0x11, 0x87, 0x23, 
                    0xD8, 0xA6, 0xF7, 0x6F, 0x7A, 0x59, 0x87, 0xA6, 0xDE, 0x5D, 0xD8, 0xEC, 0x44, 0xBE, 0x45, 0x31, 
                    0x7F, 0x8A, 0xF0, 0x58, 0x89, 0x53, 0x74, 0xDF, 0xCC, 0xAD, 0x01, 0x24, 0xD8, 0x19, 0x65, 0x1C, 
                    0x25, 0xD3, 0xE1, 0x6B, 0x8B, 0xDA, 0xFE, 0x1D, 0xA4, 0x2C, 0x8B, 0x25, 0xED, 0x7C, 0xFF, 0x6A, 
                    0xE0, 0x63, 0xD0, 0x52, 0x20, 0x7E, 0x62, 0x49, 0xD2, 0xB3, 0x6B, 0xCC, 0x91, 0x69, 0xA5, 0x08, 
                    0x8B, 0x69, 0x65, 0xFF, 0xB9, 0xC9, 0x17, 0x02, 0x5D, 0xD8, 0x8E, 0x1A, 0x63, 0xD9, 0x2A, 0x7F, 
                    0xDB, 0xE3, 0xF8, 0x76, 0x6D, 0xEA, 0x0E, 0x36, 0x98, 0x78, 0x19, 0xC5, 0x87, 0xBA, 0x6C, 0x20, 
                    0xB6, 0x08, 0x44, 0x04, 0x4C, 0xA8, 0xD5, 0xB6, 0x9D, 0x4D, 0x00, 0x20, 0x40, 0x00, 0x90, 0x04
                };

            // hardcoded in client
            byte[] exp = { 0x01, 0x00, 0x01, 0x00 };

            BigInteger res_bn = BigInteger.ModPow(new BigInteger(blob), new BigInteger(exp), new BigInteger(modulus1));

            FixedBlob = FixBlob(res_bn.ToByteArray());

            ServerHash = new byte[0];
            Port = BitConverter.ToUInt16(FixedBlob, 21);
            IP = new IPAddress(FixedBlob.Take(4).ToArray());

            //byte[] bytes = new byte[0]
            //    .Concat(BitConverter.GetBytes(Port))
            //    .Concat(BitConverter.GetBytes(ip))
            //    .ToArray();

            //SHA1Managed sha1 = new SHA1Managed();
            ComputedHash = new byte[0]; //sha1.ComputeHash(bytes);
        }
开发者ID:SkyFire,项目名称:Kamilla.Wow,代码行数:46,代码来源:ConnectToPacket.cs

示例5: InternalOpenForReading

        protected unsafe override void InternalOpenForReading(Stream stream, bool closeStream)
        {
            base.InternalOpenForReading(stream, closeStream);

            int optLen;

            var headerBytes = m_stream.ReadBytes(MainHeader.Size);
            fixed (byte* ptr = headerBytes)
            {
                var header = (MainHeader*)ptr;
                GetClientBuildInfo(header->ClientBuild);

                var langBytes = stackalloc byte[5];
                langBytes[0] = header->Lang[0];
                langBytes[1] = header->Lang[1];
                langBytes[2] = (byte)'-';
                langBytes[3] = header->Lang[2];
                langBytes[4] = header->Lang[3];
                var lang = new string((sbyte*)langBytes, 0, 5);
                try
                {
                    this.Culture = CultureInfo.GetCultureInfo(lang);
                }
                catch
                {
                }

                optLen = header->OptionalHeaderLength;
                Marshal.Copy(new IntPtr(header->SessionKey), m_sessionKey, 0, 40);
                this.SnifferId = (PktSnifferId)header->SnifferId;
                this.StartTicks = header->StartedOnTicks;
                this.StartTime = header->StartedOnUnix.AsUnixTime();
            }

            if (this.SnifferId == PktSnifferId.Kamilla)
            {
                using (var reader = new StreamHandler(m_stream.ReadBytes(optLen)))
                {
                    var flags = (OptHeaderFlags)reader.ReadUInt32();

                    if ((flags & OptHeaderFlags.HasOCAD) != 0)
                        reader.Skip(4);

                    if ((flags & OptHeaderFlags.HasSnifferDescString) != 0)
                        this.SnifferDesc = reader.ReadCString();

                    if ((flags & OptHeaderFlags.HasFCAD) != 0)
                        this.FCAD = reader.ReadBytes(16);

                    if ((flags & OptHeaderFlags.HasSCAD) != 0)
                        this.SCAD = reader.ReadBytes(16);
                }
            }
            else
                m_stream.Skip(optLen);

            this.InternalSetCapacity((int)((m_stream.Length - m_stream.Position) / 100));
        }
开发者ID:CarlosX,项目名称:Kamilla,代码行数:58,代码来源:Pkt31NetworkLog.cs

示例6: InternalOpenForReading

        protected unsafe override void InternalOpenForReading(Stream stream, bool closeStream)
        {
            m_isLoaded = true;

            var mainHeaderBytes = new byte[MainHeader.Size];

            stream.Read(mainHeaderBytes, 0, MainHeader.Size);

            MainHeader* mainHeader;
            fixed (byte* mainHeaderBytesPtr = mainHeaderBytes)
            {
                mainHeader = (MainHeader*)mainHeaderBytesPtr;

                m_nPackets = mainHeader->PacketCount;
                this.StartTime = mainHeader->StartedOnUnix.AsUnixTime();
                this.StartTicks = mainHeader->StartedOnTicks;

                this.InternalSetCapacity(m_nPackets);
            }

            int extraLen = mainHeader->ExtraDataLength;
            if (extraLen > 0)
            {
                byte[] extraData = new byte[extraLen];
                stream.Read(extraData, 0, extraLen);
                using (var reader = new StreamHandler(extraData))
                {
                    ExtraDataFlags flags = mainHeader->ExtraInfoFlags;
                    if (flags.HasFlag(ExtraDataFlags.HasClientIPv4))
                        this.ClientAddress = new IPAddress(reader.ReadBytes(4));
                    if (flags.HasFlag(ExtraDataFlags.HasServerIPv4))
                        this.ServerAddress = new IPAddress(reader.ReadBytes(4));
                    if (flags.HasFlag(ExtraDataFlags.HasClientIPv6))
                        this.ClientAddress = new IPAddress(reader.ReadBytes(16));
                    if (flags.HasFlag(ExtraDataFlags.HasServerIPv6))
                        this.ServerAddress = new IPAddress(reader.ReadBytes(16));
                    if (flags.HasFlag(ExtraDataFlags.HasClientPort))
                        this.ClientPort = reader.ReadInt32();
                    if (flags.HasFlag(ExtraDataFlags.HasServerPort))
                        this.ServerPort = reader.ReadInt32();
                    if (flags.HasFlag(ExtraDataFlags.HasSnifferIdString))
                    {
                        int origLen = reader.ReadInt32();
                        int cmprLen = reader.ReadInt32();
                        var arr = new byte[origLen];

                        using (var iStream = new MemoryStream(reader.ReadBytes(cmprLen)))
                        using (var ds = new DeflateStream(iStream, CompressionMode.Decompress, true))
                            ds.Read(arr, 0, arr.Length);

                        this.SnifferDesc = Encoding.UTF8.GetString(arr);
                    }
                }
            }

            m_stream = new StreamHandler(stream, closeStream);
        }
开发者ID:LordJZ,项目名称:Kamilla,代码行数:57,代码来源:Krpd2NetworkLog.cs

示例7: MovementInfo


//.........这里部分代码省略.........
                    .ReadSingle(out this.Position.X);

                if (this.HavePitch)
                    Reader.ReadSingle(out this.Pitch);

                // Fall Data
                if (this.HaveFallData)
                {
                    Reader.ReadUInt32(out this.FallTime);
                    if (this.HaveFallDirection)
                    {
                        Reader
                            .ReadSingle(out this.FallSinAngle)
                            .ReadSingle(out this.FallHorizontalSpeed)
                            .ReadSingle(out this.FallCosAngle);
                    }
                    Reader.ReadSingle(out this.FallVerticalSpeed);
                }

                Reader
                    .ReadXorByte(ref p_guid.Bytes[7])
                    .ReadSingle(out this.Speeds[4])
                    .ReadXorByte(ref p_guid.Bytes[0])
                    .ReadXorByte(ref p_guid.Bytes[5]);

                if (this.TimeStamp != 0)
                    this.TimeStamp = Reader.ReadUInt32();

                Reader
                    .ReadSingle(out this.Position.Z)
                    .ReadSingle(out this.Speeds[6])
                    .ReadXorByte(ref p_guid.Bytes[1])
                    .ReadSingle(out this.Speeds[2])
                    .ReadSingle(out this.Speeds[5])
                    .ReadSingle(out this.Speeds[3])
                    .ReadSingle(out this.Speeds[0])
                    .ReadXorByte(ref p_guid.Bytes[3])
                    .ReadXorByte(ref p_guid.Bytes[4])
                    .ReadXorByte(ref p_guid.Bytes[2])
                    .ReadXorByte(ref p_guid.Bytes[6]);

                if (this.HaveSplineElevation)
                    this.SplineElevation = Reader.ReadSingle();

                this.Position.Y = Reader.ReadSingle();

                if (haveOrientation)
                    this.Orientation = Reader.ReadSingle();

                this.Speeds[1] = Reader.ReadSingle();
            }

            if (field_1C8)
            {
                Console.WriteLine("Error: 16 floats @ 1CC detected !!!");

                Reader.ReadBytes(16 * 4); // 16 floats starting at 1CC
                var field_20C = Reader.ReadByte();
            }

            // transport time
            if (this.HaveTransportTime)
                Reader.ReadUInt32(out this.TransportTime);

            // unk2 ?
            if (field_1AC)
            {
                Console.WriteLine("Error: 3 shorts @ 1AE detected !!!");

                if (field_1B0 != 0)
                    field_1B0 = Reader.ReadUInt16();
                if (field_1B2 != 0)
                    field_1B2 = Reader.ReadUInt16();
                if (field_1AE != 0)
                    field_1AE = Reader.ReadUInt16();
            }

            // go rotation?
            if (this.HaveGameObjectRotation)
                this.GameObjectRotation = Reader.ReadUInt64().UnpackQuaternion();

            // target guid?
            if (this.HaveAttackingTarget)
            {
                fixed (byte* bytes = this.AttackingTarget.Bytes)
                {
                    Reader
                        .ReadXorByte(ref bytes[3])
                        .ReadXorByte(ref bytes[5])
                        .ReadXorByte(ref bytes[0])
                        .ReadXorByte(ref bytes[7])
                        .ReadXorByte(ref bytes[2])
                        .ReadXorByte(ref bytes[4])
                        .ReadXorByte(ref bytes[6])
                        .ReadXorByte(ref bytes[1]);
                }
            }

            this.Guid = guid;
        }
开发者ID:CarlosX,项目名称:Kamilla.Wow,代码行数:101,代码来源:MovementInfo.cs

示例8: PascalStringReader

        private static string PascalStringReader(StreamHandler sh, int length)
        {
            if (length > 0)
            {
                byte[] bytes = sh.ReadBytes(length + 1);

                int len = length + 1;
                if (bytes[bytes.Length - 1] == 0x00)
                    --len;

                return Encoding.UTF8.GetString(bytes, 0, len);
            }
            else
                return string.Empty;
        }
开发者ID:CarlosX,项目名称:Kamilla,代码行数:15,代码来源:StreamHandlerExtensions.cs


注:本文中的StreamHandler.ReadBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。