]>
git.siccegge.de Git - frida/frida.git/blob - src/gui/Mainwindow.cxx
1 #include "Mainwindow.h++"
12 Mainwindow::Mainwindow()
14 openAction
= new QAction(tr("&Open"), this);
15 // saveAction = new QAction(tr("&Save"), this);
16 exitAction
= new QAction(tr("E&xit"), this);
18 connect(openAction
, SIGNAL(triggered()), this, SLOT(open()));
19 // connect(saveAction, SIGNAL(triggered()), this, SLOT(save()));
20 connect(exitAction
, SIGNAL(triggered()), qApp
, SLOT(quit()));
22 fileMenu
= menuBar()->addMenu(tr("&File"));
23 fileMenu
->addAction(openAction
);
24 // fileMenu->addAction(saveAction);
25 fileMenu
->addSeparator();
26 fileMenu
->addAction(exitAction
);
28 listWidget
= new QListWidget();
29 stackedWidget
= new QStackedWidget();
30 dockWidget
= new QDockWidget(tr("Functions"), this);
31 dockWidget
->setAllowedAreas(Qt::LeftDockWidgetArea
|
32 Qt::RightDockWidgetArea
);
33 dockWidget
->setWidget(listWidget
);
34 addDockWidget(Qt::LeftDockWidgetArea
, dockWidget
);
35 setCentralWidget(stackedWidget
);
37 connect(listWidget
, SIGNAL(currentRowChanged(int)),
38 stackedWidget
, SLOT(setCurrentIndex(int)));
40 setWindowTitle(tr("Notepad"));
43 void Mainwindow::quit()
45 QMessageBox messageBox
;
46 messageBox
.setWindowTitle(tr("Notepad"));
47 messageBox
.setText(tr("Do you really want to quit?"));
48 messageBox
.setStandardButtons(QMessageBox::Yes
| QMessageBox::No
);
49 messageBox
.setDefaultButton(QMessageBox::No
);
50 if (messageBox
.exec() == QMessageBox::Yes
)
54 void Mainwindow::open() {
55 QString fileName
= QFileDialog::getOpenFileName(this, tr("Open File"), "",
59 curBin
= new qtlldb::Binary(fileName
.toStdString());
61 std::vector
<std::string
> symbols
= curBin
->getSymbols();
62 if (0 == symbols
.size())
63 populateSymbolInformation(".text");
64 for (std::vector
<std::string
>::iterator it
= symbols
.begin();
67 populateSymbolInformation(*it
);
72 void Mainwindow::populateSymbolInformation(const std::string
& sym
) {
73 QTabWidget
* w
= new QTabWidget();
76 QTableWidget
* t
= new QTableWidget();
78 t
->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents
);
79 curBin
->for_each_instruction(sym
, [&t
](long add
, std::string bytes
, std::string mnemonic
) {
80 int row
= t
->rowCount();
82 t
->setRowCount(t
->rowCount() + 1);
84 t
->setItem(row
,0,new QTableWidgetItem(s
.str().c_str()));
87 for_each(bytes
.begin(), bytes
.end(), [&s
](char c
){s
<< (unsigned int)((unsigned char)c
) << ' ';});
88 t
->setItem(row
,1,new QTableWidgetItem(s
.str().c_str()));
89 t
->setItem(row
,2,new QTableWidgetItem(mnemonic
.c_str() + 1));
91 w
->addTab(t
, "Listing");
94 QGraphicsScene
* scene
= new QGraphicsScene
;
95 QGraphicsRectItem
*rect
= scene
->addRect(QRectF(0, 0, 100, 100));
96 rect
->setFlag(QGraphicsItem::ItemIsMovable
);
97 QGraphicsView
* view
= new QGraphicsView(scene
);
98 w
->addTab(view
, "CFG");
102 listWidget
->addItem(sym
.c_str());
103 stackedWidget
->addWidget(w
);