public void SendPacket(IPacket packet) { try { packet.Encode(); MemoryStream packetBlock = new MemoryStream(); Int32 packetLen = sizeof(Int32) + (Int32)packet.GetStream().Length; Byte[] packetHeader = BitConverter.GetBytes(packetLen); PacketObfuscation.EncodeHeader(ref packetHeader, (int)packetHeader.Length); packetBlock.Write(packetHeader, 0, (Int32)packetHeader.Length); Byte[] packetData = packet.GetStream().ToArray(); PacketObfuscation.EncodeData(ref packetData, (int)packetData.Length); packetBlock.Write(packetData, 0, (Int32)packetData.Length); Byte[] packetBytes = packetBlock.ToArray(); _Stream.Write(packetBytes, 0, (int)packetBlock.Length); _Stream.Flush(); } catch (Exception e) { if (IsConnected()) { MessageBox.Show("잘못된 처리: " + e.ToString(), "error", MessageBoxButtons.OK); Application.Exit(); } } }
private void HandleAuthSession(IPacket packet) { Stream dataStream = packet.GetStream(); BinaryReader r = packet.CreateReader(); uint version = r.ReadUInt32(); uint unk2 = r.ReadUInt32(); string accountName = r.ReadCString(); uint unk = r.ReadUInt32(); uint clientSeed = r.ReadUInt32(); ulong unk3 = r.ReadUInt64(); uint unk4 = r.ReadUInt32(); ulong unk5 = r.ReadUInt64(); byte[] clientDigest = r.ReadBytes(20); session.Account = IoC.Resolve <IAccountRepository>().FindByName(accountName); cryptor.SetSymmetricAlgorithm(new WowCryptRC4(session.Account.SessionKey)); if (!ByteArrayExtensions.Equals(clientDigest, ComputeServerDigest(clientSeed))) { throw new Exception(); } session.Send(GetAuthResponcePkt()); uint addonInfoBlockSize = r.ReadUInt32(); dataStream = new InflaterInputStream(dataStream); //дальше данные запакованы r = new BinaryReader(dataStream); try { while (true) { var addonInfo = new AddonInfo { Name = r.ReadCString(), Crc = r.ReadUInt64(), Status = r.ReadByte(), }; AddonManager.Instance[addonInfo.Name] = addonInfo; } } catch (Exception e) { } //_client.Send(GetAddonInfoPkt()); session.Send(GetTutorialFlagsPkt()); session.SendAccountDataTimes(0x15); }