ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater/Docking/UI/UIMemoryViewer.cs
(Generate patch)

Comparing trunk/RomCheater/Docking/UI/UIMemoryViewer.cs (file contents):
Revision 286 by william, Tue Jun 5 02:19:13 2012 UTC vs.
Revision 287 by william, Tue Jun 5 08:52:07 2012 UTC

# Line 14 | Line 14 | using RomCheater.PluginFramework.Interfa
14   using System.Diagnostics;
15   using Sojaner.MemoryScanner.MemoryProviers;
16   using System.Runtime.InteropServices;
17 + using RomCheater.PluginFramework.Events;
18  
19   namespace RomCheater.Docking.UI
20   {
21      public partial class UIMemoryViewer : UserControl,
22          IAcceptsPlugin<IConfigPlugin>,
23          IAcceptsProcess<Process>,
24 <        IAcceptsProcessAndConfig
24 >        IAcceptsProcessAndConfig,
25 >        IAcceptsMemoryRange,
26 >        IBrowseMemoryRegion
27      {
28          public UIMemoryViewer()
29          {
# Line 35 | Line 38 | namespace RomCheater.Docking.UI
38              txtData.BytesPerLine = (int)max_address_width;
39              txtData.UseFixedBytesPerLine = true;
40              txtData.StringViewVisible = true;
41 <            ramScroll.Minimum = (int)MemoryStart;
42 <            for (int i = MemoryStart; i < (MemoryStart + max_ram_view); i += max_address_width) { ramScroll.Maximum += (int)max_address_width; }
41 >            ramScroll.Minimum = (int)MemoryRangeStart;
42 >            for (int i = MemoryRangeStart; i < (MemoryRangeStart + max_ram_view); i += max_address_width) { ramScroll.Maximum += (int)max_address_width; }
43              ramScroll.Value = ramScroll.Minimum;
44              this.CanChangeUpdateInterval = false;
45  
# Line 60 | Line 63 | namespace RomCheater.Docking.UI
63                  GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this);
64                  provider.OpenProvider();
65                  int addr = 0;
66 <                provider.ReadFirstNonZeroByte(MemoryStart, MemorySize, out addr);
66 >                provider.ReadFirstNonZeroByte(MemoryRangeStart, MemoryRangeSize, out addr);
67                  provider.CloseProvider();
68                  GotoAddress(addr);
69              }
70   #endif
71          }
72 <
72 >        #region IBrowseMemoryRegion
73 >        public bool BrowseMemoryRegion(int MemoryRegion)
74 >        {
75 >            try
76 >            {
77 >                if (!((MemoryRangeStart <= MemoryRegion) && (MemoryRegion <= (MemoryRangeStart + MemoryRangeSize)))) { return false; }
78 >                GotoAddress(MemoryRegion);
79 >                return true;
80 >            }
81 >            catch(Exception ex)
82 >            {
83 >                logger.Error.WriteLine("UIMemoryViewer.BrowseMemoryRegion(int MemoryRegion): Failed to Browse Memory Region: 0x{0:x8}", MemoryRegion);
84 >                logger.Error.WriteLine(ex.ToString());
85 >                return false;
86 >            }
87 >        }
88 >        #endregion
89          #region  IAcceptsProcess<Process> Members
90          private Process _AcceptedProcess;
91          public Process AcceptedProcess
# Line 88 | Line 107 | namespace RomCheater.Docking.UI
107          public IConfigPlugin AcceptedPlugin { get; set; }
108          #endregion
109          #region IAcceptsMemoryRange members
110 <        public int MemoryStart { get { return MemorySizeConstants.MinimumAddress; } }
111 <        public uint MemorySize { get { return MemorySizeConstants.MaximumAddress; } }
110 >        public int MemoryRangeStart { get { return MemorySizeConstants.MinimumAddress; } set { } }
111 >        public uint MemoryRangeSize { get { if (MemoryRangeStart > 0) { return (uint)(MemorySizeConstants.MaximumAddress - MemoryRangeStart); } return MemorySizeConstants.MaximumAddress; } set { } }
112          #endregion
113          public void GotoTop() { this.CURRENT_TOP_ADDR = 0; }
114 <        public void GotoBottom() { uint size = (uint)MemorySize; this.CURRENT_TOP_ADDR = (int)((size - 1) - max_ram_view); }
114 >        public void GotoBottom() { uint size = (uint)MemoryRangeSize; this.CURRENT_TOP_ADDR = (int)((size - 1) - max_ram_view); }
115          public void GotoAddress(int addr) { this.CURRENT_TOP_ADDR = (int)(addr & 0xFFFFFFF0); }
116          private bool _UpdateEnabled;
117          public bool UpdateEnabled
# Line 266 | Line 285 | namespace RomCheater.Docking.UI
285                              for (int j = 0; j < max_address_width; j++)
286                              {
287                                  int current_addr = i + j;
288 <                                if (current_addr >= MemorySize) break;
288 >                                if (current_addr >= MemoryRangeSize) break;
289                                  byte ascii_value_raw = data[j];
290                                  char ascii_value = (char)data[j];
291                                  if (ascii_value_raw >= 0x20 && ascii_value_raw <= 0x7e)
# Line 364 | Line 383 | namespace RomCheater.Docking.UI
383                              this.CURRENT_TOP_ADDR = 0; //NonHandledKeysAreBeingPressed = false;
384                              break;
385                          case Keys.End:
386 <                            this.CURRENT_TOP_ADDR = (int)((MemorySize - 1) - max_ram_view); //NonHandledKeysAreBeingPressed = false;
386 >                            this.CURRENT_TOP_ADDR = (int)((MemoryRangeSize - 1) - max_ram_view); //NonHandledKeysAreBeingPressed = false;
387                              break;
388                          default:
389                              //NonHandledKeysAreBeingPressed = true;
# Line 408 | Line 427 | namespace RomCheater.Docking.UI
427                          break;
428                  }
429              }
430 <            if (this.CURRENT_TOP_ADDR < MemoryStart) this.CURRENT_TOP_ADDR = MemoryStart;
430 >            if (this.CURRENT_TOP_ADDR < MemoryRangeStart) this.CURRENT_TOP_ADDR = MemoryRangeStart;
431              //if (this.CURRENT_TOP_ADDR >= VTLB_VADDR_SIZE) this.CURRENT_TOP_ADDR = (size - 1) - max_ram_view;
432 <            if (this.CURRENT_TOP_ADDR + max_ram_view >= MemorySize) this.CURRENT_TOP_ADDR = (int)(MemorySize - max_ram_view);
432 >            if (this.CURRENT_TOP_ADDR + max_ram_view >= MemoryRangeSize) this.CURRENT_TOP_ADDR = (int)(MemoryRangeSize - max_ram_view);
433              
434              //this.UpdateEnabled = reenable;
435          }
# Line 510 | Line 529 | namespace RomCheater.Docking.UI
529              if (this.CURRENT_TOP_ADDR < 0) this.CURRENT_TOP_ADDR = 0;
530              //if (this.CURRENT_TOP_ADDR >= VTLB_VADDR_SIZE) this.CURRENT_TOP_ADDR = VTLB_VADDR_SIZE - max_ram_view;
531              //if (this.CURRENT_TOP_ADDR < 0 || this.CURRENT_TOP_ADDR >= VTLB_VADDR_SIZE) this.CURRENT_TOP_ADDR = ORIGINAL_ADDR;
532 <            if (this.CURRENT_TOP_ADDR + max_ram_view >= MemorySize) this.CURRENT_TOP_ADDR = (int)(MemorySize - max_ram_view);
532 >            if (this.CURRENT_TOP_ADDR + max_ram_view >= MemoryRangeSize) this.CURRENT_TOP_ADDR = (int)(MemoryRangeSize - max_ram_view);
533              //this.UpdateEnabled = reenable;
534              //isScrolling = false;
535          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines