src/gui/widgets/BasicBlockWidget.cxx
src/gui/widgets/CFGScene.cxx
src/gui/widgets/ScriptingDock.cxx
+ src/gui/dialogs/NewFunctionDialog.cxx
src/disassembler/Disassembler.cxx
src/disassembler/llvm/LLVMDisassembler.cxx
)
src/gui/widgets/BasicBlockWidget.hxx
src/gui/widgets/CFGScene.hxx
src/gui/widgets/ScriptingDock.hxx
+ src/gui/dialogs/NewFunctionDialog.hxx
src/disassembler/llvm/LLVMDisassembler.hxx
src/disassembler/Disassembler.hxx
)
virtual void printEachInstruction(uint64_t start, uint64_t end,
std::function<void (uint8_t*, size_t, const std::string&,
const std::string&)> fun) = 0;
+ virtual Function * disassembleFunctionAt(uint64_t address, const std::string& name = "") = 0;
protected:
virtual bool isFunctionCall(uint64_t address) = 0;
virtual bool isJump(uint64_t address) = 0;
#include "disassembler/llvm/LLVMDisassembler.hxx"
#include "widgets/CFGScene.hxx"
-
+#include "dialogs/NewFunctionDialog.hxx"
#include <iostream>
#include <sstream>
#include <map>
addDockWidget(Qt::BottomDockWidgetArea, scripting);
listWidget = new QListWidget();
+ listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(listWidget, SIGNAL(customContextMenuRequested(const QPoint&)),
+ this, SLOT(showListContextMenu(const QPoint&)));
+
stackedWidget = new QStackedWidget();
dockWidget = new QDockWidget(tr("Functions"), this);
dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea |
void Mainwindow::quit()
{
QMessageBox messageBox;
- messageBox.setWindowTitle(tr("Notepad"));
+ messageBox.setWindowTitle(tr("Frida"));
messageBox.setText(tr("Do you really want to quit?"));
messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
messageBox.setDefaultButton(QMessageBox::No);
manager->reset(fileName.toStdString());
}
+void Mainwindow::showListContextMenu(const QPoint& point) {
+ QListWidgetItem * item = listWidget->itemAt(point);
+ if (item) {
+ LOG4CXX_DEBUG(logger, "WOHO " << item->text().toStdString());
+ } else {
+ QMenu menu(this);
+ QAction * act = menu.addAction("AddFunction");
+ connect(act, SIGNAL(triggered()), this, SLOT(requestNewFunction()));
+
+ menu.exec(listWidget->mapToGlobal(point));
+ }
+}
+
+void Mainwindow::requestNewFunction() {
+ NewFunctionDialog dialog;
+ int result = dialog.exec();
+ if (QDialog::Accepted == result) {
+ LOG4CXX_DEBUG(logger, "requesting Function at " << std::hex << dialog.result());
+ manager->getDisassembler()->disassembleFunctionAt(dialog.result());
+ } else {
+ LOG4CXX_DEBUG(logger, "requestNewFunction aborted");
+ }
+}
+
void Mainwindow::addFunction(Function* fun) {
if (functions.find(fun) != functions.end())
return;
Q_OBJECT
public:
Mainwindow(InformationManager* mgr);
+
private:
void addFunction(Function* fun);
private Q_SLOTS:
void quit();
void open();
+ void showListContextMenu(const QPoint&);
+ void requestNewFunction();
};
#endif /* INCLUDE__Mainwindow_hxx_ */
--- /dev/null
+#include "NewFunctionDialog.hxx"
+
+NewFunctionDialog::NewFunctionDialog() {
+ QGridLayout * layout = new QGridLayout;
+
+ edit = new QLineEdit;
+ layout->addWidget(edit, 0, 0, 1, 2);
+ edit->setInputMask("\\0\\xhhhhhhhhhhhhhhhH");
+
+ QPushButton * cancelButton = new QPushButton("Cancel");
+ QPushButton * okButton = new QPushButton("OK");
+ layout->addWidget(okButton, 1, 1, 1, 1);
+ connect(okButton, SIGNAL(clicked()),
+ this, SLOT(accept()));
+ layout->addWidget(cancelButton, 1, 0, 1, 1);
+ connect(cancelButton, SIGNAL(clicked()),
+ this, SLOT(reject()));
+
+ setLayout(layout);
+ setWindowTitle("Add function");
+}
+
+uint64_t NewFunctionDialog::result() {
+ bool ok;
+ uint64_t result = edit->text().toLongLong(&ok, 16);
+ return result;
+}
--- /dev/null
+#include "gui/qt.hxx"
+
+class NewFunctionDialog : public QDialog {
+ Q_OBJECT
+public:
+ NewFunctionDialog();
+
+ uint64_t result();
+private:
+ QLineEdit * edit;
+};
#include <QPushButton>
#include <QLineEdit>
#include <QLabel>
+#include <QtGui>
+#include <QMenu>
#endif /* INCLUDE__qt_hxx_ */