ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater/Main.cs
Revision: 815
Committed: Tue Apr 15 16:34:03 2014 UTC (8 years, 7 months ago) by william
File size: 29133 byte(s)
Log Message:

File Contents

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