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

Contents of /trunk/RomCheater/Main.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 838 - (show annotations) (download)
Tue Sep 16 00:57:18 2014 UTC (6 years ago) by william
File size: 29410 byte(s)
+ add an icon resource

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

  ViewVC Help
Powered by ViewVC 1.1.22