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


C# PacketReader.ReadBytes方法代码示例

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


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

示例1: HandleAuthLogonProof

        public void HandleAuthLogonProof(PacketReader data)
        {
            Log.Message(LogType.NORMAL, "AuthLogonProof");

            using (var logonProof = new PacketWriter())
            {
                var a = data.ReadBytes(32);
                var m1 = data.ReadBytes(20);

                SecureRemotePassword.CalculateU(a);
                SecureRemotePassword.CalculateM2(m1);
                SecureRemotePassword.CalculateK();

                foreach (var b in SecureRemotePassword.K)
                    if (b < 0x10)
                        account.SessionKey += "0" + String.Format(CultureInfo.InvariantCulture, "{0:X}", b);
                    else
                        account.SessionKey += String.Format(CultureInfo.InvariantCulture, "{0:X}", b);

                logonProof.WriteUInt8((byte)ClientLink.CMD_AUTH_LOGON_PROOF);
                logonProof.WriteUInt8(0);
                logonProof.WriteBytes(SecureRemotePassword.M2);
                logonProof.WriteUInt32(0x800000);
                logonProof.WriteUInt32(0);
                logonProof.WriteUInt16(0);

                SecureRemotePassword.Dispose();

                DB.Realms.Execute("UPDATE accounts SET sessionkey = ? WHERE id = ?", account.SessionKey, account.Id);

                Send(logonProof);
            }
        }
开发者ID:ArkantosWoW,项目名称:ArkantosEmu,代码行数:33,代码来源:RealmClass.cs

示例2: HandleAuthResponse

        public static void HandleAuthResponse(ref PacketReader packet, WorldClass session)
        {
            BitUnpack BitUnpack = new BitUnpack(packet);

            ushort  skipBytes;
            uint[]  UnknownInt = new uint[5];
            ushort  clientBuild;
            byte[]  authChallenge = new byte[20];
            byte[]  UnknownByte = new byte[2];
            ulong   unknownLong;
            int     addonPackedSize;
            int     addonUnpackedSize;

            skipBytes           = packet.Read<ushort>();

            UnknownInt[4]       = packet.Read<uint>();

            authChallenge[14]   = packet.Read<byte>();
            authChallenge[8]    = packet.Read<byte>();

            UnknownInt[0]       = packet.Read<uint>();

            authChallenge[10]   = packet.Read<byte>();
            authChallenge[19]   = packet.Read<byte>();
            authChallenge[16]   = packet.Read<byte>();
            authChallenge[13]   = packet.Read<byte>();
            authChallenge[4]    = packet.Read<byte>();

            UnknownByte[1]      = packet.Read<byte>();

            authChallenge[9]    = packet.Read<byte>();
            authChallenge[0]    = packet.Read<byte>();

            UnknownInt[2]       = packet.Read<uint>();

            authChallenge[5]    = packet.Read<byte>();
            authChallenge[2]    = packet.Read<byte>();

            clientBuild         = packet.Read<ushort>();

            authChallenge[12]   = packet.Read<byte>();

            UnknownInt[3]       = packet.Read<uint>();

            authChallenge[18]   = packet.Read<byte>();
            authChallenge[17]   = packet.Read<byte>();
            authChallenge[11]   = packet.Read<byte>();

            unknownLong         = packet.Read<ulong>();

            authChallenge[7]    = packet.Read<byte>();
            authChallenge[1]    = packet.Read<byte>();
            authChallenge[3]    = packet.Read<byte>();

            UnknownByte[0]      = packet.Read<byte>();

            authChallenge[6]    = packet.Read<byte>();

            UnknownInt[1]       = packet.Read<uint>();

            authChallenge[15]   = packet.Read<byte>();

            addonPackedSize     = packet.Read<int>();
            addonUnpackedSize   = packet.Read<int>();

            byte[] packedAddon  = packet.ReadBytes(addonPackedSize - 4);
            AddonHandler.ReadAddonData(packedAddon, addonUnpackedSize, session);

            uint nameLength = BitUnpack.GetBits<uint>(11);
            bool aBit = BitUnpack.GetBit();

            // BitUnpack.Flush();

            string accountName = packet.ReadString(nameLength);

            SQLResult result = DB.Realms.Select("SELECT * FROM accounts WHERE name = ?", accountName);
            if (result.Count == 0)
                session.clientSocket.Close();
            else
                session.Account = new Account()
                {
                    Id         = result.Read<int>(0, "id"),
                    Name       = result.Read<string>(0, "name"),
                    Password   = result.Read<string>(0, "password"),
                    SessionKey = result.Read<string>(0, "sessionkey"),
                    Expansion  = result.Read<byte>(0, "expansion"),
                    GMLevel    = result.Read<byte>(0, "gmlevel"),
                    IP         = result.Read<string>(0, "ip"),
                    Language   = result.Read<string>(0, "language")
                };

            string K = session.Account.SessionKey;
            byte[] kBytes = new byte[K.Length / 2];

            for (int i = 0; i < K.Length; i += 2)
                kBytes[i / 2] = Convert.ToByte(K.Substring(i, 2), 16);

            session.Crypt.Initialize(kBytes);

            uint realmId = WorldConfig.RealmId;
//.........这里部分代码省略.........
开发者ID:mansemino,项目名称:Arctium,代码行数:101,代码来源:AuthenticationHandler.cs


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