Example #1
0
        public void AddSegment(int id, PacketSegment segment)
        {
            try
            {
                CurrentTime = DateTime.Now;

                if (CurrentPacket == null)
                {
                    CurrentPacket = new MaplePacket(id, segment.Direction);
                    CurrentPacket.Segments.Add(segment);
                }
                else
                {
                    if (CurrentPacket.Id == id)
                    {
                        CurrentPacket.Segments.Add(segment);
                    }
                    else
                    {
                        MaplePacket oldPacket = CurrentPacket;

                        this.Invoke(new DPacketFinished(OnPacketFinished), oldPacket);
                        CurrentPacket = new MaplePacket(id, segment.Direction);
                        CurrentPacket.Segments.Add(segment);
                    }
                }

                CurrentTime = DateTime.Now;
            }
            catch (Exception e)
            {
                Main.Interface.WriteConsole("Add_Segment Error: " + e.StackTrace + "\r\n" + e.Message);
            }
        }
Example #2
0
        //public int DecryptDataHooked(IntPtr @this, int dwKey)
        //{
        //int result = Main.DecrypDataOriginal(@this, dwKey);
        //return result;
        //}

        #endregion

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (CurrentPacket != null && CurrentTime != null && CurrentTime.Ticks > 0 && DateTime.Now.Ticks - CurrentTime.Ticks > 500)
            {
                MaplePacket oldPacket = CurrentPacket;
                this.Invoke(new DPacketFinished(OnPacketFinished), oldPacket);
                CurrentPacket = null;
                CurrentTime   = DateTime.Now;
            }
        }
Example #3
0
        public void OnPacketFinished(MaplePacket packet)
        {
            string data = "";


            if (packet.Segments.Count == 1)
            {
                data = "<no data>";
            }
            else
            {
                for (int i = 1; i < packet.Segments.Count; i++)
                {
                    data += packet.Segments[i].ToHexString() + " ";
                }
                data.TrimEnd(' ');
            }


            PacketSegment opcodeSegment = packet.Segments[0];
            string        opcode        = opcodeSegment.ToHexString().PadLeft(4, '0');

            if (opcodeSegment.Type == PacketSegmentType.SHORT || opcodeSegment.Type == PacketSegmentType.BYTE)
            {
                if (opcodeSegment.ToShort() > -1 && opcodeSegment.ToShort() < 0x200)
                {
                    try
                    {
                        listView1.Items.Add(new ListViewItem(new string[] { packet.Direction, packet.ToArray().Length.ToString(), BitConverter.ToString(packet.ToArray()) }));
                        listView2.Items.Add(new ListViewItem(new string[] { packet.Direction, opcode, data }));
                    }
                    catch (Exception e)
                    {
                        Main.Interface.WriteConsole("Packet_Finished Error: " + e.StackTrace + "\r\n" + e.Message);
                    }
                }
            }

            if (listView2.Items.Count > MAX_PACKETS)
            {
                listView1.Items.RemoveAt(0);
                listView2.Items.RemoveAt(0);
            }
        }