Add entropy to Section widget (#480)

This commit is contained in:
Itay Cohen 2018-05-05 13:11:44 +03:00 committed by xarkes
parent 31c7289726
commit eef5022469
4 changed files with 14 additions and 2 deletions

View File

@ -1164,7 +1164,10 @@ QList<SectionDescription> CutterCore::getAllSections()
CORE_LOCK();
QList<SectionDescription> ret;
QJsonArray sectionsArray = cmdj("Sj").array();
QJsonDocument sectionsDoc = cmdj("iSj entropy");
QJsonObject sectionsObj = sectionsDoc.object();
QJsonArray sectionsArray = sectionsObj["sections"].toArray();
for (QJsonValue value : sectionsArray) {
QJsonObject sectionObject = value.toObject();
@ -1179,6 +1182,7 @@ QList<SectionDescription> CutterCore::getAllSections()
section.paddr = sectionObject["paddr"].toVariant().toULongLong();
section.size = sectionObject["size"].toVariant().toULongLong();
section.flags = sectionObject["flags"].toString();
section.entropy = sectionObject["entropy"].toString();
ret << section;
}

View File

@ -165,6 +165,7 @@ struct SectionDescription {
RVA vsize;
QString name;
QString flags;
QString entropy;
};
struct EntrypointDescription {

View File

@ -58,6 +58,8 @@ QVariant SectionsModel::data(const QModelIndex &index, int role) const
return RAddressString(section.vaddr);
case SectionsModel::EndAddressColumn:
return RAddressString(section.vaddr + section.size);
case SectionsModel::EntropyColumn:
return section.entropy;
default:
return QVariant();
}
@ -85,6 +87,8 @@ QVariant SectionsModel::headerData(int section, Qt::Orientation, int role) const
return tr("Address");
case SectionsModel::EndAddressColumn:
return tr("EndAddress");
case SectionsModel::EntropyColumn:
return tr("Entropy");
default:
return QVariant();
}
@ -136,6 +140,9 @@ bool SectionsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &ri
case SectionsModel::AddressColumn:
case SectionsModel::EndAddressColumn:
return leftSection.vaddr < rightSection.vaddr;
case SectionsModel::EntropyColumn:
return leftSection.entropy < rightSection.entropy;
default:
break;
}

View File

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