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

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

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

--- trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2013/06/06 09:24:18	589
+++ trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2013/06/06 10:08:17	590
@@ -13,7 +13,7 @@
 #endregion
 //#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
 #if !USE_AUTOMATIC_MEMORY_SEARCH_RANGE
-#define FORCE_USE_OF_MEMORYSIZECONSTANTS // when defined wil force the use of the constants defined in MemorySizeConstants for memory search range
+//#define FORCE_USE_OF_MEMORYSIZECONSTANTS // when defined wil force the use of the constants defined in MemorySizeConstants for memory search range
 #endif
 #define DONOT_HAVE_RANGED_SEARCH_SUPPORT // when defined, indicates that ranged searches have not been implemented
 #define INCREASE_NUMBER_OF_RESULTS_BEFORE_DISPLAY // when defined will set MIN RESULTS to 0x2701 otherwise 0x03e8
@@ -41,6 +41,7 @@
 using System.Collections;
 using RomCheater.Serialization;
 using RomCheater.Core;
+using RomCheater.PluginFramework.Core;
 
 namespace RomCheater.Docking
 {
@@ -73,7 +74,31 @@
         const bool USE_OLD_SEARCH_RESULTS_COMPRATOR_CODE = false;
         const bool USE_NONRANGE_SEARCH_RESULT_READER = false;
         private bool DefaultUnsignedState = true; // set unsigned to true
-        public FloatingMemorySearcher() { InitializeComponent(); this.AcceptedPlugin = null; OnBrowseMemoryRegion = null; this.AcceptedProcess = null; SearchInProgess = false; Reload(); }
+        public FloatingMemorySearcher()
+        {
+            InitializeComponent();
+            this.AcceptedPlugin = null; 
+            OnBrowseMemoryRegion = null;
+            this.AcceptedProcess = null;
+            SearchInProgess = false;
+            MemoryRangeStart = MemorySizeConstants.MinimumSearchAddress;
+            if (this.PEData != null)
+            {
+                if (this.PEData.Is32bitAssembly())
+                {
+                    MemoryRangeSize = MemorySizeConstants.MinimumSearchAddress + MemorySizeConstants.MaximumSearchSize_x86;
+                }
+                else
+                {
+                    MemoryRangeSize = MemorySizeConstants.MinimumSearchAddress + MemorySizeConstants.MaximumSearchSize_x64;
+                }
+            }
+            else
+            {
+                MemoryRangeSize = MemorySizeConstants.MinimumSearchAddress + MemorySizeConstants.MaximumSearchSize_x86;
+            }            
+            Reload();
+        }
         public FloatingMemorySearcher(IConfigPlugin config) : this() { this.AcceptedPlugin = config; }
         public FloatingMemorySearcher(IConfigPlugin config, Process process) : this() { this.AcceptedPlugin = config; this.AcceptedProcess = process; }
 
@@ -120,7 +145,30 @@
             {
                 MemoryRangeStart = AcceptedPlugin.MemoryRangeStart;
                 MemoryRangeSize = AcceptedPlugin.MemoryRangeStart + AcceptedPlugin.MemoryRangeSize;
-            }
+
+                /* check for generic config and override the MemoryStart/Size parameters
+                   the purpose of a config plugin supplying this data was incase a plugin was created and the memory start address and size were known ahead of time
+                   however, for generic purposes use x86/x64 defaults...
+                */
+                if (config.IsGenericConfig)
+                {                    
+                    if (this.PEData != null)
+                    {
+                        if (this.PEData.Is32bitAssembly())
+                        {
+                            this.MemoryRangeSize = MemorySizeConstants.MinimumAddress + MemorySizeConstants.MaximumAddressSize_x86;
+                        }
+                        else
+                        {
+                            this.MemoryRangeSize = MemorySizeConstants.MinimumAddress + MemorySizeConstants.MaximumAddressSize_x64;
+                        }
+                    }
+                    else
+                    {
+                        this.MemoryRangeSize = MemorySizeConstants.MinimumAddress + MemorySizeConstants.MaximumAddressSize_x86;
+                    }
+                }
+            }         
         }
         private void UpdateAcceptedProcess(Process process)
         {            
@@ -195,8 +243,8 @@
 
         #region IAcceptsMemoryRange
 #if !FORCE_USE_OF_MEMORYSIZECONSTANTS
-        private uint _MemoryRangeStart;
-        private uint _MemoryRangeSize;
+        private ulong _MemoryRangeStart;
+        private ulong _MemoryRangeSize;
 #endif
         public ulong MemoryRangeStart
         {
@@ -2679,6 +2727,22 @@
         public void SetPEViewerData(IPEDData peData)
         {
             this.PEData = peData;
+            this.MemoryRangeStart = MemorySizeConstants.MinimumAddress;
+            if (this.PEData != null)
+            {
+                if (this.PEData.Is32bitAssembly())
+                {
+                    this.MemoryRangeSize= MemorySizeConstants.MinimumAddress + MemorySizeConstants.MaximumAddressSize_x86;
+                }
+                else
+                {
+                    this.MemoryRangeSize = MemorySizeConstants.MinimumAddress + MemorySizeConstants.MaximumAddressSize_x64;
+                }
+            }
+            else
+            {
+              this.MemoryRangeSize = MemorySizeConstants.MinimumAddress + MemorySizeConstants.MaximumAddressSize_x86;
+            }
         }
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22