Exemple #1
0
 /// <summary>
 /// Store the R2R reader and construct the disassembler for the appropriate architecture.
 /// </summary>
 /// <param name="reader"></param>
 public Disassembler(ReadyToRunReader reader, DumpOptions options)
 {
     _reader  = reader;
     _options = options;
     _disasm  = CoreDisTools.GetDisasm(_reader.Machine);
     SetIndentations();
 }
Exemple #2
0
        private int Run(string[] args)
        {
            ArgumentSyntax syntax = ParseCommandLine(args);

            if (_help)
            {
                _writer.WriteLine(syntax.GetHelpText());
                return(0);
            }

            if (_inputFilenames.Count == 0)
            {
                throw new ArgumentException("Input filename must be specified (--in <file>)");
            }

            // open output stream
            if (_outputFilename != null)
            {
                _writer = File.CreateText(_outputFilename);
            }
            else
            {
                _writer = Console.Out;
            }

            try
            {
                foreach (string filename in _inputFilenames)
                {
                    R2RReader r2r = new R2RReader(filename);
                    if (_disasm)
                    {
                        _disassembler = CoreDisTools.GetDisasm(r2r.Machine);
                    }

                    Dump(r2r);

                    if (_disasm)
                    {
                        CoreDisTools.FinishDisasm(_disassembler);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.ToString());
                return(1);
            }
            finally
            {
                // close output stream
                _writer.Close();
            }

            return(0);
        }
Exemple #3
0
 public Disassembler(byte[] image, Machine machine)
 {
     _disasm  = CoreDisTools.GetDisasm(machine);
     _image   = image;
     _machine = machine;
 }
Exemple #4
0
        private int Run(string[] args)
        {
            ArgumentSyntax syntax = ParseCommandLine(args);

            // open output stream
            if (_outputFilename != null)
            {
                _writer = File.CreateText(_outputFilename);
            }
            else
            {
                _writer = Console.Out;
            }

            if (_help)
            {
                _writer.WriteLine(syntax.GetHelpText());
                return(0);
            }

            try
            {
                if (_inputFilenames.Count == 0)
                {
                    throw new ArgumentException("Input filename must be specified (--in <file>)");
                }

                foreach (string filename in _inputFilenames)
                {
                    R2RReader r2r = new R2RReader(filename);

                    if (_disasm)
                    {
                        _disassembler = CoreDisTools.GetDisasm(r2r.Machine);
                    }

                    if (_xml)
                    {
                        _dumper = new XmlDumper(_ignoreSensitive, r2r, _writer, _raw, _header, _disasm, _disassembler, _unwind, _gc, _sectionContents);
                    }
                    else
                    {
                        _dumper = new TextDumper(r2r, _writer, _raw, _header, _disasm, _disassembler, _unwind, _gc, _sectionContents);
                    }

                    Dump(r2r);

                    if (_disasm)
                    {
                        CoreDisTools.FinishDisasm(_disassembler);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.ToString());
                if (e is ArgumentException)
                {
                    Console.WriteLine();
                    Console.WriteLine(syntax.GetHelpText());
                }
                if (_xml)
                {
                    XmlDocument document = new XmlDocument();
                    XmlNode     node     = document.CreateNode("element", "Error", "");
                    node.InnerText = e.Message;
                    document.AppendChild(node);
                    if (_writer != null)
                    {
                        document.Save(_writer);
                    }
                }
                return(1);
            }
            finally
            {
                // close output stream
                _writer.Close();
            }

            return(0);
        }
Exemple #5
0
 /// <summary>
 /// Store the R2R reader and construct the disassembler for the appropriate architecture.
 /// </summary>
 /// <param name="reader"></param>
 public Disassembler(R2RReader reader, DumpOptions options)
 {
     _reader  = reader;
     _options = options;
     _disasm  = CoreDisTools.GetDisasm(_reader.Machine);
 }
Exemple #6
0
 /// <summary>
 /// Store the R2R reader and construct the disassembler for the appropriate architecture.
 /// </summary>
 /// <param name="reader"></param>
 public Disassembler(R2RReader reader)
 {
     _reader = reader;
     _disasm = CoreDisTools.GetDisasm(_reader.Machine);
 }