diff --git a/src/AnalThread.cpp b/src/AnalThread.cpp index 0afe3545..91636771 100644 --- a/src/AnalThread.cpp +++ b/src/AnalThread.cpp @@ -9,7 +9,7 @@ AnalThread::AnalThread(OptionsDialog *parent) : QThread(parent), level(2), main(nullptr), - core(CutterCore::getInstance()), + core(Core()), interrupted(false) { } diff --git a/src/dialogs/FlagDialog.cpp b/src/dialogs/FlagDialog.cpp index eddaf0e4..67dc0521 100644 --- a/src/dialogs/FlagDialog.cpp +++ b/src/dialogs/FlagDialog.cpp @@ -5,7 +5,7 @@ FlagDialog::FlagDialog(RVA offset, QWidget *parent) : QDialog(parent), ui(new Ui::FlagDialog), offset(offset), - core(CutterCore::getInstance()) + core(Core()) { ui->setupUi(this); setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint)); diff --git a/src/dialogs/NewFileDialog.cpp b/src/dialogs/NewFileDialog.cpp index f99768d6..b7eda04d 100644 --- a/src/dialogs/NewFileDialog.cpp +++ b/src/dialogs/NewFileDialog.cpp @@ -253,7 +253,7 @@ bool NewFileDialog::fillRecentFilesList() bool NewFileDialog::fillProjectsList() { - CutterCore *core = CutterCore::getInstance(); + CutterCore *core = Core(); auto currentDir = Config()->getDirProjects(); diff --git a/src/dialogs/OptionsDialog.cpp b/src/dialogs/OptionsDialog.cpp index b32f684f..0f9d53b6 100644 --- a/src/dialogs/OptionsDialog.cpp +++ b/src/dialogs/OptionsDialog.cpp @@ -12,7 +12,7 @@ OptionsDialog::OptionsDialog(MainWindow *main): QDialog(0), // parent may not be main analThread(this), main(main), - core(CutterCore::getInstance()), + core(Core()), defaultAnalLevel(1), ui(new Ui::OptionsDialog) { diff --git a/src/dialogs/SaveProjectDialog.cpp b/src/dialogs/SaveProjectDialog.cpp index 724641c2..3e75cd3a 100644 --- a/src/dialogs/SaveProjectDialog.cpp +++ b/src/dialogs/SaveProjectDialog.cpp @@ -13,7 +13,7 @@ SaveProjectDialog::SaveProjectDialog(bool quit, QWidget *parent) : { ui->setupUi(this); - CutterCore *core = CutterCore::getInstance(); + CutterCore *core = Core(); if (quit) { ui->buttonBox->setStandardButtons(QDialogButtonBox::Save diff --git a/src/dialogs/XrefsDialog.cpp b/src/dialogs/XrefsDialog.cpp index ed5195a5..171fc6e5 100644 --- a/src/dialogs/XrefsDialog.cpp +++ b/src/dialogs/XrefsDialog.cpp @@ -13,7 +13,7 @@ XrefsDialog::XrefsDialog(QWidget *parent) : addr(0), func_name(QString::null), ui(new Ui::XrefsDialog), - core(CutterCore::getInstance()) + core(Core()) { ui->setupUi(this); setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint)); diff --git a/src/utils/Highlighter.cpp b/src/utils/Highlighter.cpp index 8dcc4086..981ea612 100644 --- a/src/utils/Highlighter.cpp +++ b/src/utils/Highlighter.cpp @@ -8,7 +8,7 @@ Highlighter::Highlighter(QTextDocument *parent) : { HighlightingRule rule; - core = CutterCore::getInstance(); + core = Core(); keywordFormat.setForeground(QColor(65, 131, 215)); keywordFormat.setFontWeight(QFont::Bold); diff --git a/src/widgets/ClassesWidget.cpp b/src/widgets/ClassesWidget.cpp index 09102d9e..d566349b 100644 --- a/src/widgets/ClassesWidget.cpp +++ b/src/widgets/ClassesWidget.cpp @@ -256,8 +256,8 @@ void ClassesWidget::refreshClasses() { model->beginReload(); classes = getSource() == Source::BIN - ? CutterCore::getInstance()->getAllClassesFromBin() - : CutterCore::getInstance()->getAllClassesFromFlags(); + ? Core()->getAllClassesFromBin() + : Core()->getAllClassesFromFlags(); model->endReload(); qhelpers::adjustColumns(ui->classesTreeView, 3, 0); @@ -268,5 +268,5 @@ void ClassesWidget::refreshClasses() void ClassesWidget::on_classesTreeView_doubleClicked(const QModelIndex &index) { RVA offset = index.data(ClassesModel::OffsetRole).value(); - CutterCore::getInstance()->seek(offset); + Core()->seek(offset); } diff --git a/src/widgets/CommentsWidget.cpp b/src/widgets/CommentsWidget.cpp index a3b992a0..a6ca70b9 100644 --- a/src/widgets/CommentsWidget.cpp +++ b/src/widgets/CommentsWidget.cpp @@ -39,7 +39,7 @@ void CommentsWidget::on_commentsTreeWidget_itemDoubleClicked(QTreeWidgetItem *it { // Get offset and name of item double clicked CommentDescription comment = item->data(0, Qt::UserRole).value(); - CutterCore::getInstance()->seek(comment.offset); + Core()->seek(comment.offset); } void CommentsWidget::on_nestedCmtsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int) @@ -51,7 +51,7 @@ void CommentsWidget::on_nestedCmtsTreeWidget_itemDoubleClicked(QTreeWidgetItem * // Get offset and name of item double clicked CommentDescription comment = item->data(0, Qt::UserRole).value(); - CutterCore::getInstance()->seek(comment.offset); + Core()->seek(comment.offset); } @@ -139,11 +139,11 @@ QMap>> CutterCore::getNestedComments() void CommentsWidget::refreshTree() { ui->nestedCmtsTreeWidget->clear(); - QList comments = CutterCore::getInstance()->getAllComments("CCu"); + QList comments = Core()->getAllComments("CCu"); QMap> nestedComments; for (CommentDescription comment : comments) { - QString fcn_name = CutterCore::getInstance()->cmdFunctionAt(comment.offset); + QString fcn_name = Core()->cmdFunctionAt(comment.offset); QTreeWidgetItem *item = new QTreeWidgetItem(); item->setText(0, RAddressString(comment.offset)); item->setText(1, fcn_name); diff --git a/src/widgets/ConsoleWidget.cpp b/src/widgets/ConsoleWidget.cpp index fc38404b..95b58e74 100644 --- a/src/widgets/ConsoleWidget.cpp +++ b/src/widgets/ConsoleWidget.cpp @@ -173,7 +173,7 @@ void ConsoleWidget::on_inputLineEdit_returnPressed() QString input = ui->inputLineEdit->text(); if (!input.isEmpty()) { if (!isForbidden(input)) { - QString res = CutterCore::getInstance()->cmd(input); + QString res = Core()->cmd(input); QString cmd_line = "[" + RAddressString(Core()->getOffset()) + "]> " + input + "\n"; ui->outputTextEdit->appendPlainText(cmd_line + res); scrollOutputToEnd(); diff --git a/src/widgets/Dashboard.cpp b/src/widgets/Dashboard.cpp index 7c464b4c..6641e961 100644 --- a/src/widgets/Dashboard.cpp +++ b/src/widgets/Dashboard.cpp @@ -103,12 +103,12 @@ void Dashboard::updateContents() } // Add file hashes and libraries - QString md5 = CutterCore::getInstance()->cmd("e file.md5"); - QString sha1 = CutterCore::getInstance()->cmd("e file.sha1"); + QString md5 = Core()->cmd("e file.md5"); + QString sha1 = Core()->cmd("e file.sha1"); ui->md5Edit->setText(md5); ui->sha1Edit->setText(sha1); - QString libs = CutterCore::getInstance()->cmd("il"); + QString libs = Core()->cmd("il"); QStringList lines = libs.split("\n", QString::SkipEmptyParts); if (!lines.isEmpty()) { lines.removeFirst(); @@ -142,11 +142,11 @@ void Dashboard::updateContents() ui->verticalLayout_2->addSpacerItem(spacer); // Add entropy value - QString entropy = CutterCore::getInstance()->cmd("ph entropy").trimmed(); + QString entropy = Core()->cmd("ph entropy").trimmed(); ui->lblEntropy->setText(entropy); // Get stats for the graphs - QStringList stats = CutterCore::getInstance()->getStats(); + QStringList stats = Core()->getStats(); } void Dashboard::on_certificateButton_clicked() @@ -186,4 +186,4 @@ void Dashboard::on_certificateButton_clicked() QMessageBox::NoButton, this); msgBoxCertificateInf.exec(); } -} \ No newline at end of file +} diff --git a/src/widgets/DisassemblyWidget.cpp b/src/widgets/DisassemblyWidget.cpp index 7e3ab204..818060ba 100644 --- a/src/widgets/DisassemblyWidget.cpp +++ b/src/widgets/DisassemblyWidget.cpp @@ -505,7 +505,7 @@ bool DisassemblyWidget::eventFilter(QObject *obj, QEvent *event) } if (jump != RVA_INVALID) { - CutterCore::getInstance()->seek(jump); + Core()->seek(jump); } return true; diff --git a/src/widgets/EntrypointWidget.cpp b/src/widgets/EntrypointWidget.cpp index 74611395..132868f1 100644 --- a/src/widgets/EntrypointWidget.cpp +++ b/src/widgets/EntrypointWidget.cpp @@ -28,7 +28,7 @@ EntrypointWidget::~EntrypointWidget() {} void EntrypointWidget::fillEntrypoint() { ui->entrypointTreeWidget->clear(); - for (auto i : CutterCore::getInstance()->getAllEntrypoint()) { + for (auto i : Core()->getAllEntrypoint()) { QTreeWidgetItem *item = new QTreeWidgetItem(); item->setText(0, RAddressString(i.vaddr)); item->setText(1, i.type); @@ -48,5 +48,5 @@ void EntrypointWidget::on_entrypointTreeWidget_itemDoubleClicked(QTreeWidgetItem int /* column */) { EntrypointDescription ep = item->data(0, Qt::UserRole).value(); - CutterCore::getInstance()->seek(ep.vaddr); + Core()->seek(ep.vaddr); } diff --git a/src/widgets/ExportsWidget.cpp b/src/widgets/ExportsWidget.cpp index f0e539a4..528599c1 100644 --- a/src/widgets/ExportsWidget.cpp +++ b/src/widgets/ExportsWidget.cpp @@ -148,7 +148,7 @@ ExportsWidget::~ExportsWidget() {} void ExportsWidget::refreshExports() { exports_model->beginReloadExports(); - exports = CutterCore::getInstance()->getAllExports(); + exports = Core()->getAllExports(); exports_model->endReloadExports(); qhelpers::adjustColumns(ui->exportsTreeView, 3, 0); @@ -163,5 +163,5 @@ void ExportsWidget::setScrollMode() void ExportsWidget::on_exportsTreeView_doubleClicked(const QModelIndex &index) { ExportDescription exp = index.data(ExportsModel::ExportDescriptionRole).value(); - CutterCore::getInstance()->seek(exp.vaddr); + Core()->seek(exp.vaddr); } diff --git a/src/widgets/FlagsWidget.cpp b/src/widgets/FlagsWidget.cpp index 2b5dca82..8a674202 100644 --- a/src/widgets/FlagsWidget.cpp +++ b/src/widgets/FlagsWidget.cpp @@ -150,7 +150,7 @@ FlagsWidget::~FlagsWidget() {} void FlagsWidget::on_flagsTreeView_doubleClicked(const QModelIndex &index) { FlagDescription flag = index.data(FlagsModel::FlagDescriptionRole).value(); - CutterCore::getInstance()->seek(flag.offset); + Core()->seek(flag.offset); } void FlagsWidget::on_flagspaceCombo_currentTextChanged(const QString &arg1) @@ -169,7 +169,7 @@ void FlagsWidget::on_actionRename_triggered() r->setName(flag.name); if (r->exec()) { QString new_name = r->getName(); - CutterCore::getInstance()->renameFlag(flag.name, new_name); + Core()->renameFlag(flag.name, new_name); } } @@ -204,7 +204,7 @@ void FlagsWidget::refreshFlagspaces() ui->flagspaceCombo->clear(); ui->flagspaceCombo->addItem(tr("(all)")); - for (auto i : CutterCore::getInstance()->getAllFlagspaces()) { + for (auto i : Core()->getAllFlagspaces()) { ui->flagspaceCombo->addItem(i.name, QVariant::fromValue(i)); } @@ -224,7 +224,7 @@ void FlagsWidget::refreshFlags() flags_model->beginReloadFlags(); - flags = CutterCore::getInstance()->getAllFlags(flagspace); + flags = Core()->getAllFlags(flagspace); flags_model->endReloadFlags(); qhelpers::adjustColumns(ui->flagsTreeView, 2, 0); diff --git a/src/widgets/FunctionsWidget.cpp b/src/widgets/FunctionsWidget.cpp index 28e0b72c..9328be72 100644 --- a/src/widgets/FunctionsWidget.cpp +++ b/src/widgets/FunctionsWidget.cpp @@ -169,7 +169,7 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const return static_cast(Qt::AlignLeft | Qt::AlignVCenter); case Qt::ToolTipRole: { - QList info = CutterCore::getInstance()->cmd("afi @ " + function.name).split("\n"); + QList info = Core()->cmd("afi @ " + function.name).split("\n"); if (info.length() > 2) { QString size = info[4].split(" ")[1]; QString complex = info[8].split(" ")[1]; @@ -177,8 +177,8 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const return QString("Summary:\n\n Size: " + size + "\n Cyclomatic complexity: " + complex + "\n Basic blocks: " + bb + - "\n\nDisasm preview:\n\n" + CutterCore::getInstance()->cmd("pdi 10 @ " + function.name) + - "\nStrings:\n\n" + CutterCore::getInstance()->cmd("pdsf @ " + function.name)); + "\n\nDisasm preview:\n\n" + Core()->cmd("pdi 10 @ " + function.name) + + "\nStrings:\n\n" + Core()->cmd("pdsf @ " + function.name)); } return QVariant(); } @@ -435,13 +435,13 @@ void FunctionsWidget::refreshTree() { functionModel->beginReloadFunctions(); - functions = CutterCore::getInstance()->getAllFunctions(); + functions = Core()->getAllFunctions(); importAddresses.clear(); - foreach (ImportDescription import, CutterCore::getInstance()->getAllImports()) + foreach (ImportDescription import, Core()->getAllImports()) importAddresses.insert(import.plt); - mainAdress = (ut64)CutterCore::getInstance()->cmdj("iMj").object()["vaddr"].toInt(); + mainAdress = (ut64)Core()->cmdj("iMj").object()["vaddr"].toInt(); functionModel->endReloadFunctions(); @@ -485,9 +485,9 @@ void FunctionsWidget::on_actionDisasAdd_comment_triggered() // Get new function name QString comment = c->getComment(); // Rename function in r2 core - CutterCore::getInstance()->setComment(function.offset, comment); + Core()->setComment(function.offset, comment); // Seek to new renamed function - CutterCore::getInstance()->seek(function.offset); + Core()->seek(function.offset); // TODO: Refresh functions tree widget } } @@ -509,10 +509,10 @@ void FunctionsWidget::on_actionFunctionsRename_triggered() QString new_name = r->getName(); // Rename function in r2 core - CutterCore::getInstance()->renameFunction(function.name, new_name); + Core()->renameFunction(function.name, new_name); // Seek to new renamed function - CutterCore::getInstance()->seek(function.offset); + Core()->seek(function.offset); } } diff --git a/src/widgets/ResourcesWidget.cpp b/src/widgets/ResourcesWidget.cpp index 05c238bb..33ff00ec 100644 --- a/src/widgets/ResourcesWidget.cpp +++ b/src/widgets/ResourcesWidget.cpp @@ -114,5 +114,5 @@ void ResourcesWidget::refreshResources() void ResourcesWidget::onDoubleClicked(const QModelIndex &index) { ResourcesDescription res = index.data(Qt::UserRole).value(); - CutterCore::getInstance()->seek(res.vaddr); + Core()->seek(res.vaddr); } diff --git a/src/widgets/SdbDock.cpp b/src/widgets/SdbDock.cpp index 8d7567b2..2a80306d 100644 --- a/src/widgets/SdbDock.cpp +++ b/src/widgets/SdbDock.cpp @@ -32,18 +32,18 @@ void SdbDock::reload(QString _path) ui->treeWidget->clear(); QList keys; /* key-values */ - keys = CutterCore::getInstance()->sdbListKeys(path); + keys = Core()->sdbListKeys(path); foreach (QString key, keys) { QTreeWidgetItem *tempItem = new QTreeWidgetItem(); tempItem->setText(0, key); - tempItem->setText(1, CutterCore::getInstance()->sdbGet(path, key)); + tempItem->setText(1, Core()->sdbGet(path, key)); tempItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsEditable); ui->treeWidget->insertTopLevelItem(0, tempItem); } qhelpers::adjustColumns(ui->treeWidget, 0); /* namespaces */ - keys = CutterCore::getInstance()->sdbList(path); + keys = Core()->sdbList(path); keys.append(".."); foreach (QString key, keys) { QTreeWidgetItem *tempItem = new QTreeWidgetItem(); diff --git a/src/widgets/SectionsWidget.cpp b/src/widgets/SectionsWidget.cpp index b73d6e32..d5ab37ce 100644 --- a/src/widgets/SectionsWidget.cpp +++ b/src/widgets/SectionsWidget.cpp @@ -29,7 +29,7 @@ void SectionsWidget::refreshSections() tree->clear(); int row = 0; - for (auto section : CutterCore::getInstance()->getAllSections()) { + for (auto section : Core()->getAllSections()) { fillSections(row++, section); } diff --git a/src/widgets/Sidebar.cpp b/src/widgets/Sidebar.cpp index 9241ed78..f0ae46a8 100644 --- a/src/widgets/Sidebar.cpp +++ b/src/widgets/Sidebar.cpp @@ -42,17 +42,17 @@ void SideBar::on_lockButton_clicked() void SideBar::on_calcInput_textChanged(const QString &arg1) { - ui->calcOutput->setText(QString::number(CutterCore::getInstance()->math(arg1))); + ui->calcOutput->setText(QString::number(Core()->math(arg1))); } void SideBar::on_asm2hex_clicked() { - ui->hexInput->setPlainText(CutterCore::getInstance()->assemble(ui->asmInput->toPlainText())); + ui->hexInput->setPlainText(Core()->assemble(ui->asmInput->toPlainText())); } void SideBar::on_hex2asm_clicked() { - ui->asmInput->setPlainText(CutterCore::getInstance()->disassemble(ui->hexInput->toPlainText())); + ui->asmInput->setPlainText(Core()->disassemble(ui->hexInput->toPlainText())); } void SideBar::on_respButton_toggled(bool checked) diff --git a/src/widgets/StringsWidget.cpp b/src/widgets/StringsWidget.cpp index cc0dc489..4c9c485f 100644 --- a/src/widgets/StringsWidget.cpp +++ b/src/widgets/StringsWidget.cpp @@ -165,13 +165,13 @@ StringsWidget::~StringsWidget() {} void StringsWidget::on_stringsTreeView_doubleClicked(const QModelIndex &index) { StringDescription str = index.data(StringsModel::StringDescriptionRole).value(); - CutterCore::getInstance()->seek(str.vaddr); + Core()->seek(str.vaddr); } void StringsWidget::refreshStrings() { model->beginReload(); - strings = CutterCore::getInstance()->getAllStrings(); + strings = Core()->getAllStrings(); model->endReload(); qhelpers::adjustColumns(ui->stringsTreeView, 5, 0); diff --git a/src/widgets/SymbolsWidget.cpp b/src/widgets/SymbolsWidget.cpp index 620e3c56..cd2eaef1 100644 --- a/src/widgets/SymbolsWidget.cpp +++ b/src/widgets/SymbolsWidget.cpp @@ -29,13 +29,13 @@ void SymbolsWidget::on_symbolsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item // Get offset and name of item double clicked SymbolDescription symbol = item->data(0, Qt::UserRole).value(); - CutterCore::getInstance()->seek(symbol.vaddr); + Core()->seek(symbol.vaddr); } void SymbolsWidget::fillSymbols() { ui->symbolsTreeWidget->clear(); - for (auto symbol : CutterCore::getInstance()->getAllSymbols()) { + for (auto symbol : Core()->getAllSymbols()) { QTreeWidgetItem *item = new QTreeWidgetItem(); item->setText(0, RAddressString(symbol.vaddr)); item->setText(1, QString("%1 %2").arg(symbol.bind, symbol.type).trimmed()); diff --git a/src/widgets/TypesWidget.cpp b/src/widgets/TypesWidget.cpp index 302edfa6..8de167b7 100644 --- a/src/widgets/TypesWidget.cpp +++ b/src/widgets/TypesWidget.cpp @@ -129,7 +129,7 @@ TypesWidget::~TypesWidget() {} void TypesWidget::refreshTypes() { types_model->beginReloadTypes(); - types = CutterCore::getInstance()->getAllTypes(); + types = Core()->getAllTypes(); types_model->endReloadTypes(); qhelpers::adjustColumns(ui->typesTreeView, 3, 0); @@ -144,5 +144,5 @@ void TypesWidget::on_typesTreeView_doubleClicked(const QModelIndex &index) { Q_UNUSED(index); // TypeDescription exp = index.data(TypesModel::TypeDescriptionRole).value(); - // CutterCore::getInstance()->seek(exp.vaddr); + // Core()->seek(exp.vaddr); } diff --git a/src/widgets/VTablesWidget.cpp b/src/widgets/VTablesWidget.cpp index 2da2fd07..79c90dd6 100644 --- a/src/widgets/VTablesWidget.cpp +++ b/src/widgets/VTablesWidget.cpp @@ -172,7 +172,7 @@ VTablesWidget::~VTablesWidget() void VTablesWidget::refreshVTables() { model->beginReload(); - vtables = CutterCore::getInstance()->getAllVTables(); + vtables = Core()->getAllVTables(); model->endReload(); qhelpers::adjustColumns(ui->vTableTreeView, 3, 0); @@ -184,9 +184,9 @@ void VTablesWidget::on_vTableTreeView_doubleClicked(const QModelIndex &index) { QModelIndex parent = index.parent(); if (parent.isValid()) - CutterCore::getInstance()->seek(index.data( + Core()->seek(index.data( VTableModel::VTableDescriptionRole).value().addr); else - CutterCore::getInstance()->seek(index.data( + Core()->seek(index.data( VTableModel::VTableDescriptionRole).value().addr); }