diff --git a/.gitignore b/.gitignore index 13c05569..945973ae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ build*/ -CMakeLists.txt.user +.automaton/ +.cache/ .idea/ cmake-build-*/ +CMakeLists.txt.user +compile_commands.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 23792b9e..aac9f27c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.25) project(REDasm) @@ -20,7 +20,7 @@ if(NOT Qt6_FOUND) find_package(Qt5LinguistTools) endif() -include(LibREDasm/cmake/CPM.cmake) +include(LibREDasm/cmake/get_cpm.cmake) if(GIT_FOUND) execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD diff --git a/LibREDasm b/LibREDasm index 6e98b550..c8f6e162 160000 --- a/LibREDasm +++ b/LibREDasm @@ -1 +1 @@ -Subproject commit 6e98b5509e9859f81ee3371460064a07fc85282b +Subproject commit c8f6e162229108cf8d8da55d528444719ba5385e diff --git a/hooks/disassemblerhooks.cpp b/hooks/disassemblerhooks.cpp index 075dc383..316aae16 100644 --- a/hooks/disassemblerhooks.cpp +++ b/hooks/disassemblerhooks.cpp @@ -1,183 +1,198 @@ #include "disassemblerhooks.h" -#include "../dialogs/tabledialog/tabledialog.h" #include "../dialogs/aboutdialog/aboutdialog.h" -#include "../dialogs/problemsdialog/problemsdialog.h" -#include "../dialogs/settingsdialog/settingsdialog.h" #include "../dialogs/analyzerdialog/analyzerdialog.h" -#include "../dialogs/loaderdialog/loaderdialog.h" +#include "../dialogs/databasedialog/databasedialog.h" #include "../dialogs/devdialog/devdialog.h" #include "../dialogs/flcdialog/flcdialog.h" -#include "../dialogs/databasedialog/databasedialog.h" -#include "../widgets/listing/listingview.h" -#include "../widgets/disassemblerdocks.h" +#include "../dialogs/loaderdialog/loaderdialog.h" +#include "../dialogs/problemsdialog/problemsdialog.h" +#include "../dialogs/settingsdialog/settingsdialog.h" +#include "../dialogs/tabledialog/tabledialog.h" +#include "../models/dev/blocklistmodel.h" +#include "../redasmfonts.h" +#include "../redasmsettings.h" +#include "../renderer/surfaceqt.h" #include "../widgets/callgraphview/callgraphview.h" #include "../widgets/dashboard/welcomewidget.h" -#include "../widgets/outputwidget.h" +#include "../widgets/disassemblerdocks.h" #include "../widgets/docks/dockwidget.h" -#include "../models/dev/blocklistmodel.h" -#include "../renderer/surfaceqt.h" -#include "../redasmsettings.h" -#include "../redasmfonts.h" +#include "../widgets/listing/listingview.h" +#include "../widgets/outputwidget.h" #include "dockidentifiers.h" -#include -#include #include -#include +#include #include #include -#include #include +#include +#include +#include #include -#define MAX_FUNCTION_NAME 50 +#define MAX_FUNCTION_NAME 50 #define MAX_WINDOW_ACTIONS 10 -DisassemblerHooks::DisassemblerHooks(QObject* parent): QObject(parent) { } +DisassemblerHooks::DisassemblerHooks(QObject* parent): QObject(parent) {} -void DisassemblerHooks::initialize(KDDockWidgets::MainWindow* mainwindow) -{ +void DisassemblerHooks::initialize(KDDockWidgets::MainWindow* mainwindow) { DisassemblerHooks::instance()->m_mainwindow = mainwindow; DisassemblerHooks::instance()->hook(); } -DisassemblerHooks* DisassemblerHooks::instance() -{ +DisassemblerHooks* DisassemblerHooks::instance() { static DisassemblerHooks m_instance; return &m_instance; } -KDDockWidgets::MainWindow* DisassemblerHooks::mainWindow() { return DisassemblerHooks::instance()->m_mainwindow; } +KDDockWidgets::MainWindow* DisassemblerHooks::mainWindow() { + return DisassemblerHooks::instance()->m_mainwindow; +} -DockWidget* DisassemblerHooks::dockify(QWidget* w, KDDockWidgets::DockWidget::Options options) -{ +DockWidget* +DisassemblerHooks::dockify(QWidget* w, + KDDockWidgets::DockWidget::Options options) { auto* dock = new DockWidget(w->windowTitle(), options); dock->setWidget(w); return dock; } -DockWidget* DisassemblerHooks::tabify(QWidget* w, KDDockWidgets::DockWidgetBase::Options options) { return DisassemblerHooks::tabify(DisassemblerHooks::dockify(w, options)); } +DockWidget* +DisassemblerHooks::tabify(QWidget* w, + KDDockWidgets::DockWidgetBase::Options options) { + return DisassemblerHooks::tabify(DisassemblerHooks::dockify(w, options)); +} -DockWidget* DisassemblerHooks::tabify(DockWidget* dock) -{ +DockWidget* DisassemblerHooks::tabify(DockWidget* dock) { DisassemblerHooks::mainWindow()->addDockWidgetAsTab(dock); return dock; } -void DisassemblerHooks::focusOn(QWidget* w) -{ +void DisassemblerHooks::focusOn(QWidget* w) { QWidget* cw = w; - while(cw) - { - auto* tw = dynamic_cast(cw); + while(cw) { + auto* tw = dynamic_cast(cw); - if(tw) - { - cw = tw; - break; - } + if(tw) { + cw = tw; + break; + } - cw = cw->parentWidget(); + cw = cw->parentWidget(); } - if(cw) static_cast(cw)->raise(); + if(cw) + static_cast(cw)->raise(); } -void DisassemblerHooks::log(const QString& s) -{ +void DisassemblerHooks::log(const QString& s) { auto* ow = this->outputWidget(); - if(ow) ow->log(s); - else qDebug() << s; + if(ow) + ow->log(s); + else + qDebug() << s; } -void DisassemblerHooks::clearLog() -{ +void DisassemblerHooks::clearLog() { auto* ow = this->outputWidget(); - if(ow) ow->clear(); + if(ow) + ow->clear(); } -void DisassemblerHooks::resetLayout() -{ +void DisassemblerHooks::resetLayout() {} -} - -void DisassemblerHooks::open() -{ - QString s = QFileDialog::getOpenFileName(m_mainwindow, tr("Disassemble file...")); - if(!s.isEmpty()) this->load(s); +void DisassemblerHooks::open() { + QString s = + QFileDialog::getOpenFileName(m_mainwindow, tr("Disassemble file...")); + if(!s.isEmpty()) + this->load(s); } void DisassemblerHooks::close() { this->close(true); } -void DisassemblerHooks::save() -{ +void DisassemblerHooks::save() { RDContextPtr ctx = DisassemblerHooks::activeContext(); - if(ctx) this->saveAs(ctx, m_fileinfo.baseName() + CONTEXT_STATE_EXT); + if(ctx) + this->saveAs(ctx, m_fileinfo.baseName() + CONTEXT_STATE_EXT); } -void DisassemblerHooks::saveAs() -{ +void DisassemblerHooks::saveAs() { RDContextPtr ctx = DisassemblerHooks::activeContext(); - if(!ctx) return; + if(!ctx) + return; - QString s = QFileDialog::getSaveFileName(m_mainwindow, tr("Save State..."), m_fileinfo.fileName(), "REDasm State (*.rds)"); - if(!s.isEmpty()) this->saveAs(ctx, s); + QString s = QFileDialog::getSaveFileName(m_mainwindow, tr("Save State..."), + m_fileinfo.fileName(), + "REDasm State (*.rds)"); + if(!s.isEmpty()) + this->saveAs(ctx, s); } -void DisassemblerHooks::settings() -{ +void DisassemblerHooks::settings() { SettingsDialog dlgsettings(m_mainwindow); dlgsettings.exec(); } -void DisassemblerHooks::about() -{ +void DisassemblerHooks::about() { AboutDialog dlgabout(m_mainwindow); dlgabout.exec(); } void DisassemblerHooks::exit() { m_mainwindow->close(); } -void DisassemblerHooks::showFLC() -{ - if(!m_flcdialog) m_flcdialog = new FLCDialog(m_mainwindow); +void DisassemblerHooks::showFLC() { + if(!m_flcdialog) + m_flcdialog = new FLCDialog(m_mainwindow); m_flcdialog->showFLC(this->activeContext()); } -void DisassemblerHooks::showCallGraph(rd_address address) -{ +void DisassemblerHooks::showCallGraph(rd_address address) { auto* cgv = new CallGraphView(this->activeContext()); - this->showDialog(tr("Callgraph @ ") + QString::fromStdString(rd_tohex(address)), cgv); + this->showDialog( + tr("Callgraph @ ") + QString::fromStdString(rd_tohex(address)), cgv); cgv->walk(address); } -void DisassemblerHooks::showDeveloperTools() { if(m_devdialog) m_devdialog->show(); } +void DisassemblerHooks::showDeveloperTools() { + if(m_devdialog) + m_devdialog->show(); +} -void DisassemblerHooks::showDatabase() -{ +void DisassemblerHooks::showDatabase() { DatabaseDialog dbdialog(this->activeContext(), m_mainwindow); dbdialog.exec(); } -void DisassemblerHooks::showProblems() { ProblemsDialog dlgproblems(this->activeContext(), m_mainwindow); dlgproblems.exec(); } +void DisassemblerHooks::showProblems() { + ProblemsDialog dlgproblems(this->activeContext(), m_mainwindow); + dlgproblems.exec(); +} -SurfaceQt* DisassemblerHooks::activeSurface() -{ - if(!DisassemblerHooks::activeContext()) return nullptr; - auto* activesurface = RDContext_GetActiveSurface(DisassemblerHooks::activeContext().get()); - return activesurface ? reinterpret_cast(RDSurface_GetUserData(activesurface)) : nullptr; +SurfaceQt* DisassemblerHooks::activeSurface() { + if(!DisassemblerHooks::activeContext()) + return nullptr; + auto* activesurface = + RDContext_GetActiveSurface(DisassemblerHooks::activeContext().get()); + return activesurface ? reinterpret_cast( + RDSurface_GetUserData(activesurface)) + : nullptr; } -RDContextPtr DisassemblerHooks::activeContext() { return DisassemblerHooks::instance()->m_disassemblerdocks ? DisassemblerHooks::instance()->m_disassemblerdocks->context() : nullptr; } +RDContextPtr DisassemblerHooks::activeContext() { + return DisassemblerHooks::instance()->m_disassemblerdocks + ? DisassemblerHooks::instance()->m_disassemblerdocks->context() + : nullptr; +} -void DisassemblerHooks::statusAddress(const SurfaceQt* surface) const -{ - if(!surface || RDContext_IsBusy(surface->context().get())) return; +void DisassemblerHooks::statusAddress(const SurfaceQt* surface) const { + if(!surface || RDContext_IsBusy(surface->context().get())) + return; RDDocument* doc = RDContext_GetDocument(surface->context().get()); rd_address address = surface->currentAddress(); - if(address == RD_NVAL) return; + if(address == RD_NVAL) + return; RDSegment segment; bool hassegment = RDDocument_AddressToSegment(doc, address, &segment); @@ -186,35 +201,41 @@ void DisassemblerHooks::statusAddress(const SurfaceQt* surface) const RDLocation offset = RD_Offset(surface->context().get(), address); QString segm = hassegment ? segment.name : tr("UNKNOWN"), - offs = hassegment && offset.valid ? RD_ToHexAuto(surface->context().get(), offset.value) : tr("UNKNOWN"), + offs = hassegment && offset.valid + ? RD_ToHexAuto(surface->context().get(), offset.value) + : tr("UNKNOWN"), addr = RD_ToHexAuto(surface->context().get(), address); - QString s = QString::fromWCharArray(L"Address: %1\u00A0\u00A0").arg(addr); + QString s = + QString::fromWCharArray(L"Address: %1\u00A0\u00A0").arg(addr); s += QString::fromWCharArray(L"Offset: %1\u00A0\u00A0").arg(offs); s += QString::fromWCharArray(L"Segment: %1\u00A0\u00A0").arg(segm); const char* label = RDDocument_GetLabel(doc, functionstart.address); - if(functionstart.valid && label) - { + if(functionstart.valid && label) { QString func = label; if(func.size() > MAX_FUNCTION_NAME) - func = func.left(MAX_FUNCTION_NAME) + "..."; // Elide long function names + func = func.left(MAX_FUNCTION_NAME) + + "..."; // Elide long function names if(address > functionstart.address) - func += "+" + QString::fromUtf8(RD_ToHexBits(address - functionstart.value, 8, false)); + func += "+" + QString::fromUtf8(RD_ToHexBits( + address - functionstart.value, 8, false)); else if(address < functionstart.address) - func += QString::number(static_cast::type>(address - functionstart.value)); + func += QString::number(static_cast::type>( + address - functionstart.value)); - s = QString::fromWCharArray(L"Function: %1\u00A0\u00A0").arg(func.toHtmlEscaped()) + s; + s = QString::fromWCharArray(L"Function: %1\u00A0\u00A0") + .arg(func.toHtmlEscaped()) + + s; } RD_Status(qUtf8Printable(s)); } -void DisassemblerHooks::loadDisassemblerDocks(const RDContextPtr& ctx) -{ +void DisassemblerHooks::loadDisassemblerDocks(const RDContextPtr& ctx) { this->close(false); this->setTabBarVisible(true); @@ -223,8 +244,7 @@ void DisassemblerHooks::loadDisassemblerDocks(const RDContextPtr& ctx) m_disassemblerdocks->setContext(ctx); } -void DisassemblerHooks::hook() -{ +void DisassemblerHooks::hook() { m_lblstatusicon = m_mainwindow->findChild(HOOK_STATUS_ICON); m_pbrenderer = m_mainwindow->findChild(HOOK_RENDERER); m_pbproblems = m_mainwindow->findChild(HOOK_PROBLEMS); @@ -233,11 +253,14 @@ void DisassemblerHooks::hook() this->showWelcome(); this->showOutput(); - connect(m_pbproblems, &QPushButton::clicked, this, [&]() { this->showProblems(); }); + connect(m_pbproblems, &QPushButton::clicked, this, + [&]() { this->showProblems(); }); connect(m_pbrenderer, &QPushButton::clicked, this, [&]() { const RDContextPtr& ctx = this->activeContext(); - RDContext_SetFlags(ctx.get(), ContextFlags_ShowRDIL, !RDContext_HasFlag(ctx.get(), ContextFlags_ShowRDIL)); + RDContext_SetFlags( + ctx.get(), ContextFlags_ShowRDIL, + !RDContext_HasFlag(ctx.get(), ContextFlags_ShowRDIL)); this->checkListingMode(); }); @@ -246,16 +269,14 @@ void DisassemblerHooks::hook() this->loadRecents(); } -void DisassemblerHooks::showLoaders(const QString& filepath, RDBuffer* buffer) -{ +void DisassemblerHooks::showLoaders(const QString& filepath, RDBuffer* buffer) { RDContextPtr ctx(RDContext_Create(), RDObjectDeleter()); QByteArray rawfilepath = filepath.toUtf8(); - RDLoaderRequest req = { rawfilepath.data(), buffer, { } }; + RDLoaderRequest req = {rawfilepath.data(), buffer, {}}; LoaderDialog dlgloader(ctx, &req, m_mainwindow); - if(dlgloader.exec() != LoaderDialog::Accepted) - { + if(dlgloader.exec() != LoaderDialog::Accepted) { RDObject_Free(buffer); return; } @@ -263,83 +284,87 @@ void DisassemblerHooks::showLoaders(const QString& filepath, RDBuffer* buffer) this->clearOutput(); req.buildparams = dlgloader.buildRequest(); - if(!RDContext_Bind(ctx.get(), &req, dlgloader.selectedLoaderEntry(), dlgloader.selectedAssemblerEntry())) return; + if(!RDContext_Bind(ctx.get(), &req, dlgloader.selectedLoaderEntry(), + dlgloader.selectedAssemblerEntry())) + return; const RDLoader* loader = RDContext_GetLoader(ctx.get()); const RDAssembler* assembler = RDContext_GetAssembler(ctx.get()); - rd_log(qUtf8Printable(tr("Selected loader '%1' with '%2' assembler").arg(RDLoader_GetName(loader), RDAssembler_GetName(assembler)))); + rd_log(qUtf8Printable( + tr("Selected loader '%1' with '%2' assembler") + .arg(RDLoader_GetName(loader), RDAssembler_GetName(assembler)))); - rd_log(qUtf8Printable(tr("Minimum string length set to %1").arg(dlgloader.selectedMinString()))); + rd_log(qUtf8Printable(tr("Minimum string length set to %1") + .arg(dlgloader.selectedMinString()))); RDContext_SetMinString(ctx.get(), dlgloader.selectedMinString()); AnalyzerDialog dlganalyzer(ctx, m_mainwindow); - if(dlganalyzer.exec() != AnalyzerDialog::Accepted) return; + if(dlganalyzer.exec() != AnalyzerDialog::Accepted) + return; m_fileinfo = QFileInfo(filepath); this->loadDisassemblerDocks(ctx); } -void DisassemblerHooks::setTabBarVisible(bool b) -{ +void DisassemblerHooks::setTabBarVisible(bool b) { auto* tabbar = m_mainwindow->findChild(); - if(tabbar) tabbar->setVisible(b); + if(tabbar) + tabbar->setVisible(b); } -void DisassemblerHooks::showWelcome() -{ - DisassemblerHooks::tabify(new WelcomeWidget(), KDDockWidgets::DockWidget::Option_NotClosable); +void DisassemblerHooks::showWelcome() { + DisassemblerHooks::tabify(new WelcomeWidget(), + KDDockWidgets::DockWidget::Option_NotClosable); } -void DisassemblerHooks::loadRecents() -{ - QMenu* mnurecents = m_mainwindow->findChild(HOOK_ACTION_RECENT_FILES); - if(!mnurecents) return; +void DisassemblerHooks::loadRecents() { + QMenu* mnurecents = + m_mainwindow->findChild(HOOK_ACTION_RECENT_FILES); + if(!mnurecents) + return; mnurecents->clear(); REDasmSettings settings; QStringList recents = settings.recentFiles(); mnurecents->setEnabled(!recents.empty()); - for(int i = 0; i < MAX_RECENT_FILES; i++) - { - if(i >= recents.length()) - { + for(int i = 0; i < MAX_RECENT_FILES; i++) { + if(i >= recents.length()) { QAction* action = mnurecents->addAction(QString()); action->setVisible(false); continue; } - if(!QFileInfo().exists(recents[i])) continue; + if(!QFileInfo().exists(recents[i])) + continue; - QAction* action = mnurecents->addAction(QString("%1 - %2").arg(i).arg(recents[i])); + QAction* action = + mnurecents->addAction(QString("%1 - %2").arg(i).arg(recents[i])); action->setData(recents[i]); - connect(action, &QAction::triggered, this, [=]() { - this->load(action->data().toString()); - }); + connect(action, &QAction::triggered, this, + [=]() { this->load(action->data().toString()); }); } - if(recents.empty()) return; + if(recents.empty()) + return; mnurecents->addSeparator(); QAction* action = mnurecents->addAction(tr("Clear")); - connect(action, &QAction::triggered, this, [=]() { - this->clearRecents(); - }); + connect(action, &QAction::triggered, this, [=]() { this->clearRecents(); }); } -void DisassemblerHooks::clearRecents() -{ +void DisassemblerHooks::clearRecents() { REDasmSettings settings; settings.clearRecentFiles(); this->loadRecents(); - if(!m_disassemblerdocks) this->close(true); // Recreate Welcome Tab + if(!m_disassemblerdocks) + this->close(true); // Recreate Welcome Tab } -void DisassemblerHooks::load(const QString& filepath) -{ +void DisassemblerHooks::load(const QString& filepath) { QFileInfo fi(filepath); QDir::setCurrent(fi.path()); @@ -347,18 +372,23 @@ void DisassemblerHooks::load(const QString& filepath) settings.updateRecentFiles(filepath); this->loadRecents(); - if(this->openDatabase(filepath)) return; + if(this->openDatabase(filepath)) + return; RDBuffer* buffer = RDBuffer_CreateFromFile(qUtf8Printable(filepath)); - if(buffer && RDBuffer_Size(buffer)) this->showLoaders(filepath, buffer); - else if(buffer) RDObject_Free(buffer); + if(buffer && RDBuffer_Size(buffer)) + this->showLoaders(filepath, buffer); + else if(buffer) + RDObject_Free(buffer); } -bool DisassemblerHooks::isLoaded() const { return m_disassemblerdocks != nullptr; } +bool DisassemblerHooks::isLoaded() const { + return m_disassemblerdocks != nullptr; +} -QAction* DisassemblerHooks::addWindowAction(DockWidget* dw) -{ - if(!dw || !m_mnuwindow || m_windowactions.size() == MAX_WINDOW_ACTIONS) return nullptr; +QAction* DisassemblerHooks::addWindowAction(DockWidget* dw) { + if(!dw || !m_mnuwindow || m_windowactions.size() == MAX_WINDOW_ACTIONS) + return nullptr; QAction* act = m_mnuwindow->addAction(dw->uniqueName()); connect(act, &QAction::triggered, dw, &DockWidget::raise); @@ -368,58 +398,68 @@ QAction* DisassemblerHooks::addWindowAction(DockWidget* dw) return act; } -void DisassemblerHooks::removeWindowAction(QAction* a) -{ - if(!a || !m_mnuwindow) return; +void DisassemblerHooks::removeWindowAction(QAction* a) { + if(!a || !m_mnuwindow) + return; m_windowactions.removeOne(a); m_mnuwindow->removeAction(a); this->reshortcutWindow(); } -OutputWidget* DisassemblerHooks::outputWidget() const { return m_dockoutput ? static_cast(m_dockoutput->widget()) : nullptr; } +OutputWidget* DisassemblerHooks::outputWidget() const { + return m_dockoutput ? static_cast(m_dockoutput->widget()) + : nullptr; +} -void DisassemblerHooks::reshortcutWindow() -{ +void DisassemblerHooks::reshortcutWindow() { for(int i = 0; i < m_windowactions.size(); i++) m_windowactions[i]->setShortcut(QKeySequence(QString("ALT+%1").arg(i))); } -void DisassemblerHooks::checkListingMode() -{ - if(RDContext_HasFlag(this->activeContext().get(), ContextFlags_ShowRDIL)) m_pbrenderer->setText(tr("RDIL")); - else m_pbrenderer->setText(tr("Listing")); +void DisassemblerHooks::checkListingMode() { + if(RDContext_HasFlag(this->activeContext().get(), ContextFlags_ShowRDIL)) + m_pbrenderer->setText(tr("RDIL")); + else + m_pbrenderer->setText(tr("Listing")); } -void DisassemblerHooks::showOutput() -{ - m_dockoutput = DisassemblerHooks::dockify(new OutputWidget(m_mainwindow), KDDockWidgets::DockWidget::Option_NotClosable); +void DisassemblerHooks::showOutput() { + m_dockoutput = DisassemblerHooks::dockify( + new OutputWidget(m_mainwindow), + KDDockWidgets::DockWidget::Option_NotClosable); m_mainwindow->addDockWidget(m_dockoutput, KDDockWidgets::Location_OnBottom); } -void DisassemblerHooks::close(bool showwelcome) -{ +void DisassemblerHooks::close(bool showwelcome) { this->enableViewCommands(false); this->enableCommands(nullptr); - if(m_devdialog) m_devdialog->deleteLater(); + if(m_devdialog) + m_devdialog->deleteLater(); m_devdialog = nullptr; - auto docks = m_mainwindow->findChildren(QString(), Qt::FindChildrenRecursively); + auto docks = m_mainwindow->findChildren( + QString(), Qt::FindChildrenRecursively); - std::for_each(docks.begin(), docks.end(), [](KDDockWidgets::DockWidget* dw) { - if(dynamic_cast(dw->widget())) return; - dw->deleteLater(); - }); + std::for_each(docks.begin(), docks.end(), + [](KDDockWidgets::DockWidget* dw) { + if(dynamic_cast(dw->widget())) + return; + dw->deleteLater(); + }); - if(showwelcome) this->showWelcome(); // Replaces central widget, if any - if(m_disassemblerdocks) m_disassemblerdocks->deleteLater(); + if(showwelcome) + this->showWelcome(); // Replaces central widget, if any + if(m_disassemblerdocks) + m_disassemblerdocks->deleteLater(); m_disassemblerdocks = nullptr; } -const DisassemblerDocks* DisassemblerHooks::docks() { return DisassemblerHooks::instance()->m_disassemblerdocks; } +const DisassemblerDocks* DisassemblerHooks::docks() { + return DisassemblerHooks::instance()->m_disassemblerdocks; +} -void DisassemblerHooks::showDialog(const QString& title, QWidget* w) -{ +void DisassemblerHooks::showDialog(const QString& title, QWidget* w) { QVBoxLayout* l = new QVBoxLayout(); l->setSpacing(0); l->setContentsMargins(0, 0, 0, 0); @@ -433,34 +473,31 @@ void DisassemblerHooks::showDialog(const QString& title, QWidget* w) dialog->show(); } -void DisassemblerHooks::clearOutput() -{ +void DisassemblerHooks::clearOutput() { OutputWidget* outputwidget = this->outputWidget(); - if(outputwidget) outputwidget->clear(); + if(outputwidget) + outputwidget->clear(); } -void DisassemblerHooks::enableMenu(QMenu* menu, bool enable) -{ +void DisassemblerHooks::enableMenu(QMenu* menu, bool enable) { auto actions = menu->actions(); - std::for_each(actions.begin(), actions.end(), [enable](QAction* a) { a->setEnabled(enable); }); + std::for_each(actions.begin(), actions.end(), + [enable](QAction* a) { a->setEnabled(enable); }); - if(dynamic_cast(menu->parentWidget())) menu->menuAction()->setVisible(enable); + if(dynamic_cast(menu->parentWidget())) + menu->menuAction()->setVisible(enable); menu->setEnabled(enable); } -void DisassemblerHooks::saveAs(const RDContextPtr& ctx, const QString& filepath) -{ +void DisassemblerHooks::saveAs(const RDContextPtr& ctx, + const QString& filepath) { if(RDContext_Save(ctx.get(), qUtf8Printable(filepath))) rd_log(tr("Saving Database '%1'").arg(filepath).toStdString()); } -bool DisassemblerHooks::openDatabase(const QString& filepath) -{ - return false; -} +bool DisassemblerHooks::openDatabase(const QString& filepath) { return false; } -void DisassemblerHooks::enableViewCommands(bool enable) -{ +void DisassemblerHooks::enableViewCommands(bool enable) { this->enableMenu(m_mnuwindow, enable); auto actions = m_toolbar->actions(); @@ -473,14 +510,25 @@ void DisassemblerHooks::enableViewCommands(bool enable) act->setEnabled(enable); } -void DisassemblerHooks::openHomePage() const { QDesktopServices::openUrl(QUrl("https://redasm.io")); } -void DisassemblerHooks::openTwitter() const { QDesktopServices::openUrl(QUrl("https://twitter.com/re_dasm")); } -void DisassemblerHooks::openTelegram() const { QDesktopServices::openUrl(QUrl("https://t.me/REDasmDisassembler")); } -void DisassemblerHooks::openReddit() const { QDesktopServices::openUrl(QUrl("https://www.reddit.com/r/REDasm")); } -void DisassemblerHooks::openGitHub() const { QDesktopServices::openUrl(QUrl("https://github.com/REDasmOrg/REDasm/issues")); } +void DisassemblerHooks::openHomePage() const { + QDesktopServices::openUrl(QUrl("https://redasm.io")); +} +void DisassemblerHooks::openTwitter() const { + QDesktopServices::openUrl(QUrl("https://twitter.com/re_dasm")); +} +void DisassemblerHooks::openTelegram() const { + QDesktopServices::openUrl(QUrl("https://t.me/REDasmDisassembler")); +} +void DisassemblerHooks::openReddit() const { + QDesktopServices::openUrl(QUrl("https://www.reddit.com/r/REDasm")); +} +void DisassemblerHooks::openGitHub() const { + QDesktopServices::openUrl( + QUrl("https://github.com/REDasmOrg/REDasm/issues")); +} -void DisassemblerHooks::showMessage(const QString& title, const QString& msg, size_t icon) -{ +void DisassemblerHooks::showMessage(const QString& title, const QString& msg, + size_t icon) { QMessageBox msgbox(m_mainwindow); msgbox.setWindowTitle(title); msgbox.setText(msg); @@ -488,10 +536,8 @@ void DisassemblerHooks::showMessage(const QString& title, const QString& msg, si msgbox.exec(); } -void DisassemblerHooks::updateViewWidgets(bool busy) -{ - if(!m_disassemblerdocks) - { +void DisassemblerHooks::updateViewWidgets(bool busy) { + if(!m_disassemblerdocks) { m_toolbar->actions()[4]->setEnabled(false); m_lblstatusicon->setVisible(false); m_pbproblems->setVisible(false); @@ -499,36 +545,36 @@ void DisassemblerHooks::updateViewWidgets(bool busy) return; } - if(busy) - { - m_mainwindow->setWindowTitle(QString("%1 (%2)").arg(m_fileinfo.fileName(), tr("Working"))); + if(busy) { + m_mainwindow->setWindowTitle( + QString("%1 (%2)").arg(m_fileinfo.fileName(), tr("Working"))); m_lblstatusicon->setStyleSheet("color: red;"); } - else - { + else { m_mainwindow->setWindowTitle(m_fileinfo.fileName()); m_lblstatusicon->setStyleSheet("color: green;"); } m_lblstatusicon->setVisible(true); - if(this->activeContext()) - { - m_pbproblems->setVisible(!busy && RDContext_HasProblems(this->activeContext().get())); - m_pbproblems->setText(QString::number(RDContext_GetProblemsCount(this->activeContext().get())) + tr(" problem(s)")); + if(this->activeContext()) { + m_pbproblems->setVisible( + !busy && RDContext_HasProblems(this->activeContext().get())); + m_pbproblems->setText(QString::number(RDContext_GetProblemsCount( + this->activeContext().get())) + + tr(" problem(s)")); } else m_pbproblems->setVisible(false); } -void DisassemblerHooks::enableCommands(QWidget* w) -{ - QAction* actdevtools = m_mainwindow->findChild(HOOK_ACTION_DEVTOOLS); +void DisassemblerHooks::enableCommands(QWidget* w) { + QAction* actdevtools = + m_mainwindow->findChild(HOOK_ACTION_DEVTOOLS); QAction* actflc = m_mainwindow->findChild(HOOK_ACTION_FLC); auto actions = m_toolbar->actions(); - if(!w) - { + if(!w) { for(int i = 2; i < actions.size(); i++) actions[i]->setVisible(false); @@ -539,7 +585,8 @@ void DisassemblerHooks::enableCommands(QWidget* w) } auto* listingview = dynamic_cast(w); - if(m_disassemblerdocks) this->checkListingMode(); + if(m_disassemblerdocks) + this->checkListingMode(); m_pbrenderer->setVisible(listingview); actdevtools->setVisible(listingview); diff --git a/hooks/disassemblerhooks.h b/hooks/disassemblerhooks.h index 857db227..bab21bb6 100644 --- a/hooks/disassemblerhooks.h +++ b/hooks/disassemblerhooks.h @@ -1,25 +1,25 @@ #pragma once -#define HOOK_TOOLBAR "toolBar" -#define HOOK_STATUS_ICON "lblStatusIcon" -#define HOOK_PROBLEMS "pbProblems" -#define HOOK_RENDERER "pbRenderer" -#define HOOK_MENU_WINDOW "menu_Window" -#define HOOK_ACTION_SAVE_AS "action_Save_As" -#define HOOK_ACTION_CLOSE "action_Close" +#define HOOK_TOOLBAR "toolBar" +#define HOOK_STATUS_ICON "lblStatusIcon" +#define HOOK_PROBLEMS "pbProblems" +#define HOOK_RENDERER "pbRenderer" +#define HOOK_MENU_WINDOW "menu_Window" +#define HOOK_ACTION_SAVE_AS "action_Save_As" +#define HOOK_ACTION_CLOSE "action_Close" #define HOOK_ACTION_RECENT_FILES "action_Recent_Files" -#define HOOK_ACTION_FLC "action_FLC" -#define HOOK_ACTION_DEVTOOLS "action_Developer_Tools" -#define HOOK_ACTION_DATABASE "action_Database" +#define HOOK_ACTION_FLC "action_FLC" +#define HOOK_ACTION_DEVTOOLS "action_Developer_Tools" +#define HOOK_ACTION_DATABASE "action_Database" -#include -#include -#include -#include +#include "isurface.h" #include +#include #include +#include +#include +#include #include -#include "isurface.h" class FLCDialog; class DevDialog; @@ -30,7 +30,8 @@ class DockWidget; namespace REDasmCompat { template -inline QAction* addAction(QMenu* m, const QString& text, const QObject* object, Slot slot, const QKeySequence& shortcut) { +inline QAction* addAction(QMenu* m, const QString& text, const QObject* object, + Slot slot, const QKeySequence& shortcut) { #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) return m->addAction(text, shortcut, object, slot); #else @@ -39,93 +40,99 @@ inline QAction* addAction(QMenu* m, const QString& text, const QObject* object, } template -inline QAction* addAction(QMenu* m, const QString& text, const QObject* object, Slot slot) { return m->addAction(text, object, slot); } - +inline QAction* addAction(QMenu* m, const QString& text, const QObject* object, + Slot slot) { + return m->addAction(text, object, slot); } -class DisassemblerHooks: public QObject -{ +} // namespace REDasmCompat + +class DisassemblerHooks: public QObject { Q_OBJECT - private: - DisassemblerHooks(QObject* parent = nullptr); +private: + DisassemblerHooks(QObject* parent = nullptr); - public: - static void initialize(KDDockWidgets::MainWindow* mainwindow); - static DisassemblerHooks* instance(); - static KDDockWidgets::MainWindow* mainWindow(); - static const DisassemblerDocks* docks(); - static DockWidget* dockify(QWidget* w, KDDockWidgets::DockWidget::Options options = KDDockWidgets::DockWidget::Options()); - static DockWidget* tabify(QWidget* w, KDDockWidgets::DockWidget::Options options = KDDockWidgets::DockWidget::Options()); - static DockWidget* tabify(DockWidget* dock); - static void focusOn(QWidget* w); - static SurfaceQt* activeSurface(); - static RDContextPtr activeContext(); - Q_INVOKABLE void enableViewCommands(bool enable); - void setTabBarVisible(bool b); - bool isLoaded() const; - QAction* addWindowAction(DockWidget* dw); - void removeWindowAction(QAction* a); - void openHomePage() const; - void openTwitter() const; - void openTelegram() const; - void openReddit() const; - void openGitHub() const; +public: + static void initialize(KDDockWidgets::MainWindow* mainwindow); + static DisassemblerHooks* instance(); + static KDDockWidgets::MainWindow* mainWindow(); + static const DisassemblerDocks* docks(); + static DockWidget* dockify(QWidget* w, + KDDockWidgets::DockWidget::Options options = + KDDockWidgets::DockWidget::Options()); + static DockWidget* tabify(QWidget* w, + KDDockWidgets::DockWidget::Options options = + KDDockWidgets::DockWidget::Options()); + static DockWidget* tabify(DockWidget* dock); + static void focusOn(QWidget* w); + static SurfaceQt* activeSurface(); + static RDContextPtr activeContext(); + Q_INVOKABLE void enableViewCommands(bool enable); + void setTabBarVisible(bool b); + bool isLoaded() const; + QAction* addWindowAction(DockWidget* dw); + void removeWindowAction(QAction* a); + void openHomePage() const; + void openTwitter() const; + void openTelegram() const; + void openReddit() const; + void openGitHub() const; - public Q_SLOTS: - void showMessage(const QString& title, const QString& msg, size_t icon); - void updateViewWidgets(bool busy); - void log(const QString& s); - void clearLog(); - void resetLayout(); - void open(); - void close(); - void save(); - void saveAs(); - void settings(); - void about(); - void exit(); +public Q_SLOTS: + void showMessage(const QString& title, const QString& msg, size_t icon); + void updateViewWidgets(bool busy); + void log(const QString& s); + void clearLog(); + void resetLayout(); + void open(); + void close(); + void save(); + void saveAs(); + void settings(); + void about(); + void exit(); - public: - void showFLC(); - void showCallGraph(rd_address address); - void showDeveloperTools(); - void showDatabase(); - void showProblems(); - void showDialog(const QString& title, QWidget* w); +public: + void showFLC(); + void showCallGraph(rd_address address); + void showDeveloperTools(); + void showDatabase(); + void showProblems(); + void showDialog(const QString& title, QWidget* w); - public: - Q_INVOKABLE void close(bool showwelcome); - bool openDatabase(const QString& filepath); - void enableCommands(QWidget* w); - void statusAddress(const SurfaceQt* surface) const; - void load(const QString& filepath); +public: + Q_INVOKABLE void close(bool showwelcome); + bool openDatabase(const QString& filepath); + void enableCommands(QWidget* w); + void statusAddress(const SurfaceQt* surface) const; + void load(const QString& filepath); - private: - OutputWidget* outputWidget() const; - void reshortcutWindow(); - void checkListingMode(); - void showOutput(); - void clearOutput(); - void enableMenu(QMenu* menu, bool enable); - void saveAs(const RDContextPtr& ctx, const QString& filepath); - void loadDisassemblerDocks(const RDContextPtr& ctx); - void showLoaders(const QString& filepath, RDBuffer* buffer); - void showWelcome(); - void loadRecents(); - void clearRecents(); - void hook(); +private: + OutputWidget* outputWidget() const; + void reshortcutWindow(); + void checkListingMode(); + void showOutput(); + void clearOutput(); + void enableMenu(QMenu* menu, bool enable); + void saveAs(const RDContextPtr& ctx, const QString& filepath); + void loadDisassemblerDocks(const RDContextPtr& ctx); + void showLoaders(const QString& filepath, RDBuffer* buffer); + void showWelcome(); + void loadRecents(); + void clearRecents(); + void hook(); - private: - QList m_windowactions; - KDDockWidgets::MainWindow* m_mainwindow{nullptr}; - KDDockWidgets::DockWidget* m_dockoutput{nullptr}; - QToolBar* m_toolbar{nullptr}; - QMenu* m_mnuwindow{nullptr}; - QLabel* m_lblstatusicon{nullptr}; - QPushButton *m_pbproblems{nullptr}, *m_pbrenderer{nullptr}; - DisassemblerDocks* m_disassemblerdocks{nullptr}; - DevDialog* m_devdialog{nullptr}; - FLCDialog* m_flcdialog{nullptr}; - QFileInfo m_fileinfo; +private: + QList m_windowactions; + KDDockWidgets::MainWindow* m_mainwindow{nullptr}; + KDDockWidgets::DockWidget* m_dockoutput{nullptr}; + QToolBar* m_toolbar{nullptr}; + QMenu* m_mnuwindow{nullptr}; + QLabel* m_lblstatusicon{nullptr}; + QPushButton *m_pbproblems{nullptr}, *m_pbrenderer{nullptr}; + DisassemblerDocks* m_disassemblerdocks{nullptr}; + DevDialog* m_devdialog{nullptr}; + FLCDialog* m_flcdialog{nullptr}; + QFileInfo m_fileinfo; }; diff --git a/submodules/assemblers b/submodules/assemblers index 80b8db79..fae51b29 160000 --- a/submodules/assemblers +++ b/submodules/assemblers @@ -1 +1 @@ -Subproject commit 80b8db79d65d902d2d002db22644334f34b853ed +Subproject commit fae51b29e46eab883b6f8eae250713786c0959ec diff --git a/submodules/loaders b/submodules/loaders index b401849f..433e9142 160000 --- a/submodules/loaders +++ b/submodules/loaders @@ -1 +1 @@ -Subproject commit b401849f9aa54dfd9562aed1a6d2e03f75ac455f +Subproject commit 433e9142c4a5a334efadfdedcbe9f81c2fc92ad5 diff --git a/submodules/plugins b/submodules/plugins index 1b3eaa4d..8d96325e 160000 --- a/submodules/plugins +++ b/submodules/plugins @@ -1 +1 @@ -Subproject commit 1b3eaa4d8514a1bfa5dee1e842d4b3519dcf6787 +Subproject commit 8d96325e41a2f4d9fab875778d0287fce5fc66e2 diff --git a/widgets/disassemblerdocks.cpp b/widgets/disassemblerdocks.cpp index 0ce95ac7..c4d3341e 100644 --- a/widgets/disassemblerdocks.cpp +++ b/widgets/disassemblerdocks.cpp @@ -1,86 +1,92 @@ #include "disassemblerdocks.h" #include "../hooks/disassemblerhooks.h" -#include "../models/segmentsmodel.h" #include "../models/functionsmodel.h" +#include "../models/segmentsmodel.h" #include "../models/stringsmodel.h" -#include "widgets/dashboard/analysiswidget.h" -#include "widgets/outputwidget.h" #include "listing/listingsplitview.h" #include "listing/listingview.h" #include "listingmap/listingmap.h" #include "tablewidget.h" +#include "widgets/dashboard/analysiswidget.h" +#include "widgets/outputwidget.h" #include -DisassemblerDocks::DisassemblerDocks(QObject* parent) : QObject(parent) { } +DisassemblerDocks::DisassemblerDocks(QObject* parent): QObject(parent) {} -DisassemblerDocks::~DisassemblerDocks() -{ +DisassemblerDocks::~DisassemblerDocks() { RDObject_Unsubscribe(m_context.get(), this); - if(m_worker.valid()) m_worker.get(); + if(m_worker.valid()) + m_worker.get(); RD_Status(""); } -void DisassemblerDocks::showSegments() const -{ - TableWidget* tw = this->createTable(new SegmentsModel(m_context), tr("Segments")); - connect(tw, &TableWidget::resizeColumns, tw, &TableWidget::resizeAllColumns); +void DisassemblerDocks::showSegments() const { + TableWidget* tw = + this->createTable(new SegmentsModel(m_context), tr("Segments")); + connect(tw, &TableWidget::resizeColumns, tw, + &TableWidget::resizeAllColumns); DisassemblerHooks::tabify(tw); } -void DisassemblerDocks::showFunctions() const -{ - TableWidget* tw = this->createTable(new FunctionsModel(m_context), tr("Functions")); - connect(tw, &TableWidget::resizeColumns, this, [tw]() { tw->resizeColumn(0); }); +void DisassemblerDocks::showFunctions() const { + TableWidget* tw = + this->createTable(new FunctionsModel(m_context), tr("Functions")); + connect(tw, &TableWidget::resizeColumns, this, + [tw]() { tw->resizeColumn(0); }); auto* dock = DisassemblerHooks::dockify(tw); - DisassemblerHooks::mainWindow()->addDockWidget(dock, KDDockWidgets::Location_OnLeft, nullptr, tw->sizeHint()); + DisassemblerHooks::mainWindow()->addDockWidget( + dock, KDDockWidgets::Location_OnLeft, nullptr, tw->sizeHint()); } -void DisassemblerDocks::showExports() const -{ - TableWidget* tw = this->createTable(new LabelsModel(m_context, AddressFlags_Exported), tr("Exports")); - connect(tw, &TableWidget::resizeColumns, tw, &TableWidget::resizeAllColumns); +void DisassemblerDocks::showExports() const { + TableWidget* tw = this->createTable( + new LabelsModel(m_context, AddressFlags_Exported), tr("Exports")); + connect(tw, &TableWidget::resizeColumns, tw, + &TableWidget::resizeAllColumns); DisassemblerHooks::tabify(tw); } -void DisassemblerDocks::showImports() const -{ - TableWidget* tw = this->createTable(new LabelsModel(m_context, AddressFlags_Imported), tr("Imports")); - connect(tw, &TableWidget::resizeColumns, tw, &TableWidget::resizeAllColumns); +void DisassemblerDocks::showImports() const { + TableWidget* tw = this->createTable( + new LabelsModel(m_context, AddressFlags_Imported), tr("Imports")); + connect(tw, &TableWidget::resizeColumns, tw, + &TableWidget::resizeAllColumns); DisassemblerHooks::tabify(tw); } -void DisassemblerDocks::showStrings() const -{ - TableWidget* tw = this->createTable(new StringsModel(m_context), tr("Strings")); - connect(tw, &TableWidget::resizeColumns, tw, &TableWidget::resizeAllColumns); +void DisassemblerDocks::showStrings() const { + TableWidget* tw = + this->createTable(new StringsModel(m_context), tr("Strings")); + connect(tw, &TableWidget::resizeColumns, tw, + &TableWidget::resizeAllColumns); DisassemblerHooks::tabify(tw); } -void DisassemblerDocks::showMap(KDDockWidgets::DockWidget* relative) const -{ +void DisassemblerDocks::showMap(KDDockWidgets::DockWidget* relative) const { auto* listingmap = new ListingMap(m_context); auto* mapdock = DisassemblerHooks::dockify(listingmap); KDDockWidgets::InitialOption opt(listingmap->sizeHint()); opt.preferredLength(Qt::Vertical); - DisassemblerHooks::mainWindow()->addDockWidget(mapdock, KDDockWidgets::Location_OnRight, relative, opt); + DisassemblerHooks::mainWindow()->addDockWidget( + mapdock, KDDockWidgets::Location_OnRight, relative, opt); } -void DisassemblerDocks::onItemDoubleClicked(const QModelIndex& index) -{ +void DisassemblerDocks::onItemDoubleClicked(const QModelIndex& index) { auto* surface = DisassemblerHooks::activeSurface(); - if(!surface) return; + if(!surface) + return; auto* addressmodel = dynamic_cast(index.model()); - if(!addressmodel) return; + if(!addressmodel) + return; surface->goTo(addressmodel->address(index)); DisassemblerHooks::focusOn(surface->widget()); } -void DisassemblerDocks::showDisassembly() -{ +void DisassemblerDocks::showDisassembly() { auto* listingdock = this->showListing(); this->showSegments(); this->showExports(); @@ -96,8 +102,8 @@ void DisassemblerDocks::showDisassembly() const RDContextPtr& DisassemblerDocks::context() const { return m_context; } -TableWidget* DisassemblerDocks::createTable(ContextModel* model, const QString& title) const -{ +TableWidget* DisassemblerDocks::createTable(ContextModel* model, + const QString& title) const { model->setContext(m_context); TableWidget* tw = new TableWidget(); @@ -105,23 +111,26 @@ TableWidget* DisassemblerDocks::createTable(ContextModel* model, const QString& tw->setWindowTitle(title); tw->setModel(model); - connect(tw, &TableWidget::doubleClicked, this, &DisassemblerDocks::onItemDoubleClicked); + connect(tw, &TableWidget::doubleClicked, this, + &DisassemblerDocks::onItemDoubleClicked); return tw; } -void DisassemblerDocks::listenEvents(const RDEventArgs* e) -{ +void DisassemblerDocks::listenEvents(const RDEventArgs* e) { auto* thethis = reinterpret_cast(e->owner); - switch(e->id) - { + switch(e->id) { case Event_BusyChanged: - QMetaObject::invokeMethod(DisassemblerHooks::instance(), "updateViewWidgets", Qt::QueuedConnection, Q_ARG(bool, RDContext_IsBusy(thethis->m_context.get()))); + QMetaObject::invokeMethod( + DisassemblerHooks::instance(), "updateViewWidgets", + Qt::QueuedConnection, + Q_ARG(bool, RDContext_IsBusy(thethis->m_context.get()))); break; case Event_Error: { const auto* ee = reinterpret_cast(e); - QMetaObject::invokeMethod(DisassemblerHooks::instance(), "showMessage", Qt::QueuedConnection, + QMetaObject::invokeMethod(DisassemblerHooks::instance(), + "showMessage", Qt::QueuedConnection, Q_ARG(QString, "Error"), Q_ARG(QString, ee->message), Q_ARG(size_t, QMessageBox::Critical)); @@ -130,13 +139,15 @@ void DisassemblerDocks::listenEvents(const RDEventArgs* e) } } -DockWidget* DisassemblerDocks::showListing() const { return DisassemblerHooks::tabify(new ListingSplitView(m_context)); } +DockWidget* DisassemblerDocks::showListing() const { + return DisassemblerHooks::tabify(new ListingSplitView(m_context)); +} -void DisassemblerDocks::setContext(const RDContextPtr& ctx) -{ +void DisassemblerDocks::setContext(const RDContextPtr& ctx) { m_context = ctx; auto* analysiswidget = new AnalysisWidget(ctx); - m_analysisdock = DisassemblerHooks::dockify(analysiswidget, KDDockWidgets::DockWidget::Option_NotClosable); + m_analysisdock = DisassemblerHooks::dockify( + analysiswidget, KDDockWidgets::DockWidget::Option_NotClosable); connect(analysiswidget, &AnalysisWidget::listingClicked, this, [=]() { m_analysisdock->hide(); @@ -146,6 +157,7 @@ void DisassemblerDocks::setContext(const RDContextPtr& ctx) DisassemblerHooks::mainWindow()->addDockWidgetAsTab(m_analysisdock); - RDObject_Subscribe(ctx.get(), this, &DisassemblerDocks::listenEvents, nullptr); - m_worker = std::async([&, ctx]() { RDContext_Disassemble(ctx.get()); }); + RDObject_Subscribe(ctx.get(), this, &DisassemblerDocks::listenEvents, + nullptr); + m_worker = std::async([&, ctx]() { RDContext_Disassemble(ctx.get()); }); } diff --git a/widgets/disassemblerdocks.h b/widgets/disassemblerdocks.h index 07d65c4e..13e727a4 100644 --- a/widgets/disassemblerdocks.h +++ b/widgets/disassemblerdocks.h @@ -1,43 +1,42 @@ #pragma once +#include "../hooks/isurface.h" #include #include #include -#include #include -#include "../hooks/isurface.h" +#include class ContextModel; class TableWidget; class DockWidget; -class DisassemblerDocks : public QObject -{ +class DisassemblerDocks: public QObject { Q_OBJECT - public: - explicit DisassemblerDocks(QObject *parent = nullptr); - virtual ~DisassemblerDocks(); - const RDContextPtr& context() const; - void setContext(const RDContextPtr& ctx); - DockWidget* showListing() const; - void showSegments() const; - void showFunctions() const; - void showExports() const; - void showImports() const; - void showStrings() const; - void showMap(KDDockWidgets::DockWidget* relative = nullptr) const; +public: + explicit DisassemblerDocks(QObject* parent = nullptr); + virtual ~DisassemblerDocks(); + const RDContextPtr& context() const; + void setContext(const RDContextPtr& ctx); + DockWidget* showListing() const; + void showSegments() const; + void showFunctions() const; + void showExports() const; + void showImports() const; + void showStrings() const; + void showMap(KDDockWidgets::DockWidget* relative = nullptr) const; - private Q_SLOTS: - void onItemDoubleClicked(const QModelIndex& index); - void showDisassembly(); +private Q_SLOTS: + void onItemDoubleClicked(const QModelIndex& index); + void showDisassembly(); - private: - TableWidget* createTable(ContextModel* model, const QString& title) const; - static void listenEvents(const RDEventArgs* e); +private: + TableWidget* createTable(ContextModel* model, const QString& title) const; + static void listenEvents(const RDEventArgs* e); - private: - RDContextPtr m_context; - std::future m_worker; - DockWidget* m_analysisdock; +private: + RDContextPtr m_context; + std::future m_worker; + DockWidget* m_analysisdock; }; diff --git a/widgets/docks/dockwidget.cpp b/widgets/docks/dockwidget.cpp index 7f69cc13..40dc26f4 100644 --- a/widgets/docks/dockwidget.cpp +++ b/widgets/docks/dockwidget.cpp @@ -1,12 +1,19 @@ #include "dockwidget.h" #include "../hooks/disassemblerhooks.h" -DockWidget::DockWidget(const QString& widgetid, Options opt, LayoutSaverOptions lsp): KDDockWidgets::DockWidget(widgetid, opt | DockWidget::Option_DeleteOnClose, lsp) -{ +DockWidget::DockWidget(const QString& widgetid, Options opt, + LayoutSaverOptions lsp) + : KDDockWidgets::DockWidget(widgetid, + opt | DockWidget::Option_DeleteOnClose, lsp) { m_action = DisassemblerHooks::instance()->addWindowAction(this); connect(this, &DockWidget::shown, this, &DockWidget::onDockShown); } -DockWidget::~DockWidget() { DisassemblerHooks::instance()->removeWindowAction(m_action); } +DockWidget::~DockWidget() { + DisassemblerHooks::instance()->removeWindowAction(m_action); +} -void DockWidget::onDockShown() { if(this->isInMainWindow()) DisassemblerHooks::instance()->enableCommands(this->widget()); } +void DockWidget::onDockShown() { + if(this->isInMainWindow()) + DisassemblerHooks::instance()->enableCommands(this->widget()); +} diff --git a/widgets/docks/dockwidget.h b/widgets/docks/dockwidget.h index 323df2f2..ecb4a6f1 100644 --- a/widgets/docks/dockwidget.h +++ b/widgets/docks/dockwidget.h @@ -2,18 +2,18 @@ #include -class DockWidget : public KDDockWidgets::DockWidget -{ +class DockWidget: public KDDockWidgets::DockWidget { Q_OBJECT - public: - explicit DockWidget(const QString& widgetid, Options opt = DockWidget::Options(), LayoutSaverOptions lsp = LayoutSaverOptions()); - ~DockWidget() override; +public: + explicit DockWidget(const QString& widgetid, + Options opt = DockWidget::Options(), + LayoutSaverOptions lsp = LayoutSaverOptions()); + ~DockWidget() override; - protected Q_SLOTS: - virtual void onDockShown(); +protected Q_SLOTS: + virtual void onDockShown(); - private: - QAction* m_action; +private: + QAction* m_action; }; -