/[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	2012/06/20 12:16:34	398
+++ trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2012/06/20 13:24:49	399
@@ -25,6 +25,7 @@
 using RomCheater.PluginFramework.Events;
 using System.Reflection;
 using Sojaner.MemoryScanner;
+using System.Collections;
 
 namespace RomCheater.Docking
 {
@@ -106,7 +107,17 @@
 
         }
         #region ISearchInProgress members
-        public bool SearchInProgess { get; private set; }
+        private bool _SearchInProgess;
+        public bool SearchInProgess
+        {
+            get { return _SearchInProgess; }
+            private set
+            {
+                _SearchInProgess = value;
+                if (this.AcceptedPlugin != null)
+                    this.AcceptedPlugin.SetMemorySearchReference(this);
+            }
+        }
         #endregion
 
         #region IAcceptsMemoryRange
@@ -1025,14 +1036,11 @@
             //List<ResultType<object>> tmp_Results = new List<ResultType<object>>();
             List<ResultType<object>> second_tmp_Results = new List<ResultType<object>>();
             const int ElementsBeforeDisplay = 100;
-            //const double _UPDATE_DELAY = 1024.0;
-            //double UPDATE_DELAY = 1;         
-            //tmp_Results = SearchArgs.Results.GetRange(0,SearchArgs.Results.Count);
-            //SearchArgs.Results = null;
-            //SearchArgs.Results.Clear();
-            // log options
             SearchArgs.LogSearchOptions();
             uint STEP_SIZE = (uint)SearchArgs.DataType / 8;
+
+            bool unsigned = SearchArgs.IsUnsignedDataType;
+            SearchDataTypes sdt = SearchArgs.DataType;
             byte[] buffered_mem = new byte[(MemoryRangeSize - MemoryRangeStart)]; // throws OutOfMemoryException if size is over 2G
             using (GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
             {
@@ -1062,30 +1070,30 @@
                         {
                             using (ResultType<object> _tmp_result = new ResultType<object>())
                             {
-                                switch (SearchArgs.DataType)
+                                switch (sdt)
                                 {
                                     case SearchDataTypes._8bits:
-                                        if (SearchArgs.IsUnsignedDataType) { _tmp_result.Address = (uint)r_ms.BaseStream.Position; _tmp_result.Value = r_ms.ReadByte(); }
+                                        if (unsigned) { _tmp_result.Address = (uint)r_ms.BaseStream.Position; _tmp_result.Value = r_ms.ReadByte(); }
                                         else { _tmp_result.Address = (uint)r_ms.BaseStream.Position; _tmp_result.Value = r_ms.ReadSByte(); } break;
                                     case SearchDataTypes._16bits:
-                                        if (SearchArgs.IsUnsignedDataType) { _tmp_result.Address = (uint)r_ms.BaseStream.Position; _tmp_result.Value = r_ms.ReadUInt16(); }
+                                        if (unsigned) { _tmp_result.Address = (uint)r_ms.BaseStream.Position; _tmp_result.Value = r_ms.ReadUInt16(); }
                                         else { _tmp_result.Address = (uint)r_ms.BaseStream.Position; _tmp_result.Value = r_ms.ReadInt16(); } break;
                                     case SearchDataTypes._32bits:
-                                        if (SearchArgs.IsUnsignedDataType) { _tmp_result.Address = (uint)r_ms.BaseStream.Position; _tmp_result.Value = r_ms.ReadUInt32(); }
+                                        if (unsigned) { _tmp_result.Address = (uint)r_ms.BaseStream.Position; _tmp_result.Value = r_ms.ReadUInt32(); }
                                         else { _tmp_result.Address = (uint)r_ms.BaseStream.Position; _tmp_result.Value = r_ms.ReadInt32(); } break;
                                     case SearchDataTypes._64bits:
-                                        if (SearchArgs.IsUnsignedDataType) { _tmp_result.Address = (uint)r_ms.BaseStream.Position; _tmp_result.Value = r_ms.ReadUInt64(); }
+                                        if (unsigned) { _tmp_result.Address = (uint)r_ms.BaseStream.Position; _tmp_result.Value = r_ms.ReadUInt64(); }
                                         else { _tmp_result.Address = (uint)r_ms.BaseStream.Position; _tmp_result.Value = r_ms.ReadInt64(); } break;
                                 }
                                 //results_list.Add(_tmp_result);
                                 SearchArgs.Results.Add(_tmp_result);
                             }
-                            double double_percent_done = 100.0 * (double)((double)r_ms.BaseStream.Position / (double)buffered_mem.Length);
+                            double double_percent_done = 100.0 * (double)((double)r_ms.BaseStream.Position / (double)r_ms.BaseStream.Length);
                             int int_percent_done = (int)double_percent_done;
                             if (int_percent_done != Last_Whole_Percent_Done && r_ms.BaseStream.Position % ElementsBeforeDisplay == 0)
                             {
                                 resultsprogress.Value = int_percent_done;
-                                resultsprogress.Message = string.Format(" -> Reading Address: 0x{0:x8}", r_ms.BaseStream.Position);
+                                resultsprogress.Message = string.Format(" -> Reading Address: 0x{0:x8}", r_ms.BaseStream.Position + MemoryRangeStart);
                                 Last_Whole_Percent_Done = int_percent_done;
                                 //Application.DoEvents();
                             }

 

  ViewVC Help
Powered by ViewVC 1.1.22