/[RomCheater]/trunk/RomCheater/Docking/UI/UIMemoryViewer.cs
ViewVC logotype

Diff of /trunk/RomCheater/Docking/UI/UIMemoryViewer.cs

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

--- trunk/RomCheater/Docking/UI/UIMemoryViewer.cs	2012/05/31 09:31:57	206
+++ trunk/RomCheater/Docking/UI/UIMemoryViewer.cs	2012/06/02 10:43:05	214
@@ -147,10 +147,10 @@
             editor.ShowDialog();
             if (editor.BytesEdited)
             {
-                DynamicByteProvider _DynamicByteProvider = new DynamicByteProvider(editor.AsBytes);
-                txtData.ByteProvider = _DynamicByteProvider;
-                _DynamicByteProvider.Changed += new EventHandler(HexResourceViewerBytes_Changed);
-                this.WriteCurrentBytes();
+                //DynamicByteProvider _DynamicByteProvider = new DynamicByteProvider(editor.AsBytes);
+                //txtData.ByteProvider = _DynamicByteProvider;
+                //_DynamicByteProvider.Changed += new EventHandler(HexResourceViewerBytes_Changed);
+                this.WriteCurrentBytes(this.CURRENT_TOP_ADDR, editor.AsBytes);
             }
             this.UpdateEnabled = reenable;
         }
@@ -268,18 +268,18 @@
             }
             catch (Exception ex) { logger.Error.WriteLine("{0}.UpdateMemroyView():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); }
         }
-        private void HexResourceViewerBytes_Changed(object sender, System.EventArgs e)
-        {
-            this.WriteCurrentBytes();
-        }
-        private void WriteCurrentBytes()
+        //private void HexResourceViewerBytes_Changed(object sender, System.EventArgs e)
+        //{
+        //    this.WriteCurrentBytes();
+        //}
+        private void WriteCurrentBytes(uint start_address, byte[] data)
         {
             try
             {
                 if (AcceptedProcess == null) { return; }
                 if (AcceptedPlugin == null) { return; }
                 // Byte changed
-                byte[] data = (txtData.ByteProvider as DynamicByteProvider).Bytes.ToArray();
+                //byte[] data = (txtData.ByteProvider as DynamicByteProvider).Bytes.ToArray();
                 
 
                 Sojaner.MemoryScanner.ProcessMemoryReader reader = new Sojaner.MemoryScanner.ProcessMemoryReader();
@@ -287,11 +287,11 @@
                 reader.OpenProcess();
                 int bytesReadSize;
 
-                for (int i = 0; i < data.Length; i += sizeof(uint))
+                for (int i = 0; i < data.Length; i ++)
                 {
-                    uint addr = (uint)(this.CURRENT_TOP_ADDR + i);
-                    uint data_to_write = BitConverter.ToUInt32(data, i);
-                    reader.WriteProcessMemory((UIntPtr)addr, data, out bytesReadSize);
+                    uint addr = (uint)(start_address + i);
+                    byte data_to_write = data[i];
+                    reader.WriteProcessMemory((UIntPtr)addr, data_to_write, out bytesReadSize);
                 }
             }
             catch (Exception ex) { logger.Error.WriteLine("{0}.WriteCurrentBytes():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); }
@@ -308,7 +308,7 @@
                 //this.Logger.LogDebugMessage(string.Format("RunWorkerCompeleted() -> Memory Size: {0}0x{2:X8}{1}", "{", "}", RamData.Length));
                 DynamicByteProvider _DynamicByteProvider = new DynamicByteProvider(RamData);
                 txtData.ByteProvider = _DynamicByteProvider;
-                _DynamicByteProvider.Changed += new EventHandler(HexResourceViewerBytes_Changed);
+                //_DynamicByteProvider.Changed += new EventHandler(HexResourceViewerBytes_Changed);
             }
             catch (ObjectDisposedException) { } // ignore errors aobut disposed objects (usually only happens when the parent closes)
             catch (Exception ex) { logger.Error.WriteLine("{0}.ResultsUpdateWorkerThread_RunWorkerCompleted():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); }
@@ -486,5 +486,6 @@
             //this.UpdateEnabled = reenable;
             //isScrolling = false;
         }
+
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22