public void AppendPacket(Color col, string itemText, Packet_old tmpPacket) { Dispatcher.BeginInvoke( new Action( delegate { ListBoxItem item = new ListBoxItem { Content = itemText, Background = new SolidColorBrush(col) }; if (PacketsList.Items.Count == MaxPackets) { PacketsList.Items.RemoveAt(0); pp.Packets.RemoveAt(0); } if (boxCapture.IsChecked.Value) { PacketsList.Items.Add(item); if (boxAutoScroll.IsChecked.Value) { PacketsList.ScrollIntoView(item); } pp.Packets.Add(tmpPacket); } })); }
private void OnPacketSelect(object sender, SelectionChangedEventArgs e) { if (boxPackets.SelectedIndex == -1) { return; } Packet_old p = pp.Packets[boxPackets.SelectedIndex]; SetText(p.HexLongText); boxShowOpcode.Text = String.Format("0x{0:x4}", p.OpCode); boxIgnoreOpcode.Text = String.Format("0x{0:x4}", p.OpCode); }
public void Process() { fs.Seek(0, SeekOrigin.Begin); while (fs.Position < fs.Length) { Packet_old tmpPacket; BlockType type = (BlockType)reader.ReadByte(); ushort len = reader.ReadUInt16(); fs.Seek(-2, SeekOrigin.Current);; //turn it back, our packet_old class expects a length in the packet byte[] payload = reader.ReadBytes(len); switch (type) { case BlockType.MagicBytes: string magic = ASCIIEncoding.ASCII.GetString(payload, 2, payload.Length - 2); if (magic != "TeraConnectionLog") { throw new Exception("Invalid Magic Block."); } Debug.Print("found magic"); break; case BlockType.Region: string region = ASCIIEncoding.ASCII.GetString(payload, 2, payload.Length - 2); Debug.Print("region " + region); break; case BlockType.Start: Debug.Print("start"); break; case BlockType.Timestamp: //var date = LogHelper.BytesToTimeSpan(payload); //Debug.Print("time " + date.ToShortTimeString()); break; case BlockType.Client: tmpPacket = new Packet_old(Direction.CS, BitConverter.ToUInt16(payload, 2), payload, false); processor.AppendPacket(tmpPacket); break; case BlockType.Server: tmpPacket = new Packet_old(Direction.SC, BitConverter.ToUInt16(payload, 2), payload, false); processor.AppendPacket(tmpPacket); break; } } reader.Close(); }
static void teraSniffer_MessageReceived(Tera.Message message) { //Message does not contain our length, add it to see the full packet byte[] data = new byte[message.Data.Count]; Array.Copy(message.Data.Array, 0, data, 2, message.Data.Count - 2); data[0] = (byte)(((short)message.Data.Count) & 255); data[1] = (byte)(((short)message.Data.Count) >> 8); if (message.Direction == MessageDirection.ServerToClient) { Packet_old tmpPacket = new Packet_old(Direction.SC, message.OpCode, data, false); //**********************// DataParser.StoreLastPacket(tmpPacket.OpCode, tmpPacket.HexShortText); DataParser.StoreLastMessage(message); } }
public void AppendPacket(Packet_old tmpPacket) { string itemText = tmpPacket.ToString(); Color col; if (tmpPacket.Dir == Direction.SC) { col = Colors.LightBlue; } else { col = Colors.WhiteSmoke; } Dispatcher.BeginInvoke( new Action( delegate { ListBoxItem item = new ListBoxItem { Content = itemText, Background = new SolidColorBrush(col) }; while (boxPackets.Items.Count >= maxPackets) { boxPackets.Items.RemoveAt(0); pp.Packets.RemoveAt(0); } if (filter.ShowPacket(tmpPacket)) { boxPackets.Items.Add(item); if (boxAutoScroll.IsChecked.Value) { boxPackets.ScrollIntoView(item); } pp.Packets.Add(tmpPacket); } })); }
public bool ShowPacket(Packet_old packet) { if (!showAny) { return(false); } if (packet.Dir == Direction.CS && !showCS) { return(false); } if (packet.Dir == Direction.SC && !showSC) { return(false); } if (showOnlyOpcodes.Count > 0) { return(showOnlyOpcodes.Contains(packet.OpCode)); } else { return(!ignoreOpcodes.Contains(packet.OpCode)); } }