summaryrefslogtreecommitdiff
path: root/python/filemetadata.py
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2018-08-29 15:26:00 -0400
committerPeter LaFosse <peter@vector35.com>2018-08-31 14:21:07 -0400
commitf0ccb75e7d80a6c0ae8b01d794b929f03bc6ea6d (patch)
tree7569fe7689062b265329ad0f649705aa8caab922 /python/filemetadata.py
parenta6b801afadada75afd2b1779edee8d203f3b3140 (diff)
parent426bb3d8b47b93658bf969c429a8b98adae13c30 (diff)
Merging with dev
Diffstat (limited to 'python/filemetadata.py')
-rw-r--r--python/filemetadata.py37
1 files changed, 23 insertions, 14 deletions
diff --git a/python/filemetadata.py b/python/filemetadata.py
index 4bfc0214..4d51f4d9 100644
--- a/python/filemetadata.py
+++ b/python/filemetadata.py
@@ -18,16 +18,15 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
+from __future__ import absolute_import
import traceback
import ctypes
-# Binary Ninja components
-import _binaryninjacore as core
-import startup
-import associateddatastore
-import log
-import binaryview
-
+# Binary Ninja Components
+import binaryninja
+from binaryninja import _binaryninjacore as core
+from binaryninja import associateddatastore #required for _FileMetadataAssociatedDataStore
+from binaryninja import log
class NavigationHandler(object):
def _register(self, handle):
@@ -66,12 +65,13 @@ class _FileMetadataAssociatedDataStore(associateddatastore._AssociatedDataStore)
class FileMetadata(object):
- _associated_data = {}
-
"""
``class FileMetadata`` represents the file being analyzed by Binary Ninja. It is responsible for opening,
closing, creating the database (.bndb) files, and is used to keep track of undoable actions.
"""
+
+ _associated_data = {}
+
def __init__(self, filename = None, handle = None):
"""
Instantiates a new FileMetadata class.
@@ -82,7 +82,7 @@ class FileMetadata(object):
if handle is not None:
self.handle = core.handle_of_type(handle, core.BNFileMetadata)
else:
- startup._init_plugins()
+ binaryninja._init_plugins()
self.handle = core.BNCreateFileMetadata()
if filename is not None:
core.BNSetFilename(self.handle, str(filename))
@@ -114,8 +114,17 @@ class FileMetadata(object):
_FileMetadataAssociatedDataStore.set_default(name, value)
@property
+ def original_filename(self):
+ """The original name of the binary opened if a bndb, otherwise reads or sets the current filename (read/write)"""
+ return core.BNGetOriginalFilename(self.handle)
+
+ @original_filename.setter
+ def original_filename(self, value):
+ core.BNSetOriginalFilename(self.handle, str(value))
+
+ @property
def filename(self):
- """The name of the file (read/write)"""
+ """The name of the open bndb or binary filename (read/write)"""
return core.BNGetFilename(self.handle)
@filename.setter
@@ -167,7 +176,7 @@ class FileMetadata(object):
view = core.BNGetFileViewOfType(self.handle, "Raw")
if view is None:
return None
- return binaryview.BinaryView(file_metadata = self, handle = view)
+ return binaryninja.binaryview.BinaryView(file_metadata = self, handle = view)
@property
def saved(self):
@@ -322,7 +331,7 @@ class FileMetadata(object):
lambda ctxt, cur, total: progress_func(cur, total)))
if view is None:
return None
- return binaryview.BinaryView(file_metadata = self, handle = view)
+ return binaryninja.binaryview.BinaryView(file_metadata = self, handle = view)
def save_auto_snapshot(self, progress_func = None):
if progress_func is None:
@@ -341,7 +350,7 @@ class FileMetadata(object):
view = core.BNCreateBinaryViewOfType(view_type, self.raw.handle)
if view is None:
return None
- return binaryview.BinaryView(file_metadata = self, handle = view)
+ return binaryninja.binaryview.BinaryView(file_metadata = self, handle = view)
def __setattr__(self, name, value):
try: