void Patch() { // patch debug info in PE file to match PDB //try //{ byte[] DebugInfo = m_writer.GetDebugInfo(); m_writer.Close(); RVA debugHeaderRVA = m_module.Image.PEOptionalHeader.DataDirectories.Debug.VirtualAddress; long debugHeaderPos = m_module.Image.ResolveVirtualAddress(debugHeaderRVA); uint sizeUntilData = 0x1c; // copied from ImageWriter long debugDataPos = debugHeaderPos + sizeUntilData; using (FileStream fs = new FileStream(m_assembly, FileMode.Open, FileAccess.Write)) { BinaryWriter writer = new BinaryWriter(fs); writer.BaseStream.Position = debugDataPos; writer.Write(DebugInfo); } // } // catch (Exception ex) // { // System.Diagnostics.Debug.WriteLine("in PdbWriter.Patch: " + ex.Message); // } }
public void Dispose() { var entry_point = module.EntryPoint; if (entry_point != null) { writer.SetUserEntryPoint(new SymbolToken(entry_point.MetadataToken.ToInt32())); } writer.Close(); }
public void Write() { var entry_point = module.EntryPoint; if (entry_point != null) { writer.SetUserEntryPoint(entry_point.MetadataToken.ToInt32()); } debug_info = writer.GetDebugInfo(out debug_directory); debug_directory.TimeDateStamp = (int)module.timestamp; writer.Close(); }