1 |
william |
318 |
#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 |
2 |
|
|
#if !USE_AUTOMATIC_MEMORY_SEARCH_RANGE |
3 |
|
|
#define FORCE_USE_OF_MEMORYSIZECONSTANTS // when defined wil force the use of the constants defined in MemorySizeConstants for memory search range |
4 |
|
|
#endif |
5 |
|
|
using System; |
6 |
|
|
using System.Collections.Generic; |
7 |
|
|
using System.ComponentModel; |
8 |
|
|
using System.Data; |
9 |
|
|
using System.Drawing; |
10 |
|
|
using System.Linq; |
11 |
|
|
using System.Text; |
12 |
|
|
using System.Windows.Forms; |
13 |
|
|
using WeifenLuo.WinFormsUI.Docking; |
14 |
|
|
using RomCheater.PluginFramework.Interfaces; |
15 |
|
|
using System.Diagnostics; |
16 |
|
|
using Sojaner.MemoryScanner; |
17 |
william |
323 |
using RomCheater.PluginFramework.Events; |
18 |
william |
318 |
|
19 |
|
|
namespace RomCheater.Docking |
20 |
|
|
{ |
21 |
|
|
public partial class FloatingPEViewer : DockContent, |
22 |
|
|
IAcceptsPlugin<IConfigPlugin>, |
23 |
william |
477 |
IAcceptsProcess<Process>, |
24 |
william |
323 |
IAcceptsProcessAndConfig, |
25 |
william |
587 |
IAcceptPEData, |
26 |
william |
323 |
IAcceptsPEData |
27 |
william |
318 |
{ |
28 |
william |
477 |
public FloatingPEViewer() { InitializeComponent(); this.AcceptedPlugin = null; this.AcceptedProcess = null; OnPEDataUpdated = null; } |
29 |
william |
318 |
public FloatingPEViewer(IConfigPlugin config) : this() { this.AcceptedPlugin = config; } |
30 |
william |
477 |
public FloatingPEViewer(IConfigPlugin config, Process process) : this() { this.AcceptedPlugin = config; this.AcceptedProcess = process; } |
31 |
william |
318 |
#region IAcceptsProcess<Process> Members |
32 |
william |
477 |
private Process _AcceptedProcess; |
33 |
|
|
public Process AcceptedProcess { get { return _AcceptedProcess; } set { _AcceptedProcess = value; UpdateAcceptedProcess(value); } } |
34 |
william |
318 |
#endregion |
35 |
|
|
#region IAcceptsPlugin<IConfigPlugin> Members |
36 |
|
|
private IConfigPlugin _AcceptedPlugin; |
37 |
|
|
public IConfigPlugin AcceptedPlugin { get { return _AcceptedPlugin; } set { _AcceptedPlugin = value; UpdateAcceptedPlugin(value); } } |
38 |
|
|
#endregion |
39 |
william |
323 |
#region IAcceptsPEData Members |
40 |
william |
408 |
public event BaseEventHandler<PEViewerDataUpdatedEventArgs> OnPEDataUpdated; |
41 |
william |
323 |
#endregion |
42 |
william |
578 |
ulong MemoryRangeStart { get; set; } |
43 |
|
|
ulong MemoryRangeSize { get; set; } |
44 |
william |
318 |
|
45 |
|
|
private void UpdateAcceptedPlugin(IConfigPlugin config) |
46 |
|
|
{ |
47 |
|
|
} |
48 |
william |
477 |
private void UpdateAcceptedProcess(Process process) |
49 |
william |
318 |
{ |
50 |
|
|
#if USE_AUTOMATIC_MEMORY_SEARCH_RANGE && FORCE_USE_OF_MEMORYSIZECONSTANTS |
51 |
|
|
logger.Warn.WriteLine("FloatingMemorySearcher.UpdateAcceptedProcessAndConfig(IConfigPlugin config, Process process):"); |
52 |
|
|
logger.Warn.WriteLine("Both USE_AUTOMATIC_MEMORY_SEARCH_RANGE and FORCE_USE_OF_MEMORYSIZECONSTANTS are defined"); |
53 |
|
|
logger.Warn.WriteLine("FORCE_USE_OF_MEMORYSIZECONSTANTS will take precedence and will ignore the values supplied in the memeory search range"); |
54 |
|
|
#endif |
55 |
|
|
#if FORCE_USE_OF_MEMORYSIZECONSTANTS |
56 |
|
|
// force use of MemorySizeConstants |
57 |
|
|
MemoryRangeStart = MemorySizeConstants.MinimumAddress; |
58 |
william |
382 |
MemoryRangeSize = MemoryRangeStart + MemorySizeConstants.MaximumAddressSize; |
59 |
william |
318 |
#endif |
60 |
|
|
#if USE_AUTOMATIC_MEMORY_SEARCH_RANGE && !FORCE_USE_OF_MEMORYSIZECONSTANTS |
61 |
|
|
//// code to automatically choose the best starting memory address and size |
62 |
william |
477 |
if (process != null) |
63 |
william |
318 |
{ |
64 |
william |
477 |
string filename = process.MainModule.FileName; |
65 |
|
|
//string filename = @"c:\Windows\notepad.exe"; |
66 |
|
|
IPEDData peData = PEDataWrapper.GetPEData((IAcceptsProcessAndConfig)this); |
67 |
|
|
peprops.SelectedObject = peData; |
68 |
|
|
peprops.PropertySort = PropertySort.NoSort; |
69 |
|
|
if (OnPEDataUpdated != null) |
70 |
|
|
if (peData != null) |
71 |
|
|
OnPEDataUpdated(new PEViewerDataUpdatedEventArgs(this, peData)); |
72 |
william |
318 |
} |
73 |
|
|
else |
74 |
|
|
{ |
75 |
|
|
MemoryRangeStart = MemorySizeConstants.MinimumAddress; |
76 |
william |
382 |
MemoryRangeSize = MemorySizeConstants.MaximumAddressSize; |
77 |
william |
318 |
} |
78 |
|
|
#endif |
79 |
|
|
|
80 |
|
|
} |
81 |
|
|
} |
82 |
|
|
} |