/[RomCheater]/trunk/RomCheater/Main.cs
ViewVC logotype

Contents of /trunk/RomCheater/Main.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 817 - (show annotations) (download)
Tue Apr 15 18:02:07 2014 UTC (8 years, 1 month ago) by william
File size: 29423 byte(s)

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 #warning LoggingFlags setting needs to be changed to Uint32 instead of Uint16
457
458 bool upgraded_flags = Logging.Properties.Settings.Default.UpgradedLogLevel;
459 if (!upgraded_flags)
460 {
461 logging_level = new LoggingFlagsConverter(Logging.Properties.Settings.Default.LoggingFlags).ConvertFlags();
462 Logging.Properties.Settings.Default.UpgradedLogLevel = true;
463 Logging.Properties.Settings.Default.gLogLoggingFlags = (uint)logging_level;
464 Logging.Properties.Settings.Default.Save();
465 }
466 logging_level = (LogLevel)Logging.Properties.Settings.Default.gLogLoggingFlags;
467 #if FORCE_ALL_LOGGING_FLAGS
468 logging_level = LogLevel.kLogLevel_All;
469 #endif
470 #if FORCE_DISABLE_PROFILER_LOGLEVEL
471 logging_level = logging_level & ~LogLevel.kLogLevel_Profiler;
472 logging_level = logging_level & ~LogLevel.kLogLevel_VerboseProfiler;
473 #endif
474 gLog.CreateLog(LoggingConstants.AppFullLogPath, true, logging_level, new EventHandler<LoggerOnFlushEventArgs>(Log_OnFlush), LoggerInstance.Log);
475 }
476
477 private void Log_OnFlush(object sender, LoggerOnFlushEventArgs e)
478 {
479 }
480 private void load_plugins() { load_plugins(false); }
481 private void load_plugins_silent() { load_plugins(true); }
482 private void load_plugins(bool silent)
483 {
484 loader = new PluginLoader();
485 loader.LoadPlugins(silent);
486
487 ConfigPlugin = loader.GetConfigPlugin(RomCheater.Properties.Settings.Default.LastConfigPlugin);
488 if (ConfigPlugin != null && !silent)
489 gLog.Info.WriteLine("Loaded Config Plugin: {0}", ConfigPlugin.ToString());
490 InputPlugin = loader.GetInputPlugin(RomCheater.Properties.Settings.Default.LastInputPlugin);
491 if (InputPlugin != null && !silent)
492 gLog.Info.WriteLine("Loaded Input Plugin: {0}", InputPlugin.ToString());
493 WindowPlugin = loader.GetWindowPlugin(RomCheater.Properties.Settings.Default.LastWindowPlugin);
494 if (WindowPlugin != null && !silent)
495 gLog.Info.WriteLine("Loaded Window Plugin: {0}", WindowPlugin.ToString());
496
497
498 UserControlPlugins = new List<IUserControlPlugin>(loader.LoadedUserControlPlugins);
499 if (UserControlPlugins != null)
500 {
501 foreach (var t in UserControlPlugins)
502 {
503 if (!silent)
504 gLog.Info.WriteLine("Loaded UserControl Plugin: {0}", t.ToString());
505 }
506
507 string stacktrace = System.Environment.StackTrace;
508
509 if (UserControlPlugins.Count > 0)
510 {
511 m_ucd.UserPlugins = UserControlPlugins;
512 }
513 }
514
515 ConfigPlugin.WebBrowserProvider = this.WebBrowserProvider;
516
517
518 m_PIDSelector.AcceptedPlugin = ConfigPlugin;
519 m_RamDump.AcceptedPlugin = ConfigPlugin;
520 m_memoryview.AcceptedPlugin = ConfigPlugin;
521 m_memsearcher.AcceptedPlugin = ConfigPlugin;
522 m_PIDSelector.AcceptedPlugin = ConfigPlugin;
523 if (this.SelectedProcess != null)
524 {
525 m_RamDump.AcceptedProcess = SelectedProcess;
526 m_memoryview.AcceptedProcess = SelectedProcess;
527 m_memsearcher.AcceptedProcess = SelectedProcess;
528 }
529
530
531 }
532
533 private void mnuItemExit_Click(object sender, EventArgs e)
534 {
535 this.Close();
536 }
537
538
539 private void Main_Load(object sender, EventArgs e)
540 {
541 SettingsSubscriber.SaveSettings();
542 }
543
544 private void mnuItemConfig_Click(object sender, EventArgs e)
545 {
546 RomCheaterConfigDialog dlg = new RomCheaterConfigDialog(loader);
547 dlg.ShowDialog();
548 //logger.ForceLog.Info.WriteLine("LoggingFlags = 0x{0:x4} ({1})", logger.GetLoggingFlags().Value, logger.GetLoggingFlags().Name);
549 // reload plugins
550 load_plugins(true);
551 }
552
553 private void mnuItemOpenProcess_Click(object sender, EventArgs e)
554 {
555 ////List<Process> procs = ConfigPlugin.ValidProcessesForPlugin;
556 //PIDSelector selector = new PIDSelector(ConfigPlugin);
557 //selector.ShowDialog();
558 }
559
560 private void Main_Shown(object sender, EventArgs e)
561 {
562 //dockPanel.SuspendLayout(true);
563 //ShowDocks();
564 string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), DockPanelConfig);
565 if (File.Exists(configFile))
566 {
567 try
568 {
569 dockPanel.LoadFromXml(configFile, m_deserializeDockContent);
570 SetupDockWindowHandler();
571 }
572 catch (Exception)
573 {
574 this.Controls.Remove(dockPanel);
575 dockPanel = new DockPanel();
576 dockPanel.Dock = DockStyle.Fill;
577 dockPanel.DocumentStyle = DocumentStyle.DockingWindow;
578 this.Controls.Add(dockPanel);
579 ShowDocks();
580 }
581 }
582 else
583 {
584 ShowDocks();
585 }
586
587 //dockPanel.ResumeLayout(true, true);
588 }
589
590 private void mnuItemShowLogWindow_Click(object sender, EventArgs e)
591 {
592 ShowLogWindow();
593 }
594
595 private void mnuItemHelpAbout_Click(object sender, EventArgs e)
596 {
597 ShowAboutBox();
598 }
599
600 private void mnuItemShowRamDumpDialog_Click(object sender, EventArgs e)
601 {
602 ShowRamDump();
603 }
604
605 private void mnuItemShowPIDSelector_Click(object sender, EventArgs e)
606 {
607 ShowPidSelector();
608 }
609 private void mnuItemShowMemoryView_Click(object sender, EventArgs e)
610 {
611 ShowMemoryView();
612 }
613 private void Main_FormClosing(object sender, FormClosingEventArgs e)
614 {
615 SettingsSubscriber.SaveSettings();
616 string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), DockPanelConfig);
617 if (m_bSaveLayout)
618 dockPanel.SaveAsXml(configFile);
619 else if (File.Exists(configFile))
620 File.Delete(configFile);
621
622 SearchResultWriter.CleanupTemporarySearchResultFiles();
623
624
625 // notify any docked windows of formclosing
626
627 foreach (var t in this.dockPanel.Contents)
628 {
629 t.OnDeactivate<FormClosingEventArgs>(e);
630 }
631
632 }
633
634 private void mnuTestExeParse_Click(object sender, EventArgs e)
635 {
636 IPEDData peData = new PEData((IAcceptsProcessAndConfig)this);
637 }
638
639 private void mnuItemFindMaxNonNegativeHexValue_Click(object sender, EventArgs e)
640 {
641
642 //uint start = 0xf0000000;
643 uint end = uint.MaxValue;
644 //for (uint i = start; i < end; i++)
645 //{
646 ulong value = Convert.ToUInt64(end.ToString(), 16);
647 //}
648 }
649
650 private void mnuItemShowDataTypeConverter_Click(object sender, EventArgs e)
651 {
652 ShowDataTypeConverter();
653 }
654
655 private void mnuItemShowMemorySearch_Click(object sender, EventArgs e)
656 {
657 ShowMemorySearch();
658 }
659
660 private void mnuItemDateShift_Click(object sender, EventArgs e)
661 {
662 DateTime t = DateTime.Now;
663 int year = Convert.ToInt32(t.ToString("yy"));
664 int y = year << 9;
665 int m = t.Month << 5;
666 int d = t.Day;
667
668 ushort v1 = (ushort)(y | m | d);
669
670 t = t.AddDays(1);
671 year = Convert.ToInt32(t.ToString("yy"));
672 y = year << 9;
673 m = t.Month << 5;
674 d = t.Day;
675 ushort v2 = (ushort)(y | m | d);
676
677 t = t.AddDays(1);
678 year = Convert.ToInt32(t.ToString("yy"));
679 y = year << 9;
680 m = t.Month << 5;
681 d = t.Day;
682 ushort v3 = (ushort)(y | m | d);
683
684 t = new DateTime(9999,12,31);
685 year = Convert.ToInt32(t.ToString("yy"));
686 y = year << 9;
687 m = t.Month << 5;
688 d = t.Day;
689 ushort v4 = (ushort)(y | m | d);
690 }
691
692 private void mnuItemShowPEViewer_Click(object sender, EventArgs e)
693 {
694 ShowPEViewer();
695 }
696
697 private void mnuItemShowRVACalculator_Click(object sender, EventArgs e)
698 {
699 ShowRVACalculator();
700 }
701
702 private void mnuItemShowUserControlDock_Click(object sender, EventArgs e)
703 {
704 ShowUserControlDock();
705 }
706
707 private void mnuItemShowMemorySectionViewer_Click(object sender, EventArgs e)
708 {
709 ShowMemorySectionViewer();
710 }
711
712 private void mnuItemShowWebBrowser_Click(object sender, EventArgs e)
713 {
714 ShowWebBrowser();
715 }
716 }
717 }

  ViewVC Help
Powered by ViewVC 1.1.22