New test.
[mono.git] / mcs / class / Mono.PEToolkit / DataDir.cs
index c4b7bfcab984da4e829598b6b3b3c628dd79e44d..7c0b8b6922e5d805766356cd6a5943816e1254a5 100644 (file)
@@ -1,8 +1,30 @@
+\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
 /*\r
  * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
  */\r
 \r
 using System;\r
+using System.IO;\r
 using System.Runtime.InteropServices;\r
 \r
 namespace Mono.PEToolkit {\r
@@ -10,8 +32,7 @@ namespace Mono.PEToolkit {
        /// <summary>\r
        /// IMAGE_DATA_DIRECTORY.\r
        /// </summary>\r
-       [StructLayoutAttribute(LayoutKind.Sequential)]\r
-       public struct DataDir {\r
+       public class DataDir {\r
 \r
                public static readonly DataDir Null;\r
 \r
@@ -20,10 +41,31 @@ namespace Mono.PEToolkit {
 \r
                static DataDir ()\r
                {\r
+                       Null = new DataDir ();\r
                        Null.virtAddr = 0;\r
                        Null.size = 0;\r
                }\r
 \r
+               public DataDir () {\r
+\r
+               }\r
+\r
+               public DataDir (BinaryReader reader)\r
+               {\r
+                       Read (reader);\r
+               }\r
+\r
+               public void Read (BinaryReader reader)\r
+               {\r
+                       virtAddr = new RVA (reader.ReadUInt32 ());\r
+                       size = reader.ReadUInt32 ();\r
+               }\r
+\r
+               public void Write (BinaryWriter writer)\r
+               {\r
+                       virtAddr.Write (writer);\r
+                       writer.Write (size);\r
+               }\r
 \r
                public RVA VirtualAddress {\r
                        get {\r