public MetadataRowWriter(MetadataTableWriter mtwv)
 {
     m_binaryWriter = mtwv.GetWriter();
     m_root         = mtwv.GetMetadataRoot();
     m_ciCache      = new int [13];
     m_counter      = new Utilities.TableRowCounter(GetNumberOfRows);
 }
示例#2
0
		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;
		}
示例#3
0
        public MetadataWriter(AssemblyDefinition asm, MetadataRoot root,
                              AssemblyKind kind, TargetRuntime rt, BinaryWriter writer)
        {
            m_assembly     = asm;
            m_root         = root;
            m_runtime      = rt;
            m_imgWriter    = new ImageWriter(this, kind, writer);
            m_binaryWriter = m_imgWriter.GetTextWriter();

            m_stringCache  = new Hashtable();
            m_stringWriter = new MemoryBinaryWriter(Encoding.UTF8);
            m_stringWriter.Write((byte)0);

            m_guidCache  = new Hashtable();
            m_guidWriter = new MemoryBinaryWriter();

            m_usCache  = new Hashtable();
            m_usWriter = new MemoryBinaryWriter(Encoding.Unicode);
            m_usWriter.Write((byte)0);

            m_blobCache  = new Hashtable(ByteArrayEqualityComparer.Instance, ByteArrayEqualityComparer.Instance);
            m_blobWriter = new MemoryBinaryWriter();
            m_blobWriter.Write((byte)0);

            m_tWriter     = new MemoryBinaryWriter();
            m_tableWriter = new MetadataTableWriter(this, m_tWriter);

            m_cilWriter = new MemoryBinaryWriter();

            m_fieldDataWriter = new MemoryBinaryWriter();
            m_resWriter       = new MemoryBinaryWriter();
        }
示例#4
0
		public MetadataRowWriter (MetadataTableWriter mtwv)
		{
			m_binaryWriter = mtwv.GetWriter ();
			m_root = mtwv.GetMetadataRoot ();
			m_ciCache = new int [13];
			m_counter = new Utilities.TableRowCounter (GetNumberOfRows);
		}
 public MetadataRowWriter(MetadataTableWriter mtwv)
 {
     m_binaryWriter = mtwv.GetWriter ();
     m_root = mtwv.GetMetadataRoot ();
     m_ciCache = new Hashtable ();
 }
 public MetadataRowWriter(MetadataTableWriter mtwv)
 {
     m_binaryWriter = mtwv.GetWriter();
     m_root         = mtwv.GetMetadataRoot();
     m_ciCache      = new Hashtable();
 }
示例#7
0
		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;
		}
示例#8
0
        public MetadataWriter(AssemblyDefinition asm, MetadataRoot root,
			AssemblyKind kind, TargetRuntime rt, BinaryWriter writer)
        {
            m_assembly = asm;
            m_root = root;
            m_runtime = rt;
            m_imgWriter = new ImageWriter (this, kind, writer);
            m_binaryWriter = m_imgWriter.GetTextWriter ();

            m_stringCache = new Hashtable ();
            m_stringWriter = new MemoryBinaryWriter (Encoding.UTF8);
            m_stringWriter.Write ((byte) 0);

            m_guidCache = new Hashtable ();
            m_guidWriter = new MemoryBinaryWriter ();

            m_usCache = new Hashtable ();
            m_usWriter = new MemoryBinaryWriter (Encoding.Unicode);
            m_usWriter.Write ((byte) 0);

            m_blobCache = new Hashtable ();
            m_blobWriter = new MemoryBinaryWriter ();
            m_blobWriter.Write ((byte) 0);

            m_tWriter = new MemoryBinaryWriter ();
            m_tableWriter = new MetadataTableWriter (this, m_tWriter);

            m_cilWriter = new MemoryBinaryWriter ();

            m_fieldDataWriter = new MemoryBinaryWriter ();
            m_resWriter = new MemoryBinaryWriter ();
        }
		public MetadataRowWriter (MetadataTableWriter mtwv)
		{
			m_binaryWriter = mtwv.GetWriter ();
			m_root = mtwv.GetMetadataRoot ();
			m_ciCache = new int [<%= $coded_indexes.length %>];
示例#10
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 ();
        }