summaryrefslogtreecommitdiff
path: root/python/examples
diff options
context:
space:
mode:
authorKyleMiles <krm504@nyu.edu>2023-06-29 20:49:26 -0400
committerKyleMiles <krm504@nyu.edu>2023-07-10 12:58:24 -0400
commit04bc6f11ae0289aae57d63d4cd32f4ef305d1a7a (patch)
tree46f06280b13fb80f2aebf0eea9b52f884e698d0c /python/examples
parent7598688466960427890036590239565364310171 (diff)
Move binary view loading in to the core; deprecate open_view in favor of load; update examples
Diffstat (limited to 'python/examples')
-rw-r--r--python/examples/bin_info.py5
-rwxr-xr-xpython/examples/debug_info.py2
-rw-r--r--python/examples/feature_map.py2
-rw-r--r--python/examples/instruction_iterator.py4
-rw-r--r--python/examples/mappedview.py2
-rwxr-xr-xpython/examples/pe_stat.py2
-rw-r--r--python/examples/print_syscalls.py4
7 files changed, 10 insertions, 11 deletions
diff --git a/python/examples/bin_info.py b/python/examples/bin_info.py
index 8d43a999..8aaf2a38 100644
--- a/python/examples/bin_info.py
+++ b/python/examples/bin_info.py
@@ -23,10 +23,9 @@ import sys
import os
from binaryninja.log import log_warn, log_to_stdout
-from binaryninja.binaryview import BinaryViewType
import binaryninja.interaction as interaction
from binaryninja.plugin import PluginCommand
-from binaryninja import Settings
+from binaryninja import load
def get_bininfo(bv):
@@ -40,7 +39,7 @@ def get_bininfo(bv):
log_warn("No file specified")
sys.exit(1)
- bv = BinaryViewType.get_view_of_file(filename)
+ bv = load(filename)
log_to_stdout(True)
contents = "## %s ##\n" % os.path.basename(bv.file.filename)
diff --git a/python/examples/debug_info.py b/python/examples/debug_info.py
index a060e465..4f4328d3 100755
--- a/python/examples/debug_info.py
+++ b/python/examples/debug_info.py
@@ -222,7 +222,7 @@ for p in bn.debuginfo.DebugInfoParser:
print(f" {bn.debuginfo.DebugInfoParser[p.name].name}")
# Test calling our `is_valid` callback
-bv = bn.open_view(filename, options={"analysis.debugInfo.internal": False})
+bv = bn.load(filename, options={"analysis.debugInfo.internal": False})
if parser.is_valid_for_view(bv):
print("Parser is valid")
else:
diff --git a/python/examples/feature_map.py b/python/examples/feature_map.py
index 9884b510..e12508af 100644
--- a/python/examples/feature_map.py
+++ b/python/examples/feature_map.py
@@ -18,7 +18,7 @@ FeatureMapImportColor = (237, 189, 129)
FeatureMapExternColor = (237, 189, 129)
FeatureMapLibraryColor = (237, 189, 129)
-bv = binaryninja.open_view(sys.argv[1], update_analysis=True)
+bv = binaryninja.load(sys.argv[1], update_analysis=True)
imgdata = [FeatureMapBaseColor]*(WIDTH*HEIGHT)
diff --git a/python/examples/instruction_iterator.py b/python/examples/instruction_iterator.py
index 741f03c4..62329f02 100644
--- a/python/examples/instruction_iterator.py
+++ b/python/examples/instruction_iterator.py
@@ -21,7 +21,7 @@
import sys
from binaryninja.log import log_info, log_to_stdout
-from binaryninja import open_view, BinaryView
+from binaryninja import load, BinaryView
from binaryninja import PluginCommand, LogLevel
@@ -53,7 +53,7 @@ if __name__ == "__main__":
if len(sys.argv) > 1:
target = sys.argv[1]
log_to_stdout(LogLevel.WarningLog)
- with open_view(target) as bv:
+ with load(target) as bv:
log_to_stdout(LogLevel.InfoLog)
iterate(bv)
else:
diff --git a/python/examples/mappedview.py b/python/examples/mappedview.py
index 0fbf159c..30c0edfd 100644
--- a/python/examples/mappedview.py
+++ b/python/examples/mappedview.py
@@ -97,7 +97,7 @@ class MappedView(BinaryView):
def init(self):
# The BinaryView init method is invoked as part of the BinaryView creation process. This method is called under several different conditions:
# 1) When opening a file/bndb and no load options are provided.
- # 2) When opening a file/bndb and load options are provided. e.g. 'Open with Options' in the UI, or get_view_of_file_with_options
+ # 2) When opening a file/bndb and load options are provided. e.g. 'Open with Options' in the UI, or load
# 3) When parsing a file to create an ephemeral BinaryView (self.parse_only == True) for the purpose of extracting header information.
# Note: The get_load_settings_for_data classmethod is optional. If provided, it's used to generate load options for the BinaryViewType.
# If not provided, then the default load options are automatically generated by the core, extracting information automatically from a parsed BinaryView.
diff --git a/python/examples/pe_stat.py b/python/examples/pe_stat.py
index 08dd43e0..bc3a3992 100755
--- a/python/examples/pe_stat.py
+++ b/python/examples/pe_stat.py
@@ -31,7 +31,7 @@ opc2count = defaultdict(lambda: 0)
target = sys.argv[1]
print('opening %s' % target)
-bv = binaryninja.BinaryViewType.get_view_of_file(target)
+bv = binaryninja.load(target)
print('analyzing')
bv.update_analysis_and_wait()
diff --git a/python/examples/print_syscalls.py b/python/examples/print_syscalls.py
index a16cd8f9..7f10fdd0 100644
--- a/python/examples/print_syscalls.py
+++ b/python/examples/print_syscalls.py
@@ -25,13 +25,13 @@
import sys
from itertools import chain
-from binaryninja.binaryview import BinaryViewType
+from binaryninja import load
from binaryninja.enums import LowLevelILOperation
def print_syscalls(fileName):
""" Print Syscall numbers for a provided file """
- bv = BinaryViewType.get_view_of_file(fileName)
+ bv = load(fileName)
calling_convention = bv.platform.system_call_convention
if calling_convention is None:
print('Error: No syscall convention available for {:s}'.format(bv.platform))