public static MaximusParserX.Reading.DefinitionBase GetDefinition(DefinitionContext context, ClientBuild clientbuild, string opcodename, uint opcode)
        {
            var obj = Type.GetType(string.Format("MaximusParserX.Parsing.Parsers.{0}_DEF", opcodename));

            if (obj == null)
            {
                obj = Type.GetType("MaximusParserX.Parsing.Parsing.UnknownDef");
            }

            if (obj != null)
            {
                var def = (DefinitionBase)Activator.CreateInstance(obj);
                def.Initialize(context);
                return def;
            }
            else
            {
                return null;
            }
        }
Example #2
0
        public void Process(bool resume, string query)
        {
            if (!resume)
            {
                Reader.Load(query);
            }

            while (true)
            {
                if (this.Pause) { break; }

                var packet = Reader.GetNextPacket();

                if (packet != null)
                {
                    if (!FilterOpcodeList.Contains(packet.Opcode))
                    {
                        if (!DefinedOpcodeList.Contains(packet.Opcode) && !UniqueOpcodeList.Contains(packet.Opcode))
                        {
                            DelegateManager.AddInfo("Unique Opcode: {0}\t{1}", packet.OpcodeName, packet.Opcode);
                            UniqueOpcodeList.Add(packet.Opcode);
                        }

                        var context = new DefinitionContext(packet, Reader, Core);

                        var definition = context.GetDefinition();

                        definition.Parse();

                        PacketProcessed(packet);
                    }
                }
                else
                {
                    break;
                }
            }
        }
 public void Initialize(DefinitionContext context)
 {
     Context = context;
     this.Load(Context.Data);
 }
 public DefinitionBase(DefinitionContext context)
     : base(context.Data)
 {
 }
        public override bool Parse()
        {
            ResetPosition();

            int i = 0;

            while (AvailableBytes > 0)
            {
                i++;

                var size = ReadByte(i, "size");

                SetBookmarkPosition();

                GotoBookmarkPosition();

                var opcodefieldkey = FormatFieldName(i, "opcode");
                var opcode = ReadUInt16(opcodefieldkey);
                var opcodename = ParsingHandler.GetOpcodeName(opcode, MaximusParserX.Direction.ServerToClient, ClientBuild);

                if (FieldLog.ContainsKey(opcodefieldkey)) FieldLog[opcodefieldkey] = string.Format("val: {0}, Name: {1}", FieldLog[opcodefieldkey], opcodename);

                var packet = new Packet(i, base.Context.TimeStamp.AddMilliseconds(i), MaximusParserX.Direction.ServerToClient, opcode, ReadBytes(size - 2), size - 2, ClientBuild);
                var context = new DefinitionContext(packet, base.Context.Reader, base.Core);
                var definition = ParsingHandler.GetDefinition(context, ClientBuild, opcodename, opcode);

                definition.Parse();
            }

            return Validate();
        }