diff options
| author | KyleMiles <krm504@nyu.edu> | 2019-09-01 04:59:12 +0000 |
|---|---|---|
| committer | KyleMiles <krm504@nyu.edu> | 2019-09-19 02:57:49 +0000 |
| commit | f5851a8c606cdc2369cf1ee928e1fe9687513782 (patch) | |
| tree | 6693af6d3bc9297572d67c192e02a678d07ecee3 /python | |
| parent | 4d9138e3ef76ce300f054a8cb07b1a2327b35a83 (diff) | |
Fixes #1440 - use user-supplied platform before falling back to default platform
Co-authored-by: Sai <svv232@nyu.edu>
Diffstat (limited to 'python')
| -rw-r--r-- | python/binaryview.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/python/binaryview.py b/python/binaryview.py index ff85396f..a48880dd 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -2604,10 +2604,12 @@ class BinaryView(object): [<func: x86_64@0x1>] """ - if self.platform is None: + if self.platform is None and plat is None: raise Exception("Default platform not set in BinaryView") if plat is None: plat = self.platform + if not isinstance(plat, binaryninja.platform.Platform): + raise AttributeError("Provided platform is not of type `binaryninja.platform.Platform`") core.BNAddFunctionForAnalysis(self.handle, plat.handle, addr) def add_entry_point(self, addr, plat=None): @@ -2621,10 +2623,12 @@ class BinaryView(object): >>> bv.add_entry_point(0xdeadbeef) >>> """ - if self.platform is None: + if self.platform is None and plat is None: raise Exception("Default platform not set in BinaryView") if plat is None: plat = self.platform + if not isinstance(plat, binaryninja.platform.Platform): + raise AttributeError("Provided platform is not of type `binaryninja.platform.Platform`") core.BNAddEntryPointForAnalysis(self.handle, plat.handle, addr) def remove_function(self, func): @@ -3289,11 +3293,9 @@ class BinaryView(object): """ if plat is None: plat = self.platform - if plat is not None: - plat = plat.handle - if sym_type is not None: - sym_type = sym_type.handle - core.BNDefineAutoSymbolAndVariableOrFunction(self.handle, plat, sym.handle, sym_type) + elif not isinstance(plat, binaryninja.platform.Platform): + raise AttributeError("Provided platform is not of type `binaryninja.platform.Platform`") + core.BNDefineAutoSymbolAndVariableOrFunction(self.handle, plat.handle, sym.handle, sym_type.handle) def undefine_auto_symbol(self, sym): """ @@ -4750,7 +4752,7 @@ class BinaryView(object): type = "", align = 1, entry_size = 1, linked_section = "", info_section = "", info_data = 0): """ ``add_user_section`` creates a user-defined section that can help inform analysis by clarifying what types of - data exist in what ranges. Note that all data specified must already be mapped by an existing segment. + data exist in what ranges. Note that all data specified must already be mapped by an existing segment. :param str name: name of the section :param int start: virtual address of the start of the section |
