1 |
william |
414 |
#region Logging Defines |
2 |
|
|
// include this any class or method that required logging, and comment-out what is not needed |
3 |
william |
415 |
|
4 |
william |
414 |
#region Enabled logging levels |
5 |
|
|
#define LOGGING_ENABLE_INFO |
6 |
|
|
#define LOGGING_ENABLE_WARN |
7 |
|
|
#define LOGGING_ENABLE_DEBUG |
8 |
|
|
#define LOGGING_ENABLE_VERBOSEDEBUG |
9 |
|
|
#define LOGGING_ENABLE_ERROR |
10 |
|
|
#define LOGGING_ENABLE_VERBOSEERROR |
11 |
|
|
#define LOGGING_ENABLE_PROFILER |
12 |
|
|
#endregion |
13 |
|
|
#endregion |
14 |
|
|
#define FORCE_ALL_LOGGING_FLAGS // when defined will force logging flags to ALL |
15 |
william |
158 |
#define SHOW_DEBUG_MENU // when defined will show the debug menu or else it will be hidden |
16 |
william |
99 |
using System; |
17 |
william |
5 |
using System.Collections.Generic; |
18 |
|
|
using System.ComponentModel; |
19 |
|
|
using System.Data; |
20 |
|
|
using System.Drawing; |
21 |
|
|
using System.Linq; |
22 |
|
|
using System.Text; |
23 |
|
|
using System.Windows.Forms; |
24 |
william |
17 |
using RomCheater.Logging; |
25 |
william |
34 |
using RomCheater.Properties; |
26 |
|
|
using RomCheater.UserSettingsSupport; |
27 |
william |
83 |
using RomCheater.PluginFramework.Core; |
28 |
william |
86 |
using System.Diagnostics; |
29 |
william |
87 |
using RomCheater.PluginFramework.Interfaces; |
30 |
william |
144 |
using WeifenLuo.WinFormsUI.Docking; |
31 |
william |
146 |
using RomCheater.Docking; |
32 |
william |
152 |
using System.IO; |
33 |
william |
159 |
using Sojaner.MemoryScanner; |
34 |
william |
196 |
using RomCheater.PluginFramework.Events; |
35 |
william |
5 |
|
36 |
|
|
namespace RomCheater |
37 |
|
|
{ |
38 |
william |
13 |
public partial class Main : Form |
39 |
william |
5 |
{ |
40 |
william |
152 |
private bool m_bSaveLayout = true; |
41 |
william |
196 |
private Process SelectedProcess = null; |
42 |
william |
144 |
private DeserializeDockContent m_deserializeDockContent; |
43 |
|
|
private FloatingLogWindow m_LogWindow = new FloatingLogWindow(); |
44 |
william |
147 |
private FloatingAboutBox m_AboutBox = new FloatingAboutBox(); |
45 |
william |
148 |
private FloatingRamDumperDialog m_RamDump = new FloatingRamDumperDialog(); |
46 |
william |
366 |
private FloatingPIDSelector m_PIDSelector = new FloatingPIDSelector(); |
47 |
william |
196 |
private FloatingMemoryView m_memoryview = new FloatingMemoryView(); |
48 |
william |
218 |
private FloatingDataTypeConverter m_typeconverter = new FloatingDataTypeConverter(); |
49 |
william |
227 |
private FloatingMemorySearcher m_memsearcher = new FloatingMemorySearcher(); |
50 |
william |
318 |
private FloatingPEViewer m_peviewer = new FloatingPEViewer(); |
51 |
william |
366 |
private FloatingRVACalculator m_rvacalc = new FloatingRVACalculator(); |
52 |
william |
144 |
//private bool log_window_expanded = false; |
53 |
|
|
//private double log_window_splitter_default_position = 1.4045; |
54 |
william |
86 |
PluginLoader loader = null; |
55 |
william |
87 |
IConfigPlugin ConfigPlugin = null; |
56 |
|
|
IInputPlugin InputPlugin = null; |
57 |
|
|
IWindowPlugin WindowPlugin = null; |
58 |
william |
437 |
List<IUserControlPlugin> UserControlPlugins = null; |
59 |
william |
146 |
static Main() { SettingSubscriber.AddSubscriber(new Main(), Settings.Default); } |
60 |
william |
20 |
private const string t = "RomCheater"; |
61 |
william |
17 |
#region LogWriterSupport |
62 |
|
|
static LogWriter _LoggerInstance; |
63 |
|
|
static LogWriter LoggerInstance |
64 |
|
|
{ |
65 |
|
|
get { return _LoggerInstance; } |
66 |
|
|
set { _LoggerInstance = value; } |
67 |
|
|
} |
68 |
|
|
#endregion |
69 |
|
|
|
70 |
|
|
|
71 |
william |
196 |
private void OnProcessChanged(ProcessChangedEventArgs e) |
72 |
william |
151 |
{ |
73 |
william |
228 |
if (m_memsearcher.SearchInProgess) |
74 |
|
|
{ |
75 |
|
|
DialogResult result = MessageBox.Show("Do you want to start a new search with the selected process?", "A memory search is currently in progress", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3); |
76 |
|
|
if (result != DialogResult.Yes || result != DialogResult.OK) { return; } |
77 |
|
|
m_memsearcher = null; //free memory used by the memory searcher |
78 |
|
|
m_memsearcher = new FloatingMemorySearcher(); |
79 |
|
|
} |
80 |
william |
153 |
SelectedProcess = Process.GetProcessById(e.ProcessID); |
81 |
william |
196 |
m_RamDump.AcceptedPlugin = this.ConfigPlugin; |
82 |
william |
245 |
m_RamDump.AcceptedProcess = SelectedProcess; |
83 |
william |
196 |
|
84 |
william |
360 |
m_peviewer.AcceptedPlugin = this.ConfigPlugin; |
85 |
|
|
m_peviewer.AcceptedProcess = SelectedProcess; |
86 |
william |
408 |
m_peviewer.OnPEDataUpdated += new BaseEventHandler<PEViewerDataUpdatedEventArgs>(OnPEDataUpdated); |
87 |
william |
360 |
|
88 |
william |
244 |
m_memoryview.AcceptedPlugin = this.ConfigPlugin; |
89 |
william |
196 |
m_memoryview.AcceptedProcess = SelectedProcess; |
90 |
william |
227 |
|
91 |
william |
244 |
m_memsearcher.AcceptedPlugin = this.ConfigPlugin; |
92 |
william |
227 |
m_memsearcher.AcceptedProcess = SelectedProcess; |
93 |
william |
275 |
m_memsearcher.OnBrowseMemoryRegion += new BaseEventHandler<BrowseMemoryRegionEvent>(OnBrowseMemoryRegion); |
94 |
william |
318 |
|
95 |
william |
151 |
} |
96 |
william |
323 |
|
97 |
william |
408 |
void OnPEDataUpdated(PEViewerDataUpdatedEventArgs e) |
98 |
william |
323 |
{ |
99 |
william |
357 |
m_memoryview.SetPEViewerData(e.peData); |
100 |
william |
367 |
m_rvacalc.SetPEViewerData(e.peData); |
101 |
william |
323 |
} |
102 |
william |
275 |
private void OnBrowseMemoryRegion(BrowseMemoryRegionEvent e) |
103 |
|
|
{ |
104 |
william |
276 |
m_memoryview.BrowseMemoryRegion(e.MemoryRegion); |
105 |
william |
275 |
} |
106 |
william |
151 |
|
107 |
william |
144 |
#region Dock Support |
108 |
william |
313 |
void AddDockToWindowList(object sender, EventArgs e) |
109 |
|
|
{ |
110 |
|
|
DockContent dc; |
111 |
william |
315 |
TypeBinder.Bind(sender, out dc); |
112 |
william |
314 |
ToolStripMenuItem tsmi = new ToolStripMenuItem(dc.Text); |
113 |
|
|
tsmi.Name = dc.Name; |
114 |
|
|
tsmi.Tag = dc; |
115 |
william |
315 |
tsmi.Click += new EventHandler(tsmi_Click); |
116 |
william |
314 |
mnuWindows.DropDownItems.Add(tsmi); |
117 |
william |
313 |
} |
118 |
william |
314 |
void tsmi_Click(object sender, EventArgs e) |
119 |
|
|
{ |
120 |
|
|
ToolStripMenuItem tsmi; |
121 |
william |
315 |
TypeBinder.Bind(sender, out tsmi); |
122 |
william |
314 |
DockContent dc; |
123 |
william |
315 |
TypeBinder.Bind(tsmi.Tag, out dc); |
124 |
william |
314 |
dc.Activate(); |
125 |
|
|
} |
126 |
william |
313 |
void RemoveDockFromWindowList(object sender, FormClosedEventArgs e) |
127 |
|
|
{ |
128 |
|
|
DockContent dc; |
129 |
william |
315 |
TypeBinder.Bind(sender, out dc); |
130 |
william |
314 |
mnuWindows.DropDownItems.RemoveByKey(dc.Name); |
131 |
william |
313 |
} |
132 |
william |
144 |
private IDockContent GetContentFromPersistString(string persistString) |
133 |
|
|
{ |
134 |
william |
228 |
if (persistString == typeof(FloatingLogWindow).ToString()) { return m_LogWindow; } |
135 |
|
|
if (persistString == typeof(FloatingRamDumperDialog).ToString()) { return m_RamDump; } |
136 |
william |
366 |
if (persistString == typeof(FloatingPIDSelector).ToString()) { return m_PIDSelector; } |
137 |
william |
228 |
if (persistString == typeof(FloatingMemoryView).ToString()) { return m_memoryview; } |
138 |
|
|
if (persistString == typeof(FloatingDataTypeConverter).ToString()) { return m_typeconverter; } |
139 |
|
|
if (persistString == typeof(FloatingMemorySearcher).ToString()) { return m_memsearcher; } |
140 |
william |
318 |
if (persistString == typeof(FloatingPEViewer).ToString()) { return m_peviewer; } |
141 |
william |
366 |
if (persistString == typeof(FloatingRVACalculator).ToString()) { return m_rvacalc; } |
142 |
william |
228 |
else { return null; } |
143 |
william |
144 |
} |
144 |
|
|
public void SetupDocks() |
145 |
|
|
{ |
146 |
|
|
m_LogWindow = new FloatingLogWindow(); |
147 |
william |
147 |
m_AboutBox = new FloatingAboutBox(); |
148 |
william |
148 |
m_RamDump = new FloatingRamDumperDialog(); |
149 |
william |
366 |
m_PIDSelector = new FloatingPIDSelector(); |
150 |
william |
196 |
m_PIDSelector.OnSelectedProcessChanged += new BaseEventHandler<ProcessChangedEventArgs>(OnProcessChanged); |
151 |
|
|
m_memoryview = new FloatingMemoryView(); |
152 |
william |
218 |
m_typeconverter = new FloatingDataTypeConverter(); |
153 |
william |
227 |
m_memsearcher = new FloatingMemorySearcher(); |
154 |
william |
275 |
m_memsearcher.OnBrowseMemoryRegion += new BaseEventHandler<BrowseMemoryRegionEvent>(OnBrowseMemoryRegion); |
155 |
william |
318 |
m_peviewer = new FloatingPEViewer(); |
156 |
william |
408 |
m_peviewer.OnPEDataUpdated += new BaseEventHandler<PEViewerDataUpdatedEventArgs>(OnPEDataUpdated); |
157 |
william |
366 |
m_rvacalc = new FloatingRVACalculator(); |
158 |
william |
144 |
m_deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString); |
159 |
|
|
} |
160 |
william |
313 |
#region SetupDockWindowHandler support |
161 |
|
|
public void SetupDockWindowHandler() |
162 |
|
|
{ |
163 |
|
|
SetupLogWindowHandler(); |
164 |
|
|
SetupRamDumpWindowHandler(); |
165 |
|
|
SetupMemoryViewWindowHandler(); |
166 |
|
|
SetupPIDSelectorWindowHandler(); |
167 |
|
|
SetupDataTypeConverterWindowHandler(); |
168 |
|
|
SetupMemorySearchWindowHandler(); |
169 |
william |
318 |
SetupPEViewerWindowHandler(); |
170 |
william |
366 |
SetupRVACalculatorWindowHandler(); |
171 |
william |
313 |
} |
172 |
|
|
private void SetupLogWindowHandler() |
173 |
|
|
{ |
174 |
|
|
if (m_LogWindow == null) return; |
175 |
|
|
m_LogWindow.Shown += new EventHandler(AddDockToWindowList); |
176 |
william |
335 |
m_LogWindow.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
177 |
william |
314 |
m_LogWindow.Activate(); |
178 |
william |
313 |
} |
179 |
|
|
private void SetupRamDumpWindowHandler() |
180 |
|
|
{ |
181 |
|
|
if (m_RamDump == null) return; |
182 |
|
|
m_RamDump.Shown += new EventHandler(AddDockToWindowList); |
183 |
|
|
m_RamDump.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
184 |
william |
335 |
m_RamDump.AcceptedPlugin = ConfigPlugin; |
185 |
william |
314 |
m_RamDump.Activate(); |
186 |
william |
313 |
} |
187 |
|
|
private void SetupMemoryViewWindowHandler() |
188 |
|
|
{ |
189 |
|
|
if (m_memoryview == null) return; |
190 |
|
|
m_memoryview.Shown += new EventHandler(AddDockToWindowList); |
191 |
|
|
m_memoryview.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
192 |
william |
335 |
m_memoryview.AcceptedPlugin = ConfigPlugin; |
193 |
william |
314 |
m_memoryview.Activate(); |
194 |
william |
313 |
} |
195 |
|
|
private void SetupPIDSelectorWindowHandler() |
196 |
|
|
{ |
197 |
|
|
if (m_PIDSelector == null) return; |
198 |
|
|
m_PIDSelector.Shown += new EventHandler(AddDockToWindowList); |
199 |
|
|
m_PIDSelector.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
200 |
william |
335 |
m_PIDSelector.AcceptedPlugin = ConfigPlugin; |
201 |
william |
314 |
m_PIDSelector.Activate(); |
202 |
william |
313 |
} |
203 |
|
|
private void SetupDataTypeConverterWindowHandler() |
204 |
|
|
{ |
205 |
|
|
if (m_typeconverter == null) return; |
206 |
|
|
m_typeconverter.Shown += new EventHandler(AddDockToWindowList); |
207 |
|
|
m_typeconverter.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
208 |
william |
314 |
m_typeconverter.Activate(); |
209 |
william |
313 |
} |
210 |
|
|
private void SetupMemorySearchWindowHandler() |
211 |
|
|
{ |
212 |
|
|
if (m_memsearcher == null) return; |
213 |
|
|
m_memsearcher.Shown += new EventHandler(AddDockToWindowList); |
214 |
|
|
m_memsearcher.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
215 |
william |
314 |
m_memsearcher.Activate(); |
216 |
william |
313 |
} |
217 |
william |
318 |
private void SetupPEViewerWindowHandler() |
218 |
|
|
{ |
219 |
|
|
if (m_peviewer == null) return; |
220 |
|
|
m_peviewer.Shown += new EventHandler(AddDockToWindowList); |
221 |
|
|
m_peviewer.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
222 |
william |
335 |
m_PIDSelector.AcceptedPlugin = ConfigPlugin; |
223 |
william |
318 |
m_peviewer.Activate(); |
224 |
|
|
} |
225 |
william |
366 |
private void SetupRVACalculatorWindowHandler() |
226 |
|
|
{ |
227 |
|
|
if (m_rvacalc == null) return; |
228 |
|
|
m_rvacalc.Shown += new EventHandler(AddDockToWindowList); |
229 |
|
|
m_rvacalc.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
230 |
|
|
m_rvacalc.AcceptedPlugin = ConfigPlugin; |
231 |
|
|
m_rvacalc.Activate(); |
232 |
|
|
} |
233 |
william |
313 |
#endregion |
234 |
william |
144 |
public void ShowDocks() |
235 |
|
|
{ |
236 |
|
|
ShowLogWindow(); |
237 |
william |
313 |
SetupLogWindowHandler(); |
238 |
william |
152 |
//ShowAboutBox(); |
239 |
william |
148 |
ShowRamDump(); |
240 |
william |
313 |
SetupRamDumpWindowHandler(); |
241 |
william |
196 |
ShowMemoryView(); |
242 |
william |
313 |
SetupMemoryViewWindowHandler(); |
243 |
william |
148 |
ShowPidSelector(); |
244 |
william |
313 |
SetupPIDSelectorWindowHandler(); |
245 |
william |
218 |
ShowDataTypeConverter(); |
246 |
william |
313 |
SetupDataTypeConverterWindowHandler(); |
247 |
william |
227 |
ShowMemorySearch(); |
248 |
william |
313 |
SetupMemorySearchWindowHandler(); |
249 |
william |
318 |
ShowPEViewer(); |
250 |
|
|
SetupPEViewerWindowHandler(); |
251 |
william |
366 |
ShowRVACalculator(); |
252 |
|
|
SetupRVACalculatorWindowHandler(); |
253 |
william |
144 |
} |
254 |
|
|
public void ShowLogWindow() |
255 |
william |
218 |
{ |
256 |
|
|
if (m_LogWindow == null || m_LogWindow.IsDisposed) { m_LogWindow = new FloatingLogWindow(); } |
257 |
william |
263 |
LoggerInstance = m_LogWindow.Logwriter; |
258 |
william |
264 |
LoggerInstance.CreateNewLog(false); |
259 |
william |
313 |
m_LogWindow.Show(dockPanel, DockState.DockBottom); |
260 |
william |
144 |
} |
261 |
william |
147 |
public void ShowAboutBox() |
262 |
|
|
{ |
263 |
william |
218 |
if (m_AboutBox == null || m_AboutBox.IsDisposed) { m_AboutBox = new FloatingAboutBox(); } |
264 |
william |
148 |
m_AboutBox.ShowDialog(); |
265 |
william |
147 |
} |
266 |
william |
148 |
public void ShowRamDump() |
267 |
|
|
{ |
268 |
william |
366 |
load_plugins_silent(); |
269 |
william |
153 |
m_RamDump = new FloatingRamDumperDialog(ConfigPlugin); |
270 |
william |
201 |
m_RamDump.AcceptedProcess = SelectedProcess; |
271 |
william |
313 |
m_RamDump.Show(dockPanel); |
272 |
|
|
} |
273 |
william |
196 |
public void ShowMemoryView() |
274 |
|
|
{ |
275 |
william |
366 |
load_plugins_silent(); |
276 |
william |
196 |
m_memoryview = new FloatingMemoryView(ConfigPlugin); |
277 |
william |
201 |
m_memoryview.AcceptedProcess = SelectedProcess; |
278 |
william |
196 |
m_memoryview.Show(dockPanel); |
279 |
|
|
} |
280 |
william |
148 |
public void ShowPidSelector() |
281 |
|
|
{ |
282 |
william |
366 |
load_plugins_silent(); |
283 |
william |
148 |
//List<Process> procs = ConfigPlugin.ValidProcessesForPlugin; |
284 |
william |
366 |
m_PIDSelector = new FloatingPIDSelector(ConfigPlugin); |
285 |
william |
196 |
m_PIDSelector.OnSelectedProcessChanged += new BaseEventHandler<ProcessChangedEventArgs>(OnProcessChanged); |
286 |
william |
148 |
m_PIDSelector.Show(dockPanel); |
287 |
|
|
} |
288 |
william |
218 |
public void ShowDataTypeConverter() |
289 |
|
|
{ |
290 |
|
|
if (m_typeconverter == null || m_typeconverter.IsDisposed) { m_typeconverter = new FloatingDataTypeConverter(); } |
291 |
william |
313 |
m_typeconverter.Show(dockPanel, DockState.DockRightAutoHide); |
292 |
william |
218 |
} |
293 |
william |
227 |
public void ShowMemorySearch() |
294 |
|
|
{ |
295 |
william |
366 |
load_plugins_silent(); |
296 |
william |
227 |
m_memsearcher = new FloatingMemorySearcher(ConfigPlugin); |
297 |
|
|
m_memsearcher.AcceptedProcess = SelectedProcess; |
298 |
william |
275 |
m_memsearcher.OnBrowseMemoryRegion += new BaseEventHandler<BrowseMemoryRegionEvent>(OnBrowseMemoryRegion); |
299 |
william |
227 |
m_memsearcher.Show(dockPanel); |
300 |
|
|
} |
301 |
william |
318 |
public void ShowPEViewer() |
302 |
|
|
{ |
303 |
william |
366 |
load_plugins_silent(); |
304 |
william |
318 |
m_peviewer = new FloatingPEViewer(ConfigPlugin); |
305 |
|
|
m_peviewer.AcceptedProcess = SelectedProcess; |
306 |
william |
408 |
m_peviewer.OnPEDataUpdated += new BaseEventHandler<PEViewerDataUpdatedEventArgs>(OnPEDataUpdated); |
307 |
william |
318 |
m_peviewer.Show(dockPanel); |
308 |
|
|
} |
309 |
william |
366 |
public void ShowRVACalculator() |
310 |
|
|
{ |
311 |
|
|
load_plugins_silent(); |
312 |
|
|
m_rvacalc = new FloatingRVACalculator(ConfigPlugin); |
313 |
|
|
m_rvacalc.AcceptedProcess = SelectedProcess; |
314 |
|
|
m_rvacalc.Show(dockPanel, DockState.DockRightAutoHide); |
315 |
|
|
} |
316 |
william |
144 |
#endregion |
317 |
|
|
|
318 |
|
|
|
319 |
william |
117 |
public Main() : this(false) { } |
320 |
|
|
public Main(bool no_console_redirect) |
321 |
william |
5 |
{ |
322 |
|
|
InitializeComponent(); |
323 |
william |
158 |
#if SHOW_DEBUG_MENU |
324 |
|
|
mnuDebug.Visible = true; |
325 |
|
|
#else |
326 |
|
|
mnuDebug.Visible = false; |
327 |
|
|
#endif |
328 |
william |
83 |
load_loggerflags(); |
329 |
william |
144 |
SetupDocks(); |
330 |
|
|
LoggerInstance = m_LogWindow.Logwriter; |
331 |
william |
23 |
LoggerInstance.CreateNewLog(false); |
332 |
william |
112 |
logger.ForceLog.Info.WriteLine("LoggingFlags = 0x{0:x4} ({1})", logger.GetLoggingFlags().Value, logger.GetLoggingFlags().Name); |
333 |
william |
87 |
load_plugins(); |
334 |
william |
117 |
if (no_console_redirect) |
335 |
|
|
LoggerInstance.RedirectConsoleOutput = false; |
336 |
william |
158 |
|
337 |
|
|
|
338 |
william |
144 |
|
339 |
william |
5 |
} |
340 |
william |
83 |
private void load_loggerflags() |
341 |
|
|
{ |
342 |
william |
111 |
logger.SetLoggingFlags(Logging.Properties.Settings.Default.LoggingFlags); |
343 |
william |
99 |
#if FORCE_ALL_LOGGING_FLAGS |
344 |
|
|
logger.SetLoggingFlags(loggerflags.ALL); |
345 |
|
|
#endif |
346 |
william |
83 |
} |
347 |
william |
366 |
private void load_plugins() { load_plugins(false); } |
348 |
|
|
private void load_plugins_silent() { load_plugins(true); } |
349 |
|
|
private void load_plugins(bool silent) |
350 |
william |
87 |
{ |
351 |
|
|
loader = new PluginLoader(); |
352 |
william |
366 |
loader.LoadPlugins(silent); |
353 |
william |
83 |
|
354 |
william |
87 |
ConfigPlugin = loader.GetConfigPlugin(RomCheater.Properties.Settings.Default.LastConfigPlugin); |
355 |
william |
366 |
if (ConfigPlugin != null && !silent) |
356 |
william |
87 |
logger.Info.WriteLine("Loaded Config Plugin: {0}", ConfigPlugin.ToString()); |
357 |
|
|
InputPlugin = loader.GetInputPlugin(RomCheater.Properties.Settings.Default.LastInputPlugin); |
358 |
william |
366 |
if (InputPlugin != null && !silent) |
359 |
william |
87 |
logger.Info.WriteLine("Loaded Input Plugin: {0}", InputPlugin.ToString()); |
360 |
|
|
WindowPlugin = loader.GetWindowPlugin(RomCheater.Properties.Settings.Default.LastWindowPlugin); |
361 |
william |
366 |
if (WindowPlugin != null && !silent) |
362 |
william |
87 |
logger.Info.WriteLine("Loaded Window Plugin: {0}", WindowPlugin.ToString()); |
363 |
|
|
|
364 |
william |
437 |
|
365 |
|
|
UserControlPlugins = new List<IUserControlPlugin>(loader.LoadedUserControlPlugins); |
366 |
|
|
if (UserControlPlugins != null && !silent && UserControlPlugins.Count > 0) |
367 |
|
|
{ |
368 |
|
|
foreach (var t in UserControlPlugins) |
369 |
|
|
{ |
370 |
|
|
logger.Info.WriteLine("Loaded UserControl Plugin: {0}", t.ToString()); |
371 |
|
|
} |
372 |
|
|
} |
373 |
|
|
|
374 |
|
|
|
375 |
|
|
|
376 |
william |
153 |
m_PIDSelector.AcceptedPlugin = ConfigPlugin; |
377 |
|
|
m_RamDump.AcceptedPlugin = ConfigPlugin; |
378 |
william |
267 |
m_memoryview.AcceptedPlugin = ConfigPlugin; |
379 |
|
|
m_memsearcher.AcceptedPlugin = ConfigPlugin; |
380 |
william |
335 |
m_PIDSelector.AcceptedPlugin = ConfigPlugin; |
381 |
william |
153 |
if (this.SelectedProcess != null) |
382 |
william |
267 |
{ |
383 |
william |
153 |
m_RamDump.AcceptedProcess = SelectedProcess; |
384 |
william |
267 |
m_memoryview.AcceptedProcess = SelectedProcess; |
385 |
|
|
m_memsearcher.AcceptedProcess = SelectedProcess; |
386 |
|
|
} |
387 |
william |
152 |
|
388 |
william |
87 |
} |
389 |
|
|
|
390 |
william |
14 |
private void mnuItemExit_Click(object sender, EventArgs e) |
391 |
|
|
{ |
392 |
|
|
this.Close(); |
393 |
|
|
} |
394 |
william |
16 |
|
395 |
william |
17 |
|
396 |
|
|
private void Main_Load(object sender, EventArgs e) |
397 |
william |
144 |
{ |
398 |
william |
152 |
|
399 |
william |
17 |
} |
400 |
william |
63 |
|
401 |
|
|
private void mnuItemConfig_Click(object sender, EventArgs e) |
402 |
|
|
{ |
403 |
william |
86 |
RomCheaterConfigDialog dlg = new RomCheaterConfigDialog(loader); |
404 |
william |
63 |
dlg.ShowDialog(); |
405 |
william |
270 |
logger.ForceLog.Info.WriteLine("LoggingFlags = 0x{0:x4} ({1})", logger.GetLoggingFlags().Value, logger.GetLoggingFlags().Name); |
406 |
william |
92 |
// reload plugins |
407 |
william |
366 |
load_plugins(true); |
408 |
william |
63 |
} |
409 |
william |
69 |
|
410 |
|
|
private void mnuItemOpenProcess_Click(object sender, EventArgs e) |
411 |
|
|
{ |
412 |
william |
148 |
////List<Process> procs = ConfigPlugin.ValidProcessesForPlugin; |
413 |
|
|
//PIDSelector selector = new PIDSelector(ConfigPlugin); |
414 |
|
|
//selector.ShowDialog(); |
415 |
william |
69 |
} |
416 |
william |
104 |
|
417 |
william |
144 |
private void Main_Shown(object sender, EventArgs e) |
418 |
william |
104 |
{ |
419 |
william |
152 |
//dockPanel.SuspendLayout(true); |
420 |
|
|
//ShowDocks(); |
421 |
|
|
string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "DockPanel.config"); |
422 |
|
|
if (File.Exists(configFile)) |
423 |
|
|
{ |
424 |
|
|
try |
425 |
|
|
{ |
426 |
|
|
dockPanel.LoadFromXml(configFile, m_deserializeDockContent); |
427 |
william |
313 |
SetupDockWindowHandler(); |
428 |
william |
152 |
} |
429 |
william |
177 |
catch (Exception) |
430 |
william |
152 |
{ |
431 |
|
|
this.Controls.Remove(dockPanel); |
432 |
|
|
dockPanel = new DockPanel(); |
433 |
|
|
dockPanel.Dock = DockStyle.Fill; |
434 |
|
|
dockPanel.DocumentStyle = DocumentStyle.DockingWindow; |
435 |
|
|
this.Controls.Add(dockPanel); |
436 |
|
|
ShowDocks(); |
437 |
|
|
} |
438 |
|
|
} |
439 |
|
|
else |
440 |
|
|
{ |
441 |
|
|
ShowDocks(); |
442 |
|
|
} |
443 |
|
|
|
444 |
|
|
//dockPanel.ResumeLayout(true, true); |
445 |
william |
104 |
} |
446 |
william |
144 |
|
447 |
|
|
private void mnuItemShowLogWindow_Click(object sender, EventArgs e) |
448 |
|
|
{ |
449 |
|
|
ShowLogWindow(); |
450 |
|
|
} |
451 |
william |
147 |
|
452 |
|
|
private void mnuItemHelpAbout_Click(object sender, EventArgs e) |
453 |
|
|
{ |
454 |
|
|
ShowAboutBox(); |
455 |
|
|
} |
456 |
william |
148 |
|
457 |
|
|
private void mnuItemShowRamDumpDialog_Click(object sender, EventArgs e) |
458 |
|
|
{ |
459 |
|
|
ShowRamDump(); |
460 |
|
|
} |
461 |
|
|
|
462 |
|
|
private void mnuItemShowPIDSelector_Click(object sender, EventArgs e) |
463 |
|
|
{ |
464 |
|
|
ShowPidSelector(); |
465 |
|
|
} |
466 |
william |
201 |
private void mnuItemShowMemoryView_Click(object sender, EventArgs e) |
467 |
|
|
{ |
468 |
|
|
ShowMemoryView(); |
469 |
|
|
} |
470 |
william |
152 |
private void Main_FormClosing(object sender, FormClosingEventArgs e) |
471 |
|
|
{ |
472 |
|
|
string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "DockPanel.config"); |
473 |
|
|
if (m_bSaveLayout) |
474 |
|
|
dockPanel.SaveAsXml(configFile); |
475 |
|
|
else if (File.Exists(configFile)) |
476 |
|
|
File.Delete(configFile); |
477 |
|
|
} |
478 |
william |
158 |
|
479 |
|
|
private void mnuTestExeParse_Click(object sender, EventArgs e) |
480 |
|
|
{ |
481 |
william |
357 |
IPEDData peData = PEDataWrapper.GetPEData((IAcceptsProcessAndConfig)this); |
482 |
william |
158 |
} |
483 |
william |
201 |
|
484 |
|
|
private void mnuItemFindMaxNonNegativeHexValue_Click(object sender, EventArgs e) |
485 |
|
|
{ |
486 |
|
|
|
487 |
|
|
//uint start = 0xf0000000; |
488 |
|
|
uint end = uint.MaxValue; |
489 |
|
|
//for (uint i = start; i < end; i++) |
490 |
|
|
//{ |
491 |
|
|
ulong value = Convert.ToUInt64(end.ToString(), 16); |
492 |
|
|
//} |
493 |
|
|
} |
494 |
william |
218 |
|
495 |
|
|
private void mnuItemShowDataTypeConverter_Click(object sender, EventArgs e) |
496 |
|
|
{ |
497 |
|
|
ShowDataTypeConverter(); |
498 |
|
|
} |
499 |
william |
227 |
|
500 |
|
|
private void mnuItemShowMemorySearch_Click(object sender, EventArgs e) |
501 |
|
|
{ |
502 |
|
|
ShowMemorySearch(); |
503 |
|
|
} |
504 |
william |
260 |
|
505 |
|
|
private void mnuItemDateShift_Click(object sender, EventArgs e) |
506 |
|
|
{ |
507 |
|
|
DateTime t = DateTime.Now; |
508 |
|
|
int year = Convert.ToInt32(t.ToString("yy")); |
509 |
|
|
int y = year << 9; |
510 |
|
|
int m = t.Month << 5; |
511 |
|
|
int d = t.Day; |
512 |
|
|
|
513 |
|
|
ushort v1 = (ushort)(y | m | d); |
514 |
|
|
|
515 |
|
|
t = t.AddDays(1); |
516 |
|
|
year = Convert.ToInt32(t.ToString("yy")); |
517 |
|
|
y = year << 9; |
518 |
|
|
m = t.Month << 5; |
519 |
|
|
d = t.Day; |
520 |
|
|
ushort v2 = (ushort)(y | m | d); |
521 |
|
|
|
522 |
|
|
t = t.AddDays(1); |
523 |
|
|
year = Convert.ToInt32(t.ToString("yy")); |
524 |
|
|
y = year << 9; |
525 |
|
|
m = t.Month << 5; |
526 |
|
|
d = t.Day; |
527 |
|
|
ushort v3 = (ushort)(y | m | d); |
528 |
|
|
|
529 |
|
|
t = new DateTime(9999,12,31); |
530 |
|
|
year = Convert.ToInt32(t.ToString("yy")); |
531 |
|
|
y = year << 9; |
532 |
|
|
m = t.Month << 5; |
533 |
|
|
d = t.Day; |
534 |
|
|
ushort v4 = (ushort)(y | m | d); |
535 |
|
|
} |
536 |
william |
318 |
|
537 |
|
|
private void mnuItemShowPEViewer_Click(object sender, EventArgs e) |
538 |
|
|
{ |
539 |
|
|
ShowPEViewer(); |
540 |
|
|
} |
541 |
|
|
|
542 |
william |
366 |
private void mnuItemShowRVACalculator_Click(object sender, EventArgs e) |
543 |
|
|
{ |
544 |
|
|
ShowRVACalculator(); |
545 |
|
|
} |
546 |
william |
5 |
} |
547 |
|
|
} |