/[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 407 by william, Thu Jun 21 12:51:57 2012 UTC revision 408 by william, Thu Jun 21 18:10:21 2012 UTC
# Line 6  using RomCheater.Logging; Line 6  using RomCheater.Logging;
6  using System.Diagnostics;  using System.Diagnostics;
7  using RomCheater.PluginFramework.Interfaces;  using RomCheater.PluginFramework.Interfaces;
8  using System.IO;  using System.IO;
9    using RomCheater.PluginFramework.Events;
10    
11  namespace Sojaner.MemoryScanner.MemoryProviers  namespace Sojaner.MemoryScanner.MemoryProviers
12  {  {
# Line 18  namespace Sojaner.MemoryScanner.MemoryPr Line 19  namespace Sojaner.MemoryScanner.MemoryPr
19          IMemoryReader,          IMemoryReader,
20          IMemoryWriter,          IMemoryWriter,
21          IFileWriter,          IFileWriter,
22          IDisposable          IDisposable,
23            IAcceptsBytesReadEvent
24      {      {
25          private ProcessMemoryReader provider;          private ProcessMemoryReader provider;
26          public BaseMemoryProvider() { this.AcceptedPlugin = null; this.AcceptedProcess = null; isClosed = true; isOpen = false; }          public BaseMemoryProvider() { this.AcceptedPlugin = null; this.AcceptedProcess = null; isClosed = true; isOpen = false; }
# Line 27  namespace Sojaner.MemoryScanner.MemoryPr Line 29  namespace Sojaner.MemoryScanner.MemoryPr
29          public BaseMemoryProvider(IAcceptsProcessAndConfig pconfig) : this() { this.AcceptedPlugin = pconfig.AcceptedPlugin; this.AcceptedProcess = pconfig.AcceptedProcess; }          public BaseMemoryProvider(IAcceptsProcessAndConfig pconfig) : this() { this.AcceptedPlugin = pconfig.AcceptedPlugin; this.AcceptedProcess = pconfig.AcceptedProcess; }
30    
31    
32            public event BaseEventHandler<OnBytesReadEventArgs> OnBytesRead;
33    
34          private bool isOpen { get; set; }          private bool isOpen { get; set; }
35          private bool isClosed { get; set; }          private bool isClosed { get; set; }
36    
37            private void provider_OnBytesRead(OnBytesReadEventArgs e)
38            {
39                e.Sender = this;
40                if (this.OnBytesRead != null)
41                    this.OnBytesRead.Invoke(e);
42            }
43          #region Open/Close Provider          #region Open/Close Provider
44          #region public virtual void OpenProvider()          #region public virtual void OpenProvider()
45          public virtual void OpenProvider()          public virtual void OpenProvider()
# Line 43  namespace Sojaner.MemoryScanner.MemoryPr Line 53  namespace Sojaner.MemoryScanner.MemoryPr
53              {              {
54                  provider = new ProcessMemoryReader();                  provider = new ProcessMemoryReader();
55                  provider.ReadProcess = this.AcceptedProcess;                  provider.ReadProcess = this.AcceptedProcess;
56                    provider.OnBytesRead += new BaseEventHandler<OnBytesReadEventArgs>(provider_OnBytesRead);
57                  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) { logger.Error.WriteLine("{0}.OpenProvider() Could not attach to process: {1}", "", this.GetType().Name, this.AcceptedProcess.ToString()); return; }
58                  provider.OpenProcess();                  provider.OpenProcess();
59                  isOpen = true;                  isOpen = true;
# Line 261  namespace Sojaner.MemoryScanner.MemoryPr Line 272  namespace Sojaner.MemoryScanner.MemoryPr
272          }          }
273          #endregion          #endregion
274          #region public virtual void ReadProcessMemoryAtOnce(int MemoryAddress, uint bytesToRead, out int bytesRead, out byte[] data)          #region public virtual void ReadProcessMemoryAtOnce(int MemoryAddress, uint bytesToRead, out int bytesRead, out byte[] data)
275            public virtual void ReadProcessMemoryAtOnce(uint MemoryAddress, uint bytesToRead, object UserState)
276            {
277                if (!EnsureProviderIsOpen()) { return; }
278                try { provider.ReadProcessMemoryAtOnce(MemoryAddress, bytesToRead,UserState); }
279                catch {  }
280            }
281          public virtual void ReadProcessMemoryAtOnce(uint MemoryAddress, uint bytesToRead, out int bytesRead, out byte[] data)          public virtual void ReadProcessMemoryAtOnce(uint MemoryAddress, uint bytesToRead, out int bytesRead, out byte[] data)
282          {          {
283              bytesRead = 0x00;              bytesRead = 0x00;

Legend:
Removed from v.407  
changed lines
  Added in v.408

  ViewVC Help
Powered by ViewVC 1.1.22