]>
git.siccegge.de Git - frida/frida.git/blob - src/gui/Mainwindow.cxx
1 #include "Mainwindow.hxx"
2 #include "widgets/BasicBlockWidget.hxx"
4 #include "disassembler/llvm/LLVMDisassembler.hxx"
11 Mainwindow::Mainwindow()
13 openAction
= new QAction(tr("&Open"), this);
14 // saveAction = new QAction(tr("&Save"), this);
15 exitAction
= new QAction(tr("E&xit"), this);
17 connect(openAction
, SIGNAL(triggered()), this, SLOT(open()));
18 // connect(saveAction, SIGNAL(triggered()), this, SLOT(save()));
19 connect(exitAction
, SIGNAL(triggered()), qApp
, SLOT(quit()));
21 fileMenu
= menuBar()->addMenu(tr("&File"));
22 fileMenu
->addAction(openAction
);
23 // fileMenu->addAction(saveAction);
24 fileMenu
->addSeparator();
25 fileMenu
->addAction(exitAction
);
27 listWidget
= new QListWidget();
28 stackedWidget
= new QStackedWidget();
29 dockWidget
= new QDockWidget(tr("Functions"), this);
30 dockWidget
->setAllowedAreas(Qt::LeftDockWidgetArea
|
31 Qt::RightDockWidgetArea
);
32 dockWidget
->setWidget(listWidget
);
33 addDockWidget(Qt::LeftDockWidgetArea
, dockWidget
);
34 setCentralWidget(stackedWidget
);
36 connect(listWidget
, SIGNAL(currentRowChanged(int)),
37 stackedWidget
, SLOT(setCurrentIndex(int)));
39 setWindowTitle(tr("Notepad"));
42 void Mainwindow::quit()
44 QMessageBox messageBox
;
45 messageBox
.setWindowTitle(tr("Notepad"));
46 messageBox
.setText(tr("Do you really want to quit?"));
47 messageBox
.setStandardButtons(QMessageBox::Yes
| QMessageBox::No
);
48 messageBox
.setDefaultButton(QMessageBox::No
);
49 if (messageBox
.exec() == QMessageBox::Yes
)
53 void Mainwindow::open() {
54 QString fileName
= QFileDialog::getOpenFileName(this, tr("Open File"), "",
58 disassembler
.reset(new LLVMDisassembler(fileName
.toStdString()));
59 // curBin = new Binary(fileName.toStdString());
61 // std::vector<std::string> symbols = curBin->getSymbols();
62 // if (0 == symbols.size())
63 // populateSymbolInformation(".text");
64 // for (auto it = symbols.begin(); it != symbols.end(); ++it) {
65 // populateSymbolInformation(*it);
70 void Mainwindow::populateSymbolInformation(const std::string
& sym
) {
71 QTabWidget
* w
= new QTabWidget();
74 QTableWidget
* t
= new QTableWidget();
76 t
->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents
);
77 // curBin->for_each_instruction(sym, [&t](long add, std::string bytes, std::string mnemonic) {
78 // int row = t->rowCount();
79 // std::stringstream s;
80 // t->setRowCount(t->rowCount() + 1);
81 // s << std::hex << add;
82 // t->setItem(row,0,new QTableWidgetItem(s.str().c_str()));
85 // for_each(bytes.begin(), bytes.end(), [&s](char c){s << (unsigned int)((unsigned char)c) << ' ';});
86 // t->setItem(row,1,new QTableWidgetItem(s.str().c_str()));
87 // t->setItem(row,2,new QTableWidgetItem(mnemonic.c_str() + 1));
89 w
->addTab(t
, "Listing");
92 QGraphicsScene
* scene
= new QGraphicsScene
;
94 BasicBlockWidget
* s1
= new BasicBlockWidget
;
96 s1
->setFlag(QGraphicsItem::ItemIsMovable
, true);
98 BasicBlockWidget
* s2
= new BasicBlockWidget
;
100 s2
->setFlag(QGraphicsItem::ItemIsMovable
, true);
101 s2
->moveBy(-200, 350);
103 BasicBlockWidget
* s3
= new BasicBlockWidget
;
105 s3
->setFlag(QGraphicsItem::ItemIsMovable
, true);
106 s3
->moveBy(100, 350);
108 BasicBlockWidget
* s4
= new BasicBlockWidget
;
110 s4
->setFlag(QGraphicsItem::ItemIsMovable
, true);
111 s4
->moveBy(400, 350);
114 QGraphicsView
* view
= new QGraphicsView(scene
);
115 w
->addTab(view
, "CFG");
117 listWidget
->addItem(sym
.c_str());
118 stackedWidget
->addWidget(w
);