From 661d7c953e7a81e82f3eb6a70c03041354d73bfd Mon Sep 17 00:00:00 2001 From: galenbwill Date: Thu, 15 Jul 2021 12:29:51 -0400 Subject: Fix for create_user_function does not consult get_associated_platform_by_address when no platform is specified Fix for https://github.com/Vector35/binaryninja-api/issues/2554#issue-945559859 --- python/binaryview.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'python/binaryview.py') diff --git a/python/binaryview.py b/python/binaryview.py index a4b36f43..2c259741 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -3067,7 +3067,9 @@ class BinaryView(object): """ if plat is None: - plat = self.platform + if self.platform is None: + raise ValueError("Can't create user function with no platform specified.") + plat, addr = self.platform.get_associated_platform_by_address(addr) return binaryninja.function.Function(self, core.BNCreateUserFunction(self.handle, plat.handle, addr)) def remove_user_function(self, func): @@ -3257,14 +3259,14 @@ class BinaryView(object): def get_functions_by_name(self, name, plat=None, ordered_filter=[SymbolType.FunctionSymbol, SymbolType.ImportedFunctionSymbol, SymbolType.LibraryFunctionSymbol]): """``get_functions_by_name`` returns a list of Function objects function with a Symbol of ``name``. -​ + :param str name: name of the functions :param Platform plat: (optional) platform :param list(SymbolType) ordered_filter: (optional) an ordered filter based on SymbolType :return: returns a list of Function objects or an empty list :rtype: list(Function) :Example: -​ + >>> bv.get_function_by_name("main")) >>> -- cgit v1.3.1