mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-19 02:48:49 +00:00
Add entropy to Section widget (#480)
This commit is contained in:
parent
31c7289726
commit
eef5022469
@ -1164,7 +1164,10 @@ QList<SectionDescription> CutterCore::getAllSections()
|
|||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
QList<SectionDescription> ret;
|
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) {
|
for (QJsonValue value : sectionsArray) {
|
||||||
QJsonObject sectionObject = value.toObject();
|
QJsonObject sectionObject = value.toObject();
|
||||||
|
|
||||||
@ -1179,6 +1182,7 @@ QList<SectionDescription> CutterCore::getAllSections()
|
|||||||
section.paddr = sectionObject["paddr"].toVariant().toULongLong();
|
section.paddr = sectionObject["paddr"].toVariant().toULongLong();
|
||||||
section.size = sectionObject["size"].toVariant().toULongLong();
|
section.size = sectionObject["size"].toVariant().toULongLong();
|
||||||
section.flags = sectionObject["flags"].toString();
|
section.flags = sectionObject["flags"].toString();
|
||||||
|
section.entropy = sectionObject["entropy"].toString();
|
||||||
|
|
||||||
ret << section;
|
ret << section;
|
||||||
}
|
}
|
||||||
|
@ -165,6 +165,7 @@ struct SectionDescription {
|
|||||||
RVA vsize;
|
RVA vsize;
|
||||||
QString name;
|
QString name;
|
||||||
QString flags;
|
QString flags;
|
||||||
|
QString entropy;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EntrypointDescription {
|
struct EntrypointDescription {
|
||||||
|
@ -58,6 +58,8 @@ QVariant SectionsModel::data(const QModelIndex &index, int role) const
|
|||||||
return RAddressString(section.vaddr);
|
return RAddressString(section.vaddr);
|
||||||
case SectionsModel::EndAddressColumn:
|
case SectionsModel::EndAddressColumn:
|
||||||
return RAddressString(section.vaddr + section.size);
|
return RAddressString(section.vaddr + section.size);
|
||||||
|
case SectionsModel::EntropyColumn:
|
||||||
|
return section.entropy;
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -85,6 +87,8 @@ QVariant SectionsModel::headerData(int section, Qt::Orientation, int role) const
|
|||||||
return tr("Address");
|
return tr("Address");
|
||||||
case SectionsModel::EndAddressColumn:
|
case SectionsModel::EndAddressColumn:
|
||||||
return tr("EndAddress");
|
return tr("EndAddress");
|
||||||
|
case SectionsModel::EntropyColumn:
|
||||||
|
return tr("Entropy");
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -136,6 +140,9 @@ bool SectionsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &ri
|
|||||||
case SectionsModel::AddressColumn:
|
case SectionsModel::AddressColumn:
|
||||||
case SectionsModel::EndAddressColumn:
|
case SectionsModel::EndAddressColumn:
|
||||||
return leftSection.vaddr < rightSection.vaddr;
|
return leftSection.vaddr < rightSection.vaddr;
|
||||||
|
case SectionsModel::EntropyColumn:
|
||||||
|
return leftSection.entropy < rightSection.entropy;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ private:
|
|||||||
QList<SectionDescription> *sections;
|
QList<SectionDescription> *sections;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Column { NameColumn = 0, SizeColumn, AddressColumn, EndAddressColumn, ColumnCount };
|
enum Column { NameColumn = 0, SizeColumn, AddressColumn, EndAddressColumn, EntropyColumn, ColumnCount };
|
||||||
enum Role { SectionDescriptionRole = Qt::UserRole };
|
enum Role { SectionDescriptionRole = Qt::UserRole };
|
||||||
|
|
||||||
SectionsModel(QList<SectionDescription> *sections, QObject *parent = nullptr);
|
SectionsModel(QList<SectionDescription> *sections, QObject *parent = nullptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user