summaryrefslogtreecommitdiff
path: root/binaryviewtype.cpp
diff options
context:
space:
mode:
authorRyan Snyder <ryan@vector35.com>2021-08-04 11:17:40 -0400
committerRyan Snyder <ryan@vector35.com>2021-08-20 04:34:14 -0400
commitcc1e85a4a8b2001f9fd6cf91b93fb39abef3a0e2 (patch)
tree45fdf52d2bdb8e09f57fc76079a3a91b6528f4a1 /binaryviewtype.cpp
parentc1e526ea39d97c4c374de4cf8c211dc39ebbb538 (diff)
platforms: specify platform types and add bvt platform callbacks
Diffstat (limited to 'binaryviewtype.cpp')
-rw-r--r--binaryviewtype.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/binaryviewtype.cpp b/binaryviewtype.cpp
index b49191f8..3e0feae2 100644
--- a/binaryviewtype.cpp
+++ b/binaryviewtype.cpp
@@ -197,6 +197,23 @@ Ref<Platform> BinaryViewType::GetPlatform(uint32_t id, Architecture* arch)
}
+void BinaryViewType::RegisterPlatformRecognizer(uint64_t id, BNEndianness endian, const std::function<Ref<Platform>(BinaryView* view, Metadata* metadata)>& callback)
+{
+ PlatformRecognizerFunction* ctxt = new PlatformRecognizerFunction;
+ ctxt->action = callback;
+ BNRegisterPlatformRecognizerForViewType(m_object, id, endian, PlatformRecognizerCallback, ctxt);
+}
+
+
+Ref<Platform> BinaryViewType::RecognizePlatform(uint64_t id, BNEndianness endian, BinaryView* view, Metadata* metadata)
+{
+ BNPlatform* platform = BNRecognizePlatformForViewType(m_object, id, endian, view->GetObject(), metadata->GetObject());
+ if (!platform)
+ return nullptr;
+ return new Platform(platform);
+}
+
+
string BinaryViewType::GetName()
{
char* contents = BNGetBinaryViewTypeName(m_object);
@@ -244,6 +261,18 @@ void BinaryViewType::BinaryViewEventCallback(void* ctxt, BNBinaryView* view)
}
+BNPlatform* BinaryViewType::PlatformRecognizerCallback(void* ctxt, BNBinaryView* view, BNMetadata* metadata)
+{
+ PlatformRecognizerFunction* callback = (PlatformRecognizerFunction*) ctxt;
+ Ref<BinaryView> viewObject = new BinaryView(BNNewViewReference(view));
+ Ref<Metadata> metadataObject = new Metadata(BNNewMetadataReference(metadata));
+ Ref<Platform> result = callback->action(viewObject, metadataObject);
+ if (!result)
+ return nullptr;
+ return BNNewPlatformReference(result->GetObject());
+}
+
+
CoreBinaryViewType::CoreBinaryViewType(BNBinaryViewType* type): BinaryViewType(type)
{
}