#define USE_AUTOMATIC_MEMORY_SEARCH_RANGE // when defined will automatically choose the best starting address and size for memory search otherwise it will use the constants defined in MemorySizeConstants #if !USE_AUTOMATIC_MEMORY_SEARCH_RANGE #define FORCE_USE_OF_MEMORYSIZECONSTANTS // when defined wil force the use of the constants defined in MemorySizeConstants for memory search range #endif using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using WeifenLuo.WinFormsUI.Docking; using RomCheater.PluginFramework.Interfaces; using System.Diagnostics; using Sojaner.MemoryScanner; namespace RomCheater.Docking { public partial class FloatingPEViewer : DockContent, IAcceptsPlugin, IAcceptsProcess, IAcceptsProcessAndConfig { public FloatingPEViewer() { InitializeComponent(); this.AcceptedPlugin = null; this.AcceptedProcess = null; } public FloatingPEViewer(IConfigPlugin config) : this() { this.AcceptedPlugin = config; } public FloatingPEViewer(IConfigPlugin config, Process process) : this() { this.AcceptedPlugin = config; this.AcceptedProcess = process; } #region IAcceptsProcess Members private Process _AcceptedProcess; public Process AcceptedProcess { get { return _AcceptedProcess; } set { _AcceptedProcess = value; UpdateAcceptedProcess(value); } } #endregion #region IAcceptsPlugin Members private IConfigPlugin _AcceptedPlugin; public IConfigPlugin AcceptedPlugin { get { return _AcceptedPlugin; } set { _AcceptedPlugin = value; UpdateAcceptedPlugin(value); } } #endregion int MemoryRangeStart { get; set; } uint MemoryRangeSize { get; set; } private void UpdateAcceptedPlugin(IConfigPlugin config) { } private void UpdateAcceptedProcess(Process process) { #if USE_AUTOMATIC_MEMORY_SEARCH_RANGE && FORCE_USE_OF_MEMORYSIZECONSTANTS logger.Warn.WriteLine("FloatingMemorySearcher.UpdateAcceptedProcessAndConfig(IConfigPlugin config, Process process):"); logger.Warn.WriteLine("Both USE_AUTOMATIC_MEMORY_SEARCH_RANGE and FORCE_USE_OF_MEMORYSIZECONSTANTS are defined"); logger.Warn.WriteLine("FORCE_USE_OF_MEMORYSIZECONSTANTS will take precedence and will ignore the values supplied in the memeory search range"); #endif #if FORCE_USE_OF_MEMORYSIZECONSTANTS // force use of MemorySizeConstants MemoryRangeStart = MemorySizeConstants.MinimumAddress; MemoryRangeSizee = (MemorySizeConstants.MinimumAddress > 0) ? (uint)(MemorySizeConstants.MaximumAddress - MemorySizeConstants.MinimumAddress) : MemorySizeConstants.MaximumAddress; #endif #if USE_AUTOMATIC_MEMORY_SEARCH_RANGE && !FORCE_USE_OF_MEMORYSIZECONSTANTS //// code to automatically choose the best starting memory address and size if (process != null) { string filename = process.MainModule.FileName; //string filename = @"c:\Windows\notepad.exe"; PEReader peReader = new PEReader(filename); peprops.SelectedObject = peReader.GetData; peprops.PropertySort = PropertySort.NoSort; } else { MemoryRangeStart = MemorySizeConstants.MinimumAddress; MemoryRangeSize = (MemorySizeConstants.MinimumAddress > 0) ? (uint)(MemorySizeConstants.MaximumAddress - MemorySizeConstants.MinimumAddress) : MemorySizeConstants.MaximumAddress; } #endif } } }