summaryrefslogtreecommitdiff
path: root/binaryviewtype.cpp
diff options
context:
space:
mode:
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)
{
}