/[RomCheater]/trunk/RomCheater/Docking/FloatingPEViewer.cs
ViewVC logotype

Contents of /trunk/RomCheater/Docking/FloatingPEViewer.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 325 - (show annotations) (download)
Thu Jun 7 17:44:20 2012 UTC (8 years, 4 months ago) by william
File size: 4277 byte(s)
add check: if (peData != null) before calling OnPEDataUpdated

1 #define USE_AUTOMATIC_MEMORY_SEARCH_RANGE // when defined will automatically choose the best starting address and size for memory search otherwise it will use the constants defined in MemorySizeConstants
2 #if !USE_AUTOMATIC_MEMORY_SEARCH_RANGE
3 #define FORCE_USE_OF_MEMORYSIZECONSTANTS // when defined wil force the use of the constants defined in MemorySizeConstants for memory search range
4 #endif
5 using System;
6 using System.Collections.Generic;
7 using System.ComponentModel;
8 using System.Data;
9 using System.Drawing;
10 using System.Linq;
11 using System.Text;
12 using System.Windows.Forms;
13 using WeifenLuo.WinFormsUI.Docking;
14 using RomCheater.PluginFramework.Interfaces;
15 using System.Diagnostics;
16 using Sojaner.MemoryScanner;
17 using RomCheater.PluginFramework.Events;
18
19 namespace RomCheater.Docking
20 {
21 public partial class FloatingPEViewer : DockContent,
22 IAcceptsPlugin<IConfigPlugin>,
23 IAcceptsProcess<Process>,
24 IAcceptsProcessAndConfig,
25 IAcceptsPEData
26 {
27 public FloatingPEViewer() { InitializeComponent(); this.AcceptedPlugin = null; this.AcceptedProcess = null; OnPEDataUpdated = null; }
28 public FloatingPEViewer(IConfigPlugin config) : this() { this.AcceptedPlugin = config; }
29 public FloatingPEViewer(IConfigPlugin config, Process process) : this() { this.AcceptedPlugin = config; this.AcceptedProcess = process; }
30 #region IAcceptsProcess<Process> Members
31 private Process _AcceptedProcess;
32 public Process AcceptedProcess { get { return _AcceptedProcess; } set { _AcceptedProcess = value; UpdateAcceptedProcess(value); } }
33 #endregion
34 #region IAcceptsPlugin<IConfigPlugin> Members
35 private IConfigPlugin _AcceptedPlugin;
36 public IConfigPlugin AcceptedPlugin { get { return _AcceptedPlugin; } set { _AcceptedPlugin = value; UpdateAcceptedPlugin(value); } }
37 #endregion
38 #region IAcceptsPEData Members
39 public event BaseEventHandler<PEViewerDataUpdatedEvent> OnPEDataUpdated;
40 #endregion
41 int MemoryRangeStart { get; set; }
42 uint MemoryRangeSize { get; set; }
43
44 private void UpdateAcceptedPlugin(IConfigPlugin config)
45 {
46 }
47 private void UpdateAcceptedProcess(Process process)
48 {
49 #if USE_AUTOMATIC_MEMORY_SEARCH_RANGE && FORCE_USE_OF_MEMORYSIZECONSTANTS
50 logger.Warn.WriteLine("FloatingMemorySearcher.UpdateAcceptedProcessAndConfig(IConfigPlugin config, Process process):");
51 logger.Warn.WriteLine("Both USE_AUTOMATIC_MEMORY_SEARCH_RANGE and FORCE_USE_OF_MEMORYSIZECONSTANTS are defined");
52 logger.Warn.WriteLine("FORCE_USE_OF_MEMORYSIZECONSTANTS will take precedence and will ignore the values supplied in the memeory search range");
53 #endif
54 #if FORCE_USE_OF_MEMORYSIZECONSTANTS
55 // force use of MemorySizeConstants
56 MemoryRangeStart = MemorySizeConstants.MinimumAddress;
57 MemoryRangeSizee = (MemorySizeConstants.MinimumAddress > 0) ? (uint)(MemorySizeConstants.MaximumAddress - MemorySizeConstants.MinimumAddress) : MemorySizeConstants.MaximumAddress;
58 #endif
59 #if USE_AUTOMATIC_MEMORY_SEARCH_RANGE && !FORCE_USE_OF_MEMORYSIZECONSTANTS
60 //// code to automatically choose the best starting memory address and size
61 if (process != null)
62 {
63 string filename = process.MainModule.FileName;
64 //string filename = @"c:\Windows\notepad.exe";
65 PEReader peReader = new PEReader(filename);
66 PEReader.PEData peData = peReader.GetPEData;
67 peprops.SelectedObject = peData;
68 peprops.PropertySort = PropertySort.NoSort;
69 if (OnPEDataUpdated != null)
70 if (peData != null)
71 OnPEDataUpdated(new PEViewerDataUpdatedEvent(this, peData));
72 }
73 else
74 {
75 MemoryRangeStart = MemorySizeConstants.MinimumAddress;
76 MemoryRangeSize = (MemorySizeConstants.MinimumAddress > 0) ? (uint)(MemorySizeConstants.MaximumAddress - MemorySizeConstants.MinimumAddress) : MemorySizeConstants.MaximumAddress;
77 }
78 #endif
79
80 }
81 }
82 }

  ViewVC Help
Powered by ViewVC 1.1.22