From 3d7e682b9b62a51811e414a1969f5ba1252fd050 Mon Sep 17 00:00:00 2001 From: pancake Date: Thu, 27 Feb 2025 17:15:20 +0100 Subject: [PATCH] Fix build for latest r2-5.9.9 --- src/core/Iaito.cpp | 21 +++++++++++++-------- src/core/Iaito.h | 8 +++++++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/core/Iaito.cpp b/src/core/Iaito.cpp index 95dadfd3..6df88822 100644 --- a/src/core/Iaito.cpp +++ b/src/core/Iaito.cpp @@ -31,6 +31,11 @@ #else #define BO o #endif +#if R2_VERSION_NUMBER >= 50909 +#define ADDRESS_OF(x) (x)->addr +#else +#define ADDRESS_OF(x) (x)->offset +#endif Q_GLOBAL_STATIC(IaitoCore, uniqueInstance) @@ -409,13 +414,13 @@ QString IaitoCore::cmdHtml(const char *str) { CORE_LOCK(); - RVA offset = core->offset; + RVA offset = ADDRESS_OF (core); r_core_cmd0(core, "e scr.html=true;e scr.color=2"); char *res = r_core_cmd_str(core, str); r_core_cmd0(core, "e scr.html=false;e scr.color=0"); QString o = fromOwnedCharPtr(res); - if (offset != core->offset) { + if (offset != ADDRESS_OF (core)) { updateSeek(); } return o; @@ -425,11 +430,11 @@ QString IaitoCore::cmd(const char *str) { CORE_LOCK(); - RVA offset = core->offset; + RVA offset = ADDRESS_OF (core); char *res = r_core_cmd_str(core, str); QString o = fromOwnedCharPtr(res); - if (offset != core->offset) { + if (offset != ADDRESS_OF (core)) { updateSeek(); } return o; @@ -490,13 +495,13 @@ bool IaitoCore::asyncCmd(const char *str, QSharedPointer &task) CORE_LOCK(); - RVA offset = core->offset; + RVA offset = ADDRESS_OF (core); task = QSharedPointer(new R2Task(str, true)); connect(task.data(), &R2Task::finished, task.data(), [this, offset, task]() { CORE_LOCK(); - if (offset != core->offset) { + if (offset != ADDRESS_OF (core)) { updateSeek(); } }); @@ -991,7 +996,7 @@ void IaitoCore::seek(ut64 offset) // use cmd and not cmdRaw to make sure seekChanged is emitted cmd(QStringLiteral("s %1").arg(offset)); - // cmd already does emit seekChanged(core_->offset); + // cmd already does emit seekChanged(core_->addr); } void IaitoCore::showMemoryWidget() @@ -1070,7 +1075,7 @@ RVA IaitoCore::nextOpAddr(RVA startAddr, int count) RVA IaitoCore::getOffset() { - return core_->offset; + return ADDRESS_OF (core_); } ut64 IaitoCore::math(const QString &expr) diff --git a/src/core/Iaito.h b/src/core/Iaito.h index 04fce335..9f17c184 100644 --- a/src/core/Iaito.h +++ b/src/core/Iaito.h @@ -31,6 +31,12 @@ class R2TaskDialog; #include "common/R2Task.h" #include "dialogs/R2TaskDialog.h" +#if R2_VERSION_NUMBER >= 50909 +#define ADDRESS_OF(x) (x)->addr +#else +#define ADDRESS_OF(x) (x)->offset +#endif + #if __APPLE__ && QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #define QFILEDIALOG_FLAGS QFileDialog::DontUseNativeDialog #else @@ -65,7 +71,7 @@ class IAITO_EXPORT IaitoCore : public QObject AsyncTaskManager *getAsyncTaskManager() { return asyncTaskManager; } - RVA getOffset() const { return core_->offset; } + RVA getOffset() const { return ADDRESS_OF (core_); } /* Core functions (commands) */ static QString sanitizeStringForCommand(QString s);