Esempio n. 1
0
        public void DisassembleFile(string outputfile)
        {
            bool _skipDisassembly = false;

            if (File.Exists(outputfile))
            {
                if (MessageBox.Show("Assemblerfile already exists, do you want to redo the disassembly?", "Question", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    _skipDisassembly = true;
                }
            }
            if (!_skipDisassembly)
            {
                Disassembler disasm = new Disassembler();
                disasm.onProgress += new Disassembler.Progress(disasm_onProgress);
                logger.Debug("Starting disassembly");
                disasm.DisassembleFile(filename, m_symbols);
                logger.Debug("Done disassembling: " + disasm.Mnemonics.Count.ToString());
                using (StreamWriter sw = new StreamWriter(outputfile))
                {
                    foreach (MNemonicHelper helper in disasm.Mnemonics)
                    {
                        if (helper.Mnemonic.Contains(":"))
                        {
                            //listBox1.Items.Add(helper.Mnemonic);
                            if (!helper.Mnemonic.Contains("LBL_"))
                            {
                                sw.WriteLine();
                            }
                            sw.WriteLine(helper.Mnemonic);
                        }
                        else
                        {
                            //listBox1.Items.Add(helper.Address.ToString("X8") + " " + helper.Mnemonic);
                            sw.WriteLine("0x" + helper.Address.ToString("X8") + "\t" + helper.Mnemonic);
                        }
                    }
                }
                // start the external viewer with the file
            }
            LoadFile(outputfile);
            string copyFile = filename + DateTime.Now.Ticks.ToString();
            File.Copy(filename, copyFile);
            LoadBinaryFile(copyFile, m_symbols);
        }
Esempio n. 2
0
 void disasm_onProgress(object sender, Disassembler.ProgressEventArgs e)
 {
     switch (e.Type)
     {
         case Disassembler.ProgressType.DisassemblingVectors:
             toolStripProgressBar1.Value = e.Percentage;
             break;
         case Disassembler.ProgressType.DisassemblingFunctions:
             toolStripStatusLabel3.Text = e.Percentage.ToString("D3") + " functions disassembled";
             break;
         case Disassembler.ProgressType.TranslatingVectors:
         case Disassembler.ProgressType.TranslatingLabels:
         case Disassembler.ProgressType.SortingData:
             if (e.Percentage <= toolStripProgressBar2.Maximum)
             {
                 toolStripProgressBar2.Value = e.Percentage;
             }
             break;
     }
     Application.DoEvents();
 }