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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 318 - (show annotations) (download)
Tue Jun 5 17:57:37 2012 UTC (8 years, 2 months ago) by william
File size: 3821 byte(s)
+ add support for displaying PE Struct data into property grid (read-only)

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
18 namespace RomCheater.Docking
19 {
20 public partial class FloatingPEViewer : DockContent,
21 IAcceptsPlugin<IConfigPlugin>,
22 IAcceptsProcess<Process>,
23 IAcceptsProcessAndConfig
24 {
25 public FloatingPEViewer() { InitializeComponent(); this.AcceptedPlugin = null; this.AcceptedProcess = null; }
26 public FloatingPEViewer(IConfigPlugin config) : this() { this.AcceptedPlugin = config; }
27 public FloatingPEViewer(IConfigPlugin config, Process process) : this() { this.AcceptedPlugin = config; this.AcceptedProcess = process; }
28 #region IAcceptsProcess<Process> Members
29 private Process _AcceptedProcess;
30 public Process AcceptedProcess { get { return _AcceptedProcess; } set { _AcceptedProcess = value; UpdateAcceptedProcess(value); } }
31 #endregion
32 #region IAcceptsPlugin<IConfigPlugin> Members
33 private IConfigPlugin _AcceptedPlugin;
34 public IConfigPlugin AcceptedPlugin { get { return _AcceptedPlugin; } set { _AcceptedPlugin = value; UpdateAcceptedPlugin(value); } }
35 #endregion
36
37 int MemoryRangeStart { get; set; }
38 uint MemoryRangeSize { get; set; }
39
40 private void UpdateAcceptedPlugin(IConfigPlugin config)
41 {
42 }
43 private void UpdateAcceptedProcess(Process process)
44 {
45 #if USE_AUTOMATIC_MEMORY_SEARCH_RANGE && FORCE_USE_OF_MEMORYSIZECONSTANTS
46 logger.Warn.WriteLine("FloatingMemorySearcher.UpdateAcceptedProcessAndConfig(IConfigPlugin config, Process process):");
47 logger.Warn.WriteLine("Both USE_AUTOMATIC_MEMORY_SEARCH_RANGE and FORCE_USE_OF_MEMORYSIZECONSTANTS are defined");
48 logger.Warn.WriteLine("FORCE_USE_OF_MEMORYSIZECONSTANTS will take precedence and will ignore the values supplied in the memeory search range");
49 #endif
50 #if FORCE_USE_OF_MEMORYSIZECONSTANTS
51 // force use of MemorySizeConstants
52 MemoryRangeStart = MemorySizeConstants.MinimumAddress;
53 MemoryRangeSizee = (MemorySizeConstants.MinimumAddress > 0) ? (uint)(MemorySizeConstants.MaximumAddress - MemorySizeConstants.MinimumAddress) : MemorySizeConstants.MaximumAddress;
54 #endif
55 #if USE_AUTOMATIC_MEMORY_SEARCH_RANGE && !FORCE_USE_OF_MEMORYSIZECONSTANTS
56 //// code to automatically choose the best starting memory address and size
57 if (process != null)
58 {
59 string filename = process.MainModule.FileName;
60 //string filename = @"c:\Windows\notepad.exe";
61 PEReader peReader = new PEReader(filename);
62 peprops.SelectedObject = peReader.GetData;
63 peprops.PropertySort = PropertySort.NoSort;
64 }
65 else
66 {
67 MemoryRangeStart = MemorySizeConstants.MinimumAddress;
68 MemoryRangeSize = (MemorySizeConstants.MinimumAddress > 0) ? (uint)(MemorySizeConstants.MaximumAddress - MemorySizeConstants.MinimumAddress) : MemorySizeConstants.MaximumAddress;
69 }
70 #endif
71
72 }
73 }
74 }

  ViewVC Help
Powered by ViewVC 1.1.22