/[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 07:39:39	472
+++ trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2013/06/03 09:21:03	473
@@ -67,6 +67,11 @@
         //new Action<int, string>(UpdateProgress) to use this as a delegate
         private void UpdateProgress(int value, string message)
         {
+            //string stacktrace = string.Empty;
+            //if (value == 0 && message == string.Empty)
+            //{
+            //    stacktrace = System.Environment.StackTrace;
+            //}
             resultsprogress.Value = value;
             resultsprogress.Message = message;
         }
@@ -1370,16 +1375,19 @@
                                 if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
                             }
                             catch (EndOfStreamException) { }
-                            double double_percent_done = 100.0 * (double)((double)CurrentIndex / (double)e.TotalCount);
-                            int int_percent_done = (int)double_percent_done;
-                            if (int_percent_done != Last_Whole_Percent_Done && CurrentIndex % 100000 == 0)
+                            if (e.ReportProgress)
                             {
-                                if (int_percent_done <= 100)
+                                double double_percent_done = 100.0 * (double)((double)CurrentIndex / (double)e.TotalCount);
+                                int int_percent_done = (int)double_percent_done;
+                                if (int_percent_done != Last_Whole_Percent_Done && CurrentIndex % 100000 == 0)
                                 {
-                                    new Action<int, string>(UpdateProgress).Invoke(int_percent_done, string.Format(" -> Reading Address: 0x{0:x8}", (CurrentIndex + MemoryRangeStart)));
-                                    Last_Whole_Percent_Done = int_percent_done;
+                                    if (int_percent_done <= 100)
+                                    {
+                                        new Action<int, string>(UpdateProgress).Invoke(int_percent_done, string.Format(" -> Reading Address: 0x{0:x8}", (CurrentIndex + MemoryRangeStart)));
+                                        Last_Whole_Percent_Done = int_percent_done;
+                                    }
+                                    if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
                                 }
-                                if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
                             }
                             switch (sdt)
                             {
@@ -1462,31 +1470,50 @@
                             guid[guid.Length - 1]++; // increment the search guid by 1
                             Guid new_SearchGuid = new Guid(guid);
                             //provider.OnBytesRead += new BaseEventHandler<OnBytesReadEventArgs>(search_provider_OnBytesRead);
-                            int count = 0;
+                            //int count = 0;
                             //int Last_Whole_Percent_Done = 0;
                             //var results = reader.GetResults(SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress));
 
                             //reader.WriteUpdatedEntries(new_SearchGuid, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress));
 
+                            const int item_count = 0x1;
                             using (SearchResultWriter writer = new SearchResultWriter((int)(reader.ResultCount), new_SearchGuid))
                             {
-                                for (int i = 0; i < reader.ResultCount; i++)
-                                {
+                                //int Last_Whole_Percent_Done = 0;
+                                for (int i = 0; i < reader.ResultCount; i += item_count)
+                                {                                   
                                     var item = reader.GetResultAtIndex(i, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress));
-                                    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, item.Address, (uint)reader.ResultCount);
-                                    t.Invoke(t_args);
-                                    t = null;
-                                    t_args = null;
-                                    double percent_done = 100.0 * ((double)count / (double)reader.ResultCount);
-                                    new Action<int, string>(UpdateProgress).Invoke((int)percent_done, string.Format(" -> Reading Address: 0x{0:x8}", item.Address));
-                                    count++;
-                                    data = null;
-                                    provider.CloseProvider();
+                                    double double_percent_done = 100.0 * (double)((double)i / (double)reader.ResultCount);
+                                    int int_percent_done = (int)double_percent_done;
+                                    if (i % 10 == 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 j = 0; j < items.Count(); 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, item.Address, (uint)reader.ResultCount, false);
+                                        t.Invoke(t_args);
+                                        t = null;
+                                        t_args = null;
+                                        data = null;
+                                        provider.CloseProvider();
+                                        //double percent_done = 100.0 * ((double)i+(double)j / (double)reader.ResultCount);
+
+                                        
+
+                                        //double percent_done = 100.0 * ((double)i / (double)reader.ResultCount);
+                                        //new Action<int, string>(UpdateProgress).Invoke((int)percent_done, string.Format(" -> Reading Address: 0x{0:x8}", item.Address));
+                                    //}                                 
                                 }
                             }
                             SearchGuid = new_SearchGuid;

 

  ViewVC Help
Powered by ViewVC 1.1.22