public ResourceWriter(Image img, Section rsrc, MemoryBinaryWriter writer) { m_img = img; m_rsrc = rsrc; m_writer = writer; m_dataEntries = new ArrayList (); m_stringEntries = new ArrayList (); }
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 (); }
internal MetadataRoot (Image img) { m_image = img; }
public ResourceReader(Image img) { m_img = img; }
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 (); }
public override void TerminateImage(Image img) { m_binaryWriter.BaseStream.Position = 0x200; WriteSection (m_textSect, m_textWriter); WriteSection (m_relocSect, m_relocWriter); if (m_rsrcSect != null) WriteSection (m_rsrcSect, m_rsrcWriter); }
public override void TerminateImage (Image img) { m_binaryWriter.BaseStream.Position = 0x200; m_textWriter.MemoryStream.WriteTo (m_binaryWriter.BaseStream); m_binaryWriter.Write (new byte [ m_textSect.SizeOfRawData - m_textWriter.BaseStream.Length]); m_relocWriter.MemoryStream.WriteTo (m_binaryWriter.BaseStream); m_binaryWriter.Write (new byte [ m_relocSect.SizeOfRawData - m_relocWriter.BaseStream.Length]); }