/[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/03 16:48:28	474
+++ trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2013/06/03 17:43:12	475
@@ -1378,14 +1378,14 @@
                             {
                                 double double_percent_done = 100.0 * (double)((double)CurrentIndex / (double)e.TotalCount);
                                 int int_percent_done = (int)double_percent_done;
-                                if (CurrentIndex % 10 == 0)
-                                {
-                                    if (int_percent_done <= 100)
-                                    {
-                                        new Action<int, string>(UpdateProgress).Invoke(int_percent_done, string.Format(" -> Reading Index: 0x{0:x8} of 0x{1:x8}", CurrentIndex, e.TotalCount));
-                                    }
-                                    if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
-                                }
+                                //if (CurrentIndex % 10 == 0)
+                                //{
+                                //    if (int_percent_done <= 100)
+                                //    {
+                                new Action<int, string>(UpdateProgress).Invoke(int_percent_done, string.Format(" -> Reading Index: 0x{0:x8} of 0x{1:x8}", CurrentIndex, e.TotalCount));
+                                //    }
+                                //    if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
+                                //}
                             }
                             //switch (sdt)
                             //{
@@ -1821,70 +1821,56 @@
                             byte[] guid = SearchGuid.ToByteArray();
                             guid[guid.Length - 1]++; // increment the search guid by 1
                             Guid new_SearchGuid = new Guid(guid);
-                            const int item_count = 0x100;
+                            //const int item_count = 0x100;
                             using (SearchResultWriter writer = new SearchResultWriter((int)(reader.ResultCount), new_SearchGuid))
                             {
-                                ////int Last_Whole_Percent_Done = 0;
-                                //for (int i = 0; i < reader.ResultCount; i += item_count)
-                                //{                                   
-                                //    var items = reader.GetResultRangeAtIndex(i,item_count, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress));
-                                //    for (int j = 0; j < items.Count(); j++)
-                                //    {
-                                //        int index = i + j;
-                                //        var item = items[j];
-                                //        provider.OpenProvider();
-                                //        int bytesRead = 0;
-                                //        byte[] data = new byte[STEP_SIZE];
-                                //        provider.ReadProcessMemory(item.Address, STEP_SIZE, out bytesRead, out data);
-                                //        BaseEventHandler<OnBytesReadEventArgs> t = new BaseEventHandler<OnBytesReadEventArgs>(search_provider_OnBytesRead);
-                                //        OnBytesReadEventArgs t_args = new OnBytesReadEventArgs(this, writer, data, (uint)index, (uint)reader.ResultCount, false);
-                                //        t.Invoke(t_args);
-                                //        t = null;
-                                //        t_args = null;
-                                //        data = null;
-                                //        provider.CloseProvider();                                        
-                                //        //double double_percent_done = 100.0 * (double)((double)index / (double)reader.ResultCount);
-                                //        //int int_percent_done = (int)double_percent_done;
-                                //        //if (i % item_count == 0)
-                                //        //{
-                                //        //    if (int_percent_done <= 100)
-                                //        //    {
-                                //        //        new Action<int, string>(UpdateProgress).Invoke(int_percent_done, string.Format(" -> Loading value for Address: 0x{0:x8}", item.Address));
-                                //        //        //Last_Whole_Percent_Done = int_percent_done;
-                                //        //    }
-                                //        //}
-                                //    }                                    
-                                //}
-                                for (int i = 0; i < reader.ResultCount; i += item_count)
-                                {
-                                    var items = reader.GetResultRangeAtIndex(i, item_count, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress));
+                                var items = reader.GetSearchAddressValueMatches((IAcceptsProcessAndConfig)this,SearchArgs, new Action<int, string>(UpdateProgress));
 
-                                    provider.OpenProvider();
-                                    int count = 0;
-                                    foreach (var item in items)
-                                    {
-                                        uint bytesToRead = STEP_SIZE;
-                                        int bytesRead = 0;
-                                        byte[] data = new byte[bytesToRead];
-                                        provider.ReadProcessMemory(item.Address, bytesToRead, out bytesRead, out data);
-                                        BaseEventHandler<OnBytesReadEventArgs> t = new BaseEventHandler<OnBytesReadEventArgs>(search_provider_OnBytesRead_compare_only);
-                                        OnBytesReadEventArgs t_args = new OnBytesReadEventArgs(this, writer, data, (uint)count, (uint)item_count, true);
-                                        t.Invoke(t_args);
-                                        t = null;
-                                        t_args = null;
-                                        count++;
-                                    }
-                                    double double_percent_done = 100.0 * (double)((double)i / (double)reader.ResultCount);
-                                    int int_percent_done = (int)double_percent_done;
-                                    if (i % item_count == 0)
+                                foreach (var item in items)
+                                {
+                                    switch (SearchArgs.DataType)
                                     {
-                                        if (int_percent_done <= 100)
-                                        {
-                                            new Action<int, string>(UpdateProgress).Invoke(int_percent_done, string.Format(" -> Loaded {0} value(s) from index: 0x{1:x8}", item_count, i));
-                                            //Last_Whole_Percent_Done = int_percent_done;
-                                        }
+                                        case SearchDataTypes._8bits:
+                                            if (SearchArgs.IsUnsignedDataType)
+                                            {
+                                                writer.WriteResult<byte>(item.Address, Convert.ToByte(item.Value));
+                                            }
+                                            else
+                                            {
+                                                writer.WriteResult<sbyte>(item.Address, Convert.ToSByte(item.Value));
+                                            }
+                                            break;
+                                        case SearchDataTypes._16bits:
+                                            if (SearchArgs.IsUnsignedDataType)
+                                            {
+                                                writer.WriteResult<ushort>(item.Address, Convert.ToUInt16(item.Value));
+                                            }
+                                            else
+                                            {
+                                                writer.WriteResult<short>(item.Address, Convert.ToInt16(item.Value));
+                                            }
+                                            break;
+                                        case SearchDataTypes._32bits:
+                                            if (SearchArgs.IsUnsignedDataType)
+                                            {
+                                                writer.WriteResult<uint>(item.Address, Convert.ToUInt32(item.Value));
+                                            }
+                                            else
+                                            {
+                                                writer.WriteResult<int>(item.Address, Convert.ToInt32(item.Value));
+                                            }
+                                            break;
+                                        case SearchDataTypes._64bits:
+                                            if (SearchArgs.IsUnsignedDataType)
+                                            {
+                                                writer.WriteResult<ulong>(item.Address, Convert.ToUInt64(item.Value));
+                                            }
+                                            else
+                                            {
+                                                writer.WriteResult<long>(item.Address, Convert.ToInt64(item.Value));
+                                            }
+                                            break;
                                     }
-                                    provider.CloseProvider();
                                 }
                             }
                             SearchGuid = new_SearchGuid;

 

  ViewVC Help
Powered by ViewVC 1.1.22