/[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 04:59:44	618
+++ trunk/Win32/Sojaner.MemoryScanner/PEData.cs	2013/06/08 05:42:00	619
@@ -32,6 +32,18 @@
         IMAGE_OPTIONAL_HEADER64 OptionalHeader64 { get; }
         IMAGE_SECTION_HEADER[] SectionHeaders { get; }        
         bool Is32bitAssembly();
+
+        [Browsable(false)]
+        uint _VirtualEntryPoint { get; }
+        string  VirtualEntryPoint { get; }
+
+        [Browsable(false)]
+        uint _VirtualRVA { get; }
+        string VirtualRVA { get; }
+
+        [Browsable(false)]
+        ulong _VirtualImageBase { get; }
+        string VirtualImageBase { get; }
     }
 
     public class PEData : IPEDData
@@ -46,6 +58,47 @@
         public IMAGE_SECTION_HEADER[] SectionHeaders { get { if (reader == null) { return new IMAGE_SECTION_HEADER[0]; } else { return reader.ImageSectionHeaders; } } }  
 
         public Boolean Is32bitAssembly() { if (reader == null) { return true; } else { return reader.Is32BitHeader; } }
+
+
+        [Browsable(false)]
+        public uint _VirtualEntryPoint { get; private set; }
+        public string VirtualEntryPoint { get { return string.Format("0x{0:x8}", _VirtualEntryPoint); } }
+
+        [Browsable(false)]
+        public uint _VirtualRVA
+        {
+            get
+            {
+                if (this.Is32bitAssembly())
+                {
+                    return (_VirtualEntryPoint - OptionalHeader32._AddressOfEntryPoint);
+                }
+                else
+                {
+                    return (_VirtualEntryPoint - OptionalHeader64._AddressOfEntryPoint);
+                }
+            }
+        }
+        public string VirtualRVA { get { return string.Format("0x{0:x8}", _VirtualRVA); } }
+
+        [Browsable(false)]
+        public ulong _VirtualImageBase { get; private set; }
+        public string VirtualImageBase
+        {
+            get
+            {
+                if (this.Is32bitAssembly())
+                {
+                    return string.Format("0x{0:x8}", _VirtualImageBase);
+                }
+                else
+                {
+                    return string.Format("0x{0:x16}", _VirtualImageBase);
+                }
+            }
+        }
+
+
         #endregion
 
         private PeHeaderReader reader = null;
@@ -58,6 +111,19 @@
             if (iap == null) { throw new ArgumentNullException("iap", "The selected process cannot be null"); }
             Process p = iap.AcceptedProcess;            
             reader = new PeHeaderReader(p);
+
+            this._VirtualEntryPoint = (uint)p.MainModule.EntryPointAddress;
+            if (this.Is32bitAssembly())
+            {
+                this._VirtualImageBase = (uint)p.MainModule.BaseAddress;
+            }
+            else
+            {
+                this._VirtualImageBase = (ulong)p.MainModule.BaseAddress;
+            }
+            
+
+
         }
         public PEData(IAcceptsProcessAndConfig iapc) : this((IAcceptsProcess)iapc) { }
     }
@@ -228,22 +294,9 @@
         public string SizeOfInitializedData { get { return string.Format("0x{0:x8}", _SizeOfInitializedData); } }
         public string SizeOfUninitializedData { get { return string.Format("0x{0:x8}", _SizeOfUninitializedData); } }
         public string AddressOfEntryPoint { get { return string.Format("0x{0:x8}", _AddressOfEntryPoint); } }
-        [Browsable(false)]
-        public UInt32 _VirtualEntryPoint { get; set; }
-        public string VirtualEntryPoint { get { return string.Format("0x{0:x8}", _VirtualEntryPoint); } }
-
-        [Browsable(false)]
-        public UInt32 _VirtualRVA { get { return (_VirtualEntryPoint - _AddressOfEntryPoint); } }
-        public string VirtualRVA { get { return string.Format("0x{0:x8}", _VirtualRVA); } }
-
         public string BaseOfCode { get { return string.Format("0x{0:x8}", _BaseOfCode); } }
         public string BaseOfData { get { return string.Format("0x{0:x8}", _BaseOfData); } }
         public string ImageBase { get { return string.Format("0x{0:x8}", _ImageBase); } }
-
-        [Browsable(false)]
-        public UInt32 _VirtualImageBase { get; set; }
-        public string VirtualImageBase { get { return string.Format("0x{0:x8}", _VirtualImageBase); } }
-
         public string SectionAlignment { get { return string.Format("0x{0:x8}", _SectionAlignment); } }
         public string FileAlignment { get { return string.Format("0x{0:x8}", _FileAlignment); } }
 
@@ -325,28 +378,8 @@
         public string SizeOfInitializedData { get { return string.Format("0x{0:x8}", _SizeOfInitializedData); } }
         public string SizeOfUninitializedData { get { return string.Format("0x{0:x8}", _SizeOfUninitializedData); } }
         public string AddressOfEntryPoint { get { return string.Format("0x{0:x8}", _AddressOfEntryPoint); } }
-        [Browsable(false)]
-        public UInt32 _VirtualEntryPoint { get; set; }
-        public string VirtualEntryPoint { get { return string.Format("0x{0:x8}", _VirtualEntryPoint); } }
-
-        [Browsable(false)]
-        public UInt32 _VirtualRVA { get { return (_VirtualEntryPoint - _AddressOfEntryPoint); } }
-        public string VirtualRVA { get { return string.Format("0x{0:x8}", _VirtualRVA); } }
-
         public string BaseOfCode { get { return string.Format("0x{0:x8}", _BaseOfCode); } }
-
-
-        
-
         public string ImageBase { get { return string.Format("0x{0:x16}", _ImageBase); } }
-        [Browsable(false)]
-        public UInt64 _VirtualImageBase { get; set; }
-        public string VirtualImageBase { get { return string.Format("0x{0:x16}", _VirtualImageBase); } }
-
-        
-
-
-
         public string SectionAlignment { get { return string.Format("0x{0:x8}", _SectionAlignment); } }
         public string FileAlignment { get { return string.Format("0x{0:x8}", _FileAlignment); } }
 
@@ -446,7 +479,7 @@
         [FieldOffset(36)]
         public DataSectionFlags _Characteristics;
 
-        public string Name { get { return _Name; } }
+        public string Name { get { if (_Name == null || _Name.Length == 0) { return string.Empty; } else { return _Name; } } }
         //public Misc Misc { get { return _Misc; } }
         public string VirtualSize { get { return string.Format("0x{0:x8}", _VirtualSize); } }
         public string VirtualAddress { get { return string.Format("0x{0:x8}", _VirtualAddress); } }
@@ -461,6 +494,7 @@
         public string NumberOfRelocations { get { return string.Format("0x{0:x4}", _NumberOfRelocations); } }
         public string NumberOfLinenumbers { get { return string.Format("0x{0:x4}", _NumberOfLinenumbers); } }
         public string Characteristics { get { return _Characteristics.ToString(); } }
+
         public override string ToString()
         {
             return Name;
@@ -776,14 +810,14 @@
                     if (this.Is32BitHeader)
                     {
                         optionalHeader32 = FromBinaryReader<IMAGE_OPTIONAL_HEADER32>(reader);                        
-                        optionalHeader32._VirtualEntryPoint = (uint)p.MainModule.EntryPointAddress;
-                        optionalHeader32._VirtualImageBase = (uint)p.MainModule.BaseAddress;
+                        //optionalHeader32._VirtualEntryPoint = (uint)p.MainModule.EntryPointAddress;
+                        //optionalHeader32._VirtualImageBase = (uint)p.MainModule.BaseAddress;
                     }
                     else
                     {
                         optionalHeader64 = FromBinaryReader<IMAGE_OPTIONAL_HEADER64>(reader);
-                        optionalHeader64._VirtualEntryPoint = (uint)p.MainModule.EntryPointAddress;
-                        optionalHeader64._VirtualImageBase = (ulong)p.MainModule.BaseAddress;
+                        //optionalHeader64._VirtualEntryPoint = (uint)p.MainModule.EntryPointAddress;
+                        //optionalHeader64._VirtualImageBase = (ulong)p.MainModule.BaseAddress;
                     }
 
                     imageSectionHeaders = new IMAGE_SECTION_HEADER[fileHeader._NumberOfSections];

 

  ViewVC Help
Powered by ViewVC 1.1.22