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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 471 - (hide annotations) (download)
Mon Jun 3 07:13:44 2013 UTC (7 years, 4 months ago) by william
File size: 4104 byte(s)
+ pass process informatin by using the process's PID, instead of passing the process as a reference

1 william 318 #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 william 323 using RomCheater.PluginFramework.Events;
18 william 318
19     namespace RomCheater.Docking
20     {
21     public partial class FloatingPEViewer : DockContent,
22     IAcceptsPlugin<IConfigPlugin>,
23 william 471 IAcceptsProcess,
24 william 323 IAcceptsProcessAndConfig,
25     IAcceptsPEData
26 william 318 {
27 william 471 public FloatingPEViewer() { InitializeComponent(); this.AcceptedPlugin = null; this.ProcessPID = 0; OnPEDataUpdated = null; }
28 william 318 public FloatingPEViewer(IConfigPlugin config) : this() { this.AcceptedPlugin = config; }
29 william 471 public FloatingPEViewer(IConfigPlugin config, int pid) : this() { this.AcceptedPlugin = config; this.ProcessPID = pid; }
30 william 318 #region IAcceptsProcess<Process> Members
31 william 471 private int _ProcessPID;
32     public int ProcessPID { get { return _ProcessPID; } set { _ProcessPID = value; UpdateProcessPID(value); } }
33 william 318 #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 william 323 #region IAcceptsPEData Members
39 william 408 public event BaseEventHandler<PEViewerDataUpdatedEventArgs> OnPEDataUpdated;
40 william 323 #endregion
41 william 378 uint MemoryRangeStart { get; set; }
42 william 318 uint MemoryRangeSize { get; set; }
43    
44     private void UpdateAcceptedPlugin(IConfigPlugin config)
45     {
46     }
47 william 471 private void UpdateProcessPID(int pid)
48 william 318 {
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 william 382 MemoryRangeSize = MemoryRangeStart + MemorySizeConstants.MaximumAddressSize;
58 william 318 #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 william 471 if (ProcessPID != 0)
62 william 318 {
63 william 471 using (Process p = Process.GetProcessById(ProcessPID))
64     {
65     string filename = p.MainModule.FileName;
66     //string filename = @"c:\Windows\notepad.exe";
67     IPEDData peData = PEDataWrapper.GetPEData((IAcceptsProcessAndConfig)this);
68     peprops.SelectedObject = peData;
69     peprops.PropertySort = PropertySort.NoSort;
70     if (OnPEDataUpdated != null)
71     if (peData != null)
72     OnPEDataUpdated(new PEViewerDataUpdatedEventArgs(this, peData));
73     }
74 william 318 }
75     else
76     {
77     MemoryRangeStart = MemorySizeConstants.MinimumAddress;
78 william 382 MemoryRangeSize = MemorySizeConstants.MaximumAddressSize;
79 william 318 }
80     #endif
81    
82     }
83     }
84     }

  ViewVC Help
Powered by ViewVC 1.1.22