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

Annotation of /trunk/RomCheater/Main.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 699 - (hide annotations) (download)
Mon Jun 17 12:40:47 2013 UTC (7 years, 4 months ago) by william
File size: 28061 byte(s)
+ work out passing around the webbrowser through the config plugin

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

  ViewVC Help
Powered by ViewVC 1.1.22