#include <QtGui>
-Mainwindow::Mainwindow()
+Mainwindow::Mainwindow(const std::string& filename)
{
openAction = new QAction(tr("&Open"), this);
// saveAction = new QAction(tr("&Save"), this);
stackedWidget, SLOT(setCurrentIndex(int)));
setWindowTitle(tr("Notepad"));
+
+ openBinary(filename);
}
void Mainwindow::quit()
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "",
tr("Binaries (*)"));
- if (fileName != "") {
- disassembler.reset(new LLVMDisassembler(fileName.toStdString()));
+ openBinary(fileName.toStdString());
+}
+
+void Mainwindow::openBinary(const std::string& filename) {
+ if (filename != "") {
+ disassembler.reset(new LLVMDisassembler(filename));
// curBin = new Binary(fileName.toStdString());
// std::vector<std::string> symbols = curBin->getSymbols();
class Mainwindow : public QMainWindow {
Q_OBJECT
public:
- Mainwindow();
+ Mainwindow(const std::string& filename = "");
private:
+ void openBinary(const std::string& filename);
+
void populateSymbolInformation(const std::string& sym);
QTextEdit *textEdit;
log4cxx::BasicConfigurator::configure();
log4cxx::LoggerPtr _logger(log4cxx::Logger::getLogger("main"));
+ QCommandLineParser parser;
+
+ QApplication::setApplicationName("frida");
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.addPositionalArgument("filename", QCoreApplication::translate("main", "File to disassemble."));
+
+ QApplication app(argc, argv);
+ parser.process(app);
+
LOG4CXX_DEBUG(_logger, "Initializing LLVM");
llvm::InitializeAllTargetInfos();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllDisassemblers();
LOG4CXX_DEBUG(_logger, "Initializing Qt");
- QApplication app(argc, argv);
- QCommandLineParser parser;
-
- QApplication::setApplicationName("frida");
- parser.addHelpOption();
- parser.process(app);
- Mainwindow m;
+ Mainwindow m(parser.positionalArguments().at(0).toStdString());
m.show();
return app.exec();