private ClientInformation(PacketIn packet)
        {
            try
            {
                ProtocolVersion = packet.ReadByte();
                var claimedRemainingLength = packet.ReadUInt16();
                if (packet.RemainingLength != claimedRemainingLength)
                {
                    Log.Warn(WCell_Core.Auth_Logon_with_invalid_length, claimedRemainingLength, packet.RemainingLength);
                }

                var clientInstallationType = packet.ReadFourCC();
                _clientInstallationType = ClientTypeUtility.Lookup(clientInstallationType);

                Version      = new ClientVersion(packet.ReadBytes(5));
                Architecture = packet.ReadFourCC().TrimEnd('\0');
                OS           = packet.ReadFourCC().TrimEnd('\0');

                var locale = packet.ReadFourCC();
                _locale = ClientLocaleUtility.Lookup(locale);

                TimeZone  = BitConverter.ToUInt32(packet.ReadBytes(4), 0);
                IPAddress = new XmlIPAddress(packet.ReadBytes(4));

                Log.Info(WCell_Core.ClientInformationFourCCs, ProtocolVersion, ClientInstallationType, Version, Architecture, OS, Locale, TimeZone, IPAddress);
            }
            catch
            {
            }
        }
 private ClientInformation(PacketIn packet)
 {
     try
     {
         this.ProtocolVersion = packet.ReadByte();
         ushort num = packet.ReadUInt16();
         if (packet.RemainingLength != (int)num)
         {
             ClientInformation.Log.Warn(WCell_Core.Auth_Logon_with_invalid_length, (object)num,
                                        (object)packet.RemainingLength);
         }
         this._clientInstallationType = ClientTypeUtility.Lookup(packet.ReadFourCC());
         this.Version      = new ClientVersion(packet.ReadBytes(5));
         this.Architecture = packet.ReadFourCC().TrimEnd(new char[1]);
         this.OS           = packet.ReadFourCC().TrimEnd(new char[1]);
         this._locale      = ClientLocaleUtility.Lookup(packet.ReadFourCC());
         this.TimeZone     = BitConverter.ToUInt32(packet.ReadBytes(4), 0);
         this.IPAddress    = new XmlIPAddress(packet.ReadBytes(4));
         ClientInformation.Log.Info(WCell_Core.ClientInformationFourCCs, (object)this.ProtocolVersion,
                                    (object)this.ClientInstallationType, (object)this.Version, (object)this.Architecture,
                                    (object)this.OS, (object)this.Locale, (object)this.TimeZone, (object)this.IPAddress);
     }
     catch
     {
     }
 }
Exemple #3
0
        public bool IsReconnectProofValid(PacketIn packet, AuthenticationInfo authInfo)
        {
            //md5 hash of account name and secure random
            byte[] md5Hash = packet.ReadBytes(16);

            //byte[20] sha1 hash of accountname, md5 from above, reconnectProof, byte[40] sessionkey
            byte[] shaHash1 = packet.ReadBytes(20);
            //byte[20] sha1 hash of md5 from above and byte[20] (all zero)
            byte[] shaHash2 = packet.ReadBytes(20);

            byte[] username = WCellConstants.DefaultEncoding.GetBytes(m_srp.Username);

            var sha = new SHA1Managed();

            sha.TransformBlock(username, 0, username.Length, username, 0);
            sha.TransformBlock(md5Hash, 0, md5Hash.Length, md5Hash, 0);
            sha.TransformBlock(ReconnectProof, 0, ReconnectProof.Length, ReconnectProof, 0);
            sha.TransformBlock(authInfo.SessionKey, 0, authInfo.SessionKey.Length, authInfo.SessionKey, 0);
            byte[] hash = sha.TransformFinalBlock(new byte[0], 0, 0);

            for (int i = 0; i < 20; i++)
            {
                if (shaHash1[i] != hash[i])
                {
                    return(false);
                }
            }
            return(true);
        }
 private ClientInformation(PacketIn packet)
 {
     try
     {
         ProtocolVersion = packet.ReadByte();
         ushort num = packet.ReadUInt16();
         if (packet.RemainingLength != num)
         {
             Log.Warn(WCell_Core.Auth_Logon_with_invalid_length, num,
                      packet.RemainingLength);
         }
         _clientInstallationType = ClientTypeUtility.Lookup(packet.ReadFourCC());
         Version      = new ClientVersion(packet.ReadBytes(5));
         Architecture = packet.ReadFourCC().TrimEnd(new char[1]);
         OS           = packet.ReadFourCC().TrimEnd(new char[1]);
         _locale      = ClientLocaleUtility.Lookup(packet.ReadFourCC());
         TimeZone     = BitConverter.ToUInt32(packet.ReadBytes(4), 0);
         IPAddress    = new XmlIPAddress(packet.ReadBytes(4));
         Log.Info(WCell_Core.ClientInformationFourCCs, (object)ProtocolVersion,
                  (object)ClientInstallationType, (object)Version, (object)Architecture,
                  (object)OS, (object)Locale, (object)TimeZone, (object)IPAddress);
     }
     catch
     {
     }
 }
Exemple #5
0
        public void HandleAnyMove(PacketIn packet)
        {
            byte mask = packet.ReadByte();

            WoWGuid guid = new WoWGuid(mask, packet.ReadBytes(WoWGuid.BitCount8(mask)));

            Object obj = objectMgr.getObject(guid);

            if (obj != null)
            {
                packet.ReadBytes(9);
                obj.Position = new Coordinate(packet.ReadFloat(), packet.ReadFloat(), packet.ReadFloat(), packet.ReadFloat());
            }
        }
        private static void BroadcastMovementInfo(PacketIn packet, Character chr, Unit mover, uint clientTime)
        {
            var clients = chr.GetNearbyClients(false);

            if (clients.Count <= 0)
            {
                return;
            }

            using (var outPacket = new RealmPacketOut(packet.PacketId))
            {
                var guidLength = mover.EntityId.WritePacked(outPacket);

                // set position to start of data
                packet.Position = packet.HeaderSize + guidLength;

                outPacket.Write(packet.ReadBytes(packet.RemainingLength));

                foreach (var outClient in clients)
                {
                    // 4 packet header + 4 moveflags + 2 moveflags2 + packed guid length
                    SendMovementPacket(outClient, outPacket, 10 + guidLength, clientTime);
                }
            }
        }
        public void Handle_CreatureQuery(PacketIn packet)
        {
            Entry entry = new Entry();

            entry.entry   = packet.ReadUInt32();
            entry.name    = packet.ReadString();
            entry.blarg   = packet.ReadBytes(3);
            entry.subname = packet.ReadString();
            entry.flags   = packet.ReadUInt32();
            entry.subtype = packet.ReadUInt32();
            entry.family  = packet.ReadUInt32();
            entry.rank    = packet.ReadUInt32();

            foreach (Object obj in objectMgr.getObjectArray())
            {
                if (obj.Fields != null)
                {
                    if (obj.Fields[(int)UpdateFields.OBJECT_FIELD_ENTRY] == entry.entry)
                    {
                        obj.Name = entry.name;
                        objectMgr.updateObject(obj);
                    }
                }
            }
        }
        /// <summary>
        /// Generates a system information objet from the given packet.
        /// </summary>
        /// <param name="inPacket">contains the system information in a raw, serialized format</param>
        public static SystemInformation ReadFromPacket(PacketIn inPacket)
        {
            SystemInformation info = new SystemInformation();

            inPacket.SkipBytes(1);      // 0

            try
            {
                info.Version      = new ClientVersion(inPacket.ReadBytes(5));
                info.Architecture = inPacket.ReadReversedString();
                info.OS           = inPacket.ReadReversedString();
                info.Locale       = inPacket.ReadReversedPascalString(4);
                info.TimeZone     = BitConverter.ToUInt32(inPacket.ReadBytes(4), 0);
                info.IPAddress    = new XmlIPAddress(inPacket.ReadBytes(4));
            }
            catch
            {
            }

            return(info);
        }
Exemple #9
0
        public bool IsReconnectProofValid(PacketIn packet, AuthenticationInfo authInfo)
        {
            byte[] numArray1 = packet.ReadBytes(16);
            byte[] numArray2 = packet.ReadBytes(20);
            packet.ReadBytes(20);
            byte[]      bytes       = WCellConstants.DefaultEncoding.GetBytes(this.m_srp.Username);
            SHA1Managed shA1Managed = new SHA1Managed();

            shA1Managed.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
            shA1Managed.TransformBlock(numArray1, 0, numArray1.Length, numArray1, 0);
            shA1Managed.TransformBlock(this.ReconnectProof, 0, this.ReconnectProof.Length, this.ReconnectProof, 0);
            shA1Managed.TransformBlock(authInfo.SessionKey, 0, authInfo.SessionKey.Length, authInfo.SessionKey, 0);
            byte[] numArray3 = shA1Managed.TransformFinalBlock(new byte[0], 0, 0);
            for (int index = 0; index < 20; ++index)
            {
                if ((int)numArray2[index] != (int)numArray3[index])
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #10
0
        public static byte[] GetBytes(PacketIn updatePacket)
        {
            var bytes = updatePacket.ReadBytes(updatePacket.Length - updatePacket.HeaderSize);

            if (updatePacket.PacketId.RawId == (uint)RealmServerOpCode.SMSG_COMPRESSED_UPDATE_OBJECT)
            {
                bytes = UpdateFieldsUtil.Decompress(bytes);
            }
            else if (updatePacket.PacketId.RawId != (uint)RealmServerOpCode.SMSG_UPDATE_OBJECT)
            {
                throw new Exception("Given Packet " + updatePacket + " is not an Update Packet!");
            }
            return(bytes);
        }
Exemple #11
0
        private static void BroadcastMovementInfo(PacketIn packet, Character chr, Unit mover, uint clientTime)
        {
            ICollection <IRealmClient> nearbyClients = chr.GetNearbyClients <Character>(false);

            if (nearbyClients.Count <= 0)
            {
                return;
            }
            using (RealmPacketOut pak = new RealmPacketOut(packet.PacketId))
            {
                int num = mover.EntityId.WritePacked((BinaryWriter)pak);
                packet.Position = packet.HeaderSize + num;
                pak.Write(packet.ReadBytes(packet.RemainingLength));
                foreach (IRealmClient client in (IEnumerable <IRealmClient>)nearbyClients)
                {
                    MovementHandler.SendMovementPacket(client, pak, 10 + num, clientTime);
                }
            }
        }
        public void HandleUpdateObjectFieldBlock(PacketIn packet, Object newObject)
        {
            uint lenght = packet.ReadByte();

            UpdateMask UpdateMask = new UpdateMask();

            UpdateMask.SetCount((ushort)(lenght));
            UpdateMask.SetMask(packet.ReadBytes((int)lenght * 4), (ushort)lenght);
            UInt32[] Fields = new UInt32[UpdateMask.GetCount()];

            for (int i = 0; i < UpdateMask.GetCount(); i++)
            {
                if (!UpdateMask.GetBit((ushort)i))
                {
                    UInt32 val = packet.ReadUInt32();
                    newObject.SetField(i, val);
                    Log.WriteLine(LogType.Normal, "Update Field: {0} = {1}", (UpdateFields)i, val);
                }
            }
        }
Exemple #13
0
        /// <summary>
        /// Checks if the client's proof matches our proof.
        /// </summary>
        /// <param name="packet">the packet to read from</param>
        /// <returns>true if the client proof matches; false otherwise</returns>
        public bool IsClientProofValid(PacketIn packet)
        {
            m_srp.PublicEphemeralValueA = packet.ReadBigInteger(32);

            BigInteger proof = packet.ReadBigInteger(20);

            // SHA1 of PublicEphemeralValueA and the 16 random bytes sent in
            // AUTH_LOGON_CHALLENGE from the server
            byte[] arr = packet.ReadBytes(20);

            byte keyCount = packet.ReadByte();

            for (int i = 0; i < keyCount; i++)
            {
                ushort keyUnk1     = packet.ReadUInt16();
                uint   keyUnk2     = packet.ReadUInt32();
                byte[] keyUnkArray = packet.ReadBytes(4);
                // sha of the SRP's PublicEphemeralValueA, PublicEphemeralValueB,
                // and 20 unknown bytes
                byte[] keyUnkSha = packet.ReadBytes(20);
            }

            byte securityFlags = packet.ReadByte();

            if ((securityFlags & 1) != 0)
            {
                // PIN
                byte[] pinRandom = packet.ReadBytes(16);
                byte[] pinSha    = packet.ReadBytes(20);
            }
            if ((securityFlags & 2) != 0)
            {
                byte[] security2Buf = packet.ReadBytes(20);
            }
            if ((securityFlags & 4) != 0)
            {
                byte   arrLen       = packet.ReadByte();
                byte[] security4Buf = packet.ReadBytes(arrLen);
            }

            return(m_srp.IsClientProofValid(proof));
        }
Exemple #14
0
        public static DisposableRealmPacketIn ParseCompressedMove(PacketIn packet)
        {
            // special treatment for the compressed move packet
            var uncompressedLength = packet.ReadInt32();

            var segment = BufferManager.GetSegment(uncompressedLength);
            var arr     = segment.Buffer.Array;

            try
            {
                Compression.DecompressZLib(packet.ReadBytes(packet.RemainingLength), arr);

                ushort            length = arr[0];
                RealmServerOpCode opCode = (RealmServerOpCode)(arr[1] | arr[2] << 8);
                return(new DisposableRealmPacketIn(segment, 1, length, length - 3, opCode));
            }
            catch (Exception e)
            {
                LogUtil.ErrorException(e, "Unable to parse packet: " + packet);
            }
            return(null);
        }
        public void HandleCharEnum(PacketIn packet)
        {
            byte count = packet.ReadByte();

            Character[] characterList = new Character[count];
            for (int i = 0; i < count; i++)
            {
                characterList[i].GUID  = packet.ReadUInt64();
                characterList[i].Name  = packet.ReadString();
                characterList[i].Race  = packet.ReadByte();
                characterList[i].Class = packet.ReadByte();
                packet.ReadByte();
                packet.ReadUInt32();
                packet.ReadByte();
                packet.ReadByte();
                packet.ReadUInt32();
                characterList[i].MapID = packet.ReadUInt32();
                packet.ReadFloat();
                packet.ReadFloat();
                packet.ReadFloat();
                packet.ReadUInt32();
                packet.ReadUInt32();
                packet.ReadByte();

                packet.ReadUInt32();
                packet.ReadUInt32();
                packet.ReadUInt32();
                packet.ReadBytes(9 * 20);
            }

            Log.WriteLine(LogType.Success, "Received info about {0} characters", count);

            Charlist = characterList;
            mCore.Event(new Event(EventType.EVENT_CHARLIST, "", new object[] { Charlist }));
            PingLoop();
        }
Exemple #16
0
        /// <summary>Checks if the client's proof matches our proof.</summary>
        /// <param name="packet">the packet to read from</param>
        /// <returns>true if the client proof matches; false otherwise</returns>
        public bool IsClientProofValid(PacketIn packet)
        {
            this.m_srp.PublicEphemeralValueA = packet.ReadBigInteger(32);
            BigInteger client_proof = packet.ReadBigInteger(20);

            packet.ReadBytes(20);
            byte num1 = packet.ReadByte();

            for (int index = 0; index < (int)num1; ++index)
            {
                packet.ReadUInt16();
                packet.ReadUInt32();
                packet.ReadBytes(4);
                packet.ReadBytes(20);
            }

            byte num2 = packet.ReadByte();

            if (((int)num2 & 1) != 0)
            {
                packet.ReadBytes(16);
                packet.ReadBytes(20);
            }

            if (((int)num2 & 2) != 0)
            {
                packet.ReadBytes(20);
            }
            if (((int)num2 & 4) != 0)
            {
                byte num3 = packet.ReadByte();
                packet.ReadBytes((int)num3);
            }

            return(this.m_srp.IsClientProofValid(client_proof));
        }
        /*
         *      [PacketHandlerAtribute(WorldServerOpCode.SMSG_COMPRESSED_UPDATE_OBJECT)]
         *      public void HandleCompressedObjectUpdate(PacketIn packet)
         *      {
         *              try
         *              {
         *                      Int32 size = packet.ReadInt32();
         *                      byte[] decomped = mClient.Shared.Compression.Decompress(size, packet.ReadRemaining());
         *                      packet = new PacketIn(decomped, 1);
         *                      HandleObjectUpdate(packet);
         *              }
         *              catch(Exception ex)
         *              {
         *                      Log.WriteLine(LogType.Error, "{1} \n {0}", ex.StackTrace, ex.Message);
         *              }
         *      }
         *
         *      [PacketHandlerAtribute(WorldServerOpCode.SMSG_UPDATE_OBJECT)]
         *      public void HandleObjectUpdate(PacketIn packet)
         *      {
         *      UInt32 UpdateBlocks = packet.ReadUInt32();
         *
         *      for(int allBlocks = 0; allBlocks < UpdateBlocks; allBlocks++)
         *      {
         *          UpdateType type = (UpdateType)packet.ReadByte();
         *
         *          WoWGuid updateGuid;
         *          uint updateId;
         *          uint fCount;
         *
         *          switch(type)
         *          {
         *              case UpdateType.Values:
         *                  Object getObject;
         *                  updateGuid = new WoWGuid(packet.ReadUInt64());
         *                  if (objectMgr.objectExists(updateGuid))
         *                  {
         *                      getObject = objectMgr.getObject(updateGuid);
         *                  }
         *                  else
         *                  {
         *                      getObject = new Object(updateGuid);
         *                      objectMgr.addObject(getObject);
         *                  }
         *                  Log.WriteLine(LogType.Normal, "Handling Fields Update for object: {0}", getObject.Guid.ToString());
         *                  HandleUpdateObjectFieldBlock(packet, getObject);
         *                  objectMgr.updateObject(getObject);
         *                  break;
         *
         *              case UpdateType.Create:
         *              case UpdateType.CreateSelf:
         *                  updateGuid = new WoWGuid(packet.ReadUInt64());
         *                  updateId = packet.ReadByte();
         *                  fCount = GeUpdateFieldsCount(updateId);
         *
         *                  if (objectMgr.objectExists(updateGuid))
         *                      objectMgr.delObject(updateGuid);
         *
         *                  Object newObject = new Object(updateGuid);
         *                  newObject.Fields = new UInt32[2000];
         *                  objectMgr.addObject(newObject);
         *                  HandleUpdateMovementBlock(packet, newObject);
         *                  HandleUpdateObjectFieldBlock(packet, newObject);
         *                  objectMgr.updateObject(newObject);
         *                  Log.WriteLine(LogType.Normal, "Handling Creation of object: {0}", newObject.Guid.ToString());
         *                  break;
         *
         *              case UpdateType.OutOfRange:
         *                  fCount = packet.ReadByte();
         *                  for (int j = 0; j < fCount; j++)
         *                  {
         *                      WoWGuid guid = new WoWGuid(packet.ReadUInt64());
         *                      Log.WriteLine(LogType.Normal, "Handling delete for object: {0}", guid.ToString());
         *                      if (objectMgr.objectExists(guid))
         *                          objectMgr.delObject(guid);
         *                  }
         *                  break;
         *          }
         *      }
         *
         * }
         */

        public void HandleUpdateMovementBlock(PacketIn packet, Object newObject)
        {
            UInt16 flags = packet.ReadUInt16();


            if ((flags & 0x20) >= 1)
            {
                UInt32 flags2 = packet.ReadUInt32();
                UInt16 unk1   = packet.ReadUInt16();
                UInt32 unk2   = packet.ReadUInt32();
                newObject.Position = new Coordinate(packet.ReadFloat(), packet.ReadFloat(), packet.ReadFloat(), packet.ReadFloat());

                if ((flags2 & 0x200) >= 1)
                {
                    packet.ReadBytes(21); //transporter
                }

                if (((flags2 & 0x2200000) >= 1) || ((unk1 & 0x20) >= 1))
                {
                    packet.ReadBytes(4); // pitch
                }

                packet.ReadBytes(4); //lastfalltime

                if ((flags2 & 0x1000) >= 1)
                {
                    packet.ReadBytes(16); // skip 4 floats
                }

                if ((flags2 & 0x4000000) >= 1)
                {
                    packet.ReadBytes(4); // skip 1 float
                }

                packet.ReadBytes(32);          // all of speeds

                if ((flags2 & 0x8000000) >= 1) //spline ;/
                {
                    UInt32 splineFlags = packet.ReadUInt32();

                    if ((splineFlags & 0x00020000) >= 1)
                    {
                        packet.ReadBytes(4); // skip 1 float
                    }
                    else
                    {
                        if ((splineFlags & 0x00010000) >= 1)
                        {
                            packet.ReadBytes(4); // skip 1 float
                        }
                        else if ((splineFlags & 0x00008000) >= 1)
                        {
                            packet.ReadBytes(12); // skip 3 float
                        }
                    }

                    packet.ReadBytes(28); // skip 8 float

                    UInt32 splineCount = packet.ReadUInt32();

                    for (UInt32 j = 0; j < splineCount; j++)
                    {
                        packet.ReadBytes(12); // skip 3 float
                    }

                    packet.ReadBytes(13);
                }
            }

            else if ((flags & 0x100) >= 1)
            {
                packet.ReadBytes(40);
            }
            else if ((flags & 0x40) >= 1)
            {
                newObject.Position = new Coordinate(packet.ReadFloat(), packet.ReadFloat(), packet.ReadFloat(), packet.ReadFloat());
            }

            if ((flags & 0x8) >= 1)
            {
                packet.ReadBytes(4);
            }

            if ((flags & 0x10) >= 1)
            {
                packet.ReadBytes(4);
            }

            if ((flags & 0x04) >= 1)
            {
                packet.ReadBytes(8);
            }

            if ((flags & 0x2) >= 1)
            {
                packet.ReadBytes(4);
            }

            if ((flags & 0x80) >= 1)
            {
                packet.ReadBytes(8);
            }

            if ((flags & 0x200) >= 1)
            {
                packet.ReadBytes(8);
            }
        }
Exemple #18
0
        public void AuthChallangeRequest(PacketIn packetIn)
        {
            packetIn.ReadByte();
            byte error = packetIn.ReadByte();

            if (error != 0x00)
            {
                Log.WriteLine(LogType.Error, "Authentication error: {0}", (AccountStatus)error);
                Disconnect();
                return;
            }

            B = new BigInteger(packetIn.ReadBytes(32));               // Varies
            byte glen = packetIn.ReadByte();                          // Length = 1

            g = packetIn.ReadBytes(glen);                             // g = 7
            byte Nlen = packetIn.ReadByte();                          // Length = 32

            N       = packetIn.ReadBytes(Nlen);                       // N = B79B3E2A87823CAB8F5EBFBF8EB10108535006298B5BADBD5B53E1895E644B89
            Salt    = new BigInteger(packetIn.ReadBytes(32));         // Salt = 3516482AC96291B3C84B4FC204E65B623EFC2563C8B4E42AA454D93FCD1B56BA
            crcsalt = packetIn.ReadBytes(16);                         // Varies



            BigInteger S;

            srp = new Srp6(new BigInteger(N), new BigInteger(g));

            do
            {
                a = BigInteger.Random(19 * 8);
                A = srp.GetA(a);

                I = Srp6.GetLogonHash(mUsername, mPassword);

                BigInteger x = Srp6.Getx(Salt, I);
                BigInteger u = Srp6.Getu(A, B);
                S = srp.ClientGetS(a, B, x, u);
            }while (S < 0);

            mKey = Srp6.ShaInterleave(S);
            M    = srp.GetM(mUsername, Salt, A, B, new BigInteger(mKey));

            packetIn.ReadByte();

            Sha1Hash sha;

            byte[] files_crc;

            // Generate CRC/hashes of the Game Files
            if (Config.Retail)
            {
                files_crc = GenerateCrc(crcsalt);
            }
            else
            {
                files_crc = new byte[20];
            }

            // get crc_hash from files_crc
            sha = new Sha1Hash();
            sha.Update(A);
            sha.Update(files_crc);
            byte[] crc_hash = sha.Final();

            PacketOut packet = new PacketOut(LogonServerOpCode.AUTH_LOGON_PROOF);

            packet.Write(A);        // 32 bytes
            packet.Write(M);        // 20 bytes
            packet.Write(crc_hash); // 20 bytes
            packet.Write((byte)0);  // number of keys
            packet.Write((byte)0);  // unk (1.11.x)
            Send(packet);
        }
        public void HandleChat(PacketIn packet)
        {
            try
            {
                string  channel = null;
                UInt64  guid = 0;
                WoWGuid fguid = null, fguid2 = null;
                string  username = null;

                byte   Type     = packet.ReadByte();
                UInt32 Language = packet.ReadUInt32();

                guid  = packet.ReadUInt64();
                fguid = new WoWGuid(guid);
                packet.ReadInt32();

                if ((ChatMsg)Type == ChatMsg.Channel)
                {
                    channel = packet.ReadString();
                }

                if (Type == 47)
                {
                    return;
                }
                fguid2 = new WoWGuid(packet.ReadUInt64());

                UInt32 Length  = packet.ReadUInt32();
                string Message = Encoding.Default.GetString(packet.ReadBytes((int)Length));

                //Message = Regex.Replace(Message, @"\|H[a-zA-z0-9:].|h", ""); // Why do i should need spells and quest linked? ;>
                Message = Regex.Replace(Message, @"\|[rc]{1}[a-zA-z0-9]{0,8}", ""); // Colorfull chat message also isn't the most important thing.

                byte afk = 0;

                if (fguid.GetOldGuid() == 0)
                {
                    username = "******";
                }
                else
                {
                    if (objectMgr.objectExists(fguid))
                    {
                        username = objectMgr.getObject(fguid).Name;
                    }
                }

                if (username == null)
                {
                    ChatQueue que = new ChatQueue();
                    que.GUID     = fguid;
                    que.Type     = Type;
                    que.Language = Language;
                    if ((ChatMsg)Type == ChatMsg.Channel)
                    {
                        que.Channel = channel;
                    }
                    que.Length  = Length;
                    que.Message = Message;
                    que.AFK     = afk;
                    ChatQueued.Add(que);
                    QueryName(guid);
                    return;
                }

                object[] param = new object[] { (ChatMsg)Type, channel, username, Message };
                mCore.Event(new Event(EventType.EVENT_CHAT_MSG, "0", param));
                //Log.WriteLine(LogType.Chat, "[{1}] {0}", Message, username);
            }
            catch (Exception ex)
            {
                Log.WriteLine(LogType.Error, "Exception Occured");
                Log.WriteLine(LogType.Error, "Message: {0}", ex.Message);
                Log.WriteLine(LogType.Error, "Stacktrace: {0}", ex.StackTrace);
            }
        }