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

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

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

revision 378 by william, Sun Jun 10 07:55:18 2012 UTC revision 379 by william, Tue Jun 19 08:09:02 2012 UTC
# Line 369  namespace Sojaner.MemoryScanner Line 369  namespace Sojaner.MemoryScanner
369      {      {
370          public UInt16 _MachineType;          public UInt16 _MachineType;
371          public UInt16 _NumberOfSections;          public UInt16 _NumberOfSections;
372          public Int32 _TimeDateStamp;          public Int32 _LinkerTime; // The time that the linker (or compiler for an OBJ file) produced this file. This field holds the number of seconds since December 31st, 1969, at 4:00 P.M.
373          public UInt32 _PointerToSymbolTable;          public UInt32 _PointerToSymbolTable;
374          public UInt32 _NumberOfSymbols;          public UInt32 _NumberOfSymbols;
375          public UInt16 _SizeOfOptionalHeader;          public UInt16 _SizeOfOptionalHeader;
# Line 378  namespace Sojaner.MemoryScanner Line 378  namespace Sojaner.MemoryScanner
378    
379          public string MachineType { get { return ((MachineTypeFlags)_MachineType).ToString(); } }          public string MachineType { get { return ((MachineTypeFlags)_MachineType).ToString(); } }
380          public string NumberOfSections { get { return string.Format("0x{0:x4}", _NumberOfSections); } }          public string NumberOfSections { get { return string.Format("0x{0:x4}", _NumberOfSections); } }
381          public string TimeDateStamp { get { return string.Format("{0} (0x{1:x8})", GetDateTimeFromDosDateTime(_TimeDateStamp).ToString(), _TimeDateStamp); } }          public string LinkerTime { get { return string.Format("{0} (0x{1:x8})", GetDateTimeFromLinkerTime(_LinkerTime).ToString(), _LinkerTime); } }
382          public string PointerToSymbolTable { get { return string.Format("0x{0:x8}", _PointerToSymbolTable); } }          public string PointerToSymbolTable { get { return string.Format("0x{0:x8}", _PointerToSymbolTable); } }
383          public string NumberOfSymbols { get { return string.Format("0x{0:x8}", _NumberOfSymbols); } }          public string NumberOfSymbols { get { return string.Format("0x{0:x8}", _NumberOfSymbols); } }
384          public string SizeOfOptionalHeader { get { return string.Format("0x{0:x4}", _SizeOfOptionalHeader); } }          public string SizeOfOptionalHeader { get { return string.Format("0x{0:x4}", _SizeOfOptionalHeader); } }
# Line 388  namespace Sojaner.MemoryScanner Line 388  namespace Sojaner.MemoryScanner
388              return MachineType;              return MachineType;
389          }          }
390    
391          private DateTime GetDateTimeFromDosDateTime(Int32 i32TimeDate)          private DateTime GetDateTimeFromLinkerTime(Int32 linker_timer)
392          {          {
393              Int16 i16Time = (Int16)(i32TimeDate & 0xFFFF);              // http://msdn.microsoft.com/en-us/library/ms809762.aspx
394              Int16 i16Date = (Int16)((i32TimeDate & 0xFFFF0000) >> 16);              // This field holds the number of seconds since December 31st, 1969, at 4:00 P.M.
395              return GetDateTimeFromDosDateTime(i16Time, i16Date);              DateTime t = new DateTime(1969, 12, 31, 16, 0, 0);
396          }              t = t.AddSeconds(linker_timer);
397          private DateTime GetDateTimeFromDosDateTime(Int16 i16Time, Int16 i16Date)              return t;
         {  
             try  
             {  
                 int iYear = 0;  
                 int iMonth = 1;  
                 int iDay = 1;  
                 int iHour = 0;  
                 int iMinute = 0;  
                 int iSecond = 0;  
                 iDay = (i16Date & 0x1F);  
                 iMonth = ((i16Date & 0x01E0) >> 5);  
                 iYear = 1980 + ((i16Date & 0xFE00) >> 9);  
                 iSecond = (i16Time & 0x1F) * 2;  
                 iMinute = ((i16Time & 0x07E0) >> 5);  
                 iHour = ((i16Time & 0x0F800) >> 11);  
                 return new DateTime(iYear, iMonth, iDay, iHour, iMinute, iSecond);  
             }  
             catch  
             {  
                 return new DateTime();  
             }  
398          }          }
399    
400      }      }

Legend:
Removed from v.378  
changed lines
  Added in v.379

  ViewVC Help
Powered by ViewVC 1.1.22