mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-24 05:45:27 +00:00
Add realname and libname to Flags and Imports widgets (#2024)
* Add realname and libname to flags and imports
This commit is contained in:
parent
7b83bbf07b
commit
8266cd074f
@ -66,6 +66,7 @@ namespace RJsonKey {
|
||||
R_JSON_KEY(license);
|
||||
R_JSON_KEY(methods);
|
||||
R_JSON_KEY(name);
|
||||
R_JSON_KEY(realname);
|
||||
R_JSON_KEY(nargs);
|
||||
R_JSON_KEY(nbbs);
|
||||
R_JSON_KEY(nlocals);
|
||||
@ -73,6 +74,7 @@ namespace RJsonKey {
|
||||
R_JSON_KEY(opcode);
|
||||
R_JSON_KEY(opcodes);
|
||||
R_JSON_KEY(ordinal);
|
||||
R_JSON_KEY(libname);
|
||||
R_JSON_KEY(outdegree);
|
||||
R_JSON_KEY(paddr);
|
||||
R_JSON_KEY(path);
|
||||
@ -2425,6 +2427,7 @@ QList<ImportDescription> CutterCore::getAllImports()
|
||||
import.ordinal = importObject[RJsonKey::ordinal].toInt();
|
||||
import.bind = importObject[RJsonKey::bind].toString();
|
||||
import.type = importObject[RJsonKey::type].toString();
|
||||
import.libname = importObject[RJsonKey::libname].toString();
|
||||
import.name = importObject[RJsonKey::name].toString();
|
||||
|
||||
ret << import;
|
||||
@ -2662,6 +2665,7 @@ QList<FlagDescription> CutterCore::getAllFlags(QString flagspace)
|
||||
flag.offset = flagObject[RJsonKey::offset].toVariant().toULongLong();
|
||||
flag.size = flagObject[RJsonKey::size].toVariant().toULongLong();
|
||||
flag.name = flagObject[RJsonKey::name].toString();
|
||||
flag.realname = flagObject[RJsonKey::realname].toString();
|
||||
|
||||
ret << flag;
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ struct ImportDescription {
|
||||
QString bind;
|
||||
QString type;
|
||||
QString name;
|
||||
QString libname;
|
||||
};
|
||||
|
||||
struct ExportDescription {
|
||||
@ -117,6 +118,7 @@ struct FlagDescription {
|
||||
RVA offset;
|
||||
RVA size;
|
||||
QString name;
|
||||
QString realname;
|
||||
};
|
||||
|
||||
struct SectionDescription {
|
||||
|
@ -42,6 +42,8 @@ QVariant FlagsModel::data(const QModelIndex &index, int role) const
|
||||
return RAddressString(flag.offset);
|
||||
case NAME:
|
||||
return flag.name;
|
||||
case REALNAME:
|
||||
return flag.realname;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -63,6 +65,8 @@ QVariant FlagsModel::headerData(int section, Qt::Orientation, int role) const
|
||||
return tr("Offset");
|
||||
case NAME:
|
||||
return tr("Name");
|
||||
case REALNAME:
|
||||
return tr("Real Name");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -100,7 +104,7 @@ bool FlagsSortFilterProxyModel::filterAcceptsRow(int row, const QModelIndex &par
|
||||
{
|
||||
QModelIndex index = sourceModel()->index(row, 0, parent);
|
||||
FlagDescription flag = index.data(FlagsModel::FlagDescriptionRole).value<FlagDescription>();
|
||||
return flag.name.contains(filterRegExp());
|
||||
return flag.name.contains(filterRegExp()) || flag.realname.contains(filterRegExp());
|
||||
}
|
||||
|
||||
bool FlagsSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
|
||||
@ -120,6 +124,10 @@ bool FlagsSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIn
|
||||
// fallthrough
|
||||
case FlagsModel::NAME:
|
||||
return left_flag->name < right_flag->name;
|
||||
|
||||
case FlagsModel::REALNAME:
|
||||
return left_flag->realname < right_flag->realname;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ private:
|
||||
QList<FlagDescription> *flags;
|
||||
|
||||
public:
|
||||
enum Columns { OFFSET = 0, SIZE, NAME, COUNT };
|
||||
enum Columns { OFFSET = 0, SIZE, NAME, REALNAME, COUNT };
|
||||
static const int FlagDescriptionRole = Qt::UserRole;
|
||||
|
||||
FlagsModel(QList<FlagDescription> *flags, QObject *parent = nullptr);
|
||||
|
@ -46,6 +46,8 @@ QVariant ImportsModel::data(const QModelIndex &index, int role) const
|
||||
return import.type;
|
||||
case ImportsModel::SafetyColumn:
|
||||
return banned.match(import.name).hasMatch() ? tr("Unsafe") : QStringLiteral("");
|
||||
case ImportsModel::LibraryColumn:
|
||||
return import.libname;
|
||||
case ImportsModel::NameColumn:
|
||||
return import.name;
|
||||
default:
|
||||
@ -72,6 +74,8 @@ QVariant ImportsModel::headerData(int section, Qt::Orientation, int role) const
|
||||
return tr("Type");
|
||||
case ImportsModel::SafetyColumn:
|
||||
return tr("Safety");
|
||||
case ImportsModel::LibraryColumn:
|
||||
return tr("Library");
|
||||
case ImportsModel::NameColumn:
|
||||
return tr("Name");
|
||||
default:
|
||||
@ -93,6 +97,12 @@ QString ImportsModel::name(const QModelIndex &index) const
|
||||
return import.name;
|
||||
}
|
||||
|
||||
QString ImportsModel::libname(const QModelIndex &index) const
|
||||
{
|
||||
const ImportDescription &import = imports->at(index.row());
|
||||
return import.libname;
|
||||
}
|
||||
|
||||
ImportsProxyModel::ImportsProxyModel(ImportsModel *sourceModel, QObject *parent)
|
||||
: AddressableFilterProxyModel(sourceModel, parent)
|
||||
{
|
||||
@ -126,8 +136,13 @@ bool ImportsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &rig
|
||||
return leftImport.type < rightImport.type;
|
||||
case ImportsModel::SafetyColumn:
|
||||
break;
|
||||
case ImportsModel::LibraryColumn:
|
||||
if (leftImport.libname != rightImport.libname)
|
||||
return leftImport.libname < rightImport.libname;
|
||||
// Fallthrough. Sort by Library and then by import name
|
||||
case ImportsModel::NameColumn:
|
||||
return leftImport.name < rightImport.name;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -148,7 +163,8 @@ ImportsWidget::ImportsWidget(MainWindow *main, QAction *action) :
|
||||
setObjectName("ImportsWidget");
|
||||
|
||||
setModels(importsProxyModel);
|
||||
ui->treeView->sortByColumn(ImportsModel::NameColumn, Qt::AscendingOrder);
|
||||
// Sort by library name by default to create a solid context per each group of imports
|
||||
ui->treeView->sortByColumn(ImportsModel::LibraryColumn, Qt::AscendingOrder);
|
||||
QShortcut *toggle_shortcut = new QShortcut(widgetShortcuts["ImportsWidget"], main);
|
||||
connect(toggle_shortcut, &QShortcut::activated, this, [=] (){
|
||||
toggleDockWidget(true);
|
||||
|
@ -43,7 +43,7 @@ private:
|
||||
QList<ImportDescription> *imports;
|
||||
|
||||
public:
|
||||
enum Column { AddressColumn = 0, TypeColumn, SafetyColumn, NameColumn, ColumnCount };
|
||||
enum Column { AddressColumn = 0, TypeColumn, LibraryColumn, NameColumn, SafetyColumn, ColumnCount };
|
||||
enum Role { ImportDescriptionRole = Qt::UserRole, AddressRole };
|
||||
|
||||
ImportsModel(QList<ImportDescription> *imports, QObject *parent = nullptr);
|
||||
@ -56,6 +56,8 @@ public:
|
||||
|
||||
RVA address(const QModelIndex &index) const override;
|
||||
QString name(const QModelIndex &index) const override;
|
||||
QString libname(const QModelIndex &index) const;
|
||||
|
||||
};
|
||||
|
||||
class ImportsProxyModel : public AddressableFilterProxyModel
|
||||
|
Loading…
Reference in New Issue
Block a user