/[RomCheater]/trunk/Win32/Sojaner.MemoryScanner/MemoryProviers/BaseMemoryProvider.cs
ViewVC logotype

Diff of /trunk/Win32/Sojaner.MemoryScanner/MemoryProviers/BaseMemoryProvider.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 811 by william, Mon Jun 17 09:31:52 2013 UTC revision 812 by william, Tue Apr 15 14:52:10 2014 UTC
# Line 21  using System.IO; Line 21  using System.IO;
21  using RomCheater.PluginFramework.Events;  using RomCheater.PluginFramework.Events;
22  using ManagedWinapi;  using ManagedWinapi;
23  using RomCheater.Core;  using RomCheater.Core;
24    using Enterprise.Logging;
25    
26  namespace Sojaner.MemoryScanner.MemoryProviers  namespace Sojaner.MemoryScanner.MemoryProviers
27  {  {
# Line 60  namespace Sojaner.MemoryScanner.MemoryPr Line 61  namespace Sojaner.MemoryScanner.MemoryPr
61          {          {
62              if (isOpen)              if (isOpen)
63              {              {
64                  logger.Warn.WriteLine("Provider has already been opened.");                  gLog.Warn.WriteLine("Provider has already been opened.");
65                  return;                  return;
66              }              }
67              try              try
# Line 68  namespace Sojaner.MemoryScanner.MemoryPr Line 69  namespace Sojaner.MemoryScanner.MemoryPr
69                  provider = new ProcessMemoryReader();                  provider = new ProcessMemoryReader();
70                  provider.ReadProcess = this.AcceptedProcess;                  provider.ReadProcess = this.AcceptedProcess;
71                  provider.OnBytesRead += new BaseEventHandler<OnBytesReadEventArgs>(provider_OnBytesRead);                  provider.OnBytesRead += new BaseEventHandler<OnBytesReadEventArgs>(provider_OnBytesRead);
72                  if (provider.ReadProcess == null) { logger.Error.WriteLine("{0}.OpenProvider() Could not attach to process: {1}", "", this.GetType().Name, this.AcceptedProcess.ToString()); return; }                  if (provider.ReadProcess == null) { gLog.Error.WriteLine("{0}.OpenProvider() Could not attach to process: {1}", "", this.GetType().Name, this.AcceptedProcess.ToString()); return; }
73                  //provider.OpenProcess();                  //provider.OpenProcess();
74                  isOpen = true;                  isOpen = true;
75                  isClosed = false;                  isClosed = false;
76              }              }
77              catch (Exception ex)              catch (Exception ex)
78              {              {
79                  logger.Error.WriteLine("Failed to open provider: {0}{1}", System.Environment.NewLine, ex.ToString());                  gLog.Error.WriteLine("Failed to open provider: {0}{1}", System.Environment.NewLine, ex.ToString());
80                  isOpen = false;                  isOpen = false;
81                  isClosed = true;                  isClosed = true;
82              }              }
# Line 86  namespace Sojaner.MemoryScanner.MemoryPr Line 87  namespace Sojaner.MemoryScanner.MemoryPr
87          {          {
88              if (isClosed)              if (isClosed)
89              {              {
90                  logger.Warn.WriteLine("Provider has already been closed.");                  gLog.Warn.WriteLine("Provider has already been closed.");
91                  return;                  return;
92              }              }
93              if (!isOpen)              if (!isOpen)
94              {              {
95                  logger.Warn.WriteLine("Provider cannot be closed, it was never opened...attempting to open provider.");                  gLog.Warn.WriteLine("Provider cannot be closed, it was never opened...attempting to open provider.");
96                  OpenProvider();                  OpenProvider();
97                  if (!isOpen)                  if (!isOpen)
98                  {                  {
99                      logger.Warn.WriteLine("Could not open provider");                      gLog.Warn.WriteLine("Could not open provider");
100                      return;                      return;
101                  }                  }
102              }              }
# Line 110  namespace Sojaner.MemoryScanner.MemoryPr Line 111  namespace Sojaner.MemoryScanner.MemoryPr
111              }              }
112              catch (Exception ex)              catch (Exception ex)
113              {              {
114                  logger.Error.WriteLine("Failed to close provider: {0}{1}", System.Environment.NewLine, ex.ToString());                  gLog.Error.WriteLine("Failed to close provider: {0}{1}", System.Environment.NewLine, ex.ToString());
115                  isClosed = false;                  isClosed = false;
116                  if (isOpen)                  if (isOpen)
117                  {                  {
# Line 139  namespace Sojaner.MemoryScanner.MemoryPr Line 140  namespace Sojaner.MemoryScanner.MemoryPr
140                  catch (Exception ex)                  catch (Exception ex)
141                  {                  {
142                      if (LogError)                      if (LogError)
143                          logger.Error.WriteLine(ex.ToString());                          gLog.Verbose.Error.WriteLine(ex.ToString());
144                      if (ThrowError)                      if (ThrowError)
145                          throw ex;                          throw ex;
146                      return false;                      return false;

Legend:
Removed from v.811  
changed lines
  Added in v.812

  ViewVC Help
Powered by ViewVC 1.1.22