Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use removed Rizin APIs #3309

Merged
merged 2 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rizin
Submodule rizin updated 113 files
3 changes: 2 additions & 1 deletion src/common/BugReporting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ void openIssue()
{
RzCoreLocked core(Core());
RzBinFile *bf = rz_bin_cur(core->bin);
RzBinInfo *info = rz_bin_get_info(core->bin);
RzBinObject *bobj = rz_bin_cur_object(core->bin);
const RzBinInfo *info = bobj ? rz_bin_object_get_info(bobj) : nullptr;
RzBinPlugin *plugin = rz_bin_file_cur_plugin(bf);

QString url, osInfo, format, arch, type;
Expand Down
33 changes: 17 additions & 16 deletions src/core/Cutter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ CutterJson CutterCore::parseJson(const char *name, char *res, const char *cmd)
return CutterJson(doc, QSharedPointer<CutterJsonOwner>::create(doc, res));
}

QStringList CutterCore::autocomplete(const QString &cmd, RzLinePromptType promptType, size_t limit)
QStringList CutterCore::autocomplete(const QString &cmd, RzLinePromptType promptType)
{
RzLineBuffer buf;
int c = snprintf(buf.data, sizeof(buf.data), "%s", cmd.toUtf8().constData());
Expand All @@ -526,18 +526,17 @@ QStringList CutterCore::autocomplete(const QString &cmd, RzLinePromptType prompt
}
buf.index = buf.length = std::min((int)(sizeof(buf.data) - 1), c);

RzLineCompletion completion;
rz_line_completion_init(&completion, limit);
rz_core_autocomplete(core(), &completion, &buf, promptType);
RzLineNSCompletionResult *compr = rz_core_autocomplete_rzshell(core(), &buf, promptType);

QStringList r;
r.reserve(rz_pvector_len(&completion.args));
for (size_t i = 0; i < rz_pvector_len(&completion.args); i++) {
auto optslen = rz_pvector_len(&compr->options);
r.reserve(optslen);
for (size_t i = 0; i < optslen; i++) {
r.push_back(QString::fromUtf8(
reinterpret_cast<const char *>(rz_pvector_at(&completion.args, i))));
reinterpret_cast<const char *>(rz_pvector_at(&compr->options, i))));
}
rz_line_ns_completion_result_free(compr);

rz_line_completion_fini(&completion);
return r;
}

Expand Down Expand Up @@ -1377,7 +1376,11 @@ CutterJson CutterCore::getSignatureInfo()
bool CutterCore::existsFileInfo()
{
CORE_LOCK();
const RzBinInfo *info = rz_bin_get_info(core->bin);
RzBinObject *bobj = rz_bin_cur_object(core->bin);
if (!bobj) {
return false;
}
const RzBinInfo *info = rz_bin_object_get_info(bobj);
if (!(info && info->rclass)) {
return false;
}
Expand Down Expand Up @@ -3179,11 +3182,11 @@ QList<SymbolDescription> CutterCore::getAllSymbols()
}
}

const RzList *entries = rz_bin_object_get_entries(bf->o);
if (entries) {
const RzPVector *entries = rz_bin_object_get_entries(bf->o);
if (symbols) {
/* list entrypoints as symbols too */
int n = 0;
for (const auto &entry : CutterRzList<RzBinSymbol>(entries)) {
for (const auto &entry : CutterPVector<RzBinAddr>(entries)) {
SymbolDescription symbol;
symbol.vaddr = entry->vaddr;
symbol.name = QString("entry") + QString::number(n++);
Expand Down Expand Up @@ -3496,10 +3499,8 @@ QList<EntrypointDescription> CutterCore::getAllEntrypoint()
ut64 laddr = rz_bin_get_laddr(core->bin);

QList<EntrypointDescription> qList;
const RzList *entries = rz_bin_object_get_entries(bf->o);
RzListIter *iter;
RzBinAddr *entry;
CutterRzListForeach (entries, iter, RzBinAddr, entry) {
const RzPVector *entries = rz_bin_object_get_entries(bf->o);
for (const auto &entry : CutterPVector<RzBinAddr>(entries)) {
if (entry->type != RZ_BIN_ENTRY_TYPE_PROGRAM) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/Cutter.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class CUTTER_EXPORT CutterCore : public QObject
return parseJson(name, res, cmd.isNull() ? nullptr : cmd.toLocal8Bit().constData());
}

QStringList autocomplete(const QString &cmd, RzLinePromptType promptType, size_t limit = 4096);
QStringList autocomplete(const QString &cmd, RzLinePromptType promptType);

/* Functions methods */
void renameFunction(const RVA offset, const QString &newName);
Expand Down
6 changes: 5 additions & 1 deletion src/dialogs/VersionInfoDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ VersionInfoDialog::~VersionInfoDialog() {}
void VersionInfoDialog::fillVersionInfo()
{
RzCoreLocked core(Core());
const RzBinInfo *info = rz_bin_get_info(core->bin);
RzBinObject *bobj = rz_bin_cur_object(core->bin);
if (!bobj) {
return;
}
const RzBinInfo *info = rz_bin_object_get_info(bobj);
if (!info || !info->rclass) {
return;
}
Expand Down
5 changes: 3 additions & 2 deletions src/widgets/Dashboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ void Dashboard::updateContents()
}

// Add file hashes, analysis info and libraries
RzBinInfo *binInfo = rz_bin_get_info(core->bin);
RzBinObject *bobj = rz_bin_cur_object(core->bin);
const RzBinInfo *binInfo = bobj ? rz_bin_object_get_info(bobj) : nullptr;

setPlainText(ui->fileEdit, binInfo ? binInfo->file : "");
setPlainText(ui->formatEdit, binInfo ? binInfo->rclass : "");
Expand Down Expand Up @@ -211,7 +212,7 @@ void Dashboard::setPlainText(QLineEdit *textBox, const QString &text)
* @brief Setting boolean values of binary information in dashboard
* @param RzBinInfo
*/
void Dashboard::setRzBinInfo(RzBinInfo *binInfo)
void Dashboard::setRzBinInfo(const RzBinInfo *binInfo)
{
setPlainText(ui->vaEdit, binInfo ? setBoolText(binInfo->has_va) : "");
setPlainText(ui->canaryEdit, binInfo ? setBoolText(binInfo->has_canary) : "");
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/Dashboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private slots:
private:
std::unique_ptr<Ui::Dashboard> ui;
void setPlainText(QLineEdit *textBox, const QString &text);
void setRzBinInfo(RzBinInfo *binInfo);
void setRzBinInfo(const RzBinInfo *binInfo);
const char *setBoolText(bool value);

QWidget *hashesWidget = nullptr;
Expand Down
Loading