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

Contents of /trunk/RomCheater/Main.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 891 - (show annotations) (download)
Wed Sep 17 05:14:20 2014 UTC (7 years, 4 months ago) by william
File size: 29992 byte(s)

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) { c.Icon = Core.Properties.Resources.romcheater_icon; }
196 private void SetDockIcon(Form c) { c.Icon = Core.Properties.Resources.romcheater_icon; }
197 private void SetDockIcons()
198 {
199 SetDockIcon(m_LogWindow);
200 SetDockIcon(m_AboutBox);
201 SetDockIcon(m_RamDump);
202 SetDockIcon(m_PIDSelector);
203 SetDockIcon(m_memoryview);
204 SetDockIcon(m_typeconverter);
205 SetDockIcon(m_memsearcher);
206 SetDockIcon(m_peviewer);
207 SetDockIcon(m_rvacalc);
208 SetDockIcon(m_ucd);
209 SetDockIcon(m_msv);
210 SetDockIcon(m_wb);
211 }
212 public void SetupDocks()
213 {
214 m_LogWindow = new FloatingLogWindow();
215 LoggerInstance = m_LogWindow.Logwriter;
216 m_AboutBox = new FloatingAboutBox();
217 m_RamDump = new FloatingRamDumperDialog();
218 m_PIDSelector = new FloatingPIDSelector();
219 m_PIDSelector.OnSelectedProcessChanged += new BaseEventHandler<ProcessChangedEventArgs>(OnProcessChanged);
220 m_memoryview = new FloatingMemoryView();
221 m_typeconverter = new FloatingDataTypeConverter();
222 m_memsearcher = new FloatingMemorySearcher();
223 m_memsearcher.OnBrowseMemoryRegion += new BaseEventHandler<BrowseMemoryRegionEvent>(OnBrowseMemoryRegion);
224 m_peviewer = new FloatingPEViewer();
225 m_peviewer.OnPEDataUpdated += new BaseEventHandler<PEViewerDataUpdatedEventArgs>(OnPEDataUpdated);
226 m_rvacalc = new FloatingRVACalculator();
227 m_ucd = new FloatingUserControlDock();
228 m_msv = new FloatingMemorySectionViewer();
229 m_deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString);
230 m_wb = new FloatingWebBrowser();
231 SetDockIcons();
232 }
233 #region SetupDockWindowHandler support
234 public void SetupDockWindowHandler()
235 {
236 SetupLogWindowHandler();
237 SetupRamDumpWindowHandler();
238 SetupMemoryViewWindowHandler();
239 SetupPIDSelectorWindowHandler();
240 SetupDataTypeConverterWindowHandler();
241 SetupMemorySearchWindowHandler();
242 SetupPEViewerWindowHandler();
243 SetupRVACalculatorWindowHandler();
244 SetupMemorySectionViewerWindowHandler();
245 SetupUserControlDockWindowHandler();
246 SetupWebBrowserWindowHandler();
247 SetDockIcons();
248 }
249 private void SetupLogWindowHandler()
250 {
251 if (m_LogWindow == null) return;
252 m_LogWindow.Shown += new EventHandler(AddDockToWindowList);
253 m_LogWindow.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList);
254 m_LogWindow.Activate();
255 }
256 private void SetupRamDumpWindowHandler()
257 {
258 if (m_RamDump == null) return;
259 m_RamDump.Shown += new EventHandler(AddDockToWindowList);
260 m_RamDump.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList);
261 m_RamDump.AcceptedPlugin = ConfigPlugin;
262 m_RamDump.Activate();
263 }
264 private void SetupMemoryViewWindowHandler()
265 {
266 if (m_memoryview == null) return;
267 m_memoryview.Shown += new EventHandler(AddDockToWindowList);
268 m_memoryview.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList);
269 m_memoryview.AcceptedPlugin = ConfigPlugin;
270 m_memoryview.Activate();
271 }
272 private void SetupPIDSelectorWindowHandler()
273 {
274 if (m_PIDSelector == null) return;
275 m_PIDSelector.Shown += new EventHandler(AddDockToWindowList);
276 m_PIDSelector.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList);
277 m_PIDSelector.AcceptedPlugin = ConfigPlugin;
278 m_PIDSelector.Activate();
279 }
280 private void SetupDataTypeConverterWindowHandler()
281 {
282 if (m_typeconverter == null) return;
283 m_typeconverter.Shown += new EventHandler(AddDockToWindowList);
284 m_typeconverter.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList);
285 m_typeconverter.Activate();
286 }
287 private void SetupMemorySearchWindowHandler()
288 {
289 if (m_memsearcher == null) return;
290 m_memsearcher.Shown += new EventHandler(AddDockToWindowList);
291 m_memsearcher.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList);
292 m_memsearcher.Activate();
293 }
294 private void SetupPEViewerWindowHandler()
295 {
296 if (m_peviewer == null) return;
297 m_peviewer.Shown += new EventHandler(AddDockToWindowList);
298 m_peviewer.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList);
299 m_PIDSelector.AcceptedPlugin = ConfigPlugin;
300 m_peviewer.Activate();
301 }
302 private void SetupRVACalculatorWindowHandler()
303 {
304 if (m_rvacalc == null) return;
305 m_rvacalc.Shown += new EventHandler(AddDockToWindowList);
306 m_rvacalc.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList);
307 m_rvacalc.AcceptedPlugin = ConfigPlugin;
308 m_rvacalc.Activate();
309 }
310 private void SetupUserControlDockWindowHandler()
311 {
312 if (m_ucd == null) return;
313 m_ucd.Shown += new EventHandler(AddDockToWindowList);
314 m_ucd.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList);
315 m_ucd.Activate();
316 }
317 private void SetupMemorySectionViewerWindowHandler()
318 {
319 if (m_msv == null) return;
320 m_msv.Shown += new EventHandler(AddDockToWindowList);
321 m_msv.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList);
322 m_msv.AcceptedPlugin = ConfigPlugin;
323 m_msv.Activate();
324 }
325 private void SetupWebBrowserWindowHandler()
326 {
327 if (m_wb == null) return;
328 m_wb.Shown += new EventHandler(AddDockToWindowList);
329 m_wb.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList);
330 m_wb.Activate();
331 }
332 #endregion
333 public void ShowDocks()
334 {
335 ShowLogWindow();
336 SetupLogWindowHandler();
337 //ShowAboutBox();
338 ShowRamDump();
339 SetupRamDumpWindowHandler();
340 ShowMemoryView();
341 SetupMemoryViewWindowHandler();
342 ShowPidSelector();
343 SetupPIDSelectorWindowHandler();
344 ShowDataTypeConverter();
345 SetupDataTypeConverterWindowHandler();
346
347 ShowRVACalculator();
348 SetupRVACalculatorWindowHandler();
349
350 ShowMemorySectionViewer();
351 SetupMemorySectionViewerWindowHandler();
352
353
354
355 ShowUserControlDock();
356 SetupUserControlDockWindowHandler();
357
358 ShowMemorySearch();
359 SetupMemorySearchWindowHandler();
360 ShowPEViewer();
361 SetupPEViewerWindowHandler();
362
363 ShowWebBrowser();
364 SetupWebBrowserWindowHandler();
365 }
366 public void ShowLogWindow()
367 {
368 if (m_LogWindow == null || m_LogWindow.IsDisposed) { m_LogWindow = new FloatingLogWindow(); }
369 LoggerInstance = m_LogWindow.Logwriter;
370 //LoggerInstance.CreateNewLog(false);
371 m_LogWindow.Show(dockPanel, DockState.DockBottom);
372 }
373 public void ShowAboutBox()
374 {
375 if (m_AboutBox == null || m_AboutBox.IsDisposed) { m_AboutBox = new FloatingAboutBox(); }
376 m_AboutBox.ShowDialog();
377 }
378 public void ShowRamDump()
379 {
380 //load_plugins_silent();
381 m_RamDump = new FloatingRamDumperDialog(ConfigPlugin);
382 m_RamDump.AcceptedProcess = SelectedProcess;
383 m_RamDump.Show(dockPanel);
384 }
385 public void ShowMemoryView()
386 {
387 //load_plugins_silent();
388 m_memoryview = new FloatingMemoryView(ConfigPlugin);
389 m_memoryview.AcceptedProcess = SelectedProcess;
390 m_memoryview.Show(dockPanel);
391 }
392 public void ShowPidSelector()
393 {
394 //load_plugins_silent();
395 //List<Process> procs = ConfigPlugin.ValidProcessesForPlugin;
396 m_PIDSelector = new FloatingPIDSelector(ConfigPlugin);
397 m_PIDSelector.OnSelectedProcessChanged += new BaseEventHandler<ProcessChangedEventArgs>(OnProcessChanged);
398 m_PIDSelector.Show(dockPanel);
399 }
400 public void ShowDataTypeConverter()
401 {
402 if (m_typeconverter == null || m_typeconverter.IsDisposed) { m_typeconverter = new FloatingDataTypeConverter(); }
403 m_typeconverter.Show(dockPanel, DockState.DockRightAutoHide);
404 }
405 public void ShowMemorySearch()
406 {
407 //load_plugins_silent();
408 m_memsearcher = new FloatingMemorySearcher(ConfigPlugin);
409 m_memsearcher.AcceptedProcess = SelectedProcess;
410 m_memsearcher.OnBrowseMemoryRegion += new BaseEventHandler<BrowseMemoryRegionEvent>(OnBrowseMemoryRegion);
411 m_memsearcher.Show(dockPanel);
412 }
413 public void ShowPEViewer()
414 {
415 //load_plugins_silent();
416 m_peviewer = new FloatingPEViewer(ConfigPlugin);
417 m_peviewer.AcceptedProcess = SelectedProcess;
418 m_peviewer.OnPEDataUpdated += new BaseEventHandler<PEViewerDataUpdatedEventArgs>(OnPEDataUpdated);
419 m_peviewer.Show(dockPanel);
420 }
421 public void ShowRVACalculator()
422 {
423 //load_plugins_silent();
424 m_rvacalc = new FloatingRVACalculator(ConfigPlugin);
425 m_rvacalc.AcceptedProcess = SelectedProcess;
426 m_rvacalc.Show(dockPanel, DockState.DockRightAutoHide);
427 }
428 public void ShowMemorySectionViewer()
429 {
430 //load_plugins_silent();
431 m_msv = new FloatingMemorySectionViewer(ConfigPlugin);
432 m_msv.AcceptedProcess = SelectedProcess;
433 m_msv.Show(dockPanel);
434 }
435 public void ShowUserControlDock()
436 {
437 //load_plugins_silent();
438 if (m_ucd == null)
439 {
440 m_ucd = new FloatingUserControlDock();
441 }
442 if (this.UserControlPlugins.Count > 0)
443 {
444 m_ucd.UserPlugins = this.UserControlPlugins;
445 }
446 m_ucd.Show(dockPanel, DockState.DockRightAutoHide);
447 }
448 public void ShowWebBrowser()
449 {
450 //load_plugins_silent();
451 m_wb = new FloatingWebBrowser();
452 m_wb.Show(dockPanel);
453 }
454 #endregion
455
456
457 public Main() : this(false) { }
458 public Main(bool no_console_redirect)
459 {
460 InitializeComponent();
461 this.Icon = Core.Properties.Resources.romcheater_icon;
462 #if SHOW_DEBUG_MENU
463 mnuDebug.Visible = true;
464 #else
465 mnuDebug.Visible = false;
466 #endif
467 SettingsSubscriber = new SettingSubscriber();
468 SettingsSubscriber.AddSubscriber(this, Settings.Default);
469 SetupDocks();
470 LoggerInstance = m_LogWindow.Logwriter;
471 load_loggerflags();
472 load_plugins();
473 }
474 private void load_loggerflags()
475 {
476 bool upgraded_flags = Logging.Properties.Settings.Default.UpgradedLogLevel;
477 if (!upgraded_flags)
478 {
479 logging_level = new LoggingFlagsConverter(Logging.Properties.Settings.Default.LoggingFlags).ConvertFlags();
480 Logging.Properties.Settings.Default.UpgradedLogLevel = true;
481 Logging.Properties.Settings.Default.gLogLoggingFlags = (uint)logging_level;
482 Logging.Properties.Settings.Default.Save();
483 }
484 logging_level = (LogLevel)Logging.Properties.Settings.Default.gLogLoggingFlags;
485 #if FORCE_ALL_LOGGING_FLAGS
486 logging_level = LogLevel.kLogLevel_All;
487 #endif
488 #if FORCE_DISABLE_PROFILER_LOGLEVEL
489 logging_level = logging_level & ~LogLevel.kLogLevel_Profiler;
490 logging_level = logging_level & ~LogLevel.kLogLevel_VerboseProfiler;
491 #endif
492 gLog.CreateLog(LoggingConstants.AppFullLogPath, true, logging_level, new EventHandler<LoggerOnFlushEventArgs>(Log_OnFlush), LoggerInstance.Log);
493 }
494
495 private void Log_OnFlush(object sender, LoggerOnFlushEventArgs e)
496 {
497 }
498 private void load_plugins() { load_plugins(false); }
499 private void load_plugins_silent() { load_plugins(true); }
500 private void load_plugins(bool silent)
501 {
502 loader = new PluginLoader();
503 loader.LoadPlugins(silent);
504
505 ConfigPlugin = loader.GetConfigPlugin(RomCheater.Properties.Settings.Default.LastConfigPlugin);
506 if (ConfigPlugin != null && !silent)
507 gLog.Info.WriteLine("Loaded Config Plugin: {0}", ConfigPlugin.ToString());
508 InputPlugin = loader.GetInputPlugin(RomCheater.Properties.Settings.Default.LastInputPlugin);
509 if (InputPlugin != null && !silent)
510 gLog.Info.WriteLine("Loaded Input Plugin: {0}", InputPlugin.ToString());
511 WindowPlugin = loader.GetWindowPlugin(RomCheater.Properties.Settings.Default.LastWindowPlugin);
512 if (WindowPlugin != null && !silent)
513 gLog.Info.WriteLine("Loaded Window Plugin: {0}", WindowPlugin.ToString());
514
515
516 UserControlPlugins = new List<IUserControlPlugin>(loader.LoadedUserControlPlugins);
517 if (UserControlPlugins != null)
518 {
519 foreach (var t in UserControlPlugins)
520 {
521 if (!silent)
522 gLog.Info.WriteLine("Loaded UserControl Plugin: {0}", t.ToString());
523 }
524
525 string stacktrace = System.Environment.StackTrace;
526
527 if (UserControlPlugins.Count > 0)
528 {
529 m_ucd.UserPlugins = UserControlPlugins;
530 }
531 }
532
533 ConfigPlugin.WebBrowserProvider = this.WebBrowserProvider;
534
535
536 m_PIDSelector.AcceptedPlugin = ConfigPlugin;
537 m_RamDump.AcceptedPlugin = ConfigPlugin;
538 m_memoryview.AcceptedPlugin = ConfigPlugin;
539 m_memsearcher.AcceptedPlugin = ConfigPlugin;
540 m_PIDSelector.AcceptedPlugin = ConfigPlugin;
541 if (this.SelectedProcess != null)
542 {
543 m_RamDump.AcceptedProcess = SelectedProcess;
544 m_memoryview.AcceptedProcess = SelectedProcess;
545 m_memsearcher.AcceptedProcess = SelectedProcess;
546 }
547
548
549 }
550
551 private void mnuItemExit_Click(object sender, EventArgs e)
552 {
553 this.Close();
554 }
555
556
557 private void Main_Load(object sender, EventArgs e)
558 {
559 SettingsSubscriber.SaveSettings();
560 }
561
562 private void mnuItemConfig_Click(object sender, EventArgs e)
563 {
564 RomCheaterConfigDialog dlg = new RomCheaterConfigDialog(loader);
565 dlg.ShowDialog();
566 //logger.ForceLog.Info.WriteLine("LoggingFlags = 0x{0:x4} ({1})", logger.GetLoggingFlags().Value, logger.GetLoggingFlags().Name);
567 // reload plugins
568 load_plugins(true);
569 }
570
571 private void mnuItemOpenProcess_Click(object sender, EventArgs e)
572 {
573 ////List<Process> procs = ConfigPlugin.ValidProcessesForPlugin;
574 //PIDSelector selector = new PIDSelector(ConfigPlugin);
575 //selector.ShowDialog();
576 }
577
578 private void Main_Shown(object sender, EventArgs e)
579 {
580 dockPanel.SuspendLayout(true);
581 //ShowDocks();
582 string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), DockPanelConfig);
583 if (File.Exists(configFile))
584 {
585 try
586 {
587 dockPanel.LoadFromXml(configFile, m_deserializeDockContent);
588 SetupDockWindowHandler();
589 }
590 catch (Exception)
591 {
592 ShowDocks();
593 }
594 }
595 else
596 {
597 ShowDocks();
598 }
599
600 if(m_PIDSelector != null)
601 m_PIDSelector.Activate();
602 dockPanel.ResumeLayout(true, true);
603 }
604
605 private void mnuItemShowLogWindow_Click(object sender, EventArgs e)
606 {
607 ShowLogWindow();
608 }
609
610 private void mnuItemHelpAbout_Click(object sender, EventArgs e)
611 {
612 ShowAboutBox();
613 }
614
615 private void mnuItemShowRamDumpDialog_Click(object sender, EventArgs e)
616 {
617 ShowRamDump();
618 }
619
620 private void mnuItemShowPIDSelector_Click(object sender, EventArgs e)
621 {
622 ShowPidSelector();
623 }
624 private void mnuItemShowMemoryView_Click(object sender, EventArgs e)
625 {
626 ShowMemoryView();
627 }
628 private void Main_FormClosing(object sender, FormClosingEventArgs e)
629 {
630 SettingsSubscriber.SaveSettings();
631 string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), DockPanelConfig);
632 if (m_bSaveLayout)
633 dockPanel.SaveAsXml(configFile);
634 else if (File.Exists(configFile))
635 File.Delete(configFile);
636
637 SearchResultWriter.CleanupTemporarySearchResultFiles();
638
639
640 // notify any docked windows of formclosing
641
642 foreach (var t in this.dockPanel.Contents)
643 {
644 t.OnDeactivate<FormClosingEventArgs>(e);
645 }
646
647 }
648
649 private void mnuTestExeParse_Click(object sender, EventArgs e)
650 {
651 IPEDData peData = new PEData((IAcceptsProcessAndConfig)this);
652 }
653
654 private void mnuItemFindMaxNonNegativeHexValue_Click(object sender, EventArgs e)
655 {
656
657 //uint start = 0xf0000000;
658 uint end = uint.MaxValue;
659 //for (uint i = start; i < end; i++)
660 //{
661 ulong value = Convert.ToUInt64(end.ToString(), 16);
662 //}
663 }
664
665 private void mnuItemShowDataTypeConverter_Click(object sender, EventArgs e)
666 {
667 ShowDataTypeConverter();
668 }
669
670 private void mnuItemShowMemorySearch_Click(object sender, EventArgs e)
671 {
672 ShowMemorySearch();
673 }
674
675 private void mnuItemDateShift_Click(object sender, EventArgs e)
676 {
677 DateTime t = DateTime.Now;
678 int year = Convert.ToInt32(t.ToString("yy"));
679 int y = year << 9;
680 int m = t.Month << 5;
681 int d = t.Day;
682
683 ushort v1 = (ushort)(y | m | d);
684
685 t = t.AddDays(1);
686 year = Convert.ToInt32(t.ToString("yy"));
687 y = year << 9;
688 m = t.Month << 5;
689 d = t.Day;
690 ushort v2 = (ushort)(y | m | d);
691
692 t = t.AddDays(1);
693 year = Convert.ToInt32(t.ToString("yy"));
694 y = year << 9;
695 m = t.Month << 5;
696 d = t.Day;
697 ushort v3 = (ushort)(y | m | d);
698
699 t = new DateTime(9999,12,31);
700 year = Convert.ToInt32(t.ToString("yy"));
701 y = year << 9;
702 m = t.Month << 5;
703 d = t.Day;
704 ushort v4 = (ushort)(y | m | d);
705 }
706
707 private void mnuItemShowPEViewer_Click(object sender, EventArgs e)
708 {
709 ShowPEViewer();
710 }
711
712 private void mnuItemShowRVACalculator_Click(object sender, EventArgs e)
713 {
714 ShowRVACalculator();
715 }
716
717 private void mnuItemShowUserControlDock_Click(object sender, EventArgs e)
718 {
719 ShowUserControlDock();
720 }
721
722 private void mnuItemShowMemorySectionViewer_Click(object sender, EventArgs e)
723 {
724 ShowMemorySectionViewer();
725 }
726
727 private void mnuItemShowWebBrowser_Click(object sender, EventArgs e)
728 {
729 ShowWebBrowser();
730 }
731 }
732 }

  ViewVC Help
Powered by ViewVC 1.1.22