/[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 159 by william, Mon May 28 05:22:28 2012 UTC revision 161 by william, Mon May 28 05:55:59 2012 UTC
# Line 30  namespace Sojaner.MemoryScanner Line 30  namespace Sojaner.MemoryScanner
30                  size = Marshal.SizeOf(typeof(IMAGE_DOS_HEADER));                  size = Marshal.SizeOf(typeof(IMAGE_DOS_HEADER));
31                  data = br.ReadBytes(size);                  data = br.ReadBytes(size);
32                  pinnedPacket = GCHandle.Alloc(data, GCHandleType.Pinned);                  pinnedPacket = GCHandle.Alloc(data, GCHandleType.Pinned);
33                  IMAGE_DOS_HEADER IMAGE_DOS_HEADER = (IMAGE_DOS_HEADER)Marshal.PtrToStructure(pinnedPacket.AddrOfPinnedObject(), typeof(IMAGE_DOS_HEADER));                  IMAGE_DOS_HEADER DOS_HEADER = (IMAGE_DOS_HEADER)Marshal.PtrToStructure(pinnedPacket.AddrOfPinnedObject(), typeof(IMAGE_DOS_HEADER));
34                  pinnedPacket.Free();                  pinnedPacket.Free();
35                  #endregion                  #endregion
36    
37                  // skip the old dos stub                  // skip the old dos stub
38                  br.BaseStream.Seek(IMAGE_DOS_HEADER.e_lfanew, SeekOrigin.Begin);                  br.BaseStream.Seek(DOS_HEADER.e_lfanew, SeekOrigin.Begin);
39    
40                  #region IMAGE_NT_HEADERS                  #region IMAGE_NT_HEADERS
41                  size = Marshal.SizeOf(typeof(IMAGE_NT_HEADERS));                  size = Marshal.SizeOf(typeof(IMAGE_NT_HEADERS));
42                  data = br.ReadBytes(size);                  data = br.ReadBytes(size);
43                  pinnedPacket = GCHandle.Alloc(data, GCHandleType.Pinned);                  pinnedPacket = GCHandle.Alloc(data, GCHandleType.Pinned);
44                  IMAGE_NT_HEADERS IMAGE_NT_HEADERS = (IMAGE_NT_HEADERS)Marshal.PtrToStructure(pinnedPacket.AddrOfPinnedObject(), typeof(IMAGE_NT_HEADERS));                  IMAGE_NT_HEADERS NT_HEADER = (IMAGE_NT_HEADERS)Marshal.PtrToStructure(pinnedPacket.AddrOfPinnedObject(), typeof(IMAGE_NT_HEADERS));
45                  pinnedPacket.Free();                  pinnedPacket.Free();
46                  #endregion                  #endregion
47    
48    
49                  br.Close();                  br.Close();
50              }              }
51    
# Line 59  namespace Sojaner.MemoryScanner Line 60  namespace Sojaner.MemoryScanner
60          {          {
61              public UInt32 VirtualAddress;              public UInt32 VirtualAddress;
62              public UInt32 Size;              public UInt32 Size;
63                public bool HasAddress { get { return (VirtualAddress != 0); } }
64                public bool HasSize { get { return (Size > 0); } }
65          }          }
66          #endregion          #endregion
67          #region IMAGE_FILE_HEADER          #region IMAGE_FILE_HEADER
68          [StructLayout(LayoutKind.Sequential)]          [StructLayout(LayoutKind.Sequential)]
69          public struct IMAGE_FILE_HEADER          public struct IMAGE_FILE_HEADER
70          {          {
71              public UInt16 Machine;              public MachineType Machine;
72              public UInt16 NumberOfSections;              public UInt16 NumberOfSections;
73              public UInt32 TimeDateStamp;              public UInt32 TimeDateStamp;
74              public UInt32 PointerToSymbolTable;              public UInt32 PointerToSymbolTable;
75              public UInt32 NumberOfSymbols;              public UInt32 NumberOfSymbols;
76              public UInt16 SizeOfOptionalHeader;              public UInt16 SizeOfOptionalHeader;
77              public UInt16 Characteristics;              public DllCharacteristicsType Characteristics;
78          }          }
79          #endregion          #endregion
80          #region IMAGE_DOS_HEADER          #region IMAGE_DOS_HEADER
# Line 169  namespace Sojaner.MemoryScanner Line 172  namespace Sojaner.MemoryScanner
172          }          }
173          #endregion          #endregion
174          #region DllCharacteristicsType          #region DllCharacteristicsType
175            [Flags]
176          public enum DllCharacteristicsType : ushort          public enum DllCharacteristicsType : ushort
177          {          {
178              RES_0 = 0x0001,              RES_0 = 0x0001,

Legend:
Removed from v.159  
changed lines
  Added in v.161

  ViewVC Help
Powered by ViewVC 1.1.22