2 * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>
\r
7 using System.Runtime.InteropServices;
\r
9 namespace Mono.PEToolkit {
\r
12 /// IMAGE_DATA_DIRECTORY.
\r
14 public class DataDir {
\r
16 public static readonly DataDir Null;
\r
18 public RVA virtAddr;
\r
23 Null = new DataDir ();
\r
32 public DataDir (BinaryReader reader)
\r
37 public void Read (BinaryReader reader)
\r
39 virtAddr = new RVA (reader.ReadUInt32 ());
\r
40 size = reader.ReadUInt32 ();
\r
43 public void Write (BinaryWriter writer)
\r
45 virtAddr.Write (writer);
\r
46 writer.Write (size);
\r
49 public RVA VirtualAddress {
\r
67 public bool IsNull {
\r
69 return (this == Null);
\r
73 public override int GetHashCode()
\r
75 return (virtAddr.GetHashCode() ^ (int)(size << 1));
\r
78 public override bool Equals(object obj)
\r
80 bool res = (obj is DataDir);
\r
82 DataDir that = (DataDir) obj;
\r
83 res = (this.virtAddr == that.virtAddr) &&
\r
84 (this.size == that.size);
\r
89 public static bool operator == (DataDir d1, DataDir d2)
\r
91 return d1.Equals(d2);
\r
94 public static bool operator != (DataDir d1, DataDir d2)
\r
96 return !d1.Equals(d2);
\r
101 /// <returns></returns>
\r
102 public override string ToString()
\r
104 if (this.IsNull) return "NULL";
\r
105 return String.Format("RVA = {0}, size = 0x{1}", virtAddr, size.ToString("X"));
\r