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

Annotation of /trunk/RomCheater/Main.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 814 - (hide annotations) (download)
Tue Apr 15 15:58:50 2014 UTC (7 years ago) by william
File size: 28750 byte(s)

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     logging_level = (LogLevel)(Logging.Properties.Settings.Default.LoggingFlags);
457     logging_level = new LoggingFlagsConverter(Logging.Properties.Settings.Default.LoggingFlags).ConvertFlags();
458 william 99 #if FORCE_ALL_LOGGING_FLAGS
459 william 814 logging_level = LogLevel.kLogLevel_All;
460     #endif
461     gLog.CreateLog(LoggingConstants.AppFullLogPath, true, logging_level, new EventHandler<LoggerOnFlushEventArgs>(Log_OnFlush), LoggerInstance.Log);
462 william 83 }
463 william 814
464     private void Log_OnFlush(object sender, LoggerOnFlushEventArgs e)
465     {
466     }
467 william 366 private void load_plugins() { load_plugins(false); }
468     private void load_plugins_silent() { load_plugins(true); }
469     private void load_plugins(bool silent)
470 william 87 {
471     loader = new PluginLoader();
472 william 366 loader.LoadPlugins(silent);
473 william 83
474 william 87 ConfigPlugin = loader.GetConfigPlugin(RomCheater.Properties.Settings.Default.LastConfigPlugin);
475 william 366 if (ConfigPlugin != null && !silent)
476 william 813 gLog.Info.WriteLine("Loaded Config Plugin: {0}", ConfigPlugin.ToString());
477 william 87 InputPlugin = loader.GetInputPlugin(RomCheater.Properties.Settings.Default.LastInputPlugin);
478 william 366 if (InputPlugin != null && !silent)
479 william 813 gLog.Info.WriteLine("Loaded Input Plugin: {0}", InputPlugin.ToString());
480 william 87 WindowPlugin = loader.GetWindowPlugin(RomCheater.Properties.Settings.Default.LastWindowPlugin);
481 william 366 if (WindowPlugin != null && !silent)
482 william 813 gLog.Info.WriteLine("Loaded Window Plugin: {0}", WindowPlugin.ToString());
483 william 87
484 william 437
485     UserControlPlugins = new List<IUserControlPlugin>(loader.LoadedUserControlPlugins);
486 william 639 if (UserControlPlugins != null)
487 william 437 {
488     foreach (var t in UserControlPlugins)
489     {
490 william 639 if (!silent)
491 william 813 gLog.Info.WriteLine("Loaded UserControl Plugin: {0}", t.ToString());
492 william 437 }
493 william 639
494     string stacktrace = System.Environment.StackTrace;
495    
496     if (UserControlPlugins.Count > 0)
497     {
498 william 696 m_ucd.UserPlugins = UserControlPlugins;
499 william 639 }
500 william 437 }
501    
502 william 696 ConfigPlugin.WebBrowserProvider = this.WebBrowserProvider;
503 william 437
504 william 696
505 william 153 m_PIDSelector.AcceptedPlugin = ConfigPlugin;
506     m_RamDump.AcceptedPlugin = ConfigPlugin;
507 william 267 m_memoryview.AcceptedPlugin = ConfigPlugin;
508     m_memsearcher.AcceptedPlugin = ConfigPlugin;
509 william 335 m_PIDSelector.AcceptedPlugin = ConfigPlugin;
510 william 477 if (this.SelectedProcess != null)
511 william 267 {
512 william 477 m_RamDump.AcceptedProcess = SelectedProcess;
513     m_memoryview.AcceptedProcess = SelectedProcess;
514     m_memsearcher.AcceptedProcess = SelectedProcess;
515 william 267 }
516 william 152
517 william 639
518 william 87 }
519    
520 william 14 private void mnuItemExit_Click(object sender, EventArgs e)
521     {
522     this.Close();
523     }
524 william 16
525 william 17
526     private void Main_Load(object sender, EventArgs e)
527 william 144 {
528 william 722 SettingsSubscriber.SaveSettings();
529 william 17 }
530 william 63
531     private void mnuItemConfig_Click(object sender, EventArgs e)
532     {
533 william 86 RomCheaterConfigDialog dlg = new RomCheaterConfigDialog(loader);
534 william 63 dlg.ShowDialog();
535 william 813 //logger.ForceLog.Info.WriteLine("LoggingFlags = 0x{0:x4} ({1})", logger.GetLoggingFlags().Value, logger.GetLoggingFlags().Name);
536 william 92 // reload plugins
537 william 366 load_plugins(true);
538 william 63 }
539 william 69
540     private void mnuItemOpenProcess_Click(object sender, EventArgs e)
541     {
542 william 148 ////List<Process> procs = ConfigPlugin.ValidProcessesForPlugin;
543     //PIDSelector selector = new PIDSelector(ConfigPlugin);
544     //selector.ShowDialog();
545 william 69 }
546 william 104
547 william 144 private void Main_Shown(object sender, EventArgs e)
548 william 104 {
549 william 152 //dockPanel.SuspendLayout(true);
550     //ShowDocks();
551 william 755 string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), DockPanelConfig);
552 william 152 if (File.Exists(configFile))
553     {
554     try
555     {
556     dockPanel.LoadFromXml(configFile, m_deserializeDockContent);
557 william 313 SetupDockWindowHandler();
558 william 152 }
559 william 177 catch (Exception)
560 william 152 {
561     this.Controls.Remove(dockPanel);
562     dockPanel = new DockPanel();
563     dockPanel.Dock = DockStyle.Fill;
564     dockPanel.DocumentStyle = DocumentStyle.DockingWindow;
565     this.Controls.Add(dockPanel);
566     ShowDocks();
567     }
568     }
569     else
570     {
571     ShowDocks();
572     }
573    
574     //dockPanel.ResumeLayout(true, true);
575 william 104 }
576 william 144
577     private void mnuItemShowLogWindow_Click(object sender, EventArgs e)
578     {
579     ShowLogWindow();
580     }
581 william 147
582     private void mnuItemHelpAbout_Click(object sender, EventArgs e)
583     {
584     ShowAboutBox();
585     }
586 william 148
587     private void mnuItemShowRamDumpDialog_Click(object sender, EventArgs e)
588     {
589     ShowRamDump();
590     }
591    
592     private void mnuItemShowPIDSelector_Click(object sender, EventArgs e)
593     {
594     ShowPidSelector();
595     }
596 william 201 private void mnuItemShowMemoryView_Click(object sender, EventArgs e)
597     {
598     ShowMemoryView();
599     }
600 william 152 private void Main_FormClosing(object sender, FormClosingEventArgs e)
601     {
602 william 722 SettingsSubscriber.SaveSettings();
603 william 755 string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), DockPanelConfig);
604 william 152 if (m_bSaveLayout)
605     dockPanel.SaveAsXml(configFile);
606     else if (File.Exists(configFile))
607     File.Delete(configFile);
608 william 449
609     SearchResultWriter.CleanupTemporarySearchResultFiles();
610    
611 william 678
612     // notify any docked windows of formclosing
613    
614     foreach (var t in this.dockPanel.Contents)
615     {
616     t.OnDeactivate<FormClosingEventArgs>(e);
617     }
618    
619 william 152 }
620 william 158
621     private void mnuTestExeParse_Click(object sender, EventArgs e)
622     {
623 william 607 IPEDData peData = new PEData((IAcceptsProcessAndConfig)this);
624 william 158 }
625 william 201
626     private void mnuItemFindMaxNonNegativeHexValue_Click(object sender, EventArgs e)
627     {
628    
629     //uint start = 0xf0000000;
630     uint end = uint.MaxValue;
631     //for (uint i = start; i < end; i++)
632     //{
633     ulong value = Convert.ToUInt64(end.ToString(), 16);
634     //}
635     }
636 william 218
637     private void mnuItemShowDataTypeConverter_Click(object sender, EventArgs e)
638     {
639     ShowDataTypeConverter();
640     }
641 william 227
642     private void mnuItemShowMemorySearch_Click(object sender, EventArgs e)
643     {
644     ShowMemorySearch();
645     }
646 william 260
647     private void mnuItemDateShift_Click(object sender, EventArgs e)
648     {
649     DateTime t = DateTime.Now;
650     int year = Convert.ToInt32(t.ToString("yy"));
651     int y = year << 9;
652     int m = t.Month << 5;
653     int d = t.Day;
654    
655     ushort v1 = (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 v2 = (ushort)(y | m | d);
663    
664     t = t.AddDays(1);
665     year = Convert.ToInt32(t.ToString("yy"));
666     y = year << 9;
667     m = t.Month << 5;
668     d = t.Day;
669     ushort v3 = (ushort)(y | m | d);
670    
671     t = new DateTime(9999,12,31);
672     year = Convert.ToInt32(t.ToString("yy"));
673     y = year << 9;
674     m = t.Month << 5;
675     d = t.Day;
676     ushort v4 = (ushort)(y | m | d);
677     }
678 william 318
679     private void mnuItemShowPEViewer_Click(object sender, EventArgs e)
680     {
681     ShowPEViewer();
682     }
683    
684 william 366 private void mnuItemShowRVACalculator_Click(object sender, EventArgs e)
685     {
686     ShowRVACalculator();
687 william 439 }
688    
689     private void mnuItemShowUserControlDock_Click(object sender, EventArgs e)
690     {
691     ShowUserControlDock();
692 william 596 }
693    
694     private void mnuItemShowMemorySectionViewer_Click(object sender, EventArgs e)
695     {
696     ShowMemorySectionViewer();
697 william 695 }
698    
699     private void mnuItemShowWebBrowser_Click(object sender, EventArgs e)
700     {
701     ShowWebBrowser();
702 william 366 }
703 william 5 }
704     }

  ViewVC Help
Powered by ViewVC 1.1.22