summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--binaryninjaapi.cpp30
-rw-r--r--binaryninjaapi.h28
-rw-r--r--pluginmanager.cpp22
3 files changed, 74 insertions, 6 deletions
diff --git a/binaryninjaapi.cpp b/binaryninjaapi.cpp
index 54ee97ad..f526320a 100644
--- a/binaryninjaapi.cpp
+++ b/binaryninjaapi.cpp
@@ -203,6 +203,36 @@ string BinaryNinja::GetVersionString()
}
+VersionInfo BinaryNinja::GetVersionInfo()
+{
+ BNVersionInfo result = BNGetVersionInfo();
+ VersionInfo info;
+ info.major = result.major;
+ info.minor = result.minor;
+ info.build = result.build;
+ info.channel = "";
+ if (result.channel)
+ info.channel = result.channel;
+ BNFreeString(result.channel);
+ return info;
+}
+
+
+VersionInfo ParseVersionString(const string &version)
+{
+ BNVersionInfo result = BNParseVersionString(version.c_str());
+ VersionInfo info;
+ info.major = result.major;
+ info.minor = result.minor;
+ info.build = result.build;
+ info.channel = "";
+ if (result.channel)
+ info.channel = result.channel;
+ BNFreeString(result.channel);
+ return info;
+}
+
+
string BinaryNinja::GetLicensedUserEmail()
{
char* str = BNGetLicensedUserEmail();
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 680b9592..e2275fdc 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -1156,6 +1156,28 @@ namespace BinaryNinja {
@addtogroup coreapi
@{
*/
+ struct VersionInfo
+ {
+ uint32_t major {};
+ uint32_t minor {};
+ uint32_t build {};
+ std::string channel;
+
+ VersionInfo() = default;
+
+ bool operator<(const VersionInfo &other) const
+ {
+ char* smallerChan = BNAllocString(channel.c_str());
+ char* largerChan = BNAllocString(other.channel.c_str());
+ BNVersionInfo smaller = { major, minor, build, smallerChan };
+ BNVersionInfo larger = { other.major, other.minor, other.build, largerChan };
+ bool result = BNVersionLessThan(smaller, larger);
+ BNFreeString(smallerChan);
+ BNFreeString(largerChan);
+ return result;
+ }
+ };
+
std::string EscapeString(const std::string& s);
std::string UnescapeString(const std::string& s);
@@ -1192,6 +1214,8 @@ namespace BinaryNinja {
std::string& output, std::string& errors, bool stdoutIsText = false, bool stderrIsText = true);
std::string GetVersionString();
+ VersionInfo GetVersionInfo();
+ VersionInfo ParseVersionString(const std::string& version);
std::string GetLicensedUserEmail();
std::string GetProduct();
std::string GetProductType();
@@ -16836,8 +16860,8 @@ namespace BinaryNinja {
std::string GetCommit() const;
std::string GetRepository() const;
std::string GetProjectData();
- BNVersionInfo GetMinimumVersionInfo() const;
- BNVersionInfo GetMaximumVersionInfo() const;
+ VersionInfo GetMinimumVersionInfo() const;
+ VersionInfo GetMaximumVersionInfo() const;
uint64_t GetLastUpdate();
bool IsViewOnly() const;
bool IsBeingDeleted() const;
diff --git a/pluginmanager.cpp b/pluginmanager.cpp
index 3e3e2033..f1e674e1 100644
--- a/pluginmanager.cpp
+++ b/pluginmanager.cpp
@@ -80,14 +80,28 @@ string RepoPlugin::GetLongdescription() const
RETURN_STRING(BNPluginGetLongdescription(m_object));
}
-BNVersionInfo RepoPlugin::GetMinimumVersionInfo() const
+VersionInfo RepoPlugin::GetMinimumVersionInfo() const
{
- return BNPluginGetMinimumVersionInfo(m_object);
+ auto coreInfo = BNPluginGetMinimumVersionInfo(m_object);
+ VersionInfo result;
+ result.major = coreInfo.major;
+ result.minor = coreInfo.minor;
+ result.build = coreInfo.build;
+ result.channel = coreInfo.channel;
+ BNFreeString(coreInfo.channel);
+ return result;
}
-BNVersionInfo RepoPlugin::GetMaximumVersionInfo() const
+VersionInfo RepoPlugin::GetMaximumVersionInfo() const
{
- return BNPluginGetMaximumVersionInfo(m_object);
+ auto coreInfo = BNPluginGetMaximumVersionInfo(m_object);
+ VersionInfo result;
+ result.major = coreInfo.major;
+ result.minor = coreInfo.minor;
+ result.build = coreInfo.build;
+ result.channel = coreInfo.channel;
+ BNFreeString(coreInfo.channel);
+ return result;
}
string RepoPlugin::GetName() const