summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkat <kat@vector35.com>2024-07-24 11:15:31 -0400
committerkat <kat@vector35.com>2024-07-24 11:30:01 -0400
commit892a0729a587d3a4e8ac248e4eee8a73c7ccc5d1 (patch)
tree318cd5a947b4c1feb9ca84c92f3a457338eeb93d
parentdfca98643532126fa78999192900d37b654e46ff (diff)
Add Platform::GetRelatedPlatforms
-rw-r--r--binaryninjaapi.h5
-rw-r--r--binaryninjacore.h1
-rw-r--r--platform.cpp16
-rw-r--r--python/platform.py15
4 files changed, 37 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index a6e433a3..49f57fad 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -14803,6 +14803,11 @@ namespace BinaryNinja {
Ref<Platform> GetRelatedPlatform(Architecture* arch);
void AddRelatedPlatform(Architecture* arch, Platform* platform);
+ /*! Get the list of related platforms for this platform
+
+ \return A vector of Ref<Platform>s
+ */
+ std::vector<Ref<Platform>> GetRelatedPlatforms();
Ref<Platform> GetAssociatedPlatformByAddress(uint64_t& addr);
/*! Get the list of platform-specific types
diff --git a/binaryninjacore.h b/binaryninjacore.h
index a55c6ff0..18bd2faf 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -6465,6 +6465,7 @@ extern "C"
BINARYNINJACOREAPI BNPlatform* BNGetRelatedPlatform(BNPlatform* platform, BNArchitecture* arch);
BINARYNINJACOREAPI void BNAddRelatedPlatform(BNPlatform* platform, BNArchitecture* arch, BNPlatform* related);
+ BINARYNINJACOREAPI BNPlatform** BNGetRelatedPlatforms(BNPlatform* platform, size_t* count);
BINARYNINJACOREAPI BNPlatform* BNGetAssociatedPlatformByAddress(BNPlatform* platform, uint64_t* addr);
BINARYNINJACOREAPI BNTypeContainer* BNGetPlatformTypeContainer(BNPlatform* platform);
diff --git a/platform.cpp b/platform.cpp
index 55044595..dc01b5ae 100644
--- a/platform.cpp
+++ b/platform.cpp
@@ -532,6 +532,22 @@ void Platform::AddRelatedPlatform(Architecture* arch, Platform* platform)
}
+std::vector<Ref<Platform>> Platform::GetRelatedPlatforms()
+{
+ size_t count;
+ BNPlatform** related = BNGetRelatedPlatforms(m_object, &count);
+
+ std::vector<Ref<Platform>> result;
+ for (size_t i = 0; i < count; i++)
+ {
+ result.push_back(new CorePlatform(BNNewPlatformReference(related[i])));
+ }
+
+ BNFreePlatformList(related, count);
+ return result;
+}
+
+
Ref<Platform> Platform::GetAssociatedPlatformByAddress(uint64_t& addr)
{
BNPlatform* platform = BNGetAssociatedPlatformByAddress(m_object, &addr);
diff --git a/python/platform.py b/python/platform.py
index 72f08341..767af952 100644
--- a/python/platform.py
+++ b/python/platform.py
@@ -546,6 +546,21 @@ class Platform(metaclass=_PlatformMetaClass):
return None
return CorePlatform._from_cache(handle=result)
+ def get_related_platforms(self) -> List['Platform']:
+ """
+ ``get_related_platforms`` returns a list of all related platforms for a given platform
+
+ :return:
+ """
+ count = ctypes.c_ulonglong()
+ platforms = core.BNGetRelatedPlatforms(self.handle, count)
+ assert platforms is not None, "core.BNGetRelatedPlatforms returned None"
+ result = []
+ for i in range(0, count.value):
+ result.append(CorePlatform._from_cache(core.BNNewPlatformReference(platforms[i])))
+ core.BNFreePlatformList(platforms, count.value)
+ return result
+
def add_related_platform(self, arch, platform):
core.BNAddRelatedPlatform(self.handle, arch.handle, platform.handle)