コード例 #1
0
def simplify_name_to_qualified_name(input_name, simplify=True):
    """
	``simplify_name_to_qualified_name`` simplifies a templated C++ name with default arguments and returns a qualified name.  This can also tokenize a string to a qualified name with/without simplifying it

	:param input_name: String or qualified name to be simplified
	:type input_name: Union[str, QualifiedName]
	:param bool simplify_name: (optional) Whether to simplify input string (no effect if given a qualified name; will always simplify)
	:return: simplified name (or one-element array containing the input if simplifier fails/cannot simplify)
	:rtype: QualifiedName
	:Example:

		>>> demangle.simplify_name_to_qualified_name(QualifiedName(["std", "__cxx11", "basic_string<wchar, std::char_traits<wchar>, std::allocator<wchar> >"]), True)
		'std::wstring'
		>>>
	"""
    result = None
    if isinstance(input_name, str):
        result = core.BNRustSimplifyStrToFQN(input_name, simplify)
    elif isinstance(input_name, types.QualifiedName):
        result = core.BNRustSimplifyStrToFQN(str(input_name), True)
    else:
        raise TypeError(
            "Parameter must be of type `str` or `types.QualifiedName`")

    native_result = []
    for name in result:
        if name == b'':
            break
        native_result.append(name)
    name_count = len(native_result)

    native_result = types.QualifiedName(native_result)
    core.BNRustFreeStringArray(result, name_count + 1)
    return native_result
コード例 #2
0
ファイル: typelibrary.py プロジェクト: meme/binaryninja-api
	def get_named_type(self, name):
		"""
		`get_named_type` direct extracts a reference to a contained type -- when
		attempting to extract types from a library into a BinaryView, consider using
		:py:meth:`import_library_type <binaryninja.binaryview.BinaryView.import_library_type>` instead.

		:param QualifiedName name:
		:rtype: Type
		"""
		if not isinstance(name, types.QualifiedName):
			name = types.QualifiedName(name)
		t = core.BNGetTypeLibraryNamedType(self.handle, name._get_core_struct())
		if t is None:
			return None
		return types.Type(t)
コード例 #3
0
ファイル: typelibrary.py プロジェクト: meme/binaryninja-api
	def add_named_type(self, name, t):
		"""
		`add_named_type` directly inserts a named object into the type library's object store.
		This is not done recursively, so care should be taken that types referring to other types
		through NamedTypeReferences are already appropriately prepared.

		To add types and objects from an existing BinaryView, it is recommended to use
		:py:meth:`export_type_to_library <binaryninja.binaryview.BinaryView.export_type_to_library>`, which will automatically pull in
		all referenced types and record additional dependencies as needed.

		:param QualifiedName name:
		:param Type t:
		:rtype: None
		"""
		if not isinstance(name, types.QualifiedName):
			name = types.QualifiedName(name)
		if not isinstance(t, types.Type):
			raise ValueError("t must be a Type")
		core.BNAddTypeLibraryNamedType(self.handle, name._get_core_struct(), t.handle)
コード例 #4
0
 def generate_auto_platform_type_id(self, name):
     name = types.QualifiedName(name)._get_core_struct()
     return core.BNGenerateAutoPlatformTypeId(self.handle, name)
コード例 #5
0
 def get_function_by_name(self, name, exactMatch=False):
     name = types.QualifiedName(name)._get_core_struct()
     obj = core.BNGetPlatformFunctionByName(self.handle, name, exactMatch)
     if not obj:
         return None
     return types.Type(obj, platform=self)
コード例 #6
0
 def get_variable_by_name(self, name):
     name = types.QualifiedName(name)._get_core_struct()
     obj = core.BNGetPlatformVariableByName(self.handle, name)
     if not obj:
         return None
     return types.Type(obj, platform=self)