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

Contents of /trunk/RomCheater/Main.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 905 - (show annotations) (download)
Wed Sep 17 13:04:54 2014 UTC (5 years, 4 months ago) by william
File size: 30333 byte(s)
+ don't activate multiple windows/panels -- only do it once

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

  ViewVC Help
Powered by ViewVC 1.1.22