/[RomCheater]/trunk/Win32/Sojaner.MemoryScanner/PEData.cs
ViewVC logotype

Diff of /trunk/Win32/Sojaner.MemoryScanner/PEData.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/Win32/Sojaner.MemoryScanner/PEData.cs	2013/06/08 05:42:00	619
+++ trunk/Win32/Sojaner.MemoryScanner/PEData.cs	2013/06/08 06:48:29	620
@@ -44,6 +44,58 @@
         [Browsable(false)]
         ulong _VirtualImageBase { get; }
         string VirtualImageBase { get; }
+
+        ISECTION_DATA[] SectionData { get; }
+    }
+    [TypeConverter(typeof(ExpandableObjectConverter))]
+    public interface ISECTION_DATA
+    {
+        string Name { get; }
+        uint _Start { get; }
+        uint _End { get; }
+        uint _Size { get; }
+
+        string Start { get; }
+        string End { get; }
+        string Size { get; }
+        string ToString();
+        
+    }
+
+    [TypeConverter(typeof(ExpandableObjectConverter))]
+    public class SECTION_DATA : ISECTION_DATA
+    {
+        public SECTION_DATA() : this(string.Empty, 0, 0) { }
+        public SECTION_DATA(string name, uint virtualAddress, uint rva, uint virtualSize) : this(name, virtualAddress + rva, virtualSize) { }
+        public SECTION_DATA(string name, uint virtualAddress, uint virtualSize) 
+        {
+            this._Name = name;
+            this._Start = virtualAddress;
+            this._Size = virtualSize;
+        }
+
+        #region ISECTION_DATA members
+        private string _Name;
+        private uint __Start;
+        [Browsable(false)]
+        public uint _Start { get { return __Start; } set { __Start = value; } }
+        [Browsable(false)]
+        public uint _End { get { return __Start + __Size; } }
+        private uint __Size;
+        [Browsable(false)]
+        public uint _Size { get { return __Size; } set { __Size = value; } }
+
+
+        public string Name { get { return _Name; } }
+        public string Start { get { return string.Format("0x{0:x8}", _Start); } }
+        public string End { get { return string.Format("0x{0:x8}", _End); } }
+        public string Size { get { return string.Format("0x{0:x8}", _Size); } }
+
+        public override string ToString()
+        {
+            return this.Name;
+        }
+        #endregion
     }
 
     public class PEData : IPEDData
@@ -55,7 +107,10 @@
         public IMAGE_OPTIONAL_HEADER32 OptionalHeader32 { get { if (reader == null) { return new IMAGE_OPTIONAL_HEADER32(); } else { return reader.OptionalHeader32; } } }
         public IMAGE_OPTIONAL_HEADER64 OptionalHeader64 { get { if (reader == null) { return new IMAGE_OPTIONAL_HEADER64(); } else { return reader.OptionalHeader64; } } }
 
-        public IMAGE_SECTION_HEADER[] SectionHeaders { get { if (reader == null) { return new IMAGE_SECTION_HEADER[0]; } else { return reader.ImageSectionHeaders; } } }  
+        public IMAGE_SECTION_HEADER[] SectionHeaders { get { if (reader == null) { return new IMAGE_SECTION_HEADER[0]; } else { return reader.ImageSectionHeaders; } } }
+
+        private ISECTION_DATA[] _SectionData;
+        public ISECTION_DATA[] SectionData { get { return _SectionData; } private set { _SectionData = value; } }
 
         public Boolean Is32bitAssembly() { if (reader == null) { return true; } else { return reader.Is32BitHeader; } }
 
@@ -121,9 +176,15 @@
             {
                 this._VirtualImageBase = (ulong)p.MainModule.BaseAddress;
             }
-            
 
+              this.SectionData = new ISECTION_DATA[this.SectionHeaders.Length];
 
+              for (int i = 0; i < this.SectionHeaders.Length; i++)
+              {
+                  var t = this.SectionHeaders[i];
+                  SECTION_DATA data = new SECTION_DATA(t.Name, t._VirtualAddress, this._VirtualRVA, t._VirtualSize);
+                  this.SectionData[i] = (ISECTION_DATA)data;
+              }
         }
         public PEData(IAcceptsProcessAndConfig iapc) : this((IAcceptsProcess)iapc) { }
     }

 

  ViewVC Help
Powered by ViewVC 1.1.22