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

revision 206 by william, Thu May 31 09:31:57 2012 UTC revision 214 by william, Sat Jun 2 10:43:05 2012 UTC
# Line 147  namespace RomCheater.Docking.UI Line 147  namespace RomCheater.Docking.UI
147              editor.ShowDialog();              editor.ShowDialog();
148              if (editor.BytesEdited)              if (editor.BytesEdited)
149              {              {
150                  DynamicByteProvider _DynamicByteProvider = new DynamicByteProvider(editor.AsBytes);                  //DynamicByteProvider _DynamicByteProvider = new DynamicByteProvider(editor.AsBytes);
151                  txtData.ByteProvider = _DynamicByteProvider;                  //txtData.ByteProvider = _DynamicByteProvider;
152                  _DynamicByteProvider.Changed += new EventHandler(HexResourceViewerBytes_Changed);                  //_DynamicByteProvider.Changed += new EventHandler(HexResourceViewerBytes_Changed);
153                  this.WriteCurrentBytes();                  this.WriteCurrentBytes(this.CURRENT_TOP_ADDR, editor.AsBytes);
154              }              }
155              this.UpdateEnabled = reenable;              this.UpdateEnabled = reenable;
156          }          }
# Line 268  namespace RomCheater.Docking.UI Line 268  namespace RomCheater.Docking.UI
268              }              }
269              catch (Exception ex) { logger.Error.WriteLine("{0}.UpdateMemroyView():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); }              catch (Exception ex) { logger.Error.WriteLine("{0}.UpdateMemroyView():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); }
270          }          }
271          private void HexResourceViewerBytes_Changed(object sender, System.EventArgs e)          //private void HexResourceViewerBytes_Changed(object sender, System.EventArgs e)
272          {          //{
273              this.WriteCurrentBytes();          //    this.WriteCurrentBytes();
274          }          //}
275          private void WriteCurrentBytes()          private void WriteCurrentBytes(uint start_address, byte[] data)
276          {          {
277              try              try
278              {              {
279                  if (AcceptedProcess == null) { return; }                  if (AcceptedProcess == null) { return; }
280                  if (AcceptedPlugin == null) { return; }                  if (AcceptedPlugin == null) { return; }
281                  // Byte changed                  // Byte changed
282                  byte[] data = (txtData.ByteProvider as DynamicByteProvider).Bytes.ToArray();                  //byte[] data = (txtData.ByteProvider as DynamicByteProvider).Bytes.ToArray();
283                                    
284    
285                  Sojaner.MemoryScanner.ProcessMemoryReader reader = new Sojaner.MemoryScanner.ProcessMemoryReader();                  Sojaner.MemoryScanner.ProcessMemoryReader reader = new Sojaner.MemoryScanner.ProcessMemoryReader();
# Line 287  namespace RomCheater.Docking.UI Line 287  namespace RomCheater.Docking.UI
287                  reader.OpenProcess();                  reader.OpenProcess();
288                  int bytesReadSize;                  int bytesReadSize;
289    
290                  for (int i = 0; i < data.Length; i += sizeof(uint))                  for (int i = 0; i < data.Length; i ++)
291                  {                  {
292                      uint addr = (uint)(this.CURRENT_TOP_ADDR + i);                      uint addr = (uint)(start_address + i);
293                      uint data_to_write = BitConverter.ToUInt32(data, i);                      byte data_to_write = data[i];
294                      reader.WriteProcessMemory((UIntPtr)addr, data, out bytesReadSize);                      reader.WriteProcessMemory((UIntPtr)addr, data_to_write, out bytesReadSize);
295                  }                  }
296              }              }
297              catch (Exception ex) { logger.Error.WriteLine("{0}.WriteCurrentBytes():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); }              catch (Exception ex) { logger.Error.WriteLine("{0}.WriteCurrentBytes():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); }
# Line 308  namespace RomCheater.Docking.UI Line 308  namespace RomCheater.Docking.UI
308                  //this.Logger.LogDebugMessage(string.Format("RunWorkerCompeleted() -> Memory Size: {0}0x{2:X8}{1}", "{", "}", RamData.Length));                  //this.Logger.LogDebugMessage(string.Format("RunWorkerCompeleted() -> Memory Size: {0}0x{2:X8}{1}", "{", "}", RamData.Length));
309                  DynamicByteProvider _DynamicByteProvider = new DynamicByteProvider(RamData);                  DynamicByteProvider _DynamicByteProvider = new DynamicByteProvider(RamData);
310                  txtData.ByteProvider = _DynamicByteProvider;                  txtData.ByteProvider = _DynamicByteProvider;
311                  _DynamicByteProvider.Changed += new EventHandler(HexResourceViewerBytes_Changed);                  //_DynamicByteProvider.Changed += new EventHandler(HexResourceViewerBytes_Changed);
312              }              }
313              catch (ObjectDisposedException) { } // ignore errors aobut disposed objects (usually only happens when the parent closes)              catch (ObjectDisposedException) { } // ignore errors aobut disposed objects (usually only happens when the parent closes)
314              catch (Exception ex) { logger.Error.WriteLine("{0}.ResultsUpdateWorkerThread_RunWorkerCompleted():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); }              catch (Exception ex) { logger.Error.WriteLine("{0}.ResultsUpdateWorkerThread_RunWorkerCompleted():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); }
# Line 486  namespace RomCheater.Docking.UI Line 486  namespace RomCheater.Docking.UI
486              //this.UpdateEnabled = reenable;              //this.UpdateEnabled = reenable;
487              //isScrolling = false;              //isScrolling = false;
488          }          }
489    
490      }      }
491  }  }

Legend:
Removed from v.206  
changed lines
  Added in v.214

  ViewVC Help
Powered by ViewVC 1.1.22