]>
git.siccegge.de Git - frida/frida.git/blob - src/gui/Mainwindow.cxx
790c1a306bbba59020383a311c8b59acae5dfe8d
1 #include "Mainwindow.hxx"
10 #include <QDockWidget>
11 #include <QMessageBox>
12 #include <QFileDialog>
13 #include <QTableWidget>
14 #include <QHeaderView>
15 #include <QGraphicsScene>
16 #include <QGraphicsItem>
17 #include <QGraphicsView>
23 Mainwindow::Mainwindow()
25 openAction
= new QAction(tr("&Open"), this);
26 // saveAction = new QAction(tr("&Save"), this);
27 exitAction
= new QAction(tr("E&xit"), this);
29 connect(openAction
, SIGNAL(triggered()), this, SLOT(open()));
30 // connect(saveAction, SIGNAL(triggered()), this, SLOT(save()));
31 connect(exitAction
, SIGNAL(triggered()), qApp
, SLOT(quit()));
33 fileMenu
= menuBar()->addMenu(tr("&File"));
34 fileMenu
->addAction(openAction
);
35 // fileMenu->addAction(saveAction);
36 fileMenu
->addSeparator();
37 fileMenu
->addAction(exitAction
);
39 listWidget
= new QListWidget();
40 stackedWidget
= new QStackedWidget();
41 dockWidget
= new QDockWidget(tr("Functions"), this);
42 dockWidget
->setAllowedAreas(Qt::LeftDockWidgetArea
|
43 Qt::RightDockWidgetArea
);
44 dockWidget
->setWidget(listWidget
);
45 addDockWidget(Qt::LeftDockWidgetArea
, dockWidget
);
46 setCentralWidget(stackedWidget
);
48 connect(listWidget
, SIGNAL(currentRowChanged(int)),
49 stackedWidget
, SLOT(setCurrentIndex(int)));
51 setWindowTitle(tr("Notepad"));
54 void Mainwindow::quit()
56 QMessageBox messageBox
;
57 messageBox
.setWindowTitle(tr("Notepad"));
58 messageBox
.setText(tr("Do you really want to quit?"));
59 messageBox
.setStandardButtons(QMessageBox::Yes
| QMessageBox::No
);
60 messageBox
.setDefaultButton(QMessageBox::No
);
61 if (messageBox
.exec() == QMessageBox::Yes
)
65 void Mainwindow::open() {
66 QString fileName
= QFileDialog::getOpenFileName(this, tr("Open File"), "",
70 curBin
= new qtlldb::Binary(fileName
.toStdString());
72 std::vector
<std::string
> symbols
= curBin
->getSymbols();
73 if (0 == symbols
.size())
74 populateSymbolInformation(".text");
75 for (std::vector
<std::string
>::iterator it
= symbols
.begin();
78 populateSymbolInformation(*it
);
83 void Mainwindow::populateSymbolInformation(const std::string
& sym
) {
84 QTabWidget
* w
= new QTabWidget();
87 QTableWidget
* t
= new QTableWidget();
89 t
->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents
);
90 curBin
->for_each_instruction(sym
, [&t
](long add
, std::string bytes
, std::string mnemonic
) {
91 int row
= t
->rowCount();
93 t
->setRowCount(t
->rowCount() + 1);
95 t
->setItem(row
,0,new QTableWidgetItem(s
.str().c_str()));
98 for_each(bytes
.begin(), bytes
.end(), [&s
](char c
){s
<< (unsigned int)((unsigned char)c
) << ' ';});
99 t
->setItem(row
,1,new QTableWidgetItem(s
.str().c_str()));
100 t
->setItem(row
,2,new QTableWidgetItem(mnemonic
.c_str() + 1));
102 w
->addTab(t
, "Listing");
105 QGraphicsScene
* scene
= new QGraphicsScene
;
106 QGraphicsRectItem
*rect
= scene
->addRect(QRectF(0, 0, 100, 100));
107 rect
->setFlag(QGraphicsItem::ItemIsMovable
);
108 QGraphicsView
* view
= new QGraphicsView(scene
);
109 w
->addTab(view
, "CFG");
111 listWidget
->addItem(sym
.c_str());
112 stackedWidget
->addWidget(w
);