diff --git a/rizin b/rizin index 5fda9165..18db8301 160000 --- a/rizin +++ b/rizin @@ -1 +1 @@ -Subproject commit 5fda91650c1665ba06b0b5f9b36d4959e9fb5362 +Subproject commit 18db8301a4cb3b3bc4ab026bcf9b822eb03f86e4 diff --git a/src/core/Cutter.cpp b/src/core/Cutter.cpp index 82e899ee..fd0cf0c2 100644 --- a/src/core/Cutter.cpp +++ b/src/core/Cutter.cpp @@ -3121,28 +3121,44 @@ QList CutterCore::getAllSections() CORE_LOCK(); QList sections; - QJsonDocument sectionsDoc = cmdj("iSj entropy"); - QJsonObject sectionsObj = sectionsDoc.object(); - QJsonArray sectionsArray = sectionsObj[RJsonKey::sections].toArray(); + RzBinObject *o = rz_bin_cur_object(core->bin); + if (!o) { + return sections; + } - for (const QJsonValue &value : sectionsArray) { - QJsonObject sectionObject = value.toObject(); - - QString name = sectionObject[RJsonKey::name].toString(); - if (name.isEmpty()) + RzList *sects = rz_bin_object_get_sections(o); + if (!sects) { + return sections; + } + 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; SectionDescription section; - section.name = name; - section.vaddr = sectionObject[RJsonKey::vaddr].toVariant().toULongLong(); - section.vsize = sectionObject[RJsonKey::vsize].toVariant().toULongLong(); - section.paddr = sectionObject[RJsonKey::paddr].toVariant().toULongLong(); - section.size = sectionObject[RJsonKey::size].toVariant().toULongLong(); - section.perm = sectionObject[RJsonKey::perm].toString(); - section.entropy = sectionObject[RJsonKey::entropy].toString(); + section.name = sect->name; + section.vaddr = sect->vaddr; + section.vsize = sect->vsize; + section.paddr = sect->paddr; + section.size = sect->size; + section.perm = rz_str_rwx_i(sect->perm); + 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; } + rz_list_free(sects); return sections; } @@ -3151,9 +3167,19 @@ QStringList CutterCore::getSectionList() CORE_LOCK(); QStringList ret; - QJsonArray sectionsArray = cmdj("iSj").array(); - for (const QJsonValue &value : sectionsArray) { - ret << value.toObject()[RJsonKey::name].toString(); + RzBinObject *o = rz_bin_cur_object(core->bin); + if (!o) { + 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; }