Example #1
0
        private void FindBtn_Click(object sender, EventArgs e)
        {
            HeadersVw.ClearItems();
            _game.GenerateMessageHashes();
            IEnumerable <ASClass> messages = _game.GetMessages(Hash);

            if (messages == null)
            {
                MessageBox.Show("Cannot find any Outgoing/Incoming messages that are associated with this hash.",
                                "Tanji ~ Alert!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                HashTxt.Select();
                HashTxt.SelectAll();
                return;
            }

            foreach (ASClass msgClass in messages)
            {
                ushort header      = _game.GetMessageHeader(msgClass);
                bool   isOutgoing  = _game.IsMessageOutgoing(msgClass);
                string messageName = msgClass.Instance.Name.Name;

                string type = "Outgoing";
                if (!isOutgoing)
                {
                    type         = "Incoming";
                    messageName += (", " + _game.GetIncomingMessageParser(
                                        msgClass).Instance.Name.Name);
                }
                ListViewItem item = HeadersVw.AddFocusedItem(type, header, messageName);
                item.Tag = msgClass; // Display the message/class information? GG m8?
            }
        }
Example #2
0
        public void Find(string hash)
        {
            Hash = hash;
            HeadersVw.ClearItems();

            IEnumerable <ASClass> messages = _game.GetMessages(HashTxt.Text);

            if (messages == null)
            {
                return;
            }

            foreach (ASClass messageClass in messages)
            {
                ushort header      = _game.GetMessageHeader(messageClass);
                bool   isOutgoing  = _game.IsMessageOutgoing(messageClass);
                string messageName = messageClass.Instance.Name.Name;

                string type = "Outgoing";
                if (!isOutgoing)
                {
                    type         = "Incoming";
                    messageName += (", " + _game.GetIncomingMessageParser(
                                        messageClass).Instance.Name.Name);
                }
                HeadersVw.AddFocusedItem(type, header, messageName);
            }
        }
Example #3
0
        static string DumpHeaders(HGame game, bool isDumpingOutgoing)
        {
            IReadOnlyDictionary <ushort, ASClass> messageClasses =
                (isDumpingOutgoing ? game.OutgoingMessages : game.IncomingMessages);

            IOrderedEnumerable <KeyValuePair <string, List <ushort> > > organizedHeaders =
                GetOrganizedHeadersByHashCount(game, messageClasses);

            string headersDump       = string.Empty;
            string unusedHeadersDump = string.Empty;
            string messageType       = (isDumpingOutgoing ? "Outgoing" : "Incoming");
            var    unusedHeaders     = new List <KeyValuePair <string, List <ushort> > >();

            foreach (KeyValuePair <string, List <ushort> > organizedHeader in organizedHeaders)
            {
                if (organizedHeader.Value.Count == 1)
                {
                    if (isDumpingOutgoing)
                    {
                        UniqueOutMessageHashCount++;
                    }
                    else
                    {
                        UniqueInMessageHashCount++;
                    }
                }
                string messageHash = organizedHeader.Key;
                foreach (ushort header in organizedHeader.Value)
                {
                    ASClass  messageClass = messageClasses[header];
                    string   messageName  = messageClass.Instance.QualifiedName.Name;
                    ASMethod messageCtor  = messageClass.Instance.Constructor;

                    string dump = $"{messageType}[{header}, {messageHash}] = {messageName}{messageCtor}";
                    if (!isDumpingOutgoing)
                    {
                        ASClass inMsgParser = game.GetIncomingMessageParser(messageClass);
                        dump += ($", Parser: {inMsgParser.Instance.QualifiedName.Name}");
                    }
                    dump += "\r\n";
                    if (!game.IsMessageReferenced(messageClass))
                    {
                        unusedHeadersDump += ("[Dead]" + dump);
                    }
                    else
                    {
                        headersDump += dump;
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(unusedHeadersDump))
            {
                headersDump += unusedHeadersDump;
            }

            return(headersDump.Trim());
        }
Example #4
0
        public void WritePacketLog(DataInterceptedEventArgs args, bool isOutgoing)
        {
            HMessage pkt  = args.Packet;
            HGame    game = MainUI.ConnectionPg.Game;

            ReadOnlyDictionary <ushort, ASClass> msgClasses = (isOutgoing ?
                                                               game.OutgoingMessages : game.IncomingMessages);

            ASClass msgClass = null;

            msgClasses.TryGetValue(pkt.Header, out msgClass);

            Color highlight = (isOutgoing ?
                               OutgoingHighlight : IncomingHighlight);

            if (DisplayTimestamp)
            {
                WriteHighlight($"[{DateTime.Now.ToLongTimeString()}]\r\n", SpecialHighlight);
            }

            if (DisplayHash)
            {
                string hash = game.GetMessageHash(msgClass);
                WriteHighlight($"[{hash}]\r\n", SpecialHighlight);
            }

            WriteHighlight((isOutgoing ?
                            "Outgoing" : "Incoming"), highlight);

            if (args.IsBlocked && DisplayBlocked)
            {
                WriteHighlight("[Blocked]", SpecialHighlight);
            }
            else if (!args.IsOriginal)
            {
                WriteHighlight("[Replaced]", SpecialHighlight);
            }

            string arrow = (isOutgoing ? "->" : "<-");

            WriteHighlight($"({pkt.Header}, {pkt.Length}", highlight);

            if (DisplayClassName && msgClass != null)
            {
                WriteHighlight(", ", highlight);
                WriteHighlight((msgClass?.Instance.Name.Name) ?? "???", SpecialHighlight);
            }
            if (!isOutgoing && DisplayParserName &&
                msgClass != null && !_invalidParsers.Contains(pkt.Header))
            {
                ASClass parserClass = game
                                      .GetIncomingMessageParser(msgClass);

                if (parserClass != null)
                {
                    WriteHighlight($", ", highlight);
                    WriteHighlight(parserClass.Instance.Name.Name, SpecialHighlight);
                }
                else
                {
                    _invalidParsers.Add(pkt.Header);
                }
            }
            WriteHighlight($") {arrow} {pkt}\r\n", highlight);

            if (DisplayStructure && isOutgoing)
            {
                WriteStructureLog(pkt, msgClass);
            }
        }