Skip to content

Commit

Permalink
Update Rizin to latest dev (#3352)
Browse files Browse the repository at this point in the history
  • Loading branch information
thestr4ng3r authored Jun 5, 2024
1 parent 38c683b commit fdfc719
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 67 deletions.
2 changes: 1 addition & 1 deletion rizin
Submodule rizin updated 247 files
58 changes: 24 additions & 34 deletions src/core/Cutter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,22 +295,25 @@ QList<QString> CutterCore::sdbList(QString path)
CORE_LOCK();
QList<QString> list = QList<QString>();
Sdb *root = sdb_ns_path(core->sdb, path.toUtf8().constData(), 0);
if (root) {
void *vsi;
ls_iter_t *iter;
ls_foreach(root->ns, iter, vsi)
{
SdbNs *nsi = (SdbNs *)vsi;
if (root && root->ns) {
for (const auto &nsi : CutterRzList<SdbNs>(root->ns)) {
list << nsi->name;
}
}
return list;
}

using SdbListPtr = std::unique_ptr<SdbList, decltype(&ls_free)>;
static SdbListPtr makeSdbListPtr(SdbList *list)
using PVectorPtr = std::unique_ptr<RzPVector, decltype(&rz_pvector_free)>;
static PVectorPtr makePVectorPtr(RzPVector *vec)
{
return { list, ls_free };
return { vec, rz_pvector_free };
}

static bool foreach_keys_cb(void *user, const SdbKv *kv)
{
auto list = reinterpret_cast<QList<QString> *>(user);
*list << kv->base.key;
return true;
}

QList<QString> CutterCore::sdbListKeys(QString path)
Expand All @@ -319,14 +322,7 @@ QList<QString> CutterCore::sdbListKeys(QString path)
QList<QString> list = QList<QString>();
Sdb *root = sdb_ns_path(core->sdb, path.toUtf8().constData(), 0);
if (root) {
void *vsi;
ls_iter_t *iter;
SdbListPtr l = makeSdbListPtr(sdb_foreach_list(root, false));
ls_foreach(l, iter, vsi)
{
SdbKv *nsi = (SdbKv *)vsi;
list << reinterpret_cast<char *>(nsi->base.key);
}
sdb_foreach(root, foreach_keys_cb, &list);
}
return list;
}
Expand All @@ -336,7 +332,7 @@ QString CutterCore::sdbGet(QString path, QString key)
CORE_LOCK();
Sdb *db = sdb_ns_path(core->sdb, path.toUtf8().constData(), 0);
if (db) {
const char *val = sdb_const_get(db, key.toUtf8().constData(), 0);
const char *val = sdb_const_get(db, key.toUtf8().constData());
if (val && *val)
return val;
}
Expand All @@ -349,7 +345,7 @@ bool CutterCore::sdbSet(QString path, QString key, QString val)
Sdb *db = sdb_ns_path(core->sdb, path.toUtf8().constData(), 1);
if (!db)
return false;
return sdb_set(db, key.toUtf8().constData(), val.toUtf8().constData(), 0);
return sdb_set(db, key.toUtf8().constData(), val.toUtf8().constData());
}

QString CutterCore::sanitizeStringForCommand(QString s)
Expand Down Expand Up @@ -3616,21 +3612,14 @@ QList<QString> CutterCore::getAllAnalysisClasses(bool sorted)
{
CORE_LOCK();
QList<QString> ret;

SdbListPtr l = makeSdbListPtr(rz_analysis_class_get_all(core->analysis, sorted));
PVectorPtr l = makePVectorPtr(rz_analysis_class_get_all(core->analysis, sorted));
if (!l) {
return ret;
}
ret.reserve(static_cast<int>(l->length));

SdbListIter *it;
void *entry;
ls_foreach(l, it, entry)
{
auto kv = reinterpret_cast<SdbKv *>(entry);
ret.reserve(static_cast<int>(rz_pvector_len(l.get())));
for (const auto &kv : CutterPVector<SdbKv>(l.get())) {
ret.append(QString::fromUtf8(reinterpret_cast<const char *>(kv->base.key)));
}

return ret;
}

Expand Down Expand Up @@ -4371,13 +4360,14 @@ QStringList CutterCore::getColorThemes()
{
QStringList r;
CORE_LOCK();
RzList *themes_list = rz_core_theme_list(core);
RzListIter *it;
const char *th;
CutterRzListForeach (themes_list, it, const char, th) {
RzPVector *themes_list = rz_core_get_themes(core);
if (!themes_list) {
return r;
}
for (const auto &th : CutterPVector<char>(themes_list)) {
r << fromOwnedCharPtr(rz_str_trim_dup(th));
}
rz_list_free(themes_list);
rz_pvector_free(themes_list);
return r;
}

Expand Down
50 changes: 25 additions & 25 deletions src/dialogs/VersionInfoDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ void VersionInfoDialog::fillVersionInfo()
// Left tree
QTreeWidgetItem *addrItemL = new QTreeWidgetItem();
addrItemL->setText(0, "Address:");
addrItemL->setText(1, RzAddressString(sdb_num_get(sdb, "addr", 0)));
addrItemL->setText(1, RzAddressString(sdb_num_get(sdb, "addr")));
ui->leftTreeWidget->addTopLevelItem(addrItemL);

QTreeWidgetItem *offItemL = new QTreeWidgetItem();
offItemL->setText(0, "Offset:");
offItemL->setText(1, RzAddressString(sdb_num_get(sdb, "offset", 0)));
offItemL->setText(1, RzAddressString(sdb_num_get(sdb, "offset")));
ui->leftTreeWidget->addTopLevelItem(offItemL);

QTreeWidgetItem *entriesItemL = new QTreeWidgetItem();
entriesItemL->setText(0, "Entries:");
const ut64 num_entries = sdb_num_get(sdb, "num_entries", 0);
const ut64 num_entries = sdb_num_get(sdb, "num_entries");
for (size_t i = 0; i < num_entries; ++i) {
auto key = QString("entry%0").arg(i);
const char *const value = sdb_const_get(sdb, key.toStdString().c_str(), 0);
const char *const value = sdb_const_get(sdb, key.toStdString().c_str());
if (!value) {
continue;
}
Expand All @@ -77,12 +77,12 @@ void VersionInfoDialog::fillVersionInfo()
// Right tree
QTreeWidgetItem *addrItemR = new QTreeWidgetItem();
addrItemR->setText(0, "Address:");
addrItemR->setText(1, RzAddressString(sdb_num_get(sdb, "addr", 0)));
addrItemR->setText(1, RzAddressString(sdb_num_get(sdb, "addr")));
ui->rightTreeWidget->addTopLevelItem(addrItemR);

QTreeWidgetItem *offItemR = new QTreeWidgetItem();
offItemR->setText(0, "Offset:");
offItemR->setText(1, RzAddressString(sdb_num_get(sdb, "offset", 0)));
offItemR->setText(1, RzAddressString(sdb_num_get(sdb, "offset")));
ui->rightTreeWidget->addTopLevelItem(offItemR);

QTreeWidgetItem *entriesItemR = new QTreeWidgetItem();
Expand All @@ -94,13 +94,13 @@ void VersionInfoDialog::fillVersionInfo()
if (!sdb) {
break;
}
const char *filename = sdb_const_get(sdb, "file_name", 0);
const char *filename = sdb_const_get(sdb, "file_name");
auto *parentItem = new QTreeWidgetItem();
parentItem->setText(0, RzAddressString(sdb_num_get(sdb, "idx", 0)));
parentItem->setText(0, RzAddressString(sdb_num_get(sdb, "idx")));
parentItem->setText(1,
QString("Version: %0\t"
"File: %1")
.arg(QString::number(sdb_num_get(sdb, "vn_version", 0)),
.arg(QString::number(sdb_num_get(sdb, "vn_version")),
QString(filename)));

int num_vernaux = 0;
Expand All @@ -113,13 +113,13 @@ void VersionInfoDialog::fillVersionInfo()
}

auto *childItem = new QTreeWidgetItem();
childItem->setText(0, RzAddressString(sdb_num_get(sdb, "idx", 0)));
childItem->setText(0, RzAddressString(sdb_num_get(sdb, "idx")));
QString childString =
QString("Name: %0\t"
"Flags: %1\t"
"Version: %2\t")
.arg(sdb_const_get(sdb, "name", 0), sdb_const_get(sdb, "flags", 0),
QString::number(sdb_num_get(sdb, "version", 0)));
.arg(sdb_const_get(sdb, "name"), sdb_const_get(sdb, "flags"),
QString::number(sdb_num_get(sdb, "version")));
childItem->setText(1, childString);
parentItem->addChild(childItem);
}
Expand All @@ -144,15 +144,15 @@ void VersionInfoDialog::fillVersionInfo()
if (!sdb) {
return;
}
ut32 file_version_ms = sdb_num_get(sdb, "FileVersionMS", 0);
ut32 file_version_ls = sdb_num_get(sdb, "FileVersionLS", 0);
ut32 file_version_ms = sdb_num_get(sdb, "FileVersionMS");
ut32 file_version_ls = sdb_num_get(sdb, "FileVersionLS");
auto file_version = QString("%0.%1.%2.%3")
.arg(file_version_ms >> 16)
.arg(file_version_ms & 0xFFFF)
.arg(file_version_ls >> 16)
.arg(file_version_ls & 0xFFFF);
ut32 product_version_ms = sdb_num_get(sdb, "ProductVersionMS", 0);
ut32 product_version_ls = sdb_num_get(sdb, "ProductVersionLS", 0);
ut32 product_version_ms = sdb_num_get(sdb, "ProductVersionMS");
ut32 product_version_ls = sdb_num_get(sdb, "ProductVersionLS");
auto product_version = QString("%0.%1.%2.%3")
.arg(product_version_ms >> 16)
.arg(product_version_ms & 0xFFFF)
Expand All @@ -161,12 +161,12 @@ void VersionInfoDialog::fillVersionInfo()

auto item = new QTreeWidgetItem();
item->setText(0, "Signature");
item->setText(1, RzHexString(sdb_num_get(sdb, "Signature", 0)));
item->setText(1, RzHexString(sdb_num_get(sdb, "Signature")));
ui->leftTreeWidget->addTopLevelItem(item);

item = new QTreeWidgetItem();
item->setText(0, "StrucVersion");
item->setText(1, RzHexString(sdb_num_get(sdb, "StrucVersion", 0)));
item->setText(1, RzHexString(sdb_num_get(sdb, "StrucVersion")));
ui->leftTreeWidget->addTopLevelItem(item);

item = new QTreeWidgetItem();
Expand All @@ -181,27 +181,27 @@ void VersionInfoDialog::fillVersionInfo()

item = new QTreeWidgetItem();
item->setText(0, "FileFlagsMask");
item->setText(1, RzHexString(sdb_num_get(sdb, "FileFlagsMask", 0)));
item->setText(1, RzHexString(sdb_num_get(sdb, "FileFlagsMask")));
ui->leftTreeWidget->addTopLevelItem(item);

item = new QTreeWidgetItem();
item->setText(0, "FileFlags");
item->setText(1, RzHexString(sdb_num_get(sdb, "FileFlags", 0)));
item->setText(1, RzHexString(sdb_num_get(sdb, "FileFlags")));
ui->leftTreeWidget->addTopLevelItem(item);

item = new QTreeWidgetItem();
item->setText(0, "FileOS");
item->setText(1, RzHexString(sdb_num_get(sdb, "FileOS", 0)));
item->setText(1, RzHexString(sdb_num_get(sdb, "FileOS")));
ui->leftTreeWidget->addTopLevelItem(item);

item = new QTreeWidgetItem();
item->setText(0, "FileType");
item->setText(1, RzHexString(sdb_num_get(sdb, "FileType", 0)));
item->setText(1, RzHexString(sdb_num_get(sdb, "FileType")));
ui->leftTreeWidget->addTopLevelItem(item);

item = new QTreeWidgetItem();
item->setText(0, "FileSubType");
item->setText(1, RzHexString(sdb_num_get(sdb, "FileSubType", 0)));
item->setText(1, RzHexString(sdb_num_get(sdb, "FileSubType")));
ui->leftTreeWidget->addTopLevelItem(item);

// Adjust columns to content
Expand All @@ -224,8 +224,8 @@ void VersionInfoDialog::fillVersionInfo()
}
int lenkey = 0;
int lenval = 0;
ut8 *key_utf16 = sdb_decode(sdb_const_get(sdb, "key", 0), &lenkey);
ut8 *val_utf16 = sdb_decode(sdb_const_get(sdb, "value", 0), &lenval);
ut8 *key_utf16 = sdb_decode(sdb_const_get(sdb, "key"), &lenkey);
ut8 *val_utf16 = sdb_decode(sdb_const_get(sdb, "value"), &lenval);
item = new QTreeWidgetItem();
item->setText(0, QString::fromUtf16(reinterpret_cast<const ushort *>(key_utf16)));
item->setText(1, QString::fromUtf16(reinterpret_cast<const ushort *>(val_utf16)));
Expand Down
8 changes: 4 additions & 4 deletions src/tools/basefind/BaseFindDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ BaseFindDialog::BaseFindDialog(QWidget *parent) : QDialog(parent), ui(new Ui::Ba
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));

// Fill in N-thread Combo
size_t n_cores = rz_th_physical_core_number();
RzThreadNCores n_cores = rz_th_physical_core_number();
ui->nCoresCombo->clear();
for (size_t i = n_cores; i > 0; i--) {
if (n_cores == i) {
Expand All @@ -36,10 +36,10 @@ BaseFindDialog::BaseFindDialog(QWidget *parent) : QDialog(parent), ui(new Ui::Ba

BaseFindDialog::~BaseFindDialog() {}

size_t BaseFindDialog::getNCores() const
RzThreadNCores BaseFindDialog::getNCores() const
{
size_t n_cores = rz_th_physical_core_number();
return n_cores - ui->nCoresCombo->currentIndex();
RzThreadNCores n_cores = rz_th_physical_core_number();
return static_cast<RzThreadNCores>(n_cores - ui->nCoresCombo->currentIndex());
}

ut32 BaseFindDialog::getPointerSize() const
Expand Down
2 changes: 1 addition & 1 deletion src/tools/basefind/BaseFindDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class BaseFindDialog : public QDialog
explicit BaseFindDialog(QWidget *parent = nullptr);
~BaseFindDialog();

size_t getNCores() const;
RzThreadNCores getNCores() const;
ut32 getPointerSize() const;
RVA getStartAddress() const;
RVA getEndAddress() const;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/basefind/BaseFindSearchDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ BaseFindSearchDialog::~BaseFindSearchDialog() {}

void BaseFindSearchDialog::show(RzBaseFindOpt *opts)
{
size_t n_cores = rz_th_physical_core_number();
RzThreadNCores n_cores = rz_th_physical_core_number();
if (opts->max_threads > n_cores || opts->max_threads < 1) {
opts->max_threads = n_cores;
}
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/Dashboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void Dashboard::updateContents()
if (bf) {
setPlainText(this->ui->compilationDateEdit, rz_core_bin_get_compile_time(bf));
if (bf->o) {
char *relco_buf = sdb_get(bf->o->kv, "elf.relro", 0);
char *relco_buf = sdb_get(bf->o->kv, "elf.relro");
if (RZ_STR_ISNOTEMPTY(relco_buf)) {
QString relro = QString(relco_buf).section(QLatin1Char(' '), 0, 0);
relro[0] = relro[0].toUpper();
Expand Down

0 comments on commit fdfc719

Please sign in to comment.