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

Contents of /trunk/RomCheater/Main.cs

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.22