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

Comparing trunk/RomCheater/Docking/FloatingMemorySearcher.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 1 | Line 1
1 < #define USE_FORCED_LOGGING_CONTROL // when defined, will override and force an internal logging control
1 > #define USE_AUTOMATIC_MEMORY_SEARCH_RANGE // when defined will automatically choose the best starting address and size for memory search otherwise it will use the constants defined in MemorySizeConstants
2 > #define FORCE_USE_OF_MEMORYSIZECONSTANTS // when defined wil force the use of the constants defined in MemorySizeConstants for memory search range
3   //#define DONOT_HAVE_RANGED_SEARCH_SUPPORT // when defined, indicates that ranged searches have not been implemented
3
4   #define INCREASE_NUMBER_OF_RESULTS_BEFORE_DISPLAY // when defined will set MIN RESULTS to 0x2701 otherwise 0x03e8
5
5   //#define DO_NOT_SUSPEND_RESUME_THREAD_ON_FREEZE // when defined will not freeze/resume thread on freeze
6   using System;
7   using System.Collections.Generic;
# Line 22 | Line 21 | using RomCheater.Logging;
21   using System.IO;
22   using Sojaner.MemoryScanner.MemoryProviers;
23   using RomCheater.PluginFramework.Events;
24 + using System.Reflection;
25  
26   namespace RomCheater.Docking
27   {
# Line 30 | Line 30 | namespace RomCheater.Docking
30          IAcceptsProcess<Process>,
31          IAcceptsProcessAndConfig,
32          ISearchInProgress,
33 <        IAcceptsBrowseMemoryRegion
33 >        IAcceptsBrowseMemoryRegion,
34 >        IAcceptsMemoryRange
35      {
36   #if INCREASE_NUMBER_OF_RESULTS_BEFORE_DISPLAY
37          const int MIN_NUMBER_OF_RESULTS_BEFORE_DISPLAY = 0x2701; // 10,000 results
# Line 39 | Line 40 | namespace RomCheater.Docking
40   #endif
41  
42          private bool DefaultUnsignedState = true; // set unsigned to true
43 <        public FloatingMemorySearcher() { InitializeComponent(); this.AcceptedPlugin = null; this.AcceptedProcess = null; SearchInProgess = false; Reload(); }
43 >        public FloatingMemorySearcher() { InitializeComponent(); this.AcceptedPlugin = null; OnBrowseMemoryRegion = null; this.AcceptedProcess = null; SearchInProgess = false; Reload(); }
44          public FloatingMemorySearcher(IConfigPlugin config) : this() { this.AcceptedPlugin = config; }
45          public FloatingMemorySearcher(IConfigPlugin config, Process process) : this() { this.AcceptedPlugin = config; this.AcceptedProcess = process; }
46  
# Line 52 | Line 53 | namespace RomCheater.Docking
53          public IConfigPlugin AcceptedPlugin { get { return _AcceptedPlugin; } set { _AcceptedPlugin = value; UpdateAcceptedProcessAndConfig(value, AcceptedProcess); } }
54          #endregion
55          #region IAcceptsBrowseMemoryRegion members
56 <        public BaseEventHandler<BrowseMemoryRegionEvent> OnBrowseMemoryRegion { get; set; }
56 >        public event BaseEventHandler<BrowseMemoryRegionEvent> OnBrowseMemoryRegion;
57          #endregion
58  
59          private void UpdateAcceptedProcessAndConfig(IConfigPlugin config, Process process)
# Line 61 | Line 62 | namespace RomCheater.Docking
62              this.lstResults.AcceptedProcess = process;
63              this.lstPatchList.AcceptedPlugin = config;
64              this.lstPatchList.AcceptedProcess = process;
65 +
66 + #if USE_AUTOMATIC_MEMORY_SEARCH_RANGE && FORCE_USE_OF_MEMORYSIZECONSTANTS
67 + //#error Both USE_AUTOMATIC_MEMORY_SEARCH_RANGE and FORCE_USE_OF_MEMORYSIZECONSTANTS are defined
68 +            logger.Warn.WriteLine("FloatingMemorySearcher.UpdateAcceptedProcessAndConfig(IConfigPlugin config, Process process):");
69 +            logger.Warn.WriteLine("Both USE_AUTOMATIC_MEMORY_SEARCH_RANGE and FORCE_USE_OF_MEMORYSIZECONSTANTS are defined");
70 +            logger.Warn.WriteLine("FORCE_USE_OF_MEMORYSIZECONSTANTS will take precedence and will ignore the values supplied in the memeory search range");
71 + #endif
72 + #if USE_AUTOMATIC_MEMORY_SEARCH_RANGE && !FORCE_USE_OF_MEMORYSIZECONSTANTS
73 +            // code to automatically choose the best starting memory address and size
74 + #endif
75 +
76          }
77          #region ISearchInProgress members
78 <        public bool SearchInProgess { get; private set; }
78 >        public bool SearchInProgess { get; private set; }
79          #endregion
80  
81 +        #region IAcceptsMemoryRange
82 + #if !FORCE_USE_OF_MEMORYSIZECONSTANTS
83 +        private int _MemoryRangeStart;
84 +        private uint _MemoryRangeSize;
85 + #endif
86 +        public int MemoryRangeStart
87 +        {
88 +            get
89 +            {
90 + #if FORCE_USE_OF_MEMORYSIZECONSTANTS
91 +                return MemorySizeConstants.MinimumAddress;
92 + #else
93 +                return _MemoryRangeStart;
94 + #endif
95 +            }
96 +            set
97 +            {
98 + #if !FORCE_USE_OF_MEMORYSIZECONSTANTS
99 +                _MemoryRangeStart = value;
100 + #endif
101 +            }
102 +        }        
103 +        public uint MemoryRangeSize
104 +        {
105 +            get
106 +            {
107 + #if FORCE_USE_OF_MEMORYSIZECONSTANTS
108 +                return (MemorySizeConstants.MinimumAddress > 0) ? (uint)(MemorySizeConstants.MaximumAddress - MemorySizeConstants.MinimumAddress) : MemorySizeConstants.MaximumAddress;
109 + #else
110 +                return _MemoryRangeSize;
111 + #endif
112 +            }
113 +            set
114 +            {
115 + #if !FORCE_USE_OF_MEMORYSIZECONSTANTS
116 +                _MemoryRangeSize = value;
117 + #endif
118 +            }
119 +        }
120 +        #endregion
121  
122          public void Reload()
123          {
# Line 935 | Line 987 | namespace RomCheater.Docking
987              provider.OpenProvider();
988              int bytes_read = 0;
989  
990 <            byte[] buffered_mem = new byte[MemorySizeConstants.MaximumAddress]; // throws OutOfMemoryException if size is over 2G
991 <            provider.ReadProcessMemory(MemorySizeConstants.MinimumAddress, MemorySizeConstants.MaximumAddress, out bytes_read, out buffered_mem);
990 >            byte[] buffered_mem = new byte[txtMemorySize.Value]; // throws OutOfMemoryException if size is over 2G
991 >            provider.ReadProcessMemory((int)txtMemoryStart.Value, (uint)txtMemorySize.Value, out bytes_read, out buffered_mem);
992              provider.CloseProvider();
993        
994              if (buffered_mem.Length == 0) { logger.Warn.WriteLine("Buffered Memory is Zero Length."); return; }
# Line 1603 | Line 1655 | namespace RomCheater.Docking
1655          private void ViewMemoryRegion(ResultDataType rdt)
1656          {
1657              if (OnBrowseMemoryRegion != null)
1606            {
1658                  OnBrowseMemoryRegion(new BrowseMemoryRegionEvent(rdt.Address));
1608            }
1659          }
1660  
1661          private void mnuAddedResults_Opening(object sender, CancelEventArgs e)
# Line 1635 | Line 1685 | namespace RomCheater.Docking
1685              if (SearchArgs == null) e.Cancel = true;
1686              if (e.Cancel) return;
1687          }
1688 +
1689 +        private void chkMemoryRangeExpertMode_CheckedChanged(object sender, EventArgs e)
1690 +        {
1691 +            txtMemoryStart.ReadOnly = !chkMemoryRangeExpertMode.Checked;
1692 +            txtMemorySize.ReadOnly = !chkMemoryRangeExpertMode.Checked;
1693 +        }
1694 +
1695 +        private void txtMemoryStart_ValueChanged(object sender, ValueChangedEventArgs e) { this.MemoryRangeStart = Convert.ToInt32(e.NewValue); }
1696 +        private void txtMemorySize_ValueChanged(object sender, ValueChangedEventArgs e) { this.MemoryRangeSize = Convert.ToUInt32(e.NewValue); }
1697 +              
1698      }
1699   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines