MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / new

Method new

python/binaryview.py:2848–2879  ·  view source on GitHub ↗

``new`` creates a new, Raw :py:class:`BinaryView` for the provided data. :param data: path to file/bndb, raw bytes, or raw view to load :type data: Union[:py:class:`str`, :py:class:`bytes`, :py:class:`bytearray`, :py:class:`~binaryninja.databuffer.DataBuffer`, :py:class:`os.PathLike`, :py:cl

(data: Optional[Union[bytes, bytearray, 'databuffer.DataBuffer']] = None, file_metadata: Optional['filemetadata.FileMetadata'] = None)

Source from the content-addressed store, hash-verified

2846
2847 @staticmethod
2848 def new(data: Optional[Union[bytes, bytearray, 'databuffer.DataBuffer']] = None, file_metadata: Optional['filemetadata.FileMetadata'] = None) -> Optional['BinaryView']:
2849 """
2850 ``new`` creates a new, Raw :py:class:`BinaryView` for the provided data.
2851
2852 :param data: path to file/bndb, raw bytes, or raw view to load
2853 :type data: Union[:py:class:`str`, :py:class:`bytes`, :py:class:`bytearray`, :py:class:`~binaryninja.databuffer.DataBuffer`, :py:class:`os.PathLike`, :py:class:`BinaryView`]
2854 :param file_metadata: Optional FileMetadata object for this new view
2855 :type file_metadata: :py:class:`~binaryninja.filemetadata.FileMetadata`
2856 :return: returns a :py:class:`BinaryView` object for the given filename or ``None``
2857 :rtype: :py:class:`BinaryView` or ``None``
2858
2859 :Example:
2860
2861 >>> binaryninja.load('/bin/ls', options={'loader.imageBase': 0xfffffff0000, 'loader.macho.processFunctionStarts' : False})
2862 <BinaryView: '/bin/ls', start 0xfffffff0000, len 0xa290>
2863 >>>
2864
2865 """
2866
2867 binaryninja._init_plugins()
2868 if file_metadata is None:
2869 file_metadata = filemetadata.FileMetadata()
2870 if data is None:
2871 view = core.BNCreateBinaryDataView(file_metadata.handle)
2872 elif isinstance(data, databuffer.DataBuffer):
2873 view = core.BNCreateBinaryDataViewFromBuffer(file_metadata.handle, data.handle)
2874 else:
2875 buf = databuffer.DataBuffer(data)
2876 view = core.BNCreateBinaryDataViewFromBuffer(file_metadata.handle, buf.handle)
2877 if view is None:
2878 return None
2879 return BinaryView(file_metadata=file_metadata, handle=view)
2880
2881 @staticmethod
2882 def load(source: Union[str, bytes, bytearray, 'databuffer.DataBuffer', 'os.PathLike', 'BinaryView', 'project.ProjectFile'], update_analysis: bool = True,

Callers 3

loadMethod · 0.45
cli_lift.pyFile · 0.45
typelib_create.pyFile · 0.45

Calls 3

FileMetadataMethod · 0.80
DataBufferMethod · 0.80
BinaryViewClass · 0.70

Tested by

no test coverage detected