]> git.siccegge.de Git - frida/frida.git/blobdiff - src/gui/Mainwindow.cxx
Pass function instead of name
[frida/frida.git] / src / gui / Mainwindow.cxx
index 061734a5bc946dde58082641543aed5ec24d6c0c..fb713fc57d3b4ca55c8ef9ab4dc286abfe3035a9 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);
@@ -36,7 +36,9 @@ Mainwindow::Mainwindow()
     connect(listWidget, SIGNAL(currentRowChanged(int)),
             stackedWidget, SLOT(setCurrentIndex(int)));
 
-    setWindowTitle(tr("Notepad"));
+    setWindowTitle(tr("FRIDA"));
+
+       openBinary(filename);
 }
 
 void Mainwindow::quit()
@@ -54,8 +56,16 @@ 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));
+               disassembler->forEachFunction([&](uint64_t address, Function* fun) {
+                               populateSymbolInformation(fun);
+                       });
+
         // curBin = new Binary(fileName.toStdString());
 
         // std::vector<std::string> symbols = curBin->getSymbols();
@@ -67,7 +77,7 @@ void Mainwindow::open() {
     }
 }
 
-void Mainwindow::populateSymbolInformation(const std::string& sym) {
+void Mainwindow::populateSymbolInformation(Function* fun) {
     QTabWidget * w = new QTabWidget();
 
     // Listing
@@ -114,6 +124,6 @@ void Mainwindow::populateSymbolInformation(const std::string& sym) {
     QGraphicsView * view = new QGraphicsView(scene);
     w->addTab(view, "CFG");
 
-    listWidget->addItem(sym.c_str());
+    listWidget->addItem(fun->getName().c_str());
     stackedWidget->addWidget(w);
 }