From e5652a742be1728708ad853377d02468da1ba657 Mon Sep 17 00:00:00 2001
From: Anton Kochkov <anton.kochkov@gmail.com>
Date: Fri, 1 Mar 2024 19:28:06 +0800
Subject: [PATCH 1/2] Do not use removed rz_bin_get_info() API

---
 src/common/BugReporting.cpp       |  3 ++-
 src/core/Cutter.cpp               | 33 ++++++++++++++++---------------
 src/core/Cutter.h                 |  2 +-
 src/dialogs/VersionInfoDialog.cpp |  6 +++++-
 src/widgets/Dashboard.cpp         |  5 +++--
 src/widgets/Dashboard.h           |  2 +-
 6 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/src/common/BugReporting.cpp b/src/common/BugReporting.cpp
index 95da855f1f..13463d00ea 100644
--- a/src/common/BugReporting.cpp
+++ b/src/common/BugReporting.cpp
@@ -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;
diff --git a/src/core/Cutter.cpp b/src/core/Cutter.cpp
index 3bce681ab9..6951e01a02 100644
--- a/src/core/Cutter.cpp
+++ b/src/core/Cutter.cpp
@@ -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());
@@ -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;
 }
 
@@ -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;
     }
@@ -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++);
@@ -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;
         }
diff --git a/src/core/Cutter.h b/src/core/Cutter.h
index 1ebf89f8d2..1715c4daeb 100644
--- a/src/core/Cutter.h
+++ b/src/core/Cutter.h
@@ -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);
diff --git a/src/dialogs/VersionInfoDialog.cpp b/src/dialogs/VersionInfoDialog.cpp
index dd43f23e73..9cd5e03c1e 100644
--- a/src/dialogs/VersionInfoDialog.cpp
+++ b/src/dialogs/VersionInfoDialog.cpp
@@ -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;
     }
diff --git a/src/widgets/Dashboard.cpp b/src/widgets/Dashboard.cpp
index 192aab302b..29a4317fc9 100644
--- a/src/widgets/Dashboard.cpp
+++ b/src/widgets/Dashboard.cpp
@@ -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 : "");
@@ -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) : "");
diff --git a/src/widgets/Dashboard.h b/src/widgets/Dashboard.h
index a7ee5c15db..758249d59b 100644
--- a/src/widgets/Dashboard.h
+++ b/src/widgets/Dashboard.h
@@ -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;

From d10508c373b18391f06a92d1cd2afe855aefed06 Mon Sep 17 00:00:00 2001
From: Anton Kochkov <anton.kochkov@gmail.com>
Date: Fri, 1 Mar 2024 20:53:37 +0800
Subject: [PATCH 2/2] Update Rizin to latest dev

---
 rizin | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rizin b/rizin
index 78d4043afb..4a0dca6613 160000
--- a/rizin
+++ b/rizin
@@ -1 +1 @@
-Subproject commit 78d4043afb39a56fe91ea7ab03c83da613319cc3
+Subproject commit 4a0dca66131de65ca10679e42e3adb5d39735ffa