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

Contents of /trunk/RomCheater/Main.cs

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.22