コード例 #1
0
ファイル: StructureWriter.cs プロジェクト: nobled/mono
		public override void VisitAssemblyDefinition (AssemblyDefinition asm)
		{
			if (asm.Kind != AssemblyKind.Dll && asm.EntryPoint == null)
				throw new ReflectionException ("Assembly does not have an entry point defined");

			if ((asm.MainModule.Image.CLIHeader.Flags & RuntimeImage.ILOnly) == 0)
				throw new NotSupportedException ("Can not write a mixed mode assembly");

			foreach (ModuleDefinition module in asm.Modules)
				if (module.Image.CLIHeader.Metadata.VirtualAddress != RVA.Zero)
					ResetImage (module);

			asm.MetadataToken = new MetadataToken (TokenType.Assembly, 1);
			ReflectionWriter rw = asm.MainModule.Controller.Writer;
			rw.StructureWriter = this;

			m_mdWriter = rw.MetadataWriter;
			m_tableWriter = rw.MetadataTableWriter;
			m_rowWriter = rw.MetadataRowWriter;

			if (!rw.SaveSymbols)
				return;

			FileStream fs = m_binaryWriter.BaseStream as FileStream;
			if (fs != null)
				rw.OutputFile = fs.Name;
		}
コード例 #2
0
ファイル: MetadataTableWriter.cs プロジェクト: nobled/mono
		public MetadataTableWriter (MetadataWriter mrv, MemoryBinaryWriter writer)
		{
			m_root = mrv.GetMetadataRoot ();
			m_heap = m_root.Streams.TablesHeap;
			m_binaryWriter = writer;
			m_mrrw = new MetadataRowWriter (this);
		}
コード例 #3
0
ファイル: ImageWriter.cs プロジェクト: sidecut/xaeios
        public ImageWriter(MetadataWriter writer, AssemblyKind kind, BinaryWriter bw)
        {
            m_mdWriter= writer;
            m_img = writer.GetMetadataRoot ().GetImage ();
            m_kind = kind;
            m_binaryWriter = bw;

            m_textWriter = new MemoryBinaryWriter ();
            m_textWriter.BaseStream.Position = 80;
            m_relocWriter = new MemoryBinaryWriter ();
        }
コード例 #4
0
ファイル: SignatureWriter.cs プロジェクト: KAW0/Alter-Native
		public SignatureWriter (MetadataWriter mdWriter)
		{
			m_mdWriter = mdWriter;
			m_sigWriter = new MemoryBinaryWriter ();
		}
コード例 #5
0
ファイル: StructureWriter.cs プロジェクト: pusp/o2platform
		public override void VisitAssemblyDefinition (AssemblyDefinition asm)
		{
			if (asm.Kind != AssemblyKind.Dll && asm.EntryPoint == null)
				throw new ReflectionException ("Assembly does not have an entry point defined");

			if ((asm.MainModule.Image.CLIHeader.Flags & RuntimeImage.ILOnly) == 0)
				throw new NotImplementedException ("Can not write a mixed mode assembly");

			foreach (ModuleDefinition module in asm.Modules)
				if (module.Image.CLIHeader.Metadata.VirtualAddress != RVA.Zero)
					ResetImage (module);

			ReflectionWriter rw = asm.MainModule.Controller.Writer;
			rw.StructureWriter = this;

			m_mdWriter = rw.MetadataWriter;
			m_tableWriter = rw.MetadataTableWriter;
			m_rowWriter = rw.MetadataRowWriter;
		}
コード例 #6
0
        void Initialize()
        {
            m_mdWriter = new MetadataWriter (
                m_mod.Assembly,
                m_mod.Image.MetadataRoot,
                m_structureWriter.Assembly.Kind,
                m_mod.Assembly.Runtime,
                m_structureWriter.GetWriter ());
            m_tableWriter = m_mdWriter.GetTableVisitor ();
            m_rowWriter = m_tableWriter.GetRowVisitor () as MetadataRowWriter;
            m_sigWriter = new SignatureWriter (m_mdWriter);
            m_codeWriter = new CodeWriter (this, m_mdWriter.CilWriter);

            m_typeDefStack = new ArrayList ();
            m_methodStack = new ArrayList ();
            m_fieldStack = new ArrayList ();
            m_genericParamStack = new ArrayList ();
            m_typeSpecCache = new Hashtable ();

            m_methodIndex = 1;
            m_fieldIndex = 1;
            m_paramIndex = 1;
            m_eventIndex = 1;
            m_propertyIndex = 1;

            m_constWriter = new MemoryBinaryWriter ();
        }
コード例 #7
0
ファイル: AssemblyStripper.cs プロジェクト: nobled/mono
		void CopyOriginalImage ()
		{
			original = assembly.MainModule.Image;
			stripped = Image.CreateImage();

			stripped.Accept (new CopyImageVisitor (original));

			assembly.MainModule.Image = stripped;

			original_tables = original.MetadataRoot.Streams.TablesHeap;
			stripped_tables = stripped.MetadataRoot.Streams.TablesHeap;

			TableCollection tables = original_tables.Tables;
			foreach (IMetadataTable table in tables)
				stripped_tables.Tables.Add(table);

			stripped_tables.Valid = original_tables.Valid;
			stripped_tables.Sorted = original_tables.Sorted;

			reflection_writer = new ReflectionWriter (assembly.MainModule);
			reflection_writer.StructureWriter = new StructureWriter (assembly, writer);
			reflection_writer.CodeWriter.Stripped = true;

			metadata_writer = reflection_writer.MetadataWriter;

			PatchHeap (metadata_writer.StringWriter, original.MetadataRoot.Streams.StringsHeap);
			PatchHeap (metadata_writer.GuidWriter, original.MetadataRoot.Streams.GuidHeap);
			PatchHeap (metadata_writer.UserStringWriter, original.MetadataRoot.Streams.UserStringsHeap);
			PatchHeap (metadata_writer.BlobWriter, original.MetadataRoot.Streams.BlobHeap);

			if (assembly.EntryPoint != null)
				metadata_writer.EntryPointToken = assembly.EntryPoint.MetadataToken.ToUInt ();
		}