Esempio n. 1
0
 public StreamHandler DecompressBlock(WowOpcodes opcode)
 {
     if (this.Opcode == opcode)
         return this.DecompressBlock();
     else
         return this.Reader;
 }
Esempio n. 2
0
        public void Prepare(WowOpcodes opcode)
        {
            ui_tbError.Text = string.Empty;

            if (opcode != WowOpcodes.UNKNOWN_OPCODE)
            {
                ui_cbInput.Text = opcode.ToString();
                Analyze(opcode);
            }
            else
            {
                ui_tbResult.Text =
                    "Enter an opcode name (case-insensitive), an opcode id, a " +
                    "jam opcode id (prefixed with '-j'), or an auth opcode " +
                    "id (prefixed with '-a'), in decimal or hexadecimal representation, " +
                    "then press Submit to view summary on the opcode." +
                    Environment.NewLine +
                    "Special and auth opcodes are decondensed automatically." +
                    Environment.NewLine + Environment.NewLine +
                    "Example:" +
                    Environment.NewLine +
                    "'-j 1' or '-j 0x1' will produce summary for jam opcode that condences into 1." +
                    Environment.NewLine +
                    "'0x76CD' will procude summary for opcode #30413." +
                    Environment.NewLine +
                    "'CMSG_PING' will produce summary for client's ping opcode." +
                    Environment.NewLine + Environment.NewLine +
                    "Press Reset when you need to read this text again.";
            }
        }
        public void Prepare(WowOpcodes opcode)
        {
            ui_tbError.Text = string.Empty;

            if (opcode != WowOpcodes.UNKNOWN_OPCODE)
            {
                ui_cbInput.Text = opcode.ToString();
                Analyze(opcode);
            }
            else
            {
                ui_tbResult.Text =
                    "Enter an opcode name (case-insensitive), an opcode id, a " +
                    "jam opcode id (prefixed with '-j'), or an auth opcode " +
                    "id (prefixed with '-a'), in decimal or hexadecimal representation, " +
                    "then press Submit to view summary on the opcode." +
                    Environment.NewLine +
                    "Special and auth opcodes are decondensed automatically." +
                    Environment.NewLine + Environment.NewLine +
                    "Example:" +
                    Environment.NewLine +
                    "'-j 1' or '-j 0x1' will produce summary for jam opcode that condences into 1." +
                    Environment.NewLine +
                    "'0x76CD' will procude summary for opcode #30413." +
                    Environment.NewLine +
                    "'CMSG_PING' will produce summary for client's ping opcode." +
                    Environment.NewLine + Environment.NewLine +
                    "Press Reset when you need to read this text again.";
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of ChatMessage, reading all the needed data from a byte array.
        /// </summary>
        /// <param name="data">
        /// The byte array that contains all needed data for the ChatMessage.
        /// </param>
        /// <param name="opcode">
        /// The opcode of a packet that contains the current message.
        ///
        /// Specify 0 opcode if you want basic parsing implementation.
        /// </param>
        public ServerChatMessage(byte[] data, WowOpcodes opcode)
        {
            StreamHandler Reader = new StreamHandler(data);

            ReadFromStreamHandler(Reader, opcode);

            Reader.Close();
        }
Esempio n. 5
0
        /// <remarks>
        /// Updated for client build 15354.
        /// </remarks>
        public static WowOpcodes MakeUncompressed(this WowOpcodes opcode)
        {
            if (!opcode.IsCompressedOpcode())
            {
                throw new InvalidOperationException();
            }

            return((WowOpcodes)((uint)opcode & 0x7FFF));
        }
Esempio n. 6
0
 public StreamHandler DecompressBlock(WowOpcodes opcode)
 {
     if (this.Opcode == opcode)
     {
         return(this.DecompressBlock());
     }
     else
     {
         return(this.Reader);
     }
 }
Esempio n. 7
0
        public static Type GetTypeByOpcode(WowOpcodes opcode)
        {
            Type type;

            if (!s_opcode2type.TryGetValue(opcode, out type))
            {
                throw new ArgumentException();
            }

            return(type);
        }
Esempio n. 8
0
 /// <remarks>
 /// Updated for client build 15354.
 /// </remarks>
 public static uint GetHandlerByOpcode(uint transformedHandler, WowOpcodes opcode)
 {
     uint o = (uint)opcode;
     return transformedHandler - ((o | (o << 16)) ^ 0x62A3A31D);
 }
 public WowPacketParserAttribute(WowOpcodes opcode)
     : base(s_protocol, (uint)opcode)
 {
 }
Esempio n. 10
0
        public static Type GetTypeByOpcode(WowOpcodes opcode)
        {
            Type type;
            if (!s_opcode2type.TryGetValue(opcode, out type))
                throw new ArgumentException();

            return type;
        }
Esempio n. 11
0
 /// <summary>
 /// Indicates whether the current opcode is JAM opcode or not.
 /// </summary>
 /// <param name="opcode">The current opcode.</param>
 /// <returns>true if the current opcode is JAM opcode; othewise, false.</returns>
 /// <remarks>
 /// Updated for client build 15354.
 /// </remarks>
 public static bool IsJamOpcode(this WowOpcodes opcode)
 {
     return(((uint)opcode & 0xA235) == 8196);
 }
Esempio n. 12
0
        internal void Analyze(WowOpcodes opcode)
        {
            ui_tbError.Text = string.Empty;

            var builder = new StringBuilder();

            builder.AppendLine("Name: " + opcode);
            builder.AppendFormatLine("Values: {0} 0x{0:X4}", (uint)opcode);
            builder.AppendLine(Enum.IsDefined(typeof(WowOpcodes), (uint)opcode) ? "Found in enum." : "Not found in enum.");
            builder.AppendLine();

            if (opcode.IsJamOpcode())
            {
                builder.AppendFormatLine("JAM opcode: {0} 0x{0:X2}", opcode.CondenseJamOpcode());
            }
            if (opcode.IsAuthOpcode())
            {
                builder.AppendFormatLine("Auth opcode: {0} 0x{0:X2}", opcode.CondenseAuthOpcode());
            }
            else if (opcode.IsRegularOpcode())
            {
                var cond = opcode.CondenseOpcode();

                builder.AppendFormatLine("Condensed opcode: {0} 0x{0:X3}", cond);

                //if (CondensedOpcodes.Storage.ContainsKey(cond))
                //    builder.AppendLine("Cond Name: " + CondensedOpcodes.Storage[cond]);
                //else
                //    builder.AppendLine("Cond Name not found.");
            }

            var info = OpcodeInfoPlugin.OpcodeInfos.FirstOrDefault(x => x.Opcode == (uint)opcode);

            if (info != null)
            {
                builder.AppendLine();
                builder.AppendLine("Opcode Info Found:");

                if (info.Index != 0)
                {
                    builder.AppendLine(" Index: " + info.Index);
                }
                if (info.Constructor != 0)
                {
                    builder.AppendLine(" Constructor: 0x" + info.Constructor.ToString("X6"));
                }
                if (info.Handler != 0)
                {
                    builder.AppendLine(" Handler: 0x" + info.Handler.ToString("X6"));
                }
                if (info.Destructor != 0)
                {
                    builder.AppendLine(" Destructor: 0x" + info.Destructor.ToString("X6"));
                }

                if (!string.IsNullOrEmpty(info.Comment))
                {
                    builder.AppendLine(" Comment: " + info.Comment);
                }

                if (info.Senders != null && info.Senders.Length > 0)
                {
                    builder.AppendLine(" Senders:");
                    foreach (var sender in info.Senders)
                    {
                        if (string.IsNullOrEmpty(sender.Name))
                        {
                            builder.AppendFormatLine("  Function at 0x{0:X6} (code at 0x{1:X6})",
                                                     sender.Function, sender.Address);
                        }
                        else
                        {
                            builder.AppendFormatLine("  '{2}' at 0x{0:X6} (code at 0x{1:X6})",
                                                     sender.Function, sender.Address, sender.Name);
                        }
                    }
                }
            }

            builder.AppendLine();

            //string desc = opcode.GetDescription();
            //if (desc != string.Empty)
            //{
            //    builder.AppendLine();
            //    builder.Append(desc);
            //}

            if (opcode.IsCompressedOpcode())
            {
                builder.AppendLine("Compressed Packet, uncompressed version:");
                Analyze(opcode.MakeUncompressed());
                builder.AppendLine(ui_tbResult.Text.PadMultiline(2));
            }

            ui_tbResult.Text = builder.ToString();
        }
Esempio n. 13
0
        /// <summary>
        /// Condenses the provided uncondensed JAM opcode.
        /// </summary>
        /// <param name="opcode">The uncondensed JAM opcode.</param>
        /// <returns>The JAM opcode index. Value ranges in [0, 128].</returns>
        /// <remarks>
        /// Updated for client build 15354.
        /// </remarks>
        public static uint CondenseJamOpcode(this WowOpcodes opcode)
        {
            var i = (uint)opcode;

            return((i & 2 | ((i & 8 | ((i & 0x1C0 | ((i & 0x1C00 | (i >> 1) & 0x2000) >> 1)) >> 2)) >> 1)) >> 1);
        }
Esempio n. 14
0
        /// <remarks>
        /// Updated for client build 15354.
        /// </remarks>
        public static uint GetHandlerByOpcode(uint transformedHandler, WowOpcodes opcode)
        {
            uint o = (uint)opcode;

            return(transformedHandler - ((o | (o << 16)) ^ 0x62A3A31D));
        }
Esempio n. 15
0
        /// <remarks>
        /// Updated for client build 15354.
        /// </remarks>
        public static uint CondenseAuthOpcode(this WowOpcodes opcode)
        {
            uint i = (uint)opcode;

            return((i & 0x10 | (((i & 0xC0) | (i >> 3) & 0x100) >> 1)) >> 4);
        }
Esempio n. 16
0
 /// <summary>
 /// Initializes a new instance of ChatMessage, reading all the needed data using a StreamHandler.
 /// </summary>
 /// <param name="Reader">
 /// The StreamHandler used to read all data for the ChatMessage.
 /// </param>
 /// <param name="opcode">
 /// The opcode of a packet that contains the current message.
 /// 
 /// Specify 0 opcode if you want basic parsing implementation.
 /// </param>
 public ServerChatMessage(StreamHandler Reader, WowOpcodes opcode)
 {
     ReadFromStreamHandler(Reader, opcode);
 }
Esempio n. 17
0
 // ctor
 public CustomPacket(WowOpcodes opcode, TransferDirection transferDirection)
 {
     this.Opcode = opcode;
     this.Data = new List<byte>();
     this.Direction = transferDirection;
 }
Esempio n. 18
0
 /// <summary>
 /// Initializes a new instance of ChatMessage, reading all the needed data using a StreamHandler.
 /// </summary>
 /// <param name="Reader">
 /// The StreamHandler used to read all data for the ChatMessage.
 /// </param>
 /// <param name="opcode">
 /// The opcode of a packet that contains the current message.
 ///
 /// Specify 0 opcode if you want basic parsing implementation.
 /// </param>
 public ServerChatMessage(StreamHandler Reader, WowOpcodes opcode)
 {
     ReadFromStreamHandler(Reader, opcode);
 }
Esempio n. 19
0
 /// <remarks>
 /// Updated for client build 15354.
 /// </remarks>
 public static bool IsAuthOpcode(this WowOpcodes opcode)
 {
     return(((uint)opcode & 0xF72F) == 5);
 }
Esempio n. 20
0
 /// <summary>
 /// Creates a new instance of <see cref="Kamilla.Network.Protocols.Wow.CustomPacket"/> using the specified opcode and direction,
 /// and saves the current packet data to it.
 /// </summary>
 /// <param name="opcode">The opcode to use to create a new instance of CustomPacket class.</param>
 /// <param name="direction">The packet direction to use to create a new instance of CustomPacket class.</param>
 /// <returns>A new instance of CustomPacket with the specified opcode, direction, and data saved to it.</returns>
 protected CustomPacket CreatePacket(WowOpcodes opcode, TransferDirection direction)
 {
     return new CustomPacket(opcode, direction).WriteBytes(Save());
 }
Esempio n. 21
0
        /// <summary>
        /// Condenses the provided uncondensed opcode.
        /// </summary>
        /// <param name="opcode">The uncondensed opcode.</param>
        /// <returns>The reqular opcode index. Value ranges in [0, 2048].</returns>
        /// <remarks>
        /// Updated for client build 15354.
        /// </remarks>
        public static uint CondenseOpcode(this WowOpcodes opcode)
        {
            var i = (uint)opcode;

            return(i & 1 | ((i & 8 | ((i & 0x1FC0 | (i >> 1) & 0x2000) >> 2)) >> 2));
        }
Esempio n. 22
0
        internal void Analyze(WowOpcodes opcode)
        {
            ui_tbError.Text = string.Empty;

            var builder = new StringBuilder();

            builder.AppendLine("Name: " + opcode);
            builder.AppendFormatLine("Values: {0} 0x{0:X4}", (uint)opcode);
            builder.AppendLine(Enum.IsDefined(typeof(WowOpcodes), (uint)opcode) ? "Found in enum." : "Not found in enum.");
            builder.AppendLine();

            if (opcode.IsJamOpcode())
                builder.AppendFormatLine("JAM opcode: {0} 0x{0:X2}", opcode.CondenseJamOpcode());
            if (opcode.IsAuthOpcode())
                builder.AppendFormatLine("Auth opcode: {0} 0x{0:X2}", opcode.CondenseAuthOpcode());
            else if (opcode.IsRegularOpcode())
            {
                var cond = opcode.CondenseOpcode();

                builder.AppendFormatLine("Condensed opcode: {0} 0x{0:X3}", cond);

                //if (CondensedOpcodes.Storage.ContainsKey(cond))
                //    builder.AppendLine("Cond Name: " + CondensedOpcodes.Storage[cond]);
                //else
                //    builder.AppendLine("Cond Name not found.");
            }

            var info = OpcodeInfoPlugin.OpcodeInfos.FirstOrDefault(x => x.Opcode == (uint)opcode);
            if (info != null)
            {
                builder.AppendLine();
                builder.AppendLine("Opcode Info Found:");

                if (info.Index != 0)
                    builder.AppendLine(" Index: " + info.Index);
                if (info.Constructor != 0)
                    builder.AppendLine(" Constructor: 0x" + info.Constructor.ToString("X6"));
                if (info.Handler != 0)
                    builder.AppendLine(" Handler: 0x" + info.Handler.ToString("X6"));
                if (info.Destructor != 0)
                    builder.AppendLine(" Destructor: 0x" + info.Destructor.ToString("X6"));

                if (!string.IsNullOrEmpty(info.Comment))
                    builder.AppendLine(" Comment: " + info.Comment);

                if (info.Senders != null && info.Senders.Length > 0)
                {
                    builder.AppendLine(" Senders:");
                    foreach (var sender in info.Senders)
                    {
                        if (string.IsNullOrEmpty(sender.Name))
                            builder.AppendFormatLine("  Function at 0x{0:X6} (code at 0x{1:X6})",
                                sender.Function, sender.Address);
                        else
                            builder.AppendFormatLine("  '{2}' at 0x{0:X6} (code at 0x{1:X6})",
                                sender.Function, sender.Address, sender.Name);
                    }
                }
            }

            builder.AppendLine();

            //string desc = opcode.GetDescription();
            //if (desc != string.Empty)
            //{
            //    builder.AppendLine();
            //    builder.Append(desc);
            //}

            if (opcode.IsCompressedOpcode())
            {
                builder.AppendLine("Compressed Packet, uncompressed version:");
                Analyze(opcode.MakeUncompressed());
                builder.AppendLine(ui_tbResult.Text.PadMultiline(2));
            }

            ui_tbResult.Text = builder.ToString();
        }
Esempio n. 23
0
        private void ReadFromStreamHandler(StreamHandler Reader, WowOpcodes opcode)
        {
            GameMasterMessage = (opcode == WowOpcodes.SMSG_GM_MESSAGECHAT);

            m_type = (ChatMessageType)Reader.ReadByte();
            if (m_type == ChatMessageType.Addon2)
            {
                m_type = ChatMessageType.Addon;
            }

            m_language      = (Language)Reader.ReadUInt32();
            m_senderGUID    = Reader.ReadGuid();
            m_unknownUInt32 = Reader.ReadUInt32();

            switch (m_type)
            {
            case ChatMessageType.MonsterSay:
            case ChatMessageType.MonsterParty:
            case ChatMessageType.MonsterYell:
            case ChatMessageType.MonsterWhisper:
            case ChatMessageType.MonsterEmote:
            case ChatMessageType.BattleNet:
            case ChatMessageType.RaidBossEmote:
            case ChatMessageType.RaidBossWhisper:
                Reader.Skip(4);
                m_senderName = Reader.ReadCString();
                m_targetGUID = Reader.ReadGuid();
                if (!m_targetGUID.IsEmpty &&
                    !m_targetGUID.IsPlayer &&
                    !m_targetGUID.IsPet)
                {
                    Reader.Skip(4);
                    m_targetName = Reader.ReadCString();
                }
                if (m_language == Language.Addon)
                {
                    m_addonPrefix = Reader.ReadCString();
                }
                Reader.Skip(4);
                m_text  = Reader.ReadCString();
                m_flags = (ChatMessageFlags)Reader.ReadByte();
                if (m_type == ChatMessageType.RaidBossEmote || m_type == ChatMessageType.RaidBossWhisper)
                {
                    m_displayTime  = Reader.ReadSingle();
                    m_suspendEvent = Reader.ReadBoolean();
                }
                break;

            case ChatMessageType.BGSystemNeutral:
            case ChatMessageType.BGSystemAlliance:
            case ChatMessageType.BGSystemHorde:
                m_targetGUID = Reader.ReadGuid();
                if (!m_targetGUID.IsEmpty &&
                    !m_targetGUID.IsPlayer)
                {
                    Reader.Skip(4);
                    m_targetName = Reader.ReadCString();
                }
                if (m_language == Language.Addon)
                {
                    m_addonPrefix = Reader.ReadCString();
                }
                Reader.Skip(4);
                m_text  = Reader.ReadCString();
                m_flags = (ChatMessageFlags)Reader.ReadByte();
                break;

            case ChatMessageType.Achievement:
            case ChatMessageType.GuildAchievement:
                m_targetGUID = Reader.ReadGuid();
                if (m_language == Language.Addon)
                {
                    m_addonPrefix = Reader.ReadCString();
                }
                Reader.Skip(4);
                m_text          = Reader.ReadCString();
                m_flags         = (ChatMessageFlags)Reader.ReadByte();
                m_achievementId = Reader.ReadUInt32();
                break;

            case ChatMessageType.WhisperForeign:
                Reader.Skip(4);
                m_senderName = Reader.ReadCString();
                m_targetGUID = Reader.ReadGuid();
                if (m_language == Language.Addon)
                {
                    m_addonPrefix = Reader.ReadCString();
                }
                Reader.Skip(4);
                m_text  = Reader.ReadCString();
                m_flags = (ChatMessageFlags)Reader.ReadByte();
                break;

            default:
                if (GameMasterMessage)
                {
                    Reader.Skip(4);
                    m_senderName = Reader.ReadCString();
                }
                if (m_type == ChatMessageType.Channel)
                {
                    m_channel = Reader.ReadCString();
                }
                m_targetGUID = Reader.ReadGuid();
                if (m_language == Language.Addon)
                {
                    m_addonPrefix = Reader.ReadCString();
                }
                Reader.Skip(4);
                m_text  = Reader.ReadCString();
                m_flags = (ChatMessageFlags)Reader.ReadByte();
                break;
            }
        }
Esempio n. 24
0
 /// <remarks>
 /// Updated for client build 15354.
 /// </remarks>
 public static bool IsCompressedOpcode(this WowOpcodes opcode)
 {
     return(((uint)opcode & 0xFFFF8000) == 0x8000);
 }
Esempio n. 25
0
        /// <summary>
        /// Initializes a new instance of ChatMessage, reading all the needed data from a byte array.
        /// </summary>
        /// <param name="data">
        /// The byte array that contains all needed data for the ChatMessage.
        /// </param>
        /// <param name="opcode">
        /// The opcode of a packet that contains the current message.
        /// 
        /// Specify 0 opcode if you want basic parsing implementation.
        /// </param>
        public ServerChatMessage(byte[] data, WowOpcodes opcode)
        {
            StreamHandler Reader = new StreamHandler(data);

            ReadFromStreamHandler(Reader, opcode);

            Reader.Close();
        }
Esempio n. 26
0
        private void Parse(WowOpcodes opcode)
        {
#warning Combat Log Parser not implemented
            /*
            switch (opcode)
            {
                case WowOpcodes.SMSG_SEND_ALL_COMBAT_LOG:
                {
                    uint count = Reader.ReadUInt32();
                    Output.AppendLine("Log Entry Count: " + count);
                    Output.AppendLine("Sent Time Ms: " + Reader.ReadUInt32());
                    for (uint i = 0; i < count; ++i)
                    {
                        Output.AppendLine();
                        Output.AppendLine("This Entry Time Ms: " + Reader.ReadUInt32());
                        WowOpcodes entryOpcode = (WowOpcodes)Reader.ReadUInt32();
                        Output.AppendLine("Opcode: " + entryOpcode);
                        Parse(entryOpcode);
                    }
                    break;
                }
                case WowOpcodes.SMSG_SPELLENERGIZELOG:
                    Output.AppendLine("Victim: " + Reader.ReadPackedGuid());
                    Output.AppendLine("Entity: " + Reader.ReadPackedGuid());
                    Output.AppendLine("Spell Id: " + Reader.ReadUInt32());
                    Output.AppendLine("Power Type: " + (PowerType)Reader.ReadUInt32());
                    Output.AppendLine("Power: " + Reader.ReadUInt32());
                    break;
                case WowOpcodes.SMSG_SPELLBREAKLOG:
                {
                    Output.AppendLine("Victim: " + Reader.ReadPackedGuid());
                    Output.AppendLine("Entity: " + Reader.ReadPackedGuid());
                    Output.AppendLine("Spell Id: " + Reader.ReadUInt32());
                    Output.AppendLine("Unk Byte" + Reader.ReadByte());
                    uint count = Reader.ReadUInt32();
                    Output.AppendLine("Count: " + count);
                    Output.AppendLine();
                    for (uint i = 0; i < count; ++i)
                        Output.AppendFormatLine("  uint32 {0}, byte {1}", Reader.ReadUInt32(), Reader.ReadByte());
                    break;
                }
                case WowOpcodes.SMSG_SPELLLOGEXECUTE:
                    ReadSpellLogExecute();
                    break;
                case WowOpcodes.SMSG_SPELLLOGMISS:
                {
                    Output.AppendLine("Spell Id: " + Reader.ReadUInt32());
                    Output.AppendLine("Guid: " + Reader.ReadGuid());
                    byte unk = Reader.ReadByte();
                    Output.AppendLine("Unk bool: " + unk);
                    uint count = Reader.ReadUInt32();
                    Output.AppendLine("Count: " + count);
                    for (uint i = 0; i < count; ++i)
                    {
                        Output.AppendLine();
                        Output.AppendLine("Guid: " + Reader.ReadGuid());
                        Output.AppendLine("Unk Byte: " + Reader.ReadByte());

                        if (unk != 0)
                        {
                            Output.AppendLine("Float1: " + Reader.ReadSingle());
                            Output.AppendLine("Float2: " + Reader.ReadSingle());
                        }
                    }
                    break;
                }
                case WowOpcodes.SMSG_SPELLNONMELEEDAMAGELOG:
                    ReadSpellNonMeleeDamageLog();
                    break;
                case WowOpcodes.SMSG_SPELLHEALLOG:
                    Output.AppendLine("Target: " + Reader.ReadPackedGuid());
                    Output.AppendLine("Entity: " + Reader.ReadPackedGuid());
                    Output.AppendLine("Spell Id: " + Reader.ReadUInt32());
                    Output.AppendLine("Heal: " + Reader.ReadUInt32());
                    Output.AppendLine("Overheal: " + Reader.ReadUInt32());
                    Output.AppendLine("Absorb: " + Reader.ReadUInt32());
                    Output.AppendLine("Critical: " + Reader.ReadByte());
                    Output.AppendLine("Unk: " + Reader.ReadByte());
                    break;
                case WowOpcodes.SMSG_PERIODICAURALOG:
                    ReadPeriodicAuraLog();
                    break;
                case WowOpcodes.SMSG_LOG_XPGAIN:
                    // sending current guid here will cause "You lose %d experience."
                    Output.AppendLine("Victim: " + Reader.ReadGuid());
                    Output.AppendLine("Total XP Gained: " + Reader.ReadUInt32());
                    XpType type;
                    Output.AppendLine("Type: " + (type = (XpType)Reader.ReadByte()));
                    if (type == XpType.Kill)
                    {
                        Output.AppendLine("XP Before Rested/RAF: " + Reader.ReadUInt32());
                        Output.AppendLine("Group/Raid Modifier: " + Reader.ReadSingle().ToString(CultureInfo.InvariantCulture));
                    }
                    Output.AppendLine("Is RAF: " + Reader.ReadByte());

                    // Calculations are as followed:
                    // total_XP_gained = initial_xp * group_modifier * rested_modifier
                    // xp_before_rested = initial_xp * group_modifier
                    break;
            }
            */
        }
Esempio n. 27
0
        private void ReadFromStreamHandler(StreamHandler Reader, WowOpcodes opcode)
        {
            GameMasterMessage = (opcode == WowOpcodes.SMSG_GM_MESSAGECHAT);

            m_type = (ChatMessageType)Reader.ReadByte();
            if (m_type == ChatMessageType.Addon2)
                m_type = ChatMessageType.Addon;

            m_language = (Language)Reader.ReadUInt32();
            m_senderGUID = Reader.ReadGuid();
            m_unknownUInt32 = Reader.ReadUInt32();

            switch (m_type)
            {
                case ChatMessageType.MonsterSay:
                case ChatMessageType.MonsterParty:
                case ChatMessageType.MonsterYell:
                case ChatMessageType.MonsterWhisper:
                case ChatMessageType.MonsterEmote:
                case ChatMessageType.BattleNet:
                case ChatMessageType.RaidBossEmote:
                case ChatMessageType.RaidBossWhisper:
                    Reader.Skip(4);
                    m_senderName = Reader.ReadCString();
                    m_targetGUID = Reader.ReadGuid();
                    if (!m_targetGUID.IsEmpty
                        && !m_targetGUID.IsPlayer
                        && !m_targetGUID.IsPet)
                    {
                        Reader.Skip(4);
                        m_targetName = Reader.ReadCString();
                    }
                    if (m_language == Language.Addon)
                        m_addonPrefix = Reader.ReadCString();
                    Reader.Skip(4);
                    m_text = Reader.ReadCString();
                    m_flags = (ChatMessageFlags)Reader.ReadByte();
                    if (m_type == ChatMessageType.RaidBossEmote || m_type == ChatMessageType.RaidBossWhisper)
                    {
                        m_displayTime = Reader.ReadSingle();
                        m_suspendEvent = Reader.ReadBoolean();
                    }
                    break;
                case ChatMessageType.BGSystemNeutral:
                case ChatMessageType.BGSystemAlliance:
                case ChatMessageType.BGSystemHorde:
                    m_targetGUID = Reader.ReadGuid();
                    if (!m_targetGUID.IsEmpty
                        && !m_targetGUID.IsPlayer)
                    {
                        Reader.Skip(4);
                        m_targetName = Reader.ReadCString();
                    }
                    if (m_language == Language.Addon)
                        m_addonPrefix = Reader.ReadCString();
                    Reader.Skip(4);
                    m_text = Reader.ReadCString();
                    m_flags = (ChatMessageFlags)Reader.ReadByte();
                    break;
                case ChatMessageType.Achievement:
                case ChatMessageType.GuildAchievement:
                    m_targetGUID = Reader.ReadGuid();
                    if (m_language == Language.Addon)
                        m_addonPrefix = Reader.ReadCString();
                    Reader.Skip(4);
                    m_text = Reader.ReadCString();
                    m_flags = (ChatMessageFlags)Reader.ReadByte();
                    m_achievementId = Reader.ReadUInt32();
                    break;
                case ChatMessageType.WhisperForeign:
                    Reader.Skip(4);
                    m_senderName = Reader.ReadCString();
                    m_targetGUID = Reader.ReadGuid();
                    if (m_language == Language.Addon)
                        m_addonPrefix = Reader.ReadCString();
                    Reader.Skip(4);
                    m_text = Reader.ReadCString();
                    m_flags = (ChatMessageFlags)Reader.ReadByte();
                    break;
                default:
                    if (GameMasterMessage)
                    {
                        Reader.Skip(4);
                        m_senderName = Reader.ReadCString();
                    }
                    if (m_type == ChatMessageType.Channel)
                        m_channel = Reader.ReadCString();
                    m_targetGUID = Reader.ReadGuid();
                    if (m_language == Language.Addon)
                        m_addonPrefix = Reader.ReadCString();
                    Reader.Skip(4);
                    m_text = Reader.ReadCString();
                    m_flags = (ChatMessageFlags)Reader.ReadByte();
                    break;
            }
        }
Esempio n. 28
0
        private void Parse(WowOpcodes opcode)
        {
#warning Combat Log Parser not implemented

            /*
             * switch (opcode)
             * {
             *  case WowOpcodes.SMSG_SEND_ALL_COMBAT_LOG:
             *  {
             *      uint count = Reader.ReadUInt32();
             *      Output.AppendLine("Log Entry Count: " + count);
             *      Output.AppendLine("Sent Time Ms: " + Reader.ReadUInt32());
             *      for (uint i = 0; i < count; ++i)
             *      {
             *          Output.AppendLine();
             *          Output.AppendLine("This Entry Time Ms: " + Reader.ReadUInt32());
             *          WowOpcodes entryOpcode = (WowOpcodes)Reader.ReadUInt32();
             *          Output.AppendLine("Opcode: " + entryOpcode);
             *          Parse(entryOpcode);
             *      }
             *      break;
             *  }
             *  case WowOpcodes.SMSG_SPELLENERGIZELOG:
             *      Output.AppendLine("Victim: " + Reader.ReadPackedGuid());
             *      Output.AppendLine("Entity: " + Reader.ReadPackedGuid());
             *      Output.AppendLine("Spell Id: " + Reader.ReadUInt32());
             *      Output.AppendLine("Power Type: " + (PowerType)Reader.ReadUInt32());
             *      Output.AppendLine("Power: " + Reader.ReadUInt32());
             *      break;
             *  case WowOpcodes.SMSG_SPELLBREAKLOG:
             *  {
             *      Output.AppendLine("Victim: " + Reader.ReadPackedGuid());
             *      Output.AppendLine("Entity: " + Reader.ReadPackedGuid());
             *      Output.AppendLine("Spell Id: " + Reader.ReadUInt32());
             *      Output.AppendLine("Unk Byte" + Reader.ReadByte());
             *      uint count = Reader.ReadUInt32();
             *      Output.AppendLine("Count: " + count);
             *      Output.AppendLine();
             *      for (uint i = 0; i < count; ++i)
             *          Output.AppendFormatLine("  uint32 {0}, byte {1}", Reader.ReadUInt32(), Reader.ReadByte());
             *      break;
             *  }
             *  case WowOpcodes.SMSG_SPELLLOGEXECUTE:
             *      ReadSpellLogExecute();
             *      break;
             *  case WowOpcodes.SMSG_SPELLLOGMISS:
             *  {
             *      Output.AppendLine("Spell Id: " + Reader.ReadUInt32());
             *      Output.AppendLine("Guid: " + Reader.ReadGuid());
             *      byte unk = Reader.ReadByte();
             *      Output.AppendLine("Unk bool: " + unk);
             *      uint count = Reader.ReadUInt32();
             *      Output.AppendLine("Count: " + count);
             *      for (uint i = 0; i < count; ++i)
             *      {
             *          Output.AppendLine();
             *          Output.AppendLine("Guid: " + Reader.ReadGuid());
             *          Output.AppendLine("Unk Byte: " + Reader.ReadByte());
             *
             *          if (unk != 0)
             *          {
             *              Output.AppendLine("Float1: " + Reader.ReadSingle());
             *              Output.AppendLine("Float2: " + Reader.ReadSingle());
             *          }
             *      }
             *      break;
             *  }
             *  case WowOpcodes.SMSG_SPELLNONMELEEDAMAGELOG:
             *      ReadSpellNonMeleeDamageLog();
             *      break;
             *  case WowOpcodes.SMSG_SPELLHEALLOG:
             *      Output.AppendLine("Target: " + Reader.ReadPackedGuid());
             *      Output.AppendLine("Entity: " + Reader.ReadPackedGuid());
             *      Output.AppendLine("Spell Id: " + Reader.ReadUInt32());
             *      Output.AppendLine("Heal: " + Reader.ReadUInt32());
             *      Output.AppendLine("Overheal: " + Reader.ReadUInt32());
             *      Output.AppendLine("Absorb: " + Reader.ReadUInt32());
             *      Output.AppendLine("Critical: " + Reader.ReadByte());
             *      Output.AppendLine("Unk: " + Reader.ReadByte());
             *      break;
             *  case WowOpcodes.SMSG_PERIODICAURALOG:
             *      ReadPeriodicAuraLog();
             *      break;
             *  case WowOpcodes.SMSG_LOG_XPGAIN:
             *      // sending current guid here will cause "You lose %d experience."
             *      Output.AppendLine("Victim: " + Reader.ReadGuid());
             *      Output.AppendLine("Total XP Gained: " + Reader.ReadUInt32());
             *      XpType type;
             *      Output.AppendLine("Type: " + (type = (XpType)Reader.ReadByte()));
             *      if (type == XpType.Kill)
             *      {
             *          Output.AppendLine("XP Before Rested/RAF: " + Reader.ReadUInt32());
             *          Output.AppendLine("Group/Raid Modifier: " + Reader.ReadSingle().ToString(CultureInfo.InvariantCulture));
             *      }
             *      Output.AppendLine("Is RAF: " + Reader.ReadByte());
             *
             *      // Calculations are as followed:
             *      // total_XP_gained = initial_xp * group_modifier * rested_modifier
             *      // xp_before_rested = initial_xp * group_modifier
             *      break;
             * }
             */
        }
Esempio n. 29
0
 // ctor
 public CustomPacket(WowOpcodes opcode, TransferDirection transferDirection)
 {
     this.Opcode    = opcode;
     this.Data      = new List <byte>();
     this.Direction = transferDirection;
 }
Esempio n. 30
0
        private void ui_btnOK_Click(object sender, RoutedEventArgs e)
        {
            WowOpcodes opcode = WowOpcodes.UNKNOWN_OPCODE;

            string text = ui_cbInput.Text;

            if (string.IsNullOrEmpty(text))
            {
                ui_tbError.Text = "Enter opcode id or name into the text box.";
                return;
            }

            Func <uint, uint> transformer = null;

            if (text.StartsWith("-j"))
            {
                transformer = x => Disassembly.UncondenseJam(x);
                text        = text.Substring(2).Trim();
            }
            else if (text.StartsWith("-ctor"))
            {
                transformer = x =>
                {
                    var info = OpcodeInfoPlugin.OpcodeInfos.FirstOrDefault(m => m.Constructor == x);
                    if (info != null)
                    {
                        return(info.Opcode);
                    }

                    return(uint.MaxValue);
                };
                text = text.Substring(5).Trim();
            }
            else if (text.StartsWith("-dtor"))
            {
                transformer = x =>
                {
                    var info = OpcodeInfoPlugin.OpcodeInfos.FirstOrDefault(m => m.Destructor == x);
                    if (info != null)
                    {
                        return(info.Opcode);
                    }

                    return(uint.MaxValue);
                };
                text = text.Substring(5).Trim();
            }
            else if (text.StartsWith("-a"))
            {
                transformer = x => Disassembly.UncondenseAuth(x);
                text        = text.Substring(2).Trim();
            }
            else if (text.StartsWith("-c"))
            {
                transformer = x => Disassembly.UncondenseRegular(x);
                text        = text.Substring(2).Trim();
            }
            else if (text.StartsWith("-h"))
            {
                transformer = x =>
                {
                    var info = OpcodeInfoPlugin.OpcodeInfos.FirstOrDefault(m => m.Handler == x);
                    if (info != null)
                    {
                        return(info.Opcode);
                    }

                    return(uint.MaxValue);
                };
                text = text.Substring(2).Trim();
            }

            uint value;

            try { value = text.ParseUInt32(); }
            catch { value = uint.MaxValue; }

            if (value != uint.MaxValue)
            {
                if (transformer != null)
                {
                    opcode = (WowOpcodes)transformer(value);
                }
                else
                {
                    opcode = (WowOpcodes)value;
                }
            }
            else if (!Enum.TryParse <WowOpcodes>(text.ToUpper(), out opcode))
            {
                opcode = WowOpcodes.UNKNOWN_OPCODE;
            }

            if (opcode == WowOpcodes.UNKNOWN_OPCODE)
            {
                ui_tbError.Text = "Cannot convert '" + text + "' to opcode.";
                return;
            }

            Analyze(opcode);
        }
Esempio n. 31
0
 /// <summary>
 /// Creates a new instance of <see cref="Kamilla.Network.Protocols.Wow.CustomPacket"/> using the specified opcode and direction,
 /// and saves the current packet data to it.
 /// </summary>
 /// <param name="opcode">The opcode to use to create a new instance of CustomPacket class.</param>
 /// <param name="direction">The packet direction to use to create a new instance of CustomPacket class.</param>
 /// <returns>A new instance of CustomPacket with the specified opcode, direction, and data saved to it.</returns>
 protected CustomPacket CreatePacket(WowOpcodes opcode, TransferDirection direction)
 {
     return(new CustomPacket(opcode, direction).WriteBytes(Save()));
 }
Esempio n. 32
0
        /// <remarks>
        /// Updated for client build 15354.
        /// </remarks>
        public static bool IsRegularOpcode(this WowOpcodes opcode)
        {
            var i = (uint)opcode;

            return((i & 0xA036) == 8228);
        }