ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/Win32/Sojaner.MemoryScanner/MemoryProviers/BaseMemoryProvider.cs
(Generate patch)

Comparing trunk/Win32/Sojaner.MemoryScanner/MemoryProviers/BaseMemoryProvider.cs (file contents):
Revision 407 by william, Thu Jun 21 12:51:57 2012 UTC vs.
Revision 408 by william, Thu Jun 21 18:10:21 2012 UTC

# Line 6 | Line 6 | using RomCheater.Logging;
6   using System.Diagnostics;
7   using RomCheater.PluginFramework.Interfaces;
8   using System.IO;
9 + using RomCheater.PluginFramework.Events;
10  
11   namespace Sojaner.MemoryScanner.MemoryProviers
12   {
# Line 18 | Line 19 | namespace Sojaner.MemoryScanner.MemoryPr
19          IMemoryReader,
20          IMemoryWriter,
21          IFileWriter,
22 <        IDisposable
22 >        IDisposable,
23 >        IAcceptsBytesReadEvent
24      {
25          private ProcessMemoryReader provider;
26          public BaseMemoryProvider() { this.AcceptedPlugin = null; this.AcceptedProcess = null; isClosed = true; isOpen = false; }
# Line 27 | Line 29 | namespace Sojaner.MemoryScanner.MemoryPr
29          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; }
35          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
44          #region public virtual void OpenProvider()
45          public virtual void OpenProvider()
# Line 43 | Line 53 | namespace Sojaner.MemoryScanner.MemoryPr
53              {
54                  provider = new ProcessMemoryReader();
55                  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; }
58                  provider.OpenProcess();
59                  isOpen = true;
# Line 261 | Line 272 | namespace Sojaner.MemoryScanner.MemoryPr
272          }
273          #endregion
274          #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)
282          {
283              bytesRead = 0x00;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines