summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--binaryninjaapi.h3
-rw-r--r--binaryninjacore.h3
-rw-r--r--binaryviewtype.cpp4
-rw-r--r--filemetadata.cpp13
-rw-r--r--python/binaryview.py5
-rw-r--r--python/filemetadata.py11
m---------suite/binaries0
-rw-r--r--suite/testcommon.py18
8 files changed, 56 insertions, 1 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 96500934..7e956161 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -940,6 +940,7 @@ __attribute__ ((format (printf, 1, 2)))
bool Navigate(const std::string& view, uint64_t offset);
BinaryNinja::Ref<BinaryNinja::BinaryView> GetViewOfType(const std::string& name);
+ std::vector<std::string> GetExistingViews() const;
};
class Function;
@@ -1832,6 +1833,8 @@ __attribute__ ((format (printf, 1, 2)))
std::string GetName();
std::string GetLongName();
+ bool IsDeprecated();
+
virtual BinaryView* Create(BinaryView* data) = 0;
virtual BinaryView* Parse(BinaryView* data) = 0;
virtual bool IsTypeValidForData(BinaryView* data) = 0;
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 189a3ea2..db88c2ff 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -2618,6 +2618,8 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI bool BNNavigate(BNFileMetadata* file, const char* view, uint64_t offset);
BINARYNINJACOREAPI BNBinaryView* BNGetFileViewOfType(BNFileMetadata* file, const char* name);
+
+ BINARYNINJACOREAPI char** BNGetExistingViews(BNFileMetadata* file, size_t* count);
// Binary view access
BINARYNINJACOREAPI BNBinaryView* BNNewViewReference(BNBinaryView* view);
@@ -2764,6 +2766,7 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI void BNFreeBinaryViewTypeList(BNBinaryViewType** types);
BINARYNINJACOREAPI char* BNGetBinaryViewTypeName(BNBinaryViewType* type);
BINARYNINJACOREAPI char* BNGetBinaryViewTypeLongName(BNBinaryViewType* type);
+ BINARYNINJACOREAPI bool BNIsBinaryViewTypeDeprecated(BNBinaryViewType* type);
BINARYNINJACOREAPI BNBinaryView* BNCreateBinaryViewOfType(BNBinaryViewType* type, BNBinaryView* data);
BINARYNINJACOREAPI BNBinaryView* BNParseBinaryViewOfType(BNBinaryViewType* type, BNBinaryView* data);
BINARYNINJACOREAPI bool BNIsBinaryViewTypeValidForData(BNBinaryViewType* type, BNBinaryView* data);
diff --git a/binaryviewtype.cpp b/binaryviewtype.cpp
index f8f58da0..8b0f8007 100644
--- a/binaryviewtype.cpp
+++ b/binaryviewtype.cpp
@@ -214,6 +214,10 @@ string BinaryViewType::GetLongName()
return result;
}
+bool BinaryViewType::IsDeprecated()
+{
+ return BNIsBinaryViewTypeDeprecated(m_object);
+}
CoreBinaryViewType::CoreBinaryViewType(BNBinaryViewType* type): BinaryViewType(type)
{
diff --git a/filemetadata.cpp b/filemetadata.cpp
index 956205bb..3af4cf6e 100644
--- a/filemetadata.cpp
+++ b/filemetadata.cpp
@@ -349,6 +349,19 @@ Ref<BinaryView> FileMetadata::GetViewOfType(const string& name)
return new BinaryView(view);
}
+std::vector<std::string> FileMetadata::GetExistingViews() const
+{
+ size_t count;
+ char** views = BNGetExistingViews(m_object, &count);
+ vector<string> result;
+ result.reserve(count);
+
+ for (size_t i = 0; i < count; i++)
+ result.push_back(string(views[i]));
+
+ BNFreeStringList(views, count);
+ return result;
+}
SaveSettings::SaveSettings()
{
diff --git a/python/binaryview.py b/python/binaryview.py
index b7f5b745..e7c39641 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -731,6 +731,11 @@ class BinaryViewType(with_metaclass(_BinaryViewTypeMetaclass, object)):
"""BinaryView long name (read-only)"""
return core.BNGetBinaryViewTypeLongName(self.handle)
+ @property
+ def is_deprecated(self):
+ """returns if the BinaryViewType is deprecated (read-only)"""
+ return core.BNIsBinaryViewTypeDeprecated(self.handle)
+
def create(self, data):
view = core.BNCreateBinaryViewOfType(self.handle, data.handle)
if view is None:
diff --git a/python/filemetadata.py b/python/filemetadata.py
index c5f6b0f9..bfcfff90 100644
--- a/python/filemetadata.py
+++ b/python/filemetadata.py
@@ -28,6 +28,7 @@ from binaryninja import _binaryninjacore as core
from binaryninja import associateddatastore #required for _FileMetadataAssociatedDataStore
from binaryninja import log
from binaryninja.enums import SaveOption
+from binaryninja import pyNativeStr
class NavigationHandler(object):
def _register(self, handle):
@@ -433,3 +434,13 @@ class FileMetadata(object):
if view is None:
return None
return binaryninja.binaryview.BinaryView(file_metadata = self, handle = view)
+
+ @property
+ def existing_views(self):
+ length = ctypes.c_ulonglong()
+ result = core.BNGetExistingViews(self.handle, ctypes.byref(length))
+ views = []
+ for i in range(length.value):
+ views.append(pyNativeStr(result[i]))
+ core.BNFreeStringList(result, length)
+ return views \ No newline at end of file
diff --git a/suite/binaries b/suite/binaries
-Subproject e5dc0bd739f63d2e38d9264ebe240d007f637db
+Subproject 5712e66fa4aad7fc0bba541b012abbb877ea576
diff --git a/suite/testcommon.py b/suite/testcommon.py
index 398d0346..09f9d589 100644
--- a/suite/testcommon.py
+++ b/suite/testcommon.py
@@ -452,6 +452,22 @@ class TestBuilder(Builder):
"""BinaryViewType list doesnt match"""
return ["BinaryViewType: " + x.name for x in binja.BinaryViewType.list]
+ def test_deprecated_BinaryViewType(self):
+ """deprecated BinaryViewType list doesnt match"""
+ file_name = os.path.join(os.path.dirname(__file__), self.test_store, "..", "fat_macho_9arch.bndb")
+ if not os.path.exists(file_name):
+ return [""]
+
+ with binja.filemetadata.FileMetadata().open_existing_database(file_name, None) as bv:
+ view_types = []
+ for view_type in bv.available_view_types:
+ if view_type.is_deprecated:
+ view_types.append('BinaryViewType: %s (deprecated)' % view_type.name)
+ else:
+ view_types.append('BinaryViewType: %s' % view_type.name)
+
+ return view_types
+
def test_Architecture_list(self):
"""Architecture list doesnt match"""
return ["Arch name: " + x.name for x in binja.Architecture.list]
@@ -543,7 +559,7 @@ class TestBuilder(Builder):
return [""]
retinfo = []
- file_name = os.path.join(self.test_store, "..", "pwnadventurez.nes")
+ file_name = os.path.join(os.path.dirname(__file__), self.test_store, "..", "pwnadventurez.nes")
bv = binja.BinaryViewType["NES Bank 0"].open(file_name)
for i in bv.platform.arch.calling_conventions: