Przeglądaj źródła

Fri Jun 7 17:04:06 CEST 2002 Paolo Molaro <[email protected]>

	* AssemblyBuilder.cs: updates for PE/COFF rewrite.

svn path=/trunk/mcs/; revision=5149
Paolo Molaro 23 lat temu
rodzic
commit
e84fc77c09

+ 8 - 18
mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs

@@ -192,16 +192,13 @@ namespace System.Reflection.Emit {
 		}
 		
 		[MethodImplAttribute(MethodImplOptions.InternalCall)]
-		private static extern int getPEHeader (AssemblyBuilder ab, byte[] buf, out int data_size);
-
-		[MethodImplAttribute(MethodImplOptions.InternalCall)]
-		private static extern int getDataChunk (AssemblyBuilder ab, byte[] buf);
+		private static extern int getDataChunk (AssemblyBuilder ab, byte[] buf, int offset);
 
 		public void Save (string assemblyFileName)
 		{
-			byte[] buf = new byte [2048];
+			byte[] buf = new byte [65536];
 			FileStream file;
-			int count, data_size, total;
+			int count, offset;
 
 			if (dir != null) {
 				assemblyFileName = String.Format ("{0}{1}{2}", dir, System.IO.Path.DirectorySeparatorChar, assemblyFileName);
@@ -209,18 +206,11 @@ namespace System.Reflection.Emit {
 
 			file = new FileStream (assemblyFileName, FileMode.Create, FileAccess.Write);
 
-			total = count = getPEHeader (this, buf, out data_size);
-			file.Write (buf, 0, count);
-			buf = new byte [data_size];
-			count = getDataChunk (this, buf);
-			file.Write (buf, 0, count);
-			// pad to file alignment
-			total += count;
-			total %= 512;
-			total = 512 - total;
-			buf = new byte [total];
-			file.Write (buf, 0, total);
-
+			offset = 0;
+			while ((count = getDataChunk (this, buf, offset)) != 0) {
+				file.Write (buf, 0, count);
+				offset += count;
+			}
 			file.Close ();
 		}
 

+ 5 - 0
mcs/class/corlib/System.Reflection.Emit/ChangeLog

@@ -1,3 +1,8 @@
+
+Fri Jun 7 17:04:06 CEST 2002 Paolo Molaro <[email protected]>
+
+	* AssemblyBuilder.cs: updates for PE/COFF rewrite.
+
 2002-05-30  Martin Baulig  <[email protected]>
 
 	* AssemblyBuilder.cs (methods): Made this internal and don't