/[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/05 22:08:38	545
+++ trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2013/06/05 23:12:01	546
@@ -58,6 +58,8 @@
         const int MIN_NUMBER_OF_RESULTS_BEFORE_DISPLAY = 0x03e8; // 1,000 results
 #endif
 
+        const uint MEM_1MB = 0x00100000;
+
         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
@@ -1504,7 +1506,16 @@
                                 //int count = (int)((MemoryRangeSize - MemoryRangeStart) / STEP_SIZE);
                                 //SearchResultWriter writer = new SearchResultWriter((int)(count), SearchGuid);
                                 int Last_Whole_Percent_Done = 0;
-                                uint size = STEP_SIZE * 4096;
+                                uint size = 0;
+                                const uint MB_SIZE = 16; /* MEM_1MB * MB_SIZE = MB_SIZE in megabytes */
+                                switch (sdt)
+                                {
+                                    case SearchDataTypes._8bits: size = STEP_SIZE * MEM_1MB * (MB_SIZE / BitTools.SizeOf<uint>(sdt)); break;
+                                    case SearchDataTypes._16bits: size = STEP_SIZE * MEM_1MB * (MB_SIZE / BitTools.SizeOf<uint>(sdt)); break;
+                                    case SearchDataTypes._32bits: size = STEP_SIZE * MEM_1MB * (MB_SIZE / BitTools.SizeOf<uint>(sdt)); break;
+                                    case SearchDataTypes._64bits: size = STEP_SIZE * MEM_1MB * (MB_SIZE / BitTools.SizeOf<uint>(sdt)); break;
+                                }
+                                //size = STEP_SIZE * 4096;
                                 for (uint i = MemoryRangeStart; i < MemoryRangeSize; i += size)
                                 {
 
@@ -1559,7 +1570,7 @@
                                                         }
                                                         if (comparer.Compare(Convert.ToByte(Value), value))
                                                         {
-                                                            if (reader.ContainsAddress(address_index, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
+                                                            if (reader.ContainsAddress(comparer.Address, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
                                                             {
                                                                 writer.WriteResult<byte>(comparer.Address, comparer.Value);
                                                             }                                                            
@@ -1603,7 +1614,7 @@
                                                         }
                                                         if (comparer.Compare(Convert.ToSByte(Value), value))
                                                         {
-                                                            if (reader.ContainsAddress(address_index, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
+                                                            if (reader.ContainsAddress(comparer.Address, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
                                                             {
                                                                 writer.WriteResult<sbyte>(comparer.Address, comparer.Value);
                                                             }
@@ -1648,7 +1659,7 @@
                                                         }
                                                         if (comparer.Compare(Convert.ToUInt16(Value), value))
                                                         {
-                                                            if (reader.ContainsAddress(address_index, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
+                                                            if (reader.ContainsAddress(comparer.Address, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
                                                             {
                                                                 writer.WriteResult<ushort>(comparer.Address, comparer.Value);
                                                             }
@@ -1692,7 +1703,7 @@
                                                         }
                                                         if (comparer.Compare(Convert.ToSByte(Value), value))
                                                         {
-                                                            if (reader.ContainsAddress(address_index, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
+                                                            if (reader.ContainsAddress(comparer.Address, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
                                                             {
                                                                 writer.WriteResult<short>(comparer.Address, comparer.Value);
                                                             }
@@ -1737,7 +1748,7 @@
                                                         }
                                                         if (comparer.Compare(Convert.ToUInt32(Value), value))
                                                         {
-                                                            if (reader.ContainsAddress(address_index, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
+                                                            if (reader.ContainsAddress(comparer.Address, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
                                                             {
                                                                 writer.WriteResult<uint>(comparer.Address, comparer.Value);
                                                             }
@@ -1781,7 +1792,7 @@
                                                         }
                                                         if (comparer.Compare(Convert.ToInt32(Value), value))
                                                         {
-                                                            if (reader.ContainsAddress(address_index, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
+                                                            if (reader.ContainsAddress(comparer.Address, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
                                                             {
                                                                 writer.WriteResult<int>(comparer.Address, comparer.Value);
                                                             }
@@ -1826,7 +1837,7 @@
                                                         }
                                                         if (comparer.Compare(Convert.ToUInt64(Value), value))
                                                         {
-                                                            if (reader.ContainsAddress(address_index, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
+                                                            if (reader.ContainsAddress(comparer.Address, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
                                                             {
                                                                 writer.WriteResult<ulong>(comparer.Address, comparer.Value);
                                                             }
@@ -1870,7 +1881,7 @@
                                                         }
                                                         if (comparer.Compare(Convert.ToInt64(Value), value))
                                                         {
-                                                            if (reader.ContainsAddress(address_index, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
+                                                            if (reader.ContainsAddress(comparer.Address, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
                                                             {
                                                                 writer.WriteResult<long>(comparer.Address, comparer.Value);
                                                             }

 

  ViewVC Help
Powered by ViewVC 1.1.22