]> git.siccegge.de Git - frida/frida.git/commitdiff
Allow opening of binary via comman argument
authorChristoph Egger <christoph@christoph-egger.org>
Fri, 23 May 2014 16:20:38 +0000 (18:20 +0200)
committerChristoph Egger <christoph@christoph-egger.org>
Fri, 23 May 2014 16:20:38 +0000 (18:20 +0200)
src/gui/Mainwindow.cxx
src/gui/Mainwindow.hxx
src/main.cxx

index 061734a5bc946dde58082641543aed5ec24d6c0c..fd0c24595da1bfe0efc675ac395970ccce764ece 100644 (file)
@@ -8,7 +8,7 @@
 
 #include <QtGui>
 
-Mainwindow::Mainwindow()
+Mainwindow::Mainwindow(const std::string& filename)
 {
     openAction = new QAction(tr("&Open"), this);
     // saveAction = new QAction(tr("&Save"), this);
@@ -37,6 +37,8 @@ Mainwindow::Mainwindow()
             stackedWidget, SLOT(setCurrentIndex(int)));
 
     setWindowTitle(tr("Notepad"));
+
+       openBinary(filename);
 }
 
 void Mainwindow::quit()
@@ -54,8 +56,12 @@ void Mainwindow::open() {
     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();
index adfe71e47a3fc0803b23245bca3498e95dc8cc5b..3892ebd61ad29572a9517f9a421a9f0c35f12d8b 100644 (file)
 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;
index 0ce89abd3c284ec41cb304f5b95cf682aaf6eec9..74d1325924fa326a44617b70519a121171950c40 100644 (file)
@@ -21,6 +21,16 @@ int main(int argc, char** argv)
     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();
@@ -28,14 +38,8 @@ int main(int argc, char** argv)
     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();