ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater/Main.cs
Revision: 755
Committed: Thu Jun 20 20:04:53 2013 UTC (9 years, 1 month ago) by william
File size: 28334 byte(s)
Log Message:
* rename DockPanel config files
* use a constant string to set the config filename (so we can update/maintain in one location)

File Contents

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