mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-30 16:25:04 +00:00
Port Sections information to the Rizin API (#2785)
This commit is contained in:
parent
4061887bfe
commit
896be642ff
2
rizin
2
rizin
@ -1 +1 @@
|
|||||||
Subproject commit 5fda91650c1665ba06b0b5f9b36d4959e9fb5362
|
Subproject commit 18db8301a4cb3b3bc4ab026bcf9b822eb03f86e4
|
@ -3121,28 +3121,44 @@ QList<SectionDescription> CutterCore::getAllSections()
|
|||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
QList<SectionDescription> sections;
|
QList<SectionDescription> sections;
|
||||||
|
|
||||||
QJsonDocument sectionsDoc = cmdj("iSj entropy");
|
RzBinObject *o = rz_bin_cur_object(core->bin);
|
||||||
QJsonObject sectionsObj = sectionsDoc.object();
|
if (!o) {
|
||||||
QJsonArray sectionsArray = sectionsObj[RJsonKey::sections].toArray();
|
return sections;
|
||||||
|
}
|
||||||
|
|
||||||
for (const QJsonValue &value : sectionsArray) {
|
RzList *sects = rz_bin_object_get_sections(o);
|
||||||
QJsonObject sectionObject = value.toObject();
|
if (!sects) {
|
||||||
|
return sections;
|
||||||
QString name = sectionObject[RJsonKey::name].toString();
|
}
|
||||||
if (name.isEmpty())
|
RzList *hashnames = rz_list_newf(free);
|
||||||
|
if (!hashnames) {
|
||||||
|
return sections;
|
||||||
|
}
|
||||||
|
rz_list_push(hashnames, rz_str_new("entropy"));
|
||||||
|
RzListIter *it;
|
||||||
|
RzBinSection *sect;
|
||||||
|
CutterRzListForeach (sects, it, RzBinSection, sect) {
|
||||||
|
if (RZ_STR_ISEMPTY(sect->name))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SectionDescription section;
|
SectionDescription section;
|
||||||
section.name = name;
|
section.name = sect->name;
|
||||||
section.vaddr = sectionObject[RJsonKey::vaddr].toVariant().toULongLong();
|
section.vaddr = sect->vaddr;
|
||||||
section.vsize = sectionObject[RJsonKey::vsize].toVariant().toULongLong();
|
section.vsize = sect->vsize;
|
||||||
section.paddr = sectionObject[RJsonKey::paddr].toVariant().toULongLong();
|
section.paddr = sect->paddr;
|
||||||
section.size = sectionObject[RJsonKey::size].toVariant().toULongLong();
|
section.size = sect->size;
|
||||||
section.perm = sectionObject[RJsonKey::perm].toString();
|
section.perm = rz_str_rwx_i(sect->perm);
|
||||||
section.entropy = sectionObject[RJsonKey::entropy].toString();
|
HtPP *digests = rz_core_bin_section_digests(core, sect, hashnames);
|
||||||
|
if (!digests) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const char *entropy = (const char*)ht_pp_find(digests, "entropy", NULL);
|
||||||
|
section.entropy = rz_str_get(entropy);
|
||||||
|
ht_pp_free(digests);
|
||||||
|
|
||||||
sections << section;
|
sections << section;
|
||||||
}
|
}
|
||||||
|
rz_list_free(sects);
|
||||||
return sections;
|
return sections;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3151,9 +3167,19 @@ QStringList CutterCore::getSectionList()
|
|||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
|
|
||||||
QJsonArray sectionsArray = cmdj("iSj").array();
|
RzBinObject *o = rz_bin_cur_object(core->bin);
|
||||||
for (const QJsonValue &value : sectionsArray) {
|
if (!o) {
|
||||||
ret << value.toObject()[RJsonKey::name].toString();
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
RzList *sects = rz_bin_object_get_sections(o);
|
||||||
|
if (!sects) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
RzListIter *it;
|
||||||
|
RzBinSection *sect;
|
||||||
|
CutterRzListForeach (sects, it, RzBinSection, sect) {
|
||||||
|
ret << sect->name;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user