/[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

revision 516 by william, Wed Jun 5 03:23:27 2013 UTC revision 517 by william, Wed Jun 5 03:49:00 2013 UTC
# Line 72  namespace RomCheater.Docking Line 72  namespace RomCheater.Docking
72              IProgressMessage pm = (o as IProgressMessage);              IProgressMessage pm = (o as IProgressMessage);
73              if (pm == null) { return; }              if (pm == null) { return; }
74              resultsprogress.Value = pm.Progress;              resultsprogress.Value = pm.Progress;
75              resultsprogress.Message = pm.Message;                        resultsprogress.Message = pm.Message;
76          }          }
77    
78          private void UpdateProgress(int progress, string message)          private void UpdateProgress(int progress, string message)
79          {          {
80              // detach the progress update from execution within the current thread (so it does not block a cpu-intensive or long running sequence)              // detach the progress update from execution within the current thread (so it does not block a cpu-intensive or long running sequence)
81              Thread t = new Thread(new ParameterizedThreadStart(thread_UpdateProgress));              Thread t = new Thread(new ParameterizedThreadStart(thread_UpdateProgress));
82              t.SetApartmentState(ApartmentState.MTA);              t.SetApartmentState(ApartmentState.STA);
83              t.Start(new ProgressMessage(progress, message));              t.Start(new ProgressMessage(progress, message));
84                //resultsprogress.Value = progress;
85                //resultsprogress.Message = message;
86          }          }
87    
88          #region IAcceptsProcess<Process> Members          #region IAcceptsProcess<Process> Members
# Line 1437  namespace RomCheater.Docking Line 1439  namespace RomCheater.Docking
1439                      double double_percent_done = 100.0 * (double)((double)CurrentIndex / (double)e.TotalCount);                      double double_percent_done = 100.0 * (double)((double)CurrentIndex / (double)e.TotalCount);
1440                      int int_percent_done = (int)double_percent_done;                      int int_percent_done = (int)double_percent_done;
1441    
1442                      //int align_base = 1000;                      double align_base = 1024;
1443                      //int align_magnitude = 1;                      double align_magnitude = 0.25;
1444                      //int alignment = align_base * align_magnitude;                      double alignment = align_base * align_magnitude;
1445                      if ((int_percent_done != Last_Whole_Percent_Done) )// && (CurrentIndex % alignment) == 0)                      if ((int_percent_done != Last_Whole_Percent_Done) && (CurrentIndex % alignment) == 0)
1446                      {                      {
1447                          if (int_percent_done <= 100)                          if (int_percent_done <= 100)
1448                          {                          {
1449                              string message = string.Format(" -> Reading Address: 0x{0:x8} of 0x{1:x8}", (CurrentIndex + MemoryRangeStart), (CurrentIndex + MemoryRangeStart) + e.Data.Length);                              string message = string.Format(" -> Reading Address: 0x{0:x8} of 0x{1:x8}", (CurrentIndex + MemoryRangeStart), (CurrentIndex + MemoryRangeStart) + e.Data.Length);
1450                              //UpdateProgress(int_percent_done, message);                              UpdateProgress(int_percent_done, message);
1451                              new Action<int, string>(UpdateProgress).Invoke(int_percent_done, message);                              //new Action<int, string>(UpdateProgress).Invoke(int_percent_done, message);
1452                              Last_Whole_Percent_Done = int_percent_done;                              Last_Whole_Percent_Done = int_percent_done;
1453                          }                          }
1454                          if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }                          if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
# Line 1790  namespace RomCheater.Docking Line 1792  namespace RomCheater.Docking
1792                  SearchDataTypes sdt = SearchArgs.DataType;                  SearchDataTypes sdt = SearchArgs.DataType;
1793                  //byte[] buffered_mem = new byte[(MemoryRangeSize - MemoryRangeStart)]; // throws OutOfMemoryException if size is over 2G                  //byte[] buffered_mem = new byte[(MemoryRangeSize - MemoryRangeStart)]; // throws OutOfMemoryException if size is over 2G
1794                  logger.Debug.WriteLine(string.Format("Buffered Memory Size -> 0x{0:x8}", MemoryRangeSize - MemoryRangeStart));                  logger.Debug.WriteLine(string.Format("Buffered Memory Size -> 0x{0:x8}", MemoryRangeSize - MemoryRangeStart));
1795                  new Action<int, string>(UpdateProgress).Invoke(0, string.Format("Search is Warming Up...Please Wait..."));                  UpdateProgress(0, string.Format("Search is Warming Up...Please Wait..."));
1796                    //new Action<int, string>(UpdateProgress).Invoke(0, string.Format("Search is Warming Up...Please Wait..."));
1797                  Stopwatch provider_st = new Stopwatch();                  Stopwatch provider_st = new Stopwatch();
1798                  provider_st.Start();                  provider_st.Start();
1799                  using (GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))                  using (GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
# Line 2441  namespace RomCheater.Docking Line 2444  namespace RomCheater.Docking
2444                                                  if (int_percent_done <= 100)                                                  if (int_percent_done <= 100)
2445                                                  {                                                  {
2446                                                      //Last_Whole_Percent_Done = int_percent_done;                                                      //Last_Whole_Percent_Done = int_percent_done;
2447                                                      new Action<int, string>(UpdateProgress).Invoke(int_percent_done, string.Format(" -> Reading Address: 0x{0:x8}", i + MemoryRangeStart));                                                      UpdateProgress(int_percent_done, string.Format(" -> Reading Address: 0x{0:x8}", i + MemoryRangeStart));
2448                                                        //new Action<int, string>(UpdateProgress).Invoke(int_percent_done, string.Format(" -> Reading Address: 0x{0:x8}", i + MemoryRangeStart));
2449                                                  }                                                  }
2450                                                  //}                                                  //}
2451                                                  //this.Refresh();                                                  //this.Refresh();
# Line 2603  namespace RomCheater.Docking Line 2607  namespace RomCheater.Docking
2607          private void SearchWorkerThread_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)          private void SearchWorkerThread_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
2608          {          {
2609              try { if ((bool)e.Result) { logger.Warn.WriteLine("Search operation was cancelled.");              try { if ((bool)e.Result) { logger.Warn.WriteLine("Search operation was cancelled.");
2610                  new Action<int, string>(UpdateProgress).Invoke(0, string.Empty);                  //new Action<int, string>(UpdateProgress).Invoke(0, string.Empty);
2611                UpdateProgress(0, string.Empty);
2612                  return; }                  return; }
2613              }              }
2614              catch (InvalidCastException) { }              catch (InvalidCastException) { }
# Line 2616  namespace RomCheater.Docking Line 2621  namespace RomCheater.Docking
2621              catch (InvalidCastException) { }              catch (InvalidCastException) { }
2622              catch (Exception ex) { throw ex; }              catch (Exception ex) { throw ex; }
2623    
2624              new Action<int, string>(UpdateProgress).Invoke(100, string.Empty);              UpdateProgress(100, String.Empty);
2625                //new Action<int, string>(UpdateProgress).Invoke(100, string.Empty);
2626              bool unsigned = SearchArgs.IsUnsignedDataType;              bool unsigned = SearchArgs.IsUnsignedDataType;
2627              using (SearchResultReader reader = new SearchResultReader(SearchGuid))              using (SearchResultReader reader = new SearchResultReader(SearchGuid))
2628              {              {
# Line 2676  namespace RomCheater.Docking Line 2682  namespace RomCheater.Docking
2682              btnSearch.Enabled = true;              btnSearch.Enabled = true;
2683              grpCompareType.Enabled = true;              grpCompareType.Enabled = true;
2684              grpCompareValue.Enabled = true;              grpCompareValue.Enabled = true;
2685              new Action<int, string>(UpdateProgress).Invoke(0, string.Empty);              UpdateProgress(0, string.Empty);
2686                //new Action<int, string>(UpdateProgress).Invoke(0, string.Empty);
2687              grpDataType.Enabled = false;              grpDataType.Enabled = false;
2688              // resume process on reset, incase it was suspended              // resume process on reset, incase it was suspended
2689              ThreadControl.ResumeProcess(this.AcceptedProcess.Id);              ThreadControl.ResumeProcess(this.AcceptedProcess.Id);
# Line 2728  namespace RomCheater.Docking Line 2735  namespace RomCheater.Docking
2735              lstResults.Items.Clear();              lstResults.Items.Clear();
2736    
2737              if (lstResults.Items.Count > 0) { timer_update_results.Enabled = true; }              if (lstResults.Items.Count > 0) { timer_update_results.Enabled = true; }
2738              else { timer_update_results.Enabled = false; }                          else { timer_update_results.Enabled = false; }
2739              new Action<int, string>(UpdateProgress).Invoke(0, string.Empty);              UpdateProgress(0, string.Empty);
2740                //new Action<int, string>(UpdateProgress).Invoke(0, string.Empty);
2741              bool _is_unsigned = chkUnsigned.Checked;              bool _is_unsigned = chkUnsigned.Checked;
2742              SearchType search_type = new SearchType();              SearchType search_type = new SearchType();
2743              SearchDataTypes _data_type = new SearchDataTypes();              SearchDataTypes _data_type = new SearchDataTypes();

Legend:
Removed from v.516  
changed lines
  Added in v.517

  ViewVC Help
Powered by ViewVC 1.1.22