/[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 03:34:46	462
+++ trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2013/06/03 04:34:39	463
@@ -1376,8 +1376,7 @@
                             {
                                 if (int_percent_done <= 100)
                                 {
-                                    resultsprogress.Value = int_percent_done;
-                                    resultsprogress.Message = string.Format(" -> Reading Address: 0x{0:x8}", (CurrentIndex + MemoryRangeStart));
+                                    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; }
@@ -1426,9 +1425,7 @@
                 SearchDataTypes sdt = SearchArgs.DataType;
                 //byte[] buffered_mem = new byte[(MemoryRangeSize - MemoryRangeStart)]; // throws OutOfMemoryException if size is over 2G
                 logger.Debug.WriteLine(string.Format("Buffered Memory Size -> 0x{0:x8}", MemoryRangeSize - MemoryRangeStart));
-                resultsprogress.Value = 0;
-                resultsprogress.Message = string.Format("Search is Warming Up...Please Wait...");
-
+                new Action<int, string>(UpdateProgress).Invoke(0, string.Format("Search is Warming Up...Please Wait..."));
                 Stopwatch provider_st = new Stopwatch();
                 provider_st.Start();
                 using (GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
@@ -1465,12 +1462,17 @@
                             guid[guid.Length-1]++; // increment the search guid by 1
                             Guid new_SearchGuid = new Guid(guid);
                             provider.OpenProvider();
-                            provider.OnBytesRead += new BaseEventHandler<OnBytesReadEventArgs>(search_provider_OnBytesRead);
+                            //provider.OnBytesRead += new BaseEventHandler<OnBytesReadEventArgs>(search_provider_OnBytesRead);
                             foreach (var item in reader.GetResults(SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress)))
                             {
                                 using (SearchResultWriter writer = new SearchResultWriter((int)(reader.ResultCount), new_SearchGuid))
                                 {
-                                    provider.ReadProcessMemoryAtOnce(item.Address, STEP_SIZE, writer);
+                                    //provider.ReadProcessMemoryAtOnce(item.Address, STEP_SIZE, writer);
+                                    int bytesRead =0;
+                                    byte[] data = new byte[STEP_SIZE];
+                                    provider.ReadProcessMemory(item.Address, STEP_SIZE, out bytesRead, out data);                                    
+                                    new BaseEventHandler<OnBytesReadEventArgs>(search_provider_OnBytesRead).Invoke(new OnBytesReadEventArgs(this, writer, data, item.Address, (uint)reader.ResultCount));
+
                                 }
                             }
                             provider.CloseProvider();
@@ -1914,10 +1916,9 @@
                                                 //if (int_percent_done != Last_Whole_Percent_Done && i % 100000 == 0)
                                                 //{
                                                 if (int_percent_done <= 100)
-                                                {
-                                                    resultsprogress.Value = int_percent_done;
-                                                    resultsprogress.Message = string.Format(" -> Reading Address: 0x{0:x8}", i + MemoryRangeStart);
+                                                {                                                    
                                                     //Last_Whole_Percent_Done = int_percent_done;
+                                                    new Action<int, string>(UpdateProgress).Invoke(int_percent_done, string.Format(" -> Reading Address: 0x{0:x8}", i + MemoryRangeStart));
                                                 }
                                                 //}
                                                 //this.Refresh();
@@ -2070,7 +2071,10 @@
 
         private void SearchWorkerThread_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
         {
-            try { if ((bool)e.Result) { logger.Warn.WriteLine("Search operation was cancelled."); resultsprogress.Value = 0; resultsprogress.Message = ""; return; } }
+            try { if ((bool)e.Result) { logger.Warn.WriteLine("Search operation was cancelled."); 
+                new Action<int, string>(UpdateProgress).Invoke(0, string.Empty);
+                return; } 
+            }
             catch (InvalidCastException) { }
             try
             {
@@ -2081,7 +2085,7 @@
             catch (InvalidCastException) { }
             catch (Exception ex) { throw ex; }
 
-            resultsprogress.Value = 100;
+            new Action<int, string>(UpdateProgress).Invoke(100, string.Empty);
             bool unsigned = SearchArgs.IsUnsignedDataType;
             using (SearchResultReader reader = new SearchResultReader(SearchGuid))
             {
@@ -2141,8 +2145,7 @@
             btnSearch.Enabled = true;
             grpCompareType.Enabled = true;
             grpCompareValue.Enabled = true;
-            resultsprogress.Value = 0;
-            resultsprogress.Message = "";
+            new Action<int, string>(UpdateProgress).Invoke(0, string.Empty);
             grpDataType.Enabled = false;
             // resume process on reset, incase it was suspended
             ThreadControl.ResumeProcess(this.AcceptedProcess.Id);
@@ -2193,10 +2196,8 @@
             lstResults.Items.Clear();
 
             if (lstResults.Items.Count > 0) { timer_update_results.Enabled = true; }
-            else { timer_update_results.Enabled = false; }
-
-
-            resultsprogress.Value = 0;
+            else { timer_update_results.Enabled = false; }            
+            new Action<int, string>(UpdateProgress).Invoke(0, string.Empty);
             bool _is_unsigned = chkUnsigned.Checked;
             SearchType search_type = new SearchType();
             SearchDataTypes _data_type = new SearchDataTypes();

 

  ViewVC Help
Powered by ViewVC 1.1.22