/[RomCheater]/trunk/RomCheater/Docking/FloatingMemorySectionViewer.cs
ViewVC logotype

Diff of /trunk/RomCheater/Docking/FloatingMemorySectionViewer.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater/Docking/FloatingMemorySectionViewer.cs	2013/06/07 12:11:46	602
+++ trunk/RomCheater/Docking/FloatingMemorySectionViewer.cs	2013/06/07 12:25:13	603
@@ -13,6 +13,7 @@
 using Sojaner.MemoryScanner;
 using Sojaner.MemoryScanner.MemoryProviers;
 using ManagedWinapi;
+using RomCheater.Core;
 
 namespace RomCheater.Docking
 {
@@ -22,9 +23,11 @@
         IAcceptsProcessAndConfig,
         IAcceptPEData
     {
+        ListViewColumnSorter lvwColumnSorter = new ListViewColumnSorter();
         public FloatingMemorySectionViewer()
         {
             InitializeComponent();
+            this.lstMemoryRegions.ListViewItemSorter = lvwColumnSorter;
         }
 
            public FloatingMemorySectionViewer(IConfigPlugin config) : this() { this.AcceptedPlugin = config; }
@@ -94,9 +97,28 @@
             {
                 ListViewItem li = new ListViewItem();
 
-                li.Text =string.Format("0x{0}", region.StartAddress.ToString("X"));
-                li.SubItems.Add(string.Format("0x{0}", region.EndAddress.ToString("X")));
-                li.SubItems.Add(string.Format("0x{0}", region.Size.ToString("X")));
+                if (this.PEData != null)
+                {
+                    if (this.PEData.Is32bitAssembly())
+                    {
+                        li.Text = string.Format("0x{0}", region.StartAddress.ToString("X").PadLeft(sizeof(uint) * 2, '0'));
+                        li.SubItems.Add(string.Format("0x{0}", region.EndAddress.ToString("X").PadLeft(sizeof(uint) * 2, '0')));
+                        li.SubItems.Add(string.Format("0x{0}", region.Size.ToString("X").PadLeft(sizeof(uint) * 2, '0')));
+                    }
+                    else
+                    {
+                        li.Text = string.Format("0x{0}", region.StartAddress.ToString("X").PadLeft(sizeof(ulong) * 2, '0'));
+                        li.SubItems.Add(string.Format("0x{0}", region.EndAddress.ToString("X").PadLeft(sizeof(ulong) * 2, '0')));
+                        li.SubItems.Add(string.Format("0x{0}", region.Size.ToString("X").PadLeft(sizeof(ulong) * 2, '0')));
+                    }
+                }
+                else
+                {
+                    li.Text = string.Format("0x{0}", region.StartAddress.ToString("X").PadLeft(sizeof(ulong) * 2, '0'));
+                    li.SubItems.Add(string.Format("0x{0}", region.EndAddress.ToString("X").PadLeft(sizeof(ulong) * 2, '0')));
+                    li.SubItems.Add(string.Format("0x{0}", region.Size.ToString("X").PadLeft(sizeof(ulong) * 2, '0')));
+                }
+                
                 li.SubItems.Add(string.Format("{0}", region.RegionInfo.Protect.ToString()));
                 li.SubItems.Add(string.Format("{0}", region.RegionInfo.State.ToString()));
                 li.SubItems.Add(string.Format("{0}", region.RegionInfo.Type.ToString()));
@@ -148,5 +170,32 @@
 
         }
 
+        
+        private void lstMemoryRegions_ColumnClick(object sender, ColumnClickEventArgs e)
+        {
+            // Determine if clicked column is already the column that is being sorted.
+            if (e.Column == lvwColumnSorter.SortColumn)
+            {
+                // Reverse the current sort direction for this column.
+                if (lvwColumnSorter.Order == SortOrder.Ascending)
+                {
+                    lvwColumnSorter.Order = SortOrder.Descending;
+                }
+                else
+                {
+                    lvwColumnSorter.Order = SortOrder.Ascending;
+                }
+            }
+            else
+            {
+                // Set the column number that is to be sorted; default to ascending.
+                lvwColumnSorter.SortColumn = e.Column;
+                lvwColumnSorter.Order = SortOrder.Ascending;
+            }
+
+            // Perform the sort with these new sort options.
+            this.lstMemoryRegions.Sort();
+        }
+
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22