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

Contents of /trunk/RomCheater/Main.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 892 - (show annotations) (download)
Wed Sep 17 05:56:41 2014 UTC (6 years, 10 months ago) by william
File size: 30231 byte(s)
+ alot of dang work to force an icon to be shown on the docked panels
  ** when it was as simple as setting: DockPanel.ShowDocumentIcon to true

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

  ViewVC Help
Powered by ViewVC 1.1.22