using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using RomCheater.Logging; using System.Diagnostics; using Sojaner.MemoryScanner.MemoryProviers; using RomCheater.PluginFramework.Interfaces; namespace RomCheater.Docking.MemorySearch { public partial class SearchRangePatcher : Form, IAcceptsPlugin, IAcceptsProcess, IAcceptsProcessAndConfig { #region IAcceptsProcess Members public Process AcceptedProcess { get; set; } #endregion #region IAcceptsPlugin Members public IConfigPlugin AcceptedPlugin { get; set; } #endregion //PCSX2MemoryProvider provider; //SearchDataTypes DataType; //bool Unsigned = false; private List PatchList; public SearchRangePatcher(IAcceptsProcessAndConfig pconfig ,List patchList) { InitializeComponent(); this.AcceptedPlugin = pconfig.AcceptedPlugin; this.AcceptedProcess = pconfig.AcceptedProcess; PatchList = patchList; int CurrentBitSize = 0; // get the larget datatype foreach (ResultDataType patch in PatchList) { if ((int)patch.ValueType > CurrentBitSize) { CurrentBitSize = (int)patch.ValueType; } } switch (CurrentBitSize) { case (int)SearchDataTypes._8bits: txtValue.CreateTypeSize(); break; case (int)SearchDataTypes._16bits: txtValue.CreateTypeSize(); break; case (int)SearchDataTypes._32bits: txtValue.CreateTypeSize(); break; case (int)SearchDataTypes._64bits: txtValue.CreateTypeSize(); break; } } private void SearchPatcher_Load(object sender, EventArgs e) { txtValue.ReadOnly = false; } private void btnCancel_Click(object sender, EventArgs e) { this.Close(); } private void btnOK_Click(object sender, EventArgs e) { GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this); foreach(ResultDataType patch in PatchList) { switch (patch.ValueType) { case SearchDataTypes._8bits: if (patch.IsUnsigned) { provider.PatchMemory(patch.Address, (byte)txtValue.Value); } else { provider.PatchMemory(patch.Address, (sbyte)txtValue.Value); } break; case SearchDataTypes._16bits: if (patch.IsUnsigned) { provider.PatchMemory(patch.Address, (ushort)txtValue.Value); } else { provider.PatchMemory(patch.Address, (short)txtValue.Value); } break; case SearchDataTypes._32bits: if (patch.IsUnsigned) { provider.PatchMemory(patch.Address, (uint)txtValue.Value); } else { provider.PatchMemory(patch.Address, (int)txtValue.Value); } break; case SearchDataTypes._64bits: if (patch.IsUnsigned) { provider.PatchMemory(patch.Address, (ulong)txtValue.Value); } else { provider.PatchMemory(patch.Address, (long)txtValue.Value); } break; } } this.Close(); } private void CopyToClipboard(string data) { Clipboard.SetData(DataFormats.Text, data); } private void btnCopyvaluetoClipboard_Click(object sender, EventArgs e) { this.CopyToClipboard(txtValue.Text); } private void SearchPatcher_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) btnOK.PerformClick(); } } }