Add Permissions Column to SectionsWidget

This commit is contained in:
Florian Märkl 2019-05-16 12:48:14 +02:00
parent e48392a1e0
commit a3a8daae55
4 changed files with 10 additions and 8 deletions

View File

@ -1838,7 +1838,7 @@ QList<SectionDescription> CutterCore::getAllSections()
section.vsize = sectionObject[RJsonKey::vsize].toVariant().toULongLong();
section.paddr = sectionObject[RJsonKey::paddr].toVariant().toULongLong();
section.size = sectionObject[RJsonKey::size].toVariant().toULongLong();
section.flags = sectionObject[RJsonKey::flags].toString();
section.perm = sectionObject[RJsonKey::perm].toString();
section.entropy = sectionObject[RJsonKey::entropy].toString();
ret << section;

View File

@ -123,7 +123,7 @@ struct SectionDescription {
RVA size;
RVA vsize;
QString name;
QString flags;
QString perm;
QString entropy;
};

View File

@ -62,6 +62,8 @@ QVariant SectionsModel::data(const QModelIndex &index, int role) const
return RAddressString(section.vaddr);
case SectionsModel::EndAddressColumn:
return RAddressString(section.vaddr + section.vsize);
case SectionsModel::PermissionsColumn:
return section.perm;
case SectionsModel::EntropyColumn:
return section.entropy;
default:
@ -91,6 +93,8 @@ QVariant SectionsModel::headerData(int section, Qt::Orientation, int role) const
return tr("Address");
case SectionsModel::EndAddressColumn:
return tr("End Address");
case SectionsModel::PermissionsColumn:
return tr("Permissions");
case SectionsModel::EntropyColumn:
return tr("Entropy");
default:
@ -115,6 +119,7 @@ bool SectionsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &ri
auto rightSection = right.data(SectionsModel::SectionDescriptionRole).value<SectionDescription>();
switch (left.column()) {
default:
case SectionsModel::NameColumn:
return leftSection.name < rightSection.name;
case SectionsModel::SizeColumn:
@ -125,14 +130,11 @@ bool SectionsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &ri
return leftSection.vaddr < rightSection.vaddr;
}
return leftSection.vsize < rightSection.vsize;
case SectionsModel::PermissionsColumn:
return leftSection.perm < rightSection.perm;
case SectionsModel::EntropyColumn:
return leftSection.entropy < rightSection.entropy;
default:
break;
}
return false;
}
SectionsWidget::SectionsWidget(MainWindow *main, QAction *action) :

View File

@ -37,7 +37,7 @@ private:
QList<SectionDescription> *sections;
public:
enum Column { NameColumn = 0, SizeColumn, AddressColumn, EndAddressColumn, EntropyColumn, ColumnCount };
enum Column { NameColumn = 0, SizeColumn, AddressColumn, EndAddressColumn, PermissionsColumn, EntropyColumn, ColumnCount };
enum Role { SectionDescriptionRole = Qt::UserRole };
SectionsModel(QList<SectionDescription> *sections, QObject *parent = nullptr);