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

Contents of /trunk/RomCheater/Main.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 815 - (show annotations) (download)
Tue Apr 15 16:34:03 2014 UTC (7 years, 7 months ago) by william
File size: 29133 byte(s)

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

  ViewVC Help
Powered by ViewVC 1.1.22