mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-24 22:05:25 +00:00
Fix new warnings
- Fix compiler and cppcheck warning - format with astyle
This commit is contained in:
parent
ebe33ffe8e
commit
f586ab2d4e
@ -59,7 +59,7 @@ namespace qhelpers
|
|||||||
}
|
}
|
||||||
|
|
||||||
QTreeWidgetItem *appendRow(QTreeWidget *tw, const QString &str, const QString &str2,
|
QTreeWidgetItem *appendRow(QTreeWidget *tw, const QString &str, const QString &str2,
|
||||||
const QString &str3, const QString &str4, const QString &str5)
|
const QString &str3, const QString &str4, const QString &str5)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
||||||
// Fill dummy hidden column
|
// Fill dummy hidden column
|
||||||
|
@ -20,7 +20,7 @@ namespace qhelpers
|
|||||||
void adjustColumns(QTreeWidget *tw, int columnCount = 0, int padding = 0);
|
void adjustColumns(QTreeWidget *tw, int columnCount = 0, int padding = 0);
|
||||||
|
|
||||||
QTreeWidgetItem *appendRow(QTreeWidget *tw, const QString &str, const QString &str2 = QString(),
|
QTreeWidgetItem *appendRow(QTreeWidget *tw, const QString &str, const QString &str2 = QString(),
|
||||||
const QString &str3 = QString(), const QString &str4 = QString(), const QString &str5 = QString());
|
const QString &str3 = QString(), const QString &str4 = QString(), const QString &str5 = QString());
|
||||||
|
|
||||||
void setVerticalScrollMode(QAbstractItemView *tw);
|
void setVerticalScrollMode(QAbstractItemView *tw);
|
||||||
}
|
}
|
||||||
|
@ -58,11 +58,11 @@ int main(int argc, char *argv[])
|
|||||||
bool analLevelSpecified = false;
|
bool analLevelSpecified = false;
|
||||||
int analLevel = 0;
|
int analLevel = 0;
|
||||||
|
|
||||||
if(cmdParser.isSet(analOption))
|
if (cmdParser.isSet(analOption))
|
||||||
{
|
{
|
||||||
analLevel = cmdParser.value(analOption).toInt(&analLevelSpecified);
|
analLevel = cmdParser.value(analOption).toInt(&analLevelSpecified);
|
||||||
|
|
||||||
if(!analLevelSpecified || analLevel < 0 || analLevel > 4)
|
if (!analLevelSpecified || analLevel < 0 || analLevel > 4)
|
||||||
{
|
{
|
||||||
printf("%s\n", QObject::tr("Invalid Analysis Level. May be a value between 0 and 4.").toLocal8Bit().constData());
|
printf("%s\n", QObject::tr("Invalid Analysis Level. May be a value between 0 and 4.").toLocal8Bit().constData());
|
||||||
return 1;
|
return 1;
|
||||||
@ -72,7 +72,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (args.empty())
|
if (args.empty())
|
||||||
{
|
{
|
||||||
if(analLevelSpecified)
|
if (analLevelSpecified)
|
||||||
{
|
{
|
||||||
printf("%s\n", QObject::tr("Filename must be specified to start analysis automatically.").toLocal8Bit().constData());
|
printf("%s\n", QObject::tr("Filename must be specified to start analysis automatically.").toLocal8Bit().constData());
|
||||||
return 1;
|
return 1;
|
||||||
@ -88,7 +88,7 @@ int main(int argc, char *argv[])
|
|||||||
o->setAttribute(Qt::WA_DeleteOnClose);
|
o->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
o->show();
|
o->show();
|
||||||
|
|
||||||
if(analLevelSpecified)
|
if (analLevelSpecified)
|
||||||
o->setupAndStartAnalysis(analLevel);
|
o->setupAndStartAnalysis(analLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ void MainWindow::refreshOmniBar(const QStringList &flags)
|
|||||||
omnibar->refresh(flags);
|
omnibar->refresh(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setFilename(QString fn)
|
void MainWindow::setFilename(const QString &fn)
|
||||||
{
|
{
|
||||||
// Add file name to window title
|
// Add file name to window title
|
||||||
this->filename = fn;
|
this->filename = fn;
|
||||||
@ -726,12 +726,12 @@ void MainWindow::seek(const QString &offset, const QString &name, bool raise_mem
|
|||||||
{
|
{
|
||||||
// TODO: remove this method and use the one with RVA only!
|
// TODO: remove this method and use the one with RVA only!
|
||||||
|
|
||||||
if(offset.length() < 2)
|
if (offset.length() < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
RVA addr = offset.mid(2).toULongLong(&ok, 16);
|
RVA addr = offset.mid(2).toULongLong(&ok, 16);
|
||||||
if(!ok)
|
if (!ok)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
seek(addr, name, raise_memory_dock);
|
seek(addr, name, raise_memory_dock);
|
||||||
@ -754,7 +754,7 @@ void MainWindow::seek(const RVA offset, const QString &name, bool raise_memory_d
|
|||||||
this->memoryDock->disasTextEdit->setFocus();
|
this->memoryDock->disasTextEdit->setFocus();
|
||||||
|
|
||||||
// Rise and shine baby!
|
// Rise and shine baby!
|
||||||
if(raise_memory_dock)
|
if (raise_memory_dock)
|
||||||
this->memoryDock->raise();
|
this->memoryDock->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -905,7 +905,7 @@ void MainWindow::on_actionhide_bottomPannel_triggered()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::send_to_notepad(QString txt)
|
void MainWindow::send_to_notepad(const QString &txt)
|
||||||
{
|
{
|
||||||
this->notepadDock->appendPlainText("```\n" + txt + "\n```");
|
this->notepadDock->appendPlainText("```\n" + txt + "\n```");
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
void start_web_server();
|
void start_web_server();
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void setFilename(QString fn);
|
void setFilename(const QString &fn);
|
||||||
//void setCore(QRCore *core);
|
//void setCore(QRCore *core);
|
||||||
void seek(const QString &offset, const QString &name = NULL, bool raise_memory_dock = false);
|
void seek(const QString &offset, const QString &name = NULL, bool raise_memory_dock = false);
|
||||||
void seek(const RVA offset, const QString &name = NULL, bool raise_memory_dock = false);
|
void seek(const RVA offset, const QString &name = NULL, bool raise_memory_dock = false);
|
||||||
@ -64,7 +64,7 @@ public:
|
|||||||
void get_refs(const QString &offset);
|
void get_refs(const QString &offset);
|
||||||
void add_output(QString msg);
|
void add_output(QString msg);
|
||||||
void add_debug_output(QString msg);
|
void add_debug_output(QString msg);
|
||||||
void send_to_notepad(QString txt);
|
void send_to_notepad(const QString &txt);
|
||||||
void setWebServerState(bool start);
|
void setWebServerState(bool start);
|
||||||
void raiseMemoryDock();
|
void raiseMemoryDock();
|
||||||
void toggleSideBarTheme();
|
void toggleSideBarTheme();
|
||||||
|
@ -230,7 +230,7 @@ QJsonDocument QRCore::cmdj(const QString &str)
|
|||||||
QJsonParseError jsonError;
|
QJsonParseError jsonError;
|
||||||
QJsonDocument doc = res ? QJsonDocument::fromJson(resString.toUtf8(), &jsonError) : QJsonDocument();
|
QJsonDocument doc = res ? QJsonDocument::fromJson(resString.toUtf8(), &jsonError) : QJsonDocument();
|
||||||
|
|
||||||
if(jsonError.error != QJsonParseError::NoError)
|
if (jsonError.error != QJsonParseError::NoError)
|
||||||
{
|
{
|
||||||
eprintf("Failed to parse JSON: %s\n", jsonError.errorString().toLocal8Bit().constData());
|
eprintf("Failed to parse JSON: %s\n", jsonError.errorString().toLocal8Bit().constData());
|
||||||
eprintf("%s\n", resString.toLocal8Bit().constData());
|
eprintf("%s\n", resString.toLocal8Bit().constData());
|
||||||
@ -856,7 +856,7 @@ QList<RVA> QRCore::getSeekHistory()
|
|||||||
QList<RVA> ret;
|
QList<RVA> ret;
|
||||||
|
|
||||||
QJsonArray jsonArray = cmdj("sj").array();
|
QJsonArray jsonArray = cmdj("sj").array();
|
||||||
foreach(QJsonValue value, jsonArray)
|
foreach (QJsonValue value, jsonArray)
|
||||||
ret << value.toVariant().toULongLong();
|
ret << value.toVariant().toULongLong();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -869,7 +869,7 @@ QList<FunctionDescription> QRCore::getAllFunctions()
|
|||||||
|
|
||||||
QJsonArray jsonArray = cmdj("aflj").array();
|
QJsonArray jsonArray = cmdj("aflj").array();
|
||||||
|
|
||||||
foreach(QJsonValue value, jsonArray)
|
foreach (QJsonValue value, jsonArray)
|
||||||
{
|
{
|
||||||
QJsonObject jsonObject = value.toObject();
|
QJsonObject jsonObject = value.toObject();
|
||||||
|
|
||||||
@ -893,7 +893,7 @@ QList<ImportDescription> QRCore::getAllImports()
|
|||||||
|
|
||||||
QJsonArray importsArray = cmdj("iij").array();
|
QJsonArray importsArray = cmdj("iij").array();
|
||||||
|
|
||||||
foreach(QJsonValue value, importsArray)
|
foreach (QJsonValue value, importsArray)
|
||||||
{
|
{
|
||||||
QJsonObject importObject = value.toObject();
|
QJsonObject importObject = value.toObject();
|
||||||
|
|
||||||
@ -951,18 +951,18 @@ QList<SymbolDescription> QRCore::getAllSymbols()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<CommentDescription> QRCore::getAllComments(QString filterType)
|
QList<CommentDescription> QRCore::getAllComments(const QString &filterType)
|
||||||
{
|
{
|
||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
QList<CommentDescription> ret;
|
QList<CommentDescription> ret;
|
||||||
|
|
||||||
QJsonArray commentsArray = cmdj("CCj").array();
|
QJsonArray commentsArray = cmdj("CCj").array();
|
||||||
for(QJsonValue value : commentsArray)
|
for (QJsonValue value : commentsArray)
|
||||||
{
|
{
|
||||||
QJsonObject commentObject = value.toObject();
|
QJsonObject commentObject = value.toObject();
|
||||||
|
|
||||||
QString type = commentObject["type"].toString();
|
QString type = commentObject["type"].toString();
|
||||||
if(type != filterType)
|
if (type != filterType)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CommentDescription comment;
|
CommentDescription comment;
|
||||||
|
@ -178,7 +178,7 @@ public:
|
|||||||
QList<FunctionDescription> getAllFunctions();
|
QList<FunctionDescription> getAllFunctions();
|
||||||
QList<ImportDescription> getAllImports();
|
QList<ImportDescription> getAllImports();
|
||||||
QList<SymbolDescription> getAllSymbols();
|
QList<SymbolDescription> getAllSymbols();
|
||||||
QList<CommentDescription> getAllComments(QString type);
|
QList<CommentDescription> getAllComments(const QString &filterType);
|
||||||
QList<RelocDescription> getAllRelocs();
|
QList<RelocDescription> getAllRelocs();
|
||||||
QList<StringDescription> getAllStrings();
|
QList<StringDescription> getAllStrings();
|
||||||
|
|
||||||
|
@ -14,23 +14,23 @@
|
|||||||
#include <QResource>
|
#include <QResource>
|
||||||
|
|
||||||
FunctionModel::FunctionModel(QList<FunctionDescription> *functions, QSet<RVA> *import_addresses, bool nested, QFont default_font, QFont highlight_font, MainWindow *main, QObject *parent)
|
FunctionModel::FunctionModel(QList<FunctionDescription> *functions, QSet<RVA> *import_addresses, bool nested, QFont default_font, QFont highlight_font, MainWindow *main, QObject *parent)
|
||||||
: functions(functions),
|
: QAbstractItemModel(parent),
|
||||||
import_addresses(import_addresses),
|
main(main),
|
||||||
main(main),
|
functions(functions),
|
||||||
nested(nested),
|
import_addresses(import_addresses),
|
||||||
default_font(default_font),
|
highlight_font(highlight_font),
|
||||||
highlight_font(highlight_font),
|
default_font(default_font),
|
||||||
QAbstractItemModel(parent)
|
nested(nested),
|
||||||
{
|
current_index(-1)
|
||||||
current_index = -1;
|
|
||||||
|
|
||||||
|
{
|
||||||
connect(main, SIGNAL(cursorAddressChanged(RVA)), this, SLOT(cursorAddressChanged(RVA)));
|
connect(main, SIGNAL(cursorAddressChanged(RVA)), this, SLOT(cursorAddressChanged(RVA)));
|
||||||
connect(main->core, SIGNAL(functionRenamed(QString, QString)), this, SLOT(functionRenamed(QString, QString)));
|
connect(main->core, SIGNAL(functionRenamed(QString, QString)), this, SLOT(functionRenamed(QString, QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex FunctionModel::index(int row, int column, const QModelIndex &parent) const
|
QModelIndex FunctionModel::index(int row, int column, const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
if(!parent.isValid())
|
if (!parent.isValid())
|
||||||
return createIndex(row, column, (quintptr)0); // root function nodes have id = 0
|
return createIndex(row, column, (quintptr)0); // root function nodes have id = 0
|
||||||
|
|
||||||
return createIndex(row, column, (quintptr)(parent.row() + 1)); // sub-nodes have id = function index + 1
|
return createIndex(row, column, (quintptr)(parent.row() + 1)); // sub-nodes have id = function index + 1
|
||||||
@ -38,23 +38,23 @@ QModelIndex FunctionModel::index(int row, int column, const QModelIndex &parent)
|
|||||||
|
|
||||||
QModelIndex FunctionModel::parent(const QModelIndex &index) const
|
QModelIndex FunctionModel::parent(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
if(!index.isValid() || index.column() != 0)
|
if (!index.isValid() || index.column() != 0)
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
if(index.internalId() == 0) // root function node
|
if (index.internalId() == 0) // root function node
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
else // sub-node
|
else // sub-node
|
||||||
return this->index((int)(index.internalId()-1), 0);
|
return this->index((int)(index.internalId() - 1), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FunctionModel::rowCount(const QModelIndex &parent) const
|
int FunctionModel::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
if(!parent.isValid())
|
if (!parent.isValid())
|
||||||
return functions->count();
|
return functions->count();
|
||||||
|
|
||||||
if(nested)
|
if (nested)
|
||||||
{
|
{
|
||||||
if(parent.internalId() == 0)
|
if (parent.internalId() == 0)
|
||||||
return 3; // sub-nodes for nested functions
|
return 3; // sub-nodes for nested functions
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -62,9 +62,9 @@ int FunctionModel::rowCount(const QModelIndex &parent) const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FunctionModel::columnCount(const QModelIndex &parent) const
|
int FunctionModel::columnCount(const QModelIndex &/*parent*/) const
|
||||||
{
|
{
|
||||||
if(nested)
|
if (nested)
|
||||||
return 1;
|
return 1;
|
||||||
else
|
else
|
||||||
return 4;
|
return 4;
|
||||||
@ -73,12 +73,12 @@ int FunctionModel::columnCount(const QModelIndex &parent) const
|
|||||||
|
|
||||||
QVariant FunctionModel::data(const QModelIndex &index, int role) const
|
QVariant FunctionModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if(!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
int function_index;
|
int function_index;
|
||||||
bool subnode;
|
bool subnode;
|
||||||
if(index.internalId() != 0) // sub-node
|
if (index.internalId() != 0) // sub-node
|
||||||
{
|
{
|
||||||
function_index = index.parent().row();
|
function_index = index.parent().row();
|
||||||
subnode = true;
|
subnode = true;
|
||||||
@ -91,90 +91,90 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
const FunctionDescription &function = functions->at(function_index);
|
const FunctionDescription &function = functions->at(function_index);
|
||||||
|
|
||||||
if(function_index >= functions->count())
|
if (function_index >= functions->count())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
switch(role)
|
switch (role)
|
||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
if(nested)
|
if (nested)
|
||||||
|
{
|
||||||
|
if (subnode)
|
||||||
{
|
{
|
||||||
if(subnode)
|
switch (index.row())
|
||||||
{
|
{
|
||||||
switch(index.row())
|
case 0:
|
||||||
{
|
return tr("Offset: %1").arg(RAddressString(function.offset));
|
||||||
case 0:
|
case 1:
|
||||||
return tr("Offset: %1").arg(RAddressString(function.offset));
|
return tr("Size: %1").arg(RSizeString(function.size));
|
||||||
case 1:
|
case 2:
|
||||||
return tr("Size: %1").arg(RSizeString(function.size));
|
return tr("Import: %1").arg(import_addresses->contains(function.offset) ? tr("true") : tr("false"));
|
||||||
case 2:
|
default:
|
||||||
return tr("Import: %1").arg(import_addresses->contains(function.offset) ? tr("true") : tr("false"));
|
return QVariant();
|
||||||
default:
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return function.name;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
return function.name;
|
||||||
switch(index.column())
|
}
|
||||||
{
|
else
|
||||||
case 0:
|
|
||||||
return RAddressString(function.offset);
|
|
||||||
case 1:
|
|
||||||
return RSizeString(function.size);
|
|
||||||
case 3:
|
|
||||||
return function.name;
|
|
||||||
default:
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case Qt::DecorationRole:
|
|
||||||
if(import_addresses->contains(function.offset) &&
|
|
||||||
(nested ? false :index.column() == 2))
|
|
||||||
return QIcon(":/img/icons/import_light.svg");
|
|
||||||
return QVariant();
|
|
||||||
|
|
||||||
case Qt::FontRole:
|
|
||||||
if(current_index == function_index)
|
|
||||||
return highlight_font;
|
|
||||||
return default_font;
|
|
||||||
|
|
||||||
case Qt::ToolTipRole:
|
|
||||||
{
|
{
|
||||||
QList<QString> info = main->core->cmd("afi @ " + function.name).split("\n");
|
switch (index.column())
|
||||||
if (info.length() > 2)
|
|
||||||
{
|
{
|
||||||
QString size = info[4].split(" ")[1];
|
case 0:
|
||||||
QString complex = info[8].split(" ")[1];
|
return RAddressString(function.offset);
|
||||||
QString bb = info[11].split(" ")[1];
|
case 1:
|
||||||
return QString("Summary:\n\n Size: " + size +
|
return RSizeString(function.size);
|
||||||
"\n Cyclomatic complexity: " + complex +
|
case 3:
|
||||||
"\n Basic blocks: " + bb +
|
return function.name;
|
||||||
"\n\nDisasm preview:\n\n" + main->core->cmd("pdi 10 @ " + function.name) +
|
default:
|
||||||
"\nStrings:\n\n" + main->core->cmd("pdsf @ " + function.name));
|
return QVariant();
|
||||||
}
|
}
|
||||||
return QVariant();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case FunctionDescriptionRole:
|
case Qt::DecorationRole:
|
||||||
return QVariant::fromValue(function);
|
if (import_addresses->contains(function.offset) &&
|
||||||
|
(nested ? false : index.column() == 2))
|
||||||
|
return QIcon(":/img/icons/import_light.svg");
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
case IsImportRole:
|
case Qt::FontRole:
|
||||||
return import_addresses->contains(function.offset);
|
if (current_index == function_index)
|
||||||
|
return highlight_font;
|
||||||
|
return default_font;
|
||||||
|
|
||||||
default:
|
case Qt::ToolTipRole:
|
||||||
return QVariant();
|
{
|
||||||
|
QList<QString> info = main->core->cmd("afi @ " + function.name).split("\n");
|
||||||
|
if (info.length() > 2)
|
||||||
|
{
|
||||||
|
QString size = info[4].split(" ")[1];
|
||||||
|
QString complex = info[8].split(" ")[1];
|
||||||
|
QString bb = info[11].split(" ")[1];
|
||||||
|
return QString("Summary:\n\n Size: " + size +
|
||||||
|
"\n Cyclomatic complexity: " + complex +
|
||||||
|
"\n Basic blocks: " + bb +
|
||||||
|
"\n\nDisasm preview:\n\n" + main->core->cmd("pdi 10 @ " + function.name) +
|
||||||
|
"\nStrings:\n\n" + main->core->cmd("pdsf @ " + function.name));
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
case FunctionDescriptionRole:
|
||||||
|
return QVariant::fromValue(function);
|
||||||
|
|
||||||
|
case IsImportRole:
|
||||||
|
return import_addresses->contains(function.offset);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return QVariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant FunctionModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant FunctionModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if(role == Qt::DisplayRole && orientation == Qt::Horizontal)
|
if (role == Qt::DisplayRole && orientation == Qt::Horizontal)
|
||||||
{
|
{
|
||||||
if(nested)
|
if (nested)
|
||||||
{
|
{
|
||||||
return tr("Name");
|
return tr("Name");
|
||||||
}
|
}
|
||||||
@ -182,16 +182,16 @@ QVariant FunctionModel::headerData(int section, Qt::Orientation orientation, int
|
|||||||
{
|
{
|
||||||
switch (section)
|
switch (section)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return tr("Offset");
|
return tr("Offset");
|
||||||
case 1:
|
case 1:
|
||||||
return tr("Size");
|
return tr("Size");
|
||||||
case 2:
|
case 2:
|
||||||
return tr("Imp.");
|
return tr("Imp.");
|
||||||
case 3:
|
case 3:
|
||||||
return tr("Name");
|
return tr("Name");
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ void FunctionModel::endReloadFunctions()
|
|||||||
void FunctionModel::cursorAddressChanged(RVA)
|
void FunctionModel::cursorAddressChanged(RVA)
|
||||||
{
|
{
|
||||||
updateCurrentIndex();
|
updateCurrentIndex();
|
||||||
emit dataChanged(index(0, 0), index(rowCount()-1, columnCount()-1));
|
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FunctionModel::updateCurrentIndex()
|
void FunctionModel::updateCurrentIndex()
|
||||||
@ -223,12 +223,12 @@ void FunctionModel::updateCurrentIndex()
|
|||||||
int index = -1;
|
int index = -1;
|
||||||
RVA offset = 0;
|
RVA offset = 0;
|
||||||
|
|
||||||
for(int i=0; i<functions->count(); i++)
|
for (int i = 0; i < functions->count(); i++)
|
||||||
{
|
{
|
||||||
const FunctionDescription &function = functions->at(i);
|
const FunctionDescription &function = functions->at(i);
|
||||||
|
|
||||||
if(function.contains(addr)
|
if (function.contains(addr)
|
||||||
&& function.offset >= offset)
|
&& function.offset >= offset)
|
||||||
{
|
{
|
||||||
offset = function.offset;
|
offset = function.offset;
|
||||||
index = i;
|
index = i;
|
||||||
@ -238,15 +238,15 @@ void FunctionModel::updateCurrentIndex()
|
|||||||
current_index = index;
|
current_index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FunctionModel::functionRenamed(QString prev_name, QString new_name)
|
void FunctionModel::functionRenamed(const QString &prev_name, const QString &new_name)
|
||||||
{
|
{
|
||||||
for(int i=0; i<functions->count(); i++)
|
for (int i = 0; i < functions->count(); i++)
|
||||||
{
|
{
|
||||||
FunctionDescription &function = (*functions)[i];
|
FunctionDescription &function = (*functions)[i];
|
||||||
if(function.name == prev_name)
|
if (function.name == prev_name)
|
||||||
{
|
{
|
||||||
function.name = new_name;
|
function.name = new_name;
|
||||||
emit dataChanged(index(i, 0), index(i, columnCount()-1));
|
emit dataChanged(index(i, 0), index(i, columnCount() - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -255,7 +255,7 @@ void FunctionModel::functionRenamed(QString prev_name, QString new_name)
|
|||||||
|
|
||||||
|
|
||||||
FunctionSortFilterProxyModel::FunctionSortFilterProxyModel(FunctionModel *source_model, QObject *parent)
|
FunctionSortFilterProxyModel::FunctionSortFilterProxyModel(FunctionModel *source_model, QObject *parent)
|
||||||
: QSortFilterProxyModel(parent)
|
: QSortFilterProxyModel(parent)
|
||||||
{
|
{
|
||||||
setSourceModel(source_model);
|
setSourceModel(source_model);
|
||||||
setFilterCaseSensitivity(Qt::CaseInsensitive);
|
setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||||
@ -272,17 +272,17 @@ bool FunctionSortFilterProxyModel::filterAcceptsRow(int row, const QModelIndex &
|
|||||||
|
|
||||||
bool FunctionSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
|
bool FunctionSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
|
||||||
{
|
{
|
||||||
if(!left.isValid() || !right.isValid())
|
if (!left.isValid() || !right.isValid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(left.parent().isValid() || right.parent().isValid())
|
if (left.parent().isValid() || right.parent().isValid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
FunctionDescription left_function = left.data(FunctionModel::FunctionDescriptionRole).value<FunctionDescription>();
|
FunctionDescription left_function = left.data(FunctionModel::FunctionDescriptionRole).value<FunctionDescription>();
|
||||||
FunctionDescription right_function = right.data(FunctionModel::FunctionDescriptionRole).value<FunctionDescription>();
|
FunctionDescription right_function = right.data(FunctionModel::FunctionDescriptionRole).value<FunctionDescription>();
|
||||||
|
|
||||||
|
|
||||||
if(static_cast<FunctionModel *>(sourceModel())->isNested())
|
if (static_cast<FunctionModel *>(sourceModel())->isNested())
|
||||||
{
|
{
|
||||||
return left_function.name < right_function.name;
|
return left_function.name < right_function.name;
|
||||||
}
|
}
|
||||||
@ -290,24 +290,24 @@ bool FunctionSortFilterProxyModel::lessThan(const QModelIndex &left, const QMode
|
|||||||
{
|
{
|
||||||
switch (left.column())
|
switch (left.column())
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return left_function.offset < right_function.offset;
|
return left_function.offset < right_function.offset;
|
||||||
case 1:
|
case 1:
|
||||||
if (left_function.size != right_function.size)
|
if (left_function.size != right_function.size)
|
||||||
return left_function.size < right_function.size;
|
return left_function.size < right_function.size;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
bool left_is_import = left.data(FunctionModel::IsImportRole).toBool();
|
bool left_is_import = left.data(FunctionModel::IsImportRole).toBool();
|
||||||
bool right_is_import = right.data(FunctionModel::IsImportRole).toBool();
|
bool right_is_import = right.data(FunctionModel::IsImportRole).toBool();
|
||||||
if(!left_is_import && right_is_import)
|
if (!left_is_import && right_is_import)
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
return left_function.name < right_function.name;
|
return left_function.name < right_function.name;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return left_function.offset < right_function.offset;
|
return left_function.offset < right_function.offset;
|
||||||
@ -390,7 +390,7 @@ void FunctionsWidget::refreshTree()
|
|||||||
functions = this->main->core->getAllFunctions();
|
functions = this->main->core->getAllFunctions();
|
||||||
|
|
||||||
import_addresses.clear();
|
import_addresses.clear();
|
||||||
foreach(ImportDescription import, main->core->getAllImports())
|
foreach (ImportDescription import, main->core->getAllImports())
|
||||||
import_addresses.insert(import.plt);
|
import_addresses.insert(import.plt);
|
||||||
|
|
||||||
function_model->endReloadFunctions();
|
function_model->endReloadFunctions();
|
||||||
|
@ -57,7 +57,7 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void cursorAddressChanged(RVA addr);
|
void cursorAddressChanged(RVA addr);
|
||||||
void functionRenamed(QString prev_name, QString new_name);
|
void functionRenamed(const QString &prev_name, const QString &new_name);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -310,7 +310,7 @@ void MemoryWidget::highlightHexCurrentLine()
|
|||||||
highlightHexWords(cursor.selectedText());
|
highlightHexWords(cursor.selectedText());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryWidget::highlightHexWords(QString str)
|
void MemoryWidget::highlightHexWords(const QString &str)
|
||||||
{
|
{
|
||||||
QString searchString = str;
|
QString searchString = str;
|
||||||
QTextDocument *document = ui->hexHexText_2->document();
|
QTextDocument *document = ui->hexHexText_2->document();
|
||||||
@ -1582,12 +1582,10 @@ QString MemoryWidget::normalize_addr(QString addr)
|
|||||||
void MemoryWidget::setFcnName(RVA addr)
|
void MemoryWidget::setFcnName(RVA addr)
|
||||||
{
|
{
|
||||||
RAnalFunction *fcn;
|
RAnalFunction *fcn;
|
||||||
bool ok;
|
|
||||||
|
|
||||||
QString addr_string;
|
QString addr_string;
|
||||||
|
|
||||||
fcn = this->main->core->functionAt(addr);
|
fcn = this->main->core->functionAt(addr);
|
||||||
if (ok && fcn)
|
if (fcn)
|
||||||
{
|
{
|
||||||
QString segment = this->main->core->cmd("S. @ " + QString::number(addr)).split(" ").last();
|
QString segment = this->main->core->cmd("S. @ " + QString::number(addr)).split(" ").last();
|
||||||
addr_string = segment.trimmed() + ":" + fcn->name;
|
addr_string = segment.trimmed() + ":" + fcn->name;
|
||||||
|
@ -116,7 +116,7 @@ private:
|
|||||||
void setScrollMode();
|
void setScrollMode();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_cursorAddressChanged(RVA offset);
|
void on_cursorAddressChanged(RVA addr);
|
||||||
|
|
||||||
void highlightCurrentLine();
|
void highlightCurrentLine();
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ private slots:
|
|||||||
void highlightDecoCurrentLine();
|
void highlightDecoCurrentLine();
|
||||||
void setFonts(QFont font);
|
void setFonts(QFont font);
|
||||||
|
|
||||||
void highlightHexWords(QString str);
|
void highlightHexWords(const QString &str);
|
||||||
void on_showInfoButton_2_clicked();
|
void on_showInfoButton_2_clicked();
|
||||||
void on_actionSettings_menu_1_triggered();
|
void on_actionSettings_menu_1_triggered();
|
||||||
void on_actionHideDisasm_side_panel_triggered();
|
void on_actionHideDisasm_side_panel_triggered();
|
||||||
|
Loading…
Reference in New Issue
Block a user