private void exportToMotorolaFileToolStripMenuItem_Click(object sender, EventArgs e) { if (coff.header.VersionID == 0x00C1) { if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Motorola motFile = new Motorola(16, coff.optionalHeader.EntryPointAddress); List <Coff.Section> sections = coff.GetSections(); foreach (int index in listViewSections.SelectedIndices) { string sec_name = listViewSections.Items[index].Text; foreach (Coff.Section sec in sections) { if (sec_name == sec.name) { if (sec.MemoryPage == 0) { motFile.AddSection(sec); } else { MessageBox.Show("Section " + sec_name + " skipped (not text area)", "COFF Analyzer", MessageBoxButtons.OK, MessageBoxIcon.Warning); } break; } } } motFile.Save(saveFileDialog1.FileName); } } else { MessageBox.Show("Sorry, not supported for this COFF object file", "COFF Analyzer", MessageBoxButtons.OK, MessageBoxIcon.Hand); } }
public MainForm(string[] args) { InitializeComponent(); if (args.Length > 0) { // Use first argument as source file if (File.Exists(args[0])) { coff = OpenCoffFile(args[0]); if (args.Length > 1) { // Use other parameters as section names List <Coff.Section> sections = coff.GetSections(); for (int index = 1; index < args.Length; ++index) { string sec_name = args[index]; foreach (Coff.Section sec in sections) { if (sec.name == sec_name) { sections.Add(sec); break; } } } toolStripStatusLabel1.Text = UpdateChecksumInformation(coff, sections); } } else { MessageBox.Show("File to open not found !", Title, MessageBoxButtons.OK, MessageBoxIcon.Hand); } } }
private Coff OpenCoffFile(string fileName) { Coff coff = new Coff(fileName); if (coff != null) { Text = Title + " - " + Path.GetFileName(fileName); // Write info textBoxInfo.Text = "EXEC CODE ADDR: " + coff.optionalHeader.ExecCodeAddress.ToString("X4") + Environment.NewLine; textBoxInfo.Text += "EXEC CODE SIZE: " + coff.optionalHeader.ExecCodeSize + Environment.NewLine; textBoxInfo.Text += "BUILD DATE: " + coff.header.Timestamp.ToString() + Environment.NewLine; // Write list view listViewSections.Items.Clear(); foreach (Coff.Section section in coff.GetSections()) { ListViewItem lvi = new ListViewItem(new string[] { section.name, section.PhysicalAddress.ToString("X4"), section.Size.ToString(), section.MemoryPage.ToString() }); listViewSections.Items.Add(lvi); } } return(coff); }