Exemplo n.º 1
0
        /// <summary>
        /// Creates an instance of the file interpreter.
        /// </summary>
        /// <param name="terminal">The terminal implementation that will be used for I/O.</param>
        public ExecutionContext(IRuntimeEnvironment environment,
                                ITerminal terminal,
                                IDataSegmentAccessor dataSegment,
                                RegisterManager regMgr,
                                TextSegmentAccessor textSegment)
        {
            m_Environment    = environment;
            m_Terminal       = terminal;
            m_InterpreterFac = new InterpreterFactory(environment, terminal);

            m_Ctx = new RuntimeContext(environment, dataSegment, regMgr);

            m_TextSegment = textSegment;
        }
        public DisassembledFileBase ParseFile(string fileName, ILogger logger)
        {
            using (var elfFileParser = new ELF_Reader(fileName))
            {
                var decompiledFile = new ELF_CompiledFile(elfFileParser);

                var dataSection = new DataSegmentAccessor(decompiledFile.DataBytes, decompiledFile.DataSegmentStartingAddress, decompiledFile.DataSegmentSize);

                var textSegmentParser = new TextSegmentParser();
                IEnumerable <DisassembledInstruction> rawTextSegment = textSegmentParser.ParseTextSegment(decompiledFile.RawInstructions);
                var textSection = new TextSegmentAccessor(rawTextSegment, decompiledFile.TextSegmentStartingAddress);

                //TODO: fix when we have better sectioning logic.
                var dummyExtern = new List <byte>();

                return(new DisassembledElfFile(dataSection, textSection, dummyExtern, decompiledFile.SymbolTable));
            }
        }
Exemplo n.º 3
0
        public DisassembledFileBase ParseFile(string fileName, ILogger logger)
        {
            JefFile jefFile = JefFile.ParseFile(fileName);

            var textParser = new TextSegmentParser();
            IEnumerable <DisassembledInstruction> instructions = textParser.ParseTextSegment(jefFile.TextElements);

            int dataSegSize = 0;

            foreach (MetadataElement elem in jefFile.DataMetadata)
            {
                dataSegSize += elem.Size;
            }

            var dataSegment = new DataSegmentAccessor(jefFile.DataElements, jefFile.BaseDataAddress, dataSegSize);

            var textSegment = new TextSegmentAccessor(instructions, jefFile.BaseTextAddress);

            return(new DisassembledJefFile(dataSegment, textSegment, jefFile.ExternElements,
                                           jefFile.SymbolTable, jefFile.DataMetadata, jefFile.DebugData));
        }