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

Contents of /trunk/RomCheater/Main.cs

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.22