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:
             toolStripProgressBar2.Value = e.Percentage;
             break;
     }
     Application.DoEvents();
 }
        public void DisassembleFile(string outputfile)
        {
            bool _skipDisassembly = false;
            Trionic5FileInformation fileinfo = _trionicFile.GetFileInfo();

            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);
                //Trionic5File m_trionicFile = new Trionic5File();
                //m_trionicFile.SelectFile(@"C:\Documents and Settings\Guido.MOBICOACH\Desktop\Guido\ASMTEST\guido.bin");
                //Trionic5FileInformation m_trionicFileInformation = m_trionicFile.ParseFile();
                //            long address = m_trionicFile.GetStartVectorAddress(m_trionicFileInformation.Filename, 1);
                Console.WriteLine("Starting disassembly");
                disasm.DisassembleFile(_trionicFile, fileinfo.Filename, outputfile, /*address,*/ fileinfo.SymbolCollection);

                Console.WriteLine("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 = fileinfo.Filename + DateTime.Now.Ticks.ToString();
            File.Copy(fileinfo.Filename, copyFile);
            LoadBinaryFile(copyFile, fileinfo.SymbolCollection);
        }
Example #3
0
 void disasm_onProgress(object sender, Disassembler.ProgressEventArgs e)
 {
 }