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


C# Packet.SetPosition方法代码示例

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


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

示例1: HandleServerWardenData

        public static void HandleServerWardenData(Packet packet)
        {
            var opcode = packet.ReadEnum<WardenServerOpcode>("Warden Server Opcode", TypeCode.Byte);

            packet.SetPosition(0);

            switch (opcode)
            {
                case WardenServerOpcode.ModuleInfo:
                {
                    packet.ReadByte();
                    packet.ReadBytes("Module MD5", 16);
                    packet.ReadBytes("Module RC4", 16);
                    packet.ReadUInt32("Module Length");
                    break;
                }
                case WardenServerOpcode.ModuleChunk:
                {
                    packet.ReadByte();

                    var length = packet.ReadUInt16("Chunk Length");
                    packet.ReadBytes("Module Chunk", length);
                    break;
                }
                case WardenServerOpcode.CheatChecks:
                {
                    packet.ReadByte();

                    byte length;
                    while ((length = packet.ReadByte()) != 0)
                    {
                        packet.ReadBytes("String", length);
                    }

                    // var rest = (int)(packet.GetLength() - packet.GetPosition());
                    break;
                }
                case WardenServerOpcode.Data:
                {
                    while (packet.CanRead())
                    {
                        packet.ReadByte();

                        var length = packet.ReadUInt16("Data Length");
                        packet.ReadInt32("Data Checksum");
                        packet.ReadBytes("Data", length);
                    }
                    break;
                }
                case WardenServerOpcode.Seed:
                {
                    packet.ReadByte();
                    packet.ReadBytes("Seed", 16);
                    break;
                }
            }
        }
开发者ID:samaelsacred,项目名称:WowPacketParser,代码行数:57,代码来源:WardenHandler.cs

示例2: HandleServerWardenData

        public static void HandleServerWardenData(Packet packet)
        {
            var opcode = packet.ReadEnum<WardenServerOpcode>("Warden Server Opcode", TypeCode.Byte);

            packet.SetPosition(0);

            switch (opcode)
            {
                case WardenServerOpcode.ModuleInfo:
                {
                    packet.ReadByte();

                    var md5 = packet.ReadBytes(16);
                    packet.WriteLine("Module MD5: " + Utilities.ByteArrayToHexString(md5));

                    var rc4 = packet.ReadBytes(16);
                    packet.WriteLine("Module RC4: " + Utilities.ByteArrayToHexString(rc4));

                    packet.ReadUInt32("Module Length");
                    break;
                }
                case WardenServerOpcode.ModuleChunk:
                {
                    packet.ReadByte();

                    var length = packet.ReadUInt16("Chunk Length");

                    var chunk = packet.ReadBytes(length);
                    packet.WriteLine("Module Chunk: " + Utilities.ByteArrayToHexString(chunk));
                    break;
                }
                case WardenServerOpcode.CheatChecks:
                {
                    packet.ReadByte();

                    byte length;
                    while ((length = packet.ReadByte()) != 0)
                    {
                        var strBytes = packet.ReadBytes(length);
                        var str = Encoding.ASCII.GetString(strBytes);
                        packet.WriteLine("String: " + str);
                    }

                    // var rest = (int)(packet.GetLength() - packet.GetPosition());
                    break;
                }
                case WardenServerOpcode.Data:
                {
                    while (packet.CanRead())
                    {
                        packet.ReadByte();

                        var length = packet.ReadUInt16("Data Length");

                        packet.ReadInt32("Data Checksum");

                        var data = packet.ReadBytes(length);
                        packet.WriteLine("Data: " + Utilities.ByteArrayToHexString(data));
                    }
                    break;
                }
                case WardenServerOpcode.Seed:
                {
                    packet.ReadByte();

                    var seed = packet.ReadBytes(16);
                    packet.WriteLine("Seed: " + Utilities.ByteArrayToHexString(seed));
                    break;
                }
            }
        }
开发者ID:Nihilianth,项目名称:WowPacketParser,代码行数:71,代码来源:WardenHandler.cs


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