private string DisassembleToTemporaryFile(string inputFileName, ILogger logger) { string outputFileName = Path.GetTempFileName(); logger.Log(LogLevel.Info, "Invoking disassembler for file " + inputFileName); try { ICompiledFileReader fileParser = m_FileParserFac.GetFileParser(inputFileName); DisassembledFileBase fileBase = fileParser.ParseFile(inputFileName, logger); IAssemblyFileWriter fileWriter = fileBase.AssemblyTextFileWriter; fileWriter.GenerateOutputFile(outputFileName); } catch (IOException ex) { logger.Log(LogLevel.Critical, ex.Message); throw; } catch (Exception ex) { logger.Log(LogLevel.Critical, "In file " + inputFileName + ":"); logger.Log(LogLevel.Critical, ex.Message); throw; } return(outputFileName); }
/// <summary> /// Task for disassembling one individual file. /// </summary> /// <param name="logger">The logging implementation to log errors/info to.</param> /// <param name="options">The options to use while disassembling.</param> /// <returns>True if the disassembler could successfully disassemble the file; otherwise returns false.</returns> public bool DisassembleFile(ILogger logger, DisassemblerOptions options) { bool success = true; logger.Log(LogLevel.Info, "Invoking disassembler for file " + options.InputFileName); try { ICompiledFileReader fileParser = m_FileParserFac.GetFileParser(options.InputFileName); DisassembledFileBase fileBase = fileParser.ParseFile(options.InputFileName, logger); IAssemblyFileWriter fileWriter = fileBase.AssemblyTextFileWriter; fileWriter.GenerateOutputFile(options.OutputFileName); } catch (IOException ex) { logger.Log(LogLevel.Critical, ex.Message); success = false; } catch (Exception ex) { logger.Log(LogLevel.Critical, "In file " + options.InputFileName + ":"); logger.Log(LogLevel.Critical, ex.Message); success = false; } return(success); }