1 |
#define FORCE_DISABLE_PROFILER_LOGLEVEL // when define will forcibly disable the profiler loglevel |
2 |
//#region Logging Defines |
3 |
//// include this any class or method that required logging, and comment-out what is not needed |
4 |
|
5 |
//#region Enabled logging levels |
6 |
//#define LOGGING_ENABLE_INFO |
7 |
//#define LOGGING_ENABLE_WARN |
8 |
//#define LOGGING_ENABLE_DEBUG |
9 |
//#define LOGGING_ENABLE_VERBOSEDEBUG |
10 |
//#define LOGGING_ENABLE_ERROR |
11 |
//#define LOGGING_ENABLE_VERBOSEERROR |
12 |
//#define LOGGING_ENABLE_PROFILER |
13 |
//#endregion |
14 |
//#endregion |
15 |
//#define FORCE_ALL_LOGGING_FLAGS // when defined will force logging flags to ALL |
16 |
#define SHOW_DEBUG_MENU // when defined will show the debug menu or else it will be hidden |
17 |
using System; |
18 |
using System.Collections.Generic; |
19 |
using System.ComponentModel; |
20 |
using System.Data; |
21 |
using System.Drawing; |
22 |
using System.Linq; |
23 |
using System.Text; |
24 |
using System.Windows.Forms; |
25 |
using RomCheater.Logging; |
26 |
using RomCheater.Properties; |
27 |
using RomCheater.UserSettingsSupport; |
28 |
using RomCheater.PluginFramework.Core; |
29 |
using System.Diagnostics; |
30 |
|
31 |
using WeifenLuo.WinFormsUI.Docking; |
32 |
using RomCheater.Docking; |
33 |
using System.IO; |
34 |
using Sojaner.MemoryScanner; |
35 |
using RomCheater.PluginFramework.Events; |
36 |
using RomCheater.Serialization; |
37 |
using RomCheater.Core; |
38 |
using Enterprise.Logging; |
39 |
|
40 |
namespace RomCheater |
41 |
{ |
42 |
public partial class Main : Form |
43 |
{ |
44 |
//private ushort Logger_flags = 0; |
45 |
private LogLevel logging_level = LogLevel.kLogLevel_All; |
46 |
const string DockPanelConfig = "RomCheater-DockPanel.conf"; |
47 |
private SettingSubscriber SettingsSubscriber; |
48 |
private bool m_bSaveLayout = true; |
49 |
private Process SelectedProcess = null; |
50 |
private DeserializeDockContent m_deserializeDockContent; |
51 |
private FloatingLogWindow m_LogWindow = new FloatingLogWindow(); |
52 |
private FloatingAboutBox m_AboutBox = new FloatingAboutBox(); |
53 |
private FloatingRamDumperDialog m_RamDump = new FloatingRamDumperDialog(); |
54 |
private FloatingPIDSelector m_PIDSelector = new FloatingPIDSelector(); |
55 |
private FloatingMemoryView m_memoryview = new FloatingMemoryView(); |
56 |
private FloatingDataTypeConverter m_typeconverter = new FloatingDataTypeConverter(); |
57 |
private FloatingMemorySearcher m_memsearcher = new FloatingMemorySearcher(); |
58 |
private FloatingPEViewer m_peviewer = new FloatingPEViewer(); |
59 |
private FloatingRVACalculator m_rvacalc = new FloatingRVACalculator(); |
60 |
|
61 |
private FloatingMemorySectionViewer m_msv = new FloatingMemorySectionViewer(); |
62 |
|
63 |
private FloatingUserControlDock m_ucd = new FloatingUserControlDock(); |
64 |
|
65 |
private FloatingWebBrowser m_wb = new FloatingWebBrowser(); |
66 |
|
67 |
//private bool log_window_expanded = false; |
68 |
//private double log_window_splitter_default_position = 1.4045; |
69 |
PluginLoader loader = null; |
70 |
IConfigPlugin ConfigPlugin = null; |
71 |
IInputPlugin InputPlugin = null; |
72 |
IWindowPlugin WindowPlugin = null; |
73 |
List<IUserControlPlugin> UserControlPlugins = null; |
74 |
//static Main() { SettingSubscriber.AddSubscriber(new Main(), Settings.Default); } |
75 |
//private const string t = "RomCheater"; |
76 |
#region LogWriterSupport |
77 |
static LogWriter _LoggerInstance; |
78 |
static LogWriter LoggerInstance |
79 |
{ |
80 |
get { return _LoggerInstance; } |
81 |
set { _LoggerInstance = value; } |
82 |
} |
83 |
#endregion |
84 |
|
85 |
|
86 |
public IWebBrowserProvider WebBrowserProvider |
87 |
{ |
88 |
get { return new WebBrowserProvider(m_wb); } |
89 |
} |
90 |
|
91 |
private void OnProcessChanged(ProcessChangedEventArgs e) |
92 |
{ |
93 |
ConfigPlugin.WebBrowserProvider = this.WebBrowserProvider; |
94 |
if (m_memsearcher.SearchInProgess) |
95 |
{ |
96 |
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); |
97 |
if (result != DialogResult.Yes || result != DialogResult.OK) { return; } |
98 |
m_memsearcher = null; //free memory used by the memory searcher |
99 |
m_memsearcher = new FloatingMemorySearcher(); |
100 |
} |
101 |
SelectedProcess = Process.GetProcessById(e.ProcessID); |
102 |
m_RamDump.AcceptedPlugin = this.ConfigPlugin; |
103 |
m_RamDump.AcceptedProcess = SelectedProcess; |
104 |
|
105 |
m_peviewer.AcceptedPlugin = this.ConfigPlugin; |
106 |
m_peviewer.AcceptedProcess = SelectedProcess; |
107 |
m_peviewer.OnPEDataUpdated += new BaseEventHandler<PEViewerDataUpdatedEventArgs>(OnPEDataUpdated); |
108 |
|
109 |
m_memoryview.AcceptedPlugin = this.ConfigPlugin; |
110 |
m_memoryview.AcceptedProcess = SelectedProcess; |
111 |
|
112 |
m_memsearcher.AcceptedPlugin = this.ConfigPlugin; |
113 |
m_memsearcher.AcceptedProcess = SelectedProcess; |
114 |
m_memsearcher.OnBrowseMemoryRegion += new BaseEventHandler<BrowseMemoryRegionEvent>(OnBrowseMemoryRegion); |
115 |
|
116 |
m_msv.AcceptedPlugin = this.ConfigPlugin; |
117 |
m_msv.AcceptedProcess = SelectedProcess; |
118 |
m_msv.OnBrowseMemoryRegion += new BaseEventHandler<BrowseMemoryRegionEvent>(OnBrowseMemoryRegion); |
119 |
|
120 |
|
121 |
AcceptedProcessAndConfig iapc = new AcceptedProcessAndConfig(this.ConfigPlugin, SelectedProcess); |
122 |
|
123 |
this.ConfigPlugin.SetAcceptedProcessAndConfig(iapc); |
124 |
this.WindowPlugin.SetAcceptedProcessAndConfig(iapc); |
125 |
this.InputPlugin.SetAcceptedProcessAndConfig(iapc); |
126 |
for (int i = 0; i < UserControlPlugins.Count; i++) |
127 |
{ |
128 |
UserControlPlugins[i].SetAcceptedProcessAndConfig(iapc); |
129 |
} |
130 |
} |
131 |
|
132 |
void OnPEDataUpdated(PEViewerDataUpdatedEventArgs e) |
133 |
{ |
134 |
m_memoryview.SetPEViewerData(e.peData); |
135 |
m_memsearcher.SetPEViewerData(e.peData); |
136 |
m_rvacalc.SetPEViewerData(e.peData); |
137 |
m_RamDump.SetPEViewerData(e.peData); |
138 |
m_msv.SetPEViewerData(e.peData); |
139 |
|
140 |
ConfigPlugin.SetPEViewerData(e.peData); |
141 |
WindowPlugin.SetPEViewerData(e.peData); |
142 |
InputPlugin.SetPEViewerData(e.peData); |
143 |
|
144 |
for (int i = 0; i < UserControlPlugins.Count; i++) |
145 |
{ |
146 |
UserControlPlugins[i].SetPEViewerData(e.peData); |
147 |
} |
148 |
|
149 |
} |
150 |
private void OnBrowseMemoryRegion(BrowseMemoryRegionEvent e) |
151 |
{ |
152 |
m_memoryview.BrowseMemoryRegion(e.MemoryRegion); |
153 |
} |
154 |
|
155 |
#region Dock Support |
156 |
void AddDockToWindowList(object sender, EventArgs e) |
157 |
{ |
158 |
DockContent dc; |
159 |
TypeBinder.Bind(sender, out dc); |
160 |
ToolStripMenuItem tsmi = new ToolStripMenuItem(dc.Text); |
161 |
tsmi.Name = dc.Name; |
162 |
tsmi.Tag = dc; |
163 |
tsmi.Click += new EventHandler(tsmi_Click); |
164 |
mnuWindows.DropDownItems.Add(tsmi); |
165 |
} |
166 |
void tsmi_Click(object sender, EventArgs e) |
167 |
{ |
168 |
ToolStripMenuItem tsmi; |
169 |
TypeBinder.Bind(sender, out tsmi); |
170 |
DockContent dc; |
171 |
TypeBinder.Bind(tsmi.Tag, out dc); |
172 |
dc.Activate(); |
173 |
} |
174 |
void RemoveDockFromWindowList(object sender, FormClosedEventArgs e) |
175 |
{ |
176 |
DockContent dc; |
177 |
TypeBinder.Bind(sender, out dc); |
178 |
mnuWindows.DropDownItems.RemoveByKey(dc.Name); |
179 |
} |
180 |
private IDockContent GetContentFromPersistString(string persistString) |
181 |
{ |
182 |
if (persistString == typeof(FloatingLogWindow).ToString()) { return m_LogWindow; } |
183 |
if (persistString == typeof(FloatingRamDumperDialog).ToString()) { return m_RamDump; } |
184 |
if (persistString == typeof(FloatingPIDSelector).ToString()) { return m_PIDSelector; } |
185 |
if (persistString == typeof(FloatingMemoryView).ToString()) { return m_memoryview; } |
186 |
if (persistString == typeof(FloatingDataTypeConverter).ToString()) { return m_typeconverter; } |
187 |
if (persistString == typeof(FloatingMemorySearcher).ToString()) { return m_memsearcher; } |
188 |
if (persistString == typeof(FloatingPEViewer).ToString()) { return m_peviewer; } |
189 |
if (persistString == typeof(FloatingRVACalculator).ToString()) { return m_rvacalc; } |
190 |
if (persistString == typeof(FloatingMemorySectionViewer).ToString()) { return m_msv; } |
191 |
if (persistString == typeof(FloatingUserControlDock).ToString()) { return m_ucd; } |
192 |
if (persistString == typeof(FloatingWebBrowser).ToString()) { return m_wb; } |
193 |
else { return null; } |
194 |
} |
195 |
public void SetupDocks() |
196 |
{ |
197 |
m_LogWindow = new FloatingLogWindow(); |
198 |
LoggerInstance = m_LogWindow.Logwriter; |
199 |
m_AboutBox = new FloatingAboutBox(); |
200 |
m_RamDump = new FloatingRamDumperDialog(); |
201 |
m_PIDSelector = new FloatingPIDSelector(); |
202 |
m_PIDSelector.OnSelectedProcessChanged += new BaseEventHandler<ProcessChangedEventArgs>(OnProcessChanged); |
203 |
m_memoryview = new FloatingMemoryView(); |
204 |
m_typeconverter = new FloatingDataTypeConverter(); |
205 |
m_memsearcher = new FloatingMemorySearcher(); |
206 |
m_memsearcher.OnBrowseMemoryRegion += new BaseEventHandler<BrowseMemoryRegionEvent>(OnBrowseMemoryRegion); |
207 |
m_peviewer = new FloatingPEViewer(); |
208 |
m_peviewer.OnPEDataUpdated += new BaseEventHandler<PEViewerDataUpdatedEventArgs>(OnPEDataUpdated); |
209 |
m_rvacalc = new FloatingRVACalculator(); |
210 |
m_ucd = new FloatingUserControlDock(); |
211 |
m_msv = new FloatingMemorySectionViewer(); |
212 |
m_deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString); |
213 |
m_wb = new FloatingWebBrowser(); |
214 |
} |
215 |
#region SetupDockWindowHandler support |
216 |
public void SetupDockWindowHandler() |
217 |
{ |
218 |
SetupLogWindowHandler(); |
219 |
SetupRamDumpWindowHandler(); |
220 |
SetupMemoryViewWindowHandler(); |
221 |
SetupPIDSelectorWindowHandler(); |
222 |
SetupDataTypeConverterWindowHandler(); |
223 |
SetupMemorySearchWindowHandler(); |
224 |
SetupPEViewerWindowHandler(); |
225 |
SetupRVACalculatorWindowHandler(); |
226 |
SetupMemorySectionViewerWindowHandler(); |
227 |
SetupUserControlDockWindowHandler(); |
228 |
SetupWebBrowserWindowHandler(); |
229 |
} |
230 |
private void SetupLogWindowHandler() |
231 |
{ |
232 |
if (m_LogWindow == null) return; |
233 |
m_LogWindow.Shown += new EventHandler(AddDockToWindowList); |
234 |
m_LogWindow.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
235 |
m_LogWindow.Activate(); |
236 |
} |
237 |
private void SetupRamDumpWindowHandler() |
238 |
{ |
239 |
if (m_RamDump == null) return; |
240 |
m_RamDump.Shown += new EventHandler(AddDockToWindowList); |
241 |
m_RamDump.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
242 |
m_RamDump.AcceptedPlugin = ConfigPlugin; |
243 |
m_RamDump.Activate(); |
244 |
} |
245 |
private void SetupMemoryViewWindowHandler() |
246 |
{ |
247 |
if (m_memoryview == null) return; |
248 |
m_memoryview.Shown += new EventHandler(AddDockToWindowList); |
249 |
m_memoryview.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
250 |
m_memoryview.AcceptedPlugin = ConfigPlugin; |
251 |
m_memoryview.Activate(); |
252 |
} |
253 |
private void SetupPIDSelectorWindowHandler() |
254 |
{ |
255 |
if (m_PIDSelector == null) return; |
256 |
m_PIDSelector.Shown += new EventHandler(AddDockToWindowList); |
257 |
m_PIDSelector.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
258 |
m_PIDSelector.AcceptedPlugin = ConfigPlugin; |
259 |
m_PIDSelector.Activate(); |
260 |
} |
261 |
private void SetupDataTypeConverterWindowHandler() |
262 |
{ |
263 |
if (m_typeconverter == null) return; |
264 |
m_typeconverter.Shown += new EventHandler(AddDockToWindowList); |
265 |
m_typeconverter.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
266 |
m_typeconverter.Activate(); |
267 |
} |
268 |
private void SetupMemorySearchWindowHandler() |
269 |
{ |
270 |
if (m_memsearcher == null) return; |
271 |
m_memsearcher.Shown += new EventHandler(AddDockToWindowList); |
272 |
m_memsearcher.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
273 |
m_memsearcher.Activate(); |
274 |
} |
275 |
private void SetupPEViewerWindowHandler() |
276 |
{ |
277 |
if (m_peviewer == null) return; |
278 |
m_peviewer.Shown += new EventHandler(AddDockToWindowList); |
279 |
m_peviewer.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
280 |
m_PIDSelector.AcceptedPlugin = ConfigPlugin; |
281 |
m_peviewer.Activate(); |
282 |
} |
283 |
private void SetupRVACalculatorWindowHandler() |
284 |
{ |
285 |
if (m_rvacalc == null) return; |
286 |
m_rvacalc.Shown += new EventHandler(AddDockToWindowList); |
287 |
m_rvacalc.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
288 |
m_rvacalc.AcceptedPlugin = ConfigPlugin; |
289 |
m_rvacalc.Activate(); |
290 |
} |
291 |
private void SetupUserControlDockWindowHandler() |
292 |
{ |
293 |
if (m_ucd == null) return; |
294 |
m_ucd.Shown += new EventHandler(AddDockToWindowList); |
295 |
m_ucd.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
296 |
m_ucd.Activate(); |
297 |
} |
298 |
private void SetupMemorySectionViewerWindowHandler() |
299 |
{ |
300 |
if (m_msv == null) return; |
301 |
m_msv.Shown += new EventHandler(AddDockToWindowList); |
302 |
m_msv.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
303 |
m_msv.AcceptedPlugin = ConfigPlugin; |
304 |
m_msv.Activate(); |
305 |
} |
306 |
private void SetupWebBrowserWindowHandler() |
307 |
{ |
308 |
if (m_wb == null) return; |
309 |
m_wb.Shown += new EventHandler(AddDockToWindowList); |
310 |
m_wb.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
311 |
m_wb.Activate(); |
312 |
} |
313 |
#endregion |
314 |
public void ShowDocks() |
315 |
{ |
316 |
ShowLogWindow(); |
317 |
SetupLogWindowHandler(); |
318 |
//ShowAboutBox(); |
319 |
ShowRamDump(); |
320 |
SetupRamDumpWindowHandler(); |
321 |
ShowMemoryView(); |
322 |
SetupMemoryViewWindowHandler(); |
323 |
ShowPidSelector(); |
324 |
SetupPIDSelectorWindowHandler(); |
325 |
ShowDataTypeConverter(); |
326 |
SetupDataTypeConverterWindowHandler(); |
327 |
|
328 |
ShowRVACalculator(); |
329 |
SetupRVACalculatorWindowHandler(); |
330 |
|
331 |
ShowMemorySectionViewer(); |
332 |
SetupMemorySectionViewerWindowHandler(); |
333 |
|
334 |
|
335 |
|
336 |
ShowUserControlDock(); |
337 |
SetupUserControlDockWindowHandler(); |
338 |
|
339 |
ShowMemorySearch(); |
340 |
SetupMemorySearchWindowHandler(); |
341 |
ShowPEViewer(); |
342 |
SetupPEViewerWindowHandler(); |
343 |
|
344 |
ShowWebBrowser(); |
345 |
SetupWebBrowserWindowHandler(); |
346 |
} |
347 |
public void ShowLogWindow() |
348 |
{ |
349 |
if (m_LogWindow == null || m_LogWindow.IsDisposed) { m_LogWindow = new FloatingLogWindow(); } |
350 |
LoggerInstance = m_LogWindow.Logwriter; |
351 |
//LoggerInstance.CreateNewLog(false); |
352 |
m_LogWindow.Show(dockPanel, DockState.DockBottom); |
353 |
} |
354 |
public void ShowAboutBox() |
355 |
{ |
356 |
if (m_AboutBox == null || m_AboutBox.IsDisposed) { m_AboutBox = new FloatingAboutBox(); } |
357 |
m_AboutBox.ShowDialog(); |
358 |
} |
359 |
public void ShowRamDump() |
360 |
{ |
361 |
//load_plugins_silent(); |
362 |
m_RamDump = new FloatingRamDumperDialog(ConfigPlugin); |
363 |
m_RamDump.AcceptedProcess = SelectedProcess; |
364 |
m_RamDump.Show(dockPanel); |
365 |
} |
366 |
public void ShowMemoryView() |
367 |
{ |
368 |
//load_plugins_silent(); |
369 |
m_memoryview = new FloatingMemoryView(ConfigPlugin); |
370 |
m_memoryview.AcceptedProcess = SelectedProcess; |
371 |
m_memoryview.Show(dockPanel); |
372 |
} |
373 |
public void ShowPidSelector() |
374 |
{ |
375 |
//load_plugins_silent(); |
376 |
//List<Process> procs = ConfigPlugin.ValidProcessesForPlugin; |
377 |
m_PIDSelector = new FloatingPIDSelector(ConfigPlugin); |
378 |
m_PIDSelector.OnSelectedProcessChanged += new BaseEventHandler<ProcessChangedEventArgs>(OnProcessChanged); |
379 |
m_PIDSelector.Show(dockPanel); |
380 |
} |
381 |
public void ShowDataTypeConverter() |
382 |
{ |
383 |
if (m_typeconverter == null || m_typeconverter.IsDisposed) { m_typeconverter = new FloatingDataTypeConverter(); } |
384 |
m_typeconverter.Show(dockPanel, DockState.DockRightAutoHide); |
385 |
} |
386 |
public void ShowMemorySearch() |
387 |
{ |
388 |
//load_plugins_silent(); |
389 |
m_memsearcher = new FloatingMemorySearcher(ConfigPlugin); |
390 |
m_memsearcher.AcceptedProcess = SelectedProcess; |
391 |
m_memsearcher.OnBrowseMemoryRegion += new BaseEventHandler<BrowseMemoryRegionEvent>(OnBrowseMemoryRegion); |
392 |
m_memsearcher.Show(dockPanel); |
393 |
} |
394 |
public void ShowPEViewer() |
395 |
{ |
396 |
//load_plugins_silent(); |
397 |
m_peviewer = new FloatingPEViewer(ConfigPlugin); |
398 |
m_peviewer.AcceptedProcess = SelectedProcess; |
399 |
m_peviewer.OnPEDataUpdated += new BaseEventHandler<PEViewerDataUpdatedEventArgs>(OnPEDataUpdated); |
400 |
m_peviewer.Show(dockPanel); |
401 |
} |
402 |
public void ShowRVACalculator() |
403 |
{ |
404 |
//load_plugins_silent(); |
405 |
m_rvacalc = new FloatingRVACalculator(ConfigPlugin); |
406 |
m_rvacalc.AcceptedProcess = SelectedProcess; |
407 |
m_rvacalc.Show(dockPanel, DockState.DockRightAutoHide); |
408 |
} |
409 |
public void ShowMemorySectionViewer() |
410 |
{ |
411 |
//load_plugins_silent(); |
412 |
m_msv = new FloatingMemorySectionViewer(ConfigPlugin); |
413 |
m_msv.AcceptedProcess = SelectedProcess; |
414 |
m_msv.Show(dockPanel); |
415 |
} |
416 |
public void ShowUserControlDock() |
417 |
{ |
418 |
//load_plugins_silent(); |
419 |
if (m_ucd == null) |
420 |
{ |
421 |
m_ucd = new FloatingUserControlDock(); |
422 |
} |
423 |
if (this.UserControlPlugins.Count > 0) |
424 |
{ |
425 |
m_ucd.UserPlugins = this.UserControlPlugins; |
426 |
} |
427 |
m_ucd.Show(dockPanel, DockState.DockRightAutoHide); |
428 |
} |
429 |
public void ShowWebBrowser() |
430 |
{ |
431 |
//load_plugins_silent(); |
432 |
m_wb = new FloatingWebBrowser(); |
433 |
m_wb.Show(dockPanel); |
434 |
} |
435 |
#endregion |
436 |
|
437 |
|
438 |
public Main() : this(false) { } |
439 |
public Main(bool no_console_redirect) |
440 |
{ |
441 |
InitializeComponent(); |
442 |
#if SHOW_DEBUG_MENU |
443 |
mnuDebug.Visible = true; |
444 |
#else |
445 |
mnuDebug.Visible = false; |
446 |
#endif |
447 |
SettingsSubscriber = new SettingSubscriber(); |
448 |
SettingsSubscriber.AddSubscriber(this, Settings.Default); |
449 |
SetupDocks(); |
450 |
LoggerInstance = m_LogWindow.Logwriter; |
451 |
load_loggerflags(); |
452 |
load_plugins(); |
453 |
} |
454 |
private void load_loggerflags() |
455 |
{ |
456 |
bool upgraded_flags = Logging.Properties.Settings.Default.UpgradedLogLevel; |
457 |
if (!upgraded_flags) |
458 |
{ |
459 |
logging_level = new LoggingFlagsConverter(Logging.Properties.Settings.Default.LoggingFlags).ConvertFlags(); |
460 |
Logging.Properties.Settings.Default.UpgradedLogLevel = true; |
461 |
Logging.Properties.Settings.Default.gLogLoggingFlags = (uint)logging_level; |
462 |
Logging.Properties.Settings.Default.Save(); |
463 |
} |
464 |
logging_level = (LogLevel)Logging.Properties.Settings.Default.gLogLoggingFlags; |
465 |
#if FORCE_ALL_LOGGING_FLAGS |
466 |
logging_level = LogLevel.kLogLevel_All; |
467 |
#endif |
468 |
#if FORCE_DISABLE_PROFILER_LOGLEVEL |
469 |
logging_level = logging_level & ~LogLevel.kLogLevel_Profiler; |
470 |
logging_level = logging_level & ~LogLevel.kLogLevel_VerboseProfiler; |
471 |
#endif |
472 |
gLog.CreateLog(LoggingConstants.AppFullLogPath, true, logging_level, new EventHandler<LoggerOnFlushEventArgs>(Log_OnFlush), LoggerInstance.Log); |
473 |
} |
474 |
|
475 |
private void Log_OnFlush(object sender, LoggerOnFlushEventArgs e) |
476 |
{ |
477 |
} |
478 |
private void load_plugins() { load_plugins(false); } |
479 |
private void load_plugins_silent() { load_plugins(true); } |
480 |
private void load_plugins(bool silent) |
481 |
{ |
482 |
loader = new PluginLoader(); |
483 |
loader.LoadPlugins(silent); |
484 |
|
485 |
ConfigPlugin = loader.GetConfigPlugin(RomCheater.Properties.Settings.Default.LastConfigPlugin); |
486 |
if (ConfigPlugin != null && !silent) |
487 |
gLog.Info.WriteLine("Loaded Config Plugin: {0}", ConfigPlugin.ToString()); |
488 |
InputPlugin = loader.GetInputPlugin(RomCheater.Properties.Settings.Default.LastInputPlugin); |
489 |
if (InputPlugin != null && !silent) |
490 |
gLog.Info.WriteLine("Loaded Input Plugin: {0}", InputPlugin.ToString()); |
491 |
WindowPlugin = loader.GetWindowPlugin(RomCheater.Properties.Settings.Default.LastWindowPlugin); |
492 |
if (WindowPlugin != null && !silent) |
493 |
gLog.Info.WriteLine("Loaded Window Plugin: {0}", WindowPlugin.ToString()); |
494 |
|
495 |
|
496 |
UserControlPlugins = new List<IUserControlPlugin>(loader.LoadedUserControlPlugins); |
497 |
if (UserControlPlugins != null) |
498 |
{ |
499 |
foreach (var t in UserControlPlugins) |
500 |
{ |
501 |
if (!silent) |
502 |
gLog.Info.WriteLine("Loaded UserControl Plugin: {0}", t.ToString()); |
503 |
} |
504 |
|
505 |
string stacktrace = System.Environment.StackTrace; |
506 |
|
507 |
if (UserControlPlugins.Count > 0) |
508 |
{ |
509 |
m_ucd.UserPlugins = UserControlPlugins; |
510 |
} |
511 |
} |
512 |
|
513 |
ConfigPlugin.WebBrowserProvider = this.WebBrowserProvider; |
514 |
|
515 |
|
516 |
m_PIDSelector.AcceptedPlugin = ConfigPlugin; |
517 |
m_RamDump.AcceptedPlugin = ConfigPlugin; |
518 |
m_memoryview.AcceptedPlugin = ConfigPlugin; |
519 |
m_memsearcher.AcceptedPlugin = ConfigPlugin; |
520 |
m_PIDSelector.AcceptedPlugin = ConfigPlugin; |
521 |
if (this.SelectedProcess != null) |
522 |
{ |
523 |
m_RamDump.AcceptedProcess = SelectedProcess; |
524 |
m_memoryview.AcceptedProcess = SelectedProcess; |
525 |
m_memsearcher.AcceptedProcess = SelectedProcess; |
526 |
} |
527 |
|
528 |
|
529 |
} |
530 |
|
531 |
private void mnuItemExit_Click(object sender, EventArgs e) |
532 |
{ |
533 |
this.Close(); |
534 |
} |
535 |
|
536 |
|
537 |
private void Main_Load(object sender, EventArgs e) |
538 |
{ |
539 |
SettingsSubscriber.SaveSettings(); |
540 |
} |
541 |
|
542 |
private void mnuItemConfig_Click(object sender, EventArgs e) |
543 |
{ |
544 |
RomCheaterConfigDialog dlg = new RomCheaterConfigDialog(loader); |
545 |
dlg.ShowDialog(); |
546 |
//logger.ForceLog.Info.WriteLine("LoggingFlags = 0x{0:x4} ({1})", logger.GetLoggingFlags().Value, logger.GetLoggingFlags().Name); |
547 |
// reload plugins |
548 |
load_plugins(true); |
549 |
} |
550 |
|
551 |
private void mnuItemOpenProcess_Click(object sender, EventArgs e) |
552 |
{ |
553 |
////List<Process> procs = ConfigPlugin.ValidProcessesForPlugin; |
554 |
//PIDSelector selector = new PIDSelector(ConfigPlugin); |
555 |
//selector.ShowDialog(); |
556 |
} |
557 |
|
558 |
private void Main_Shown(object sender, EventArgs e) |
559 |
{ |
560 |
//dockPanel.SuspendLayout(true); |
561 |
//ShowDocks(); |
562 |
string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), DockPanelConfig); |
563 |
if (File.Exists(configFile)) |
564 |
{ |
565 |
try |
566 |
{ |
567 |
dockPanel.LoadFromXml(configFile, m_deserializeDockContent); |
568 |
SetupDockWindowHandler(); |
569 |
} |
570 |
catch (Exception) |
571 |
{ |
572 |
this.Controls.Remove(dockPanel); |
573 |
dockPanel = new DockPanel(); |
574 |
dockPanel.Dock = DockStyle.Fill; |
575 |
dockPanel.DocumentStyle = DocumentStyle.DockingWindow; |
576 |
this.Controls.Add(dockPanel); |
577 |
ShowDocks(); |
578 |
} |
579 |
} |
580 |
else |
581 |
{ |
582 |
ShowDocks(); |
583 |
} |
584 |
|
585 |
//dockPanel.ResumeLayout(true, true); |
586 |
} |
587 |
|
588 |
private void mnuItemShowLogWindow_Click(object sender, EventArgs e) |
589 |
{ |
590 |
ShowLogWindow(); |
591 |
} |
592 |
|
593 |
private void mnuItemHelpAbout_Click(object sender, EventArgs e) |
594 |
{ |
595 |
ShowAboutBox(); |
596 |
} |
597 |
|
598 |
private void mnuItemShowRamDumpDialog_Click(object sender, EventArgs e) |
599 |
{ |
600 |
ShowRamDump(); |
601 |
} |
602 |
|
603 |
private void mnuItemShowPIDSelector_Click(object sender, EventArgs e) |
604 |
{ |
605 |
ShowPidSelector(); |
606 |
} |
607 |
private void mnuItemShowMemoryView_Click(object sender, EventArgs e) |
608 |
{ |
609 |
ShowMemoryView(); |
610 |
} |
611 |
private void Main_FormClosing(object sender, FormClosingEventArgs e) |
612 |
{ |
613 |
SettingsSubscriber.SaveSettings(); |
614 |
string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), DockPanelConfig); |
615 |
if (m_bSaveLayout) |
616 |
dockPanel.SaveAsXml(configFile); |
617 |
else if (File.Exists(configFile)) |
618 |
File.Delete(configFile); |
619 |
|
620 |
SearchResultWriter.CleanupTemporarySearchResultFiles(); |
621 |
|
622 |
|
623 |
// notify any docked windows of formclosing |
624 |
|
625 |
foreach (var t in this.dockPanel.Contents) |
626 |
{ |
627 |
t.OnDeactivate<FormClosingEventArgs>(e); |
628 |
} |
629 |
|
630 |
} |
631 |
|
632 |
private void mnuTestExeParse_Click(object sender, EventArgs e) |
633 |
{ |
634 |
IPEDData peData = new PEData((IAcceptsProcessAndConfig)this); |
635 |
} |
636 |
|
637 |
private void mnuItemFindMaxNonNegativeHexValue_Click(object sender, EventArgs e) |
638 |
{ |
639 |
|
640 |
//uint start = 0xf0000000; |
641 |
uint end = uint.MaxValue; |
642 |
//for (uint i = start; i < end; i++) |
643 |
//{ |
644 |
ulong value = Convert.ToUInt64(end.ToString(), 16); |
645 |
//} |
646 |
} |
647 |
|
648 |
private void mnuItemShowDataTypeConverter_Click(object sender, EventArgs e) |
649 |
{ |
650 |
ShowDataTypeConverter(); |
651 |
} |
652 |
|
653 |
private void mnuItemShowMemorySearch_Click(object sender, EventArgs e) |
654 |
{ |
655 |
ShowMemorySearch(); |
656 |
} |
657 |
|
658 |
private void mnuItemDateShift_Click(object sender, EventArgs e) |
659 |
{ |
660 |
DateTime t = DateTime.Now; |
661 |
int year = Convert.ToInt32(t.ToString("yy")); |
662 |
int y = year << 9; |
663 |
int m = t.Month << 5; |
664 |
int d = t.Day; |
665 |
|
666 |
ushort v1 = (ushort)(y | m | d); |
667 |
|
668 |
t = t.AddDays(1); |
669 |
year = Convert.ToInt32(t.ToString("yy")); |
670 |
y = year << 9; |
671 |
m = t.Month << 5; |
672 |
d = t.Day; |
673 |
ushort v2 = (ushort)(y | m | d); |
674 |
|
675 |
t = t.AddDays(1); |
676 |
year = Convert.ToInt32(t.ToString("yy")); |
677 |
y = year << 9; |
678 |
m = t.Month << 5; |
679 |
d = t.Day; |
680 |
ushort v3 = (ushort)(y | m | d); |
681 |
|
682 |
t = new DateTime(9999,12,31); |
683 |
year = Convert.ToInt32(t.ToString("yy")); |
684 |
y = year << 9; |
685 |
m = t.Month << 5; |
686 |
d = t.Day; |
687 |
ushort v4 = (ushort)(y | m | d); |
688 |
} |
689 |
|
690 |
private void mnuItemShowPEViewer_Click(object sender, EventArgs e) |
691 |
{ |
692 |
ShowPEViewer(); |
693 |
} |
694 |
|
695 |
private void mnuItemShowRVACalculator_Click(object sender, EventArgs e) |
696 |
{ |
697 |
ShowRVACalculator(); |
698 |
} |
699 |
|
700 |
private void mnuItemShowUserControlDock_Click(object sender, EventArgs e) |
701 |
{ |
702 |
ShowUserControlDock(); |
703 |
} |
704 |
|
705 |
private void mnuItemShowMemorySectionViewer_Click(object sender, EventArgs e) |
706 |
{ |
707 |
ShowMemorySectionViewer(); |
708 |
} |
709 |
|
710 |
private void mnuItemShowWebBrowser_Click(object sender, EventArgs e) |
711 |
{ |
712 |
ShowWebBrowser(); |
713 |
} |
714 |
} |
715 |
} |