diff --git a/aclogview/Form1.Designer.cs b/aclogview/Form1.Designer.cs index 19faa56..dca86b9 100644 --- a/aclogview/Form1.Designer.cs +++ b/aclogview/Form1.Designer.cs @@ -40,6 +40,9 @@ private void InitializeComponent() { this.menuItem_File = new System.Windows.Forms.MenuItem(); this.menuItem_Open = new System.Windows.Forms.MenuItem(); this.menuItem_Edit = new System.Windows.Forms.MenuItem(); + this.menuItem1 = new System.Windows.Forms.MenuItem(); + this.menuItem2 = new System.Windows.Forms.MenuItem(); + this.menuItem3 = new System.Windows.Forms.MenuItem(); this.menuItem_Help = new System.Windows.Forms.MenuItem(); this.menuItem_About = new System.Windows.Forms.MenuItem(); this.menuStrip = new System.Windows.Forms.MenuStrip(); @@ -48,9 +51,7 @@ private void InitializeComponent() { this.statusStrip = new System.Windows.Forms.StatusStrip(); this.checkBox_HideHeaderOnly = new System.Windows.Forms.CheckBox(); this.checkBox_useHighlighting = new System.Windows.Forms.CheckBox(); - this.menuItem1 = new System.Windows.Forms.MenuItem(); - this.menuItem2 = new System.Windows.Forms.MenuItem(); - this.menuItem3 = new System.Windows.Forms.MenuItem(); + this.menuItem4 = new System.Windows.Forms.MenuItem(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer_Main)).BeginInit(); this.splitContainer_Main.Panel1.SuspendLayout(); this.splitContainer_Main.Panel2.SuspendLayout(); @@ -204,6 +205,27 @@ private void InitializeComponent() { this.menuItem_Edit.Index = 1; this.menuItem_Edit.Text = "Edit"; // + // menuItem1 + // + this.menuItem1.Index = 2; + this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.menuItem2, + this.menuItem3, + this.menuItem4}); + this.menuItem1.Text = "Tools"; + // + // menuItem2 + // + this.menuItem2.Index = 0; + this.menuItem2.Text = "Count Packet Types"; + this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click); + // + // menuItem3 + // + this.menuItem3.Index = 1; + this.menuItem3.Text = "Find Bad Parsers"; + this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click); + // // menuItem_Help // this.menuItem_Help.Index = 3; @@ -273,25 +295,11 @@ private void InitializeComponent() { this.checkBox_useHighlighting.UseVisualStyleBackColor = true; this.checkBox_useHighlighting.CheckedChanged += new System.EventHandler(this.checkBox_useHighlighting_CheckedChanged); // - // menuItem1 + // menuItem4 // - this.menuItem1.Index = 2; - this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.menuItem2, - this.menuItem3}); - this.menuItem1.Text = "Tools"; - // - // menuItem2 - // - this.menuItem2.Index = 0; - this.menuItem2.Text = "Count Packet Types"; - this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click); - // - // menuItem3 - // - this.menuItem3.Index = 1; - this.menuItem3.Text = "Find Bad Parsers"; - this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click); + this.menuItem4.Index = 2; + this.menuItem4.Text = "Heatmap"; + this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click); // // Form1 // @@ -353,6 +361,7 @@ private void InitializeComponent() { private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.MenuItem menuItem2; private System.Windows.Forms.MenuItem menuItem3; + private System.Windows.Forms.MenuItem menuItem4; } } diff --git a/aclogview/Form1.cs b/aclogview/Form1.cs index 1910da2..28347c6 100644 --- a/aclogview/Form1.cs +++ b/aclogview/Form1.cs @@ -756,5 +756,53 @@ private void menuItem3_Click(object sender, EventArgs e) { } } } + + private void menuItem4_Click(object sender, EventArgs e) { + FolderBrowserDialog openFolder = new FolderBrowserDialog(); + + if (openFolder.ShowDialog() != DialogResult.OK) { + return; + } + + string[] files = Directory.GetFiles(openFolder.SelectedPath, "*.pcap", SearchOption.AllDirectories); + + uint[,] heatmap = new uint[256, 256]; + foreach (string file in files) { + loadPcap(file, true); + + foreach (PacketRecord record in records) { + foreach (BlobFrag frag in record.netPacket.fragList_) { + if (frag.dat_.Length > 20) { + BinaryReader fragDataReader = new BinaryReader(new MemoryStream(frag.dat_)); + fragDataReader.ReadUInt32(); + fragDataReader.ReadUInt32(); + if ((PacketOpcode)fragDataReader.ReadUInt32() == PacketOpcode.Evt_Movement__AutonomousPosition_ID) { + Position pos = Position.read(fragDataReader); + uint x = (pos.objcell_id >> 24) & 0xFF; + uint y = 255 - ((pos.objcell_id >> 16) & 0xFF); + heatmap[x, y] = 1; + } + } + } + } + } + + System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); + Stream imageStream = assembly.GetManifestResourceStream("aclogview.map.png"); + Bitmap heatmapImg = new Bitmap(imageStream); + for (int y = 0; y < 256; ++y) { + for (int x = 0; x < 256; ++x) { + if (heatmap[x, y] > 0) { + Color curColor = heatmapImg.GetPixel(x, y); + heatmapImg.SetPixel(x, y, Color.FromArgb(255, Math.Min(255, 200 + curColor.R), curColor.G, curColor.B)); + } + } + } + + ImagePopup popup = new ImagePopup(); + popup.ClientSize = new Size(600, 600); + popup.setImage(heatmapImg); + popup.ShowDialog(); + } } } diff --git a/aclogview/ImagePopup.Designer.cs b/aclogview/ImagePopup.Designer.cs new file mode 100644 index 0000000..5429199 --- /dev/null +++ b/aclogview/ImagePopup.Designer.cs @@ -0,0 +1,57 @@ +namespace aclogview { + partial class ImagePopup { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.SuspendLayout(); + // + // pictureBox1 + // + this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBox1.Location = new System.Drawing.Point(0, 0); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(584, 561); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pictureBox1.TabIndex = 0; + this.pictureBox1.TabStop = false; + // + // ImagePopup + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(584, 561); + this.Controls.Add(this.pictureBox1); + this.Name = "ImagePopup"; + this.Text = "ImagePopup"; + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.PictureBox pictureBox1; + } +} \ No newline at end of file diff --git a/aclogview/ImagePopup.cs b/aclogview/ImagePopup.cs new file mode 100644 index 0000000..a8ef1b0 --- /dev/null +++ b/aclogview/ImagePopup.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace aclogview { + public partial class ImagePopup : Form { + public ImagePopup() { + InitializeComponent(); + } + + public void setImage(Bitmap image) { + pictureBox1.Image = image; + } + } +} diff --git a/aclogview/ImagePopup.resx b/aclogview/ImagePopup.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/aclogview/ImagePopup.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/aclogview/aclogview.csproj b/aclogview/aclogview.csproj index 3020a1f..5f7ae7a 100644 --- a/aclogview/aclogview.csproj +++ b/aclogview/aclogview.csproj @@ -102,6 +102,12 @@ Form1.cs + + Form + + + ImagePopup.cs + @@ -120,6 +126,9 @@ Form1.cs + + ImagePopup.cs + ResXFileCodeGenerator Resources.Designer.cs @@ -145,6 +154,9 @@ + + +