diff options
| author | Alexander Taylor <alex@vector35.com> | 2024-07-24 17:17:45 -0400 |
|---|---|---|
| committer | Alexander Taylor <alex@vector35.com> | 2024-07-24 17:17:45 -0400 |
| commit | 6dee35541be6669d2d783bea37e0f230b10ade23 (patch) | |
| tree | 6b99fb0012ff62b0f449d809b9405c8a097be57f /python | |
| parent | ceeef1fe56d3f2aae280497810dc6860d1e483c5 (diff) | |
Remove deprecated API functions.
Diffstat (limited to 'python')
| -rw-r--r-- | python/__init__.py | 5 | ||||
| -rw-r--r-- | python/architecture.py | 56 | ||||
| -rw-r--r-- | python/binaryview.py | 343 | ||||
| -rw-r--r-- | python/enterprise.py | 15 | ||||
| -rw-r--r-- | python/filemetadata.py | 21 | ||||
| -rw-r--r-- | python/function.py | 436 | ||||
| -rw-r--r-- | python/highlevelil.py | 25 | ||||
| -rw-r--r-- | python/typeparser.py | 39 |
8 files changed, 2 insertions, 938 deletions
diff --git a/python/__init__.py b/python/__init__.py index 1293561d..d4cc4dac 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -417,11 +417,6 @@ def load(*args, **kwargs) -> BinaryView: return bv -@deprecation.deprecated(deprecated_in="3.5.4378", details='Use :py:func:`load` instead') -def open_view(*args, **kwargs) -> BinaryView: - return load(*args, **kwargs) - - def connect_pycharm_debugger(port=5678): """ Connect to PyCharm (Professional Edition) for debugging. diff --git a/python/architecture.py b/python/architecture.py index c3b0f705..d07d718f 100644 --- a/python/architecture.py +++ b/python/architecture.py @@ -1984,62 +1984,6 @@ class Architecture(metaclass=_ArchitectureMetaClass): """ return NotImplemented - @deprecation.deprecated(deprecated_in="3.1.3724") - def is_view_type_constant_defined(self, type_name: str, const_name: str) -> bool: - """ - :param str type_name: the BinaryView type name of the constant to query - :param str const_name: the constant name to query - :rtype: None - :Example: - - >>> ELF_RELOC_COPY = 5 - >>> arch.set_view_type_constant("ELF", "R_COPY", ELF_RELOC_COPY) - >>> arch.is_view_type_constant_defined("ELF", "R_COPY") - True - >>> arch.is_view_type_constant_defined("ELF", "NOT_THERE") - False - >>> - """ - return False - - @deprecation.deprecated(deprecated_in="3.1.3724") - def get_view_type_constant(self, type_name: str, const_name: str, default_value: int = 0) -> int: - """ - ``get_view_type_constant`` retrieves the view type constant for the given type_name and const_name. - - :param str type_name: the BinaryView type name of the constant to be retrieved - :param str const_name: the constant name to retrieved - :param int default_value: optional default value if the type_name is not present. default value is zero. - :return: The BinaryView type constant or the default_value if not found - :rtype: int - :Example: - - >>> ELF_RELOC_COPY = 5 - >>> arch.set_view_type_constant("ELF", "R_COPY", ELF_RELOC_COPY) - >>> arch.get_view_type_constant("ELF", "R_COPY") - 5 - >>> arch.get_view_type_constant("ELF", "NOT_HERE", 100) - 100 - """ - return 0 - - @deprecation.deprecated(deprecated_in="3.1.3724") - def set_view_type_constant(self, type_name: str, const_name: str, value: int) -> None: - """ - ``set_view_type_constant`` creates a new binaryview type constant. - - :param str type_name: the BinaryView type name of the constant to be registered - :param str const_name: the constant name to register - :param int value: the value of the constant - :rtype: None - :Example: - - >>> ELF_RELOC_COPY = 5 - >>> arch.set_view_type_constant("ELF", "R_COPY", ELF_RELOC_COPY) - >>> - """ - pass - def register_calling_convention(self, cc: 'callingconvention.CallingConvention') -> None: """ ``register_calling_convention`` registers a new calling convention for the Architecture. diff --git a/python/binaryview.py b/python/binaryview.py index 9f47005b..aff1e28c 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -1284,37 +1284,6 @@ class BinaryViewType(metaclass=_BinaryViewTypeMetaclass): return self.create(data) # TODO : Check if we need binary_view_type's at all after these deprecations? (move add_binaryview_finalized_event and add_binaryview_initial_analysis_completion_event to BinaryView?) - @classmethod - @deprecation.deprecated(deprecated_in="3.5.4378", details="Use :py:func:`binaryninja.load` instead.") - def get_view_of_file( - cls, filename: PathType, update_analysis: bool = True, progress_func: Optional[ProgressFuncType] = None - ) -> Optional['BinaryView']: - return BinaryViewType.load(filename, update_analysis, progress_func) - - @classmethod - @deprecation.deprecated(deprecated_in="3.5.4378", details="Use :py:func:`binaryninja.load` instead.") - def get_view_of_file_with_options( - cls, filename: Union[str, 'os.PathLike'], update_analysis: Optional[bool] = True, progress_func: Optional[ProgressFuncType] = None, - options: Mapping[str, Any] = {} - ) -> Optional['BinaryView']: - return BinaryViewType.load(filename, update_analysis, progress_func, options) - - @classmethod - @deprecation.deprecated(deprecated_in="3.5.4378", details="Use :py:func:`binaryninja.load` instead.") - def load_raw_view_with_options( - cls, raw_view: Optional['BinaryView'], update_analysis: Optional[bool] = True, progress_func: Optional[ProgressFuncType] = None, - options: Mapping[str, Any] = {} - ) -> Optional['BinaryView']: - if raw_view is None: - return None - return BinaryViewType.load(raw_view, update_analysis, progress_func, options) - - @classmethod - @deprecation.deprecated(deprecated_in="3.5.4378", details="Use :py:func:`binaryninja.load` instead.") - def load( - cls, source: Union[str, bytes, bytearray, 'databuffer.DataBuffer', 'os.PathLike', 'BinaryView'], update_analysis: Optional[bool] = True, - progress_func: Optional[ProgressFuncType] = None, options: Mapping[str, Any] = {}) -> Optional['BinaryView']: - return BinaryView.load(source, update_analysis, progress_func, options) def parse(self, data: 'BinaryView') -> Optional['BinaryView']: view = core.BNParseBinaryViewOfType(self.handle, data.handle) @@ -1325,13 +1294,6 @@ class BinaryViewType(metaclass=_BinaryViewTypeMetaclass): def is_valid_for_data(self, data: 'BinaryView') -> bool: return core.BNIsBinaryViewTypeValidForData(self.handle, data.handle) - @deprecation.deprecated(deprecated_in="3.5.4378") - def get_default_load_settings_for_data(self, data: 'BinaryView') -> Optional['settings.Settings']: - load_settings = core.BNGetBinaryViewDefaultLoadSettingsForData(self.handle, data.handle) - if load_settings is None: - return None - return settings.Settings(handle=load_settings) - def get_load_settings_for_data(self, data: 'BinaryView') -> Optional['settings.Settings']: view_handle = None if data is not None: @@ -1432,11 +1394,6 @@ class Segment: x = "x" if self.executable else "-" return f"<segment: {self.start:#x}-{self.end:#x}, {r}{w}{x}>" - @deprecation.deprecated(deprecated_in="3.4.3997", details="Use :py:attr:`length` instead. Python disallows the length of an object to " - ">= 0x8000000000000000. See https://bugs.python.org/issue21444.") - def __len__(self): - return self.length - @classmethod def serialize(cls, image_base: int, start: int, length: int, data_offset: int=0, data_length: int=0, flags: 'SegmentFlag'=SegmentFlag.SegmentReadable, auto_defined=True, segments: str="[]"): """ @@ -1546,11 +1503,6 @@ class Section: def __repr__(self): return f"<section {self.name}: {self.start:#x}-{self.end:#x}>" - @deprecation.deprecated(deprecated_in="3.4.3997", details="Use :py:attr:`length` instead. Python disallows the length of an object to " - ">= 0x8000000000000000. See https://bugs.python.org/issue21444.") - def __len__(self): - return self.length - def __bool__(self): return True @@ -2456,11 +2408,6 @@ class BinaryView: return f"<BinaryView: '{filename}', {size}>" return f"<BinaryView: {size}>" - @deprecation.deprecated(deprecated_in="3.4.3997", details="Use :py:attr:`length` instead. Python disallows the length of an object to " - ">= 0x8000000000000000. See https://bugs.python.org/issue21444.") - def __len__(self): - return int(core.BNGetViewLength(self.handle)) - @property def length(self): return int(core.BNGetViewLength(self.handle)) @@ -6146,45 +6093,6 @@ class BinaryView: core.BNAddTag(self.handle, tag.handle, user) core.BNAddUserDataTag(self.handle, addr, tag.handle) - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tag_type` instead.') - def get_tag_type_by_name(self, name: str) -> Optional['TagType']: - tag_type = core.BNGetTagType(self.handle, name) - if tag_type is None: - return None - return TagType(tag_type) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tag_type` instead.') - def get_tag_type_by_id(self, id: str) -> Optional['TagType']: - tag_type = core.BNGetTagTypeById(self.handle, id) - if tag_type is None: - return None - return TagType(tag_type) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`add_tag` instead.') - def create_user_tag(self, type: 'TagType', data: str) -> 'Tag': - return self.create_tag(type, data, True) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`add_tag` instead.') - def create_auto_tag(self, type: 'TagType', data: str) -> 'Tag': - return self.create_tag(type, data, False) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`add_tag` instead.') - def create_tag(self, tag_type: 'TagType', data: str, user: bool = True) -> 'Tag': - if not isinstance(tag_type, TagType): - raise ValueError(f"type is not a TagType instead got {type(tag_type)} : {repr(tag_type)}") - tag_handle = core.BNCreateTag(tag_type.handle, data) - assert tag_handle is not None, "core.BNCreateTag returned None" - tag = Tag(tag_handle) - core.BNAddTag(self.handle, tag.handle, user) - return tag - - @deprecation.deprecated(deprecated_in="3.4.4146") - def get_tag(self, id: str) -> Optional['Tag']: - tag = core.BNGetTag(self.handle, id) - if tag is None: - return None - return Tag(tag) - @property def tags(self) -> List[Tuple[int, 'Tag']]: """ @@ -6225,48 +6133,6 @@ class BinaryView: finally: core.BNFreeTagReferences(tags, count.value) - @property - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:attr:`tags` instead.') - def data_tags(self) -> List[Tuple[int, 'Tag']]: - return self.tags - - @property - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tags` instead.') - def auto_data_tags(self) -> List[Tuple[int, 'Tag']]: - count = ctypes.c_ulonglong() - tags = core.BNGetAutoDataTagReferences(self.handle, count) - assert tags is not None, "core.BNGetAutoDataTagReferences return None" - result = [] - try: - for i in range(0, count.value): - handle = tags[i].tag - assert handle is not None, "BNGetAutoDataTagReferences returned handle set to None" - tag_ref = core.BNNewTagReference(handle) - assert tag_ref is not None, "BNNewTagReference returned None" - tag = Tag(tag_ref) - result.append((tags[i].addr, tag)) - return result - finally: - core.BNFreeTagReferences(tags, count.value) - - @property - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tags` instead.') - def user_data_tags(self) -> List[Tuple[int, 'Tag']]: - count = ctypes.c_ulonglong() - refs = core.BNGetUserDataTagReferences(self.handle, count) - assert refs is not None, "core.BNGetUserDataTagReferences returned None" - result = [] - try: - for i in range(0, count.value): - tag_handle = refs[i].tag - assert tag_handle is not None, "BNGetUserDataTagReferences returned tag with handle set to None" - tag_ref = core.BNNewTagReference(tag_handle) - assert tag_ref is not None, "BNNewTagReference returned None" - tag = Tag(tag_ref) - result.append((refs[i].addr, tag)) - return result - finally: - core.BNFreeTagReferences(refs, count.value) def get_tags_at(self, addr: int, auto: Optional[bool] = None) -> List['Tag']: """ @@ -6298,76 +6164,6 @@ class BinaryView: finally: core.BNFreeTagList(tags, count.value) - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tags_at` instead.') - def get_data_tags_at(self, addr: int, auto: Optional[bool] = None) -> List['Tag']: - return self.get_tags_at(addr, auto) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tags_at` instead.') - def get_auto_data_tags_at(self, addr: int) -> List['Tag']: - return self.get_tags_at(addr, True) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tags_at` instead.') - def get_user_data_tags_at(self, addr: int) -> List['Tag']: - return self.get_tags_at(addr, False) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tags_at` instead.') - def get_data_tags_of_type(self, addr: int, tag_type: str, auto: Optional[bool] = None) -> List['Tag']: - count = ctypes.c_ulonglong() - - tag_type = self.get_tag_type(tag_type) - if tag_type is None: - return [] - - if auto is None: - tags = core.BNGetDataTagsOfType(self.handle, addr, tag_type.handle, count) - assert tags is not None, "BNGetDataTagsOfType returned None" - elif auto: - tags = core.BNGetAutoDataTagsOfType(self.handle, addr, tag_type.handle, count) - assert tags is not None, "core.BNGetAutoDataTagsOfType returned None" - else: - tags = core.BNGetUserDataTagsOfType(self.handle, addr, tag_type.handle, count) - assert tags is not None, "core.BNGetUserDataTagsOfType returned None" - - result = [] - try: - for i in range(0, count.value): - tag_ref = core.BNNewTagReference(tags[i]) - assert tag_ref is not None, "BNNewTagReference returned None" - result.append(Tag(tag_ref)) - return result - finally: - core.BNFreeTagList(tags, count.value) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tags_at` instead.') - def get_auto_data_tags_of_type(self, addr: int, tag_type: 'TagType') -> List['Tag']: - count = ctypes.c_ulonglong() - tags = core.BNGetAutoDataTagsOfType(self.handle, addr, tag_type.handle, count) - assert tags is not None, "core.BNGetAutoDataTagsOfType returned None" - result = [] - try: - for i in range(0, count.value): - tag_handle = core.BNNewTagReference(tags[i]) - assert tag_handle is not None, "core.BNNewTagReference returned None" - result.append(Tag(tag_handle)) - return result - finally: - core.BNFreeTagList(tags, count.value) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tags_at` instead.') - def get_user_data_tags_of_type(self, addr: int, tag_type: 'TagType') -> List['Tag']: - count = ctypes.c_ulonglong() - tags = core.BNGetUserDataTagsOfType(self.handle, addr, tag_type.handle, count) - assert tags is not None, "BNGetUserDataTagsOfType returned None" - result = [] - try: - for i in range(0, count.value): - tag_ref = core.BNNewTagReference(tags[i]) - assert tag_ref is not None, "BNNewTagReference returned None" - result.append(Tag(tag_ref)) - return result - finally: - core.BNFreeTagList(tags, count.value) - def get_tags_in_range(self, address_range: 'variable.AddressRange', auto: Optional[bool] = None) -> List[Tuple[int, 'Tag']]: """ ``get_data_tags_in_range`` gets a list of all data :py:class:`Tag` objects in a given range. @@ -6400,34 +6196,6 @@ class BinaryView: finally: core.BNFreeTagReferences(refs, count.value) - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tags_in_range` instead.') - def get_data_tags_in_range(self, address_range: 'variable.AddressRange', user: Optional[bool] = None) -> List[Tuple[int, 'Tag']]: - return self.get_tags_in_range(address_range, user) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tags_in_range` instead.') - def get_auto_data_tags_in_range(self, address_range: 'variable.AddressRange') -> List[Tuple[int, 'Tag']]: - return self.get_tags_in_range(address_range, True) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tags_in_range` instead.') - def get_user_data_tags_in_range(self, address_range: 'variable.AddressRange') -> List[Tuple[int, 'Tag']]: - return self.get_tags_in_range(address_range, False) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`add_tag` instead') - def add_user_data_tag(self, addr: int, tag: 'Tag'): - core.BNAddUserDataTag(self.handle, addr, tag.handle) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`add_tag` instead') - def create_user_data_tag(self, addr: int, type: 'TagType', data: str, unique: bool = False) -> 'Tag': - if unique: - tags = self.get_data_tags_at(addr) - for tag in tags: - if tag.type == type and tag.data == data: - return tag - - tag = self.create_tag(type, data, True) - core.BNAddUserDataTag(self.handle, addr, tag.handle) - return tag - def remove_user_data_tag(self, addr: int, tag: Tag): """ ``remove_user_data_tag`` removes a :py:class:`Tag` object at a data address. @@ -6452,22 +6220,6 @@ class BinaryView: if tag_type is not None: core.BNRemoveUserDataTagsOfType(self.handle, addr, tag_type.handle) - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`add_tag` instead') - def add_auto_data_tag(self, addr: int, tag: 'Tag'): - core.BNAddAutoDataTag(self.handle, addr, tag.handle) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`add_tag` instead') - def create_auto_data_tag(self, addr: int, type: 'TagType', data: str, unique: bool = False) -> 'Tag': - if unique: - tags = self.get_data_tags_at(addr) - for tag in tags: - if tag.type == type and tag.data == data: - return tag - - tag = self.create_tag(type, data, False) - core.BNAddAutoDataTag(self.handle, addr, tag.handle) - return tag - def remove_auto_data_tag(self, addr: int, tag: 'Tag'): """ ``remove_auto_data_tag`` removes a Tag object at a data address. @@ -10464,13 +10216,6 @@ class StructuredDataValue(object): value: bytes endian: Endianness - @deprecation.deprecated(deprecated_in="3.4.3997") - def __init__(self, t: '_type.Type', addr: int, val: bytes, e: Endianness): - self.type = t - self.address = addr - self.value = val - self.endian = e - def __str__(self): decode_str = "{}B".format(self.type.width) return ' '.join([f"{x:02x}" for x in struct.unpack(decode_str, self.value)]) @@ -10506,94 +10251,6 @@ class StructuredDataValue(object): return int(self) -class StructuredDataView(object): - """ - ``class StructuredDataView`` is a convenience class for reading structured binary data. - - StructuredDataView can be instantiated as follows:: - >>> from binaryninja import * - >>> bv = load("/bin/ls") - >>> structure = "Elf64_Header" - >>> address = bv.start - >>> elf = StructuredDataView(bv, structure, address) - >>> - - Once instantiated, members can be accessed:: - >>> print("{:x}".format(elf.machine)) - 003e - >>> - - """ - @deprecation.deprecated(deprecated_in="3.4.3997", details='Use :py:class:`TypedDataAccessor` or :py:attr:`DataVariable.value` instead.') - def __init__(self, bv: 'BinaryView', structure_name: '_types.QualifiedNameType', address: int): - self._bv = bv - self._structure_name = structure_name - self._address = address - self._members = OrderedDict() - self._endian = bv.endianness - - s = self._bv.get_type_by_name(self._structure_name) - if isinstance(s, _types.NamedTypeReferenceType): - s = s.target(self._bv) - if s is None: - raise ValueError(f"Failed to find type: {structure_name}") - if not isinstance(s, _types.StructureType): - raise ValueError(f"{self._structure_name} is not a StructureTypeClass, got: {type(s)}") - self._structure = s - - for m in self._structure.members: - self._members[m.name] = m - - def __repr__(self): - return f"<StructuredDataView type:{self._structure_name} size:{len(self._structure):#x} address:{self._address:#x}>" - - def __len__(self): - return len(self._structure) - - def __getattr__(self, key): - m = self._members.get(key, None) - if m is None: - return self.__getattribute__(key) - - return self[key] - - def __getitem__(self, key: str) -> Optional[StructuredDataValue]: - m = self._members.get(key, None) - if m is None: - return None - - ty = m.type - offset = m.offset - width = ty.width - - value = self._bv.read(self._address + offset, width) - return StructuredDataValue(ty, self._address + offset, value, self._endian) - - def __str__(self): - rv = "struct {name} 0x{addr:x} {{\n".format(name=self._structure_name, addr=self._address) - for k in self._members: - m = self._members[k] - - ty = m.type - offset = m.offset - - formatted_offset = "{:=+x}".format(offset) - formatted_type = "{:s} {:s}".format(str(ty), k) - - value = self[k] - assert value is not None - if value.width in (1, 2, 4, 8): - formatted_value = str.zfill("{:x}".format(value.int), value.width * 2) - else: - formatted_value = str(value) - - rv += "\t{:>6s} {:40s} = {:30s}\n".format(formatted_offset, formatted_type, formatted_value) - - rv += "}\n" - - return rv - - @dataclass class TypedDataAccessor: type: '_types.Type' diff --git a/python/enterprise.py b/python/enterprise.py index 5b4403d5..65fd31be 100644 --- a/python/enterprise.py +++ b/python/enterprise.py @@ -255,21 +255,6 @@ def update_license(duration, _cache=True): raise RuntimeError(last_error()) -@deprecation.deprecated(deprecated_in="3.4.4137", details="Use .update_license instead.") -def acquire_license(duration, _cache=True): - """ - Function deprecated. Use update_license instead. - - Check out and activate a license from the Enterprise Server. - - .. note:: You must authenticate with the Enterprise Server before calling this. - - :param int duration: Desired length of license checkout, in seconds. - :param bool _cache: Deprecated but left in for compatibility - """ - update_license(duration, _cache) - - def release_license(): """ Release the currently checked out license back to the Enterprise Server. diff --git a/python/filemetadata.py b/python/filemetadata.py index a78f548b..a840bd78 100644 --- a/python/filemetadata.py +++ b/python/filemetadata.py @@ -604,27 +604,6 @@ class FileMetadata: ) # TODO : When this is removed, you can probably remove `BNOpenExistingDatabase` and `BNOpenExistingDatabaseWithProgress` too - @deprecation.deprecated(deprecated_in="3.5.4378") - def open_existing_database(self, filename: str, progress_func: Optional[Callable[[int, int], bool]] = None): - if progress_func is None: - view = core.BNOpenExistingDatabase(self.handle, str(filename)) - else: - view = core.BNOpenExistingDatabaseWithProgress( - self.handle, str(filename), None, - ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, - ctypes.c_ulonglong)(lambda ctxt, cur, total: progress_func(cur, total)) - ) - if view is None: - return None - return binaryview.BinaryView(file_metadata=self, handle=view) - - # TODO : When this is removed, you can probably remove `BNOpenDatabaseForConfiguration` too - @deprecation.deprecated(deprecated_in="3.5.4378") - def open_database_for_configuration(self, filename: str) -> Optional['binaryview.BinaryView']: - view = core.BNOpenDatabaseForConfiguration(self.handle, str(filename)) - if view is None: - return None - return binaryview.BinaryView(file_metadata=self, handle=view) def save_auto_snapshot(self, progress_func: Optional[ProgressFuncType] = None, settings: Optional[SaveSettings] = None) -> bool: _settings = None diff --git a/python/function.py b/python/function.py index e21716ac..11cad6ef 100644 --- a/python/function.py +++ b/python/function.py @@ -598,12 +598,6 @@ class Function: core.BNSetUserFunctionPure(self.handle, bc) @property - @deprecation.deprecated(deprecated_in="3.4.4049", details="Use :py:attr:`Function.has_explicitly_defined_type` instead.") - def explicitly_defined_type(self) -> bool: - """Whether function has explicitly defined types (read-only)""" - return self.has_explicitly_defined_type - - @property def has_explicitly_defined_type(self) -> bool: """Whether function has explicitly defined types (read-only)""" return core.BNFunctionHasExplicitlyDefinedType(self.handle) @@ -825,68 +819,6 @@ class Function: else: core.BNAddUserAddressTag(self.handle, arch.handle, addr, tag.handle) - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`add_tag` instead.') - def create_user_tag(self, type: 'binaryview.TagType', data: str = "") -> 'binaryview.Tag': - return self.create_tag(type, data, True) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`add_tag` instead.') - def create_auto_tag(self, type: 'binaryview.TagType', data: str = "") -> 'binaryview.Tag': - return self.create_tag(type, data, False) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`add_tag` instead.') - def create_tag(self, type: 'binaryview.TagType', data: str = "", auto: bool = False) -> 'binaryview.Tag': - return self.view.create_tag(type, data, auto) - - @property - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:attr:`Function.tags` instead.') - def address_tags(self) -> TagList: - return TagList(self) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tags_at` instead.') - def get_address_tags_at(self, addr: int, - arch: Optional['architecture.Architecture'] = None) -> List['binaryview.Tag']: - if arch is None: - arch = self.arch - count = ctypes.c_ulonglong() - tags = core.BNGetAddressTags(self.handle, arch.handle, addr, count) - assert tags is not None, "core.BNGetAddressTags returned None" - result = [] - try: - for i in range(0, count.value): - core_tag = core.BNNewTagReference(tags[i]) - assert core_tag is not None, "core.BNNewTagReference returned None" - result.append(binaryview.Tag(core_tag)) - return result - finally: - core.BNFreeTagList(tags, count.value) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`add_tag` instead.') - def add_user_address_tag( - self, addr: int, tag: 'binaryview.Tag', arch: Optional['architecture.Architecture'] = None - ) -> None: - if arch is None: - arch = self.arch - core.BNAddUserAddressTag(self.handle, arch.handle, addr, tag.handle) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`add_tag` instead.') - def create_user_address_tag( - self, addr: int, tag_type: 'binaryview.TagType', data: str, unique: bool = False, - arch: Optional['architecture.Architecture'] = None - ) -> 'binaryview.Tag': - if not isinstance(tag_type, binaryview.TagType): - raise TypeError(f"type is not a TagType instead got {type(tag_type)} : {repr(tag_type)}") - if arch is None: - arch = self.arch - if unique: - tags = self.get_address_tags_at(addr, arch) - for tag in tags: - if tag.type == tag_type and tag.data == data: - return tag - - tag = self.create_tag(tag_type, data, True) - core.BNAddUserAddressTag(self.handle, arch.handle, addr, tag.handle) - return tag - def remove_user_address_tag( self, addr: int, tag: 'binaryview.Tag', arch: Optional['architecture.Architecture'] = None ) -> None: @@ -903,62 +835,6 @@ class Function: arch = self.arch core.BNRemoveUserAddressTag(self.handle, arch.handle, addr, tag.handle) - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`add_tag` instead.') - def add_auto_address_tag( - self, addr: int, tag: 'binaryview.Tag', arch: Optional['architecture.Architecture'] = None - ) -> None: - if arch is None: - arch = self.arch - core.BNAddAutoAddressTag(self.handle, arch.handle, addr, tag.handle) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`add_tag` instead.') - def create_auto_address_tag( - self, addr: int, type: 'binaryview.TagType', data: str, unique: bool = False, - arch: Optional['architecture.Architecture'] = None - ) -> 'binaryview.Tag': - if arch is None: - arch = self.arch - if unique: - tags = self.get_address_tags_at(addr, arch) - for tag in tags: - if tag.type == type and tag.data == data: - return tag - - tag = self.create_tag(type, data, False) - core.BNAddAutoAddressTag(self.handle, arch.handle, addr, tag.handle) - return tag - - @property - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py;func:`get_function_tags` instead.') - def function_tags(self) -> List['binaryview.Tag']: - count = ctypes.c_ulonglong() - tags = core.BNGetFunctionTags(self.handle, count) - assert tags is not None, "core.BNGetFunctionTags returned None" - try: - result = [] - for i in range(count.value): - core_tag = core.BNNewTagReference(tags[i]) - assert core_tag is not None, "core.BNNewTagReference returned None" - result.append(binaryview.Tag(core_tag)) - return result - finally: - core.BNFreeTagList(tags, count.value) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`add_tag` instead.') - def add_user_function_tag(self, tag: 'binaryview.Tag') -> None: - core.BNAddUserFunctionTag(self.handle, tag.handle) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`add_tag` instead.') - def create_user_function_tag(self, type: 'binaryview.TagType', data: str, unique: bool = False) -> 'binaryview.Tag': - if unique: - for tag in self.function_tags: - if tag.type == type and tag.data == data: - return tag - - tag = self.create_tag(type, data, True) - core.BNAddUserFunctionTag(self.handle, tag.handle) - return tag - def remove_user_function_tag(self, tag: 'binaryview.Tag') -> None: """ ``remove_user_function_tag`` removes a Tag object as a function tag. @@ -969,214 +845,6 @@ class Function: """ core.BNRemoveUserFunctionTag(self.handle, tag.handle) - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`add_tag` instead.') - def add_auto_function_tag(self, tag: 'binaryview.Tag') -> None: - core.BNAddAutoFunctionTag(self.handle, tag.handle) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`add_tag` instead.') - def create_auto_function_tag(self, type: 'binaryview.TagType', data: str, unique: bool = False) -> 'binaryview.Tag': - if unique: - for tag in self.function_tags: - if tag.type == type and tag.data == data: - return tag - - tag = self.create_tag(type, data, False) - core.BNAddAutoFunctionTag(self.handle, tag.handle) - return tag - - @property - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:attr:`tags` instead.') - def auto_address_tags(self) -> List[Tuple['architecture.Architecture', int, 'binaryview.Tag']]: - count = ctypes.c_ulonglong() - tags = core.BNGetAutoAddressTagReferences(self.handle, count) - assert tags is not None, "core.BNGetAutoAddressTagReferences returned None" - try: - result = [] - for i in range(0, count.value): - arch = architecture.CoreArchitecture._from_cache(tags[i].arch) - tag_ref = core.BNNewTagReference(tags[i].tag) - assert tag_ref is not None, "core.BNNewTagReference returned None" - tag = binaryview.Tag(tag_ref) - result.append((arch, tags[i].addr, tag)) - return result - finally: - core.BNFreeTagReferences(tags, count.value) - - @property - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:attr:`tags` instead.') - def user_address_tags(self): - count = ctypes.c_ulonglong() - tags = core.BNGetUserAddressTagReferences(self.handle, count) - assert tags is not None, "core.BNGetUserAddressTagReferences returned" - try: - result = [] - for i in range(0, count.value): - arch = architecture.CoreArchitecture._from_cache(tags[i].arch) - tag_ref = core.BNNewTagReference(tags[i].tag) - assert tag_ref is not None, "core.BNNewTagReference returned None" - tag = binaryview.Tag(tag_ref) - result.append((arch, tags[i].addr, tag)) - return result - finally: - core.BNFreeTagReferences(tags, count.value) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tags_at` instead.') - def get_auto_address_tags_at(self, addr, arch=None): - if arch is None: - assert self.arch is not None, "Can't call get_auto_address_tags_at for function with no architecture specified" - arch = self.arch - count = ctypes.c_ulonglong() - tags = core.BNGetAutoAddressTags(self.handle, arch.handle, addr, count) - assert tags is not None, "core.BNGetAutoAddressTags returned None" - try: - result = [] - for i in range(0, count.value): - tag_ref = core.BNNewTagReference(tags[i]) - assert tag_ref is not None, "core.BNNewTagReference returned None" - result.append(binaryview.Tag(tag_ref)) - return result - finally: - core.BNFreeTagList(tags, count.value) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tags_at` instead.') - def get_user_address_tags_at(self, addr, arch=None): - if arch is None: - assert self.arch is not None, "Can't call get_user_address_tags_at for function with no architecture specified" - arch = self.arch - count = ctypes.c_ulonglong() - tags = core.BNGetUserAddressTags(self.handle, arch.handle, addr, count) - assert tags is not None, "core.BNGetUserAddressTags returned None" - try: - result = [] - for i in range(0, count.value): - tag_ref = core.BNNewTagReference(tags[i]) - assert tag_ref is not None, "core.BNNewTagReference returned None" - result.append(binaryview.Tag(tag_ref)) - return result - finally: - core.BNFreeTagList(tags, count.value) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tags_at` instead.') - def get_address_tags_of_type(self, addr: int, tag_type: 'binaryview.TagType', arch=None): - if arch is None: - assert self.arch is not None, "Can't call get_address_tags_of_type for function with no architecture specified" - arch = self.arch - count = ctypes.c_ulonglong() - tags = core.BNGetAddressTagsOfType(self.handle, arch.handle, addr, tag_type.handle, count) - assert tags is not None, "core.BNGetAddressTagsOfType returned None" - try: - result = [] - for i in range(0, count.value): - tag_ref = core.BNNewTagReference(tags[i]) - assert tag_ref is not None, "core.BNNewTagReference returned None" - result.append(binaryview.Tag(tag_ref)) - return result - finally: - core.BNFreeTagList(tags, count.value) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tags_at` instead.') - def get_auto_address_tags_of_type( - self, addr: int, tag_type: 'binaryview.TagType', arch: Optional['architecture.Architecture'] = None - ): - if arch is None: - assert self.arch is not None, "Can't call get_auto_address_tags_of_type for function with no architecture specified" - arch = self.arch - count = ctypes.c_ulonglong() - tags = core.BNGetAutoAddressTagsOfType(self.handle, arch.handle, addr, tag_type.handle, count) - assert tags is not None, "core.BNGetAutoAddressTagsOfType returned None" - try: - result = [] - for i in range(0, count.value): - tag_ref = core.BNNewTagReference(tags[i]) - assert tag_ref is not None, "core.BNNewTagReference returned None" - result.append(binaryview.Tag(tag_ref)) - return result - finally: - core.BNFreeTagList(tags, count.value) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tags_at` instead.') - def get_user_address_tags_of_type( - self, addr: int, tag_type: 'binaryview.TagType', arch: Optional['architecture.Architecture'] = None - ): - if arch is None: - assert self.arch is not None, "Can't get_user_address_tags_of_type for function with no architecture specified" - arch = self.arch - count = ctypes.c_ulonglong() - tags = core.BNGetUserAddressTagsOfType(self.handle, arch.handle, addr, tag_type.handle, count) - assert tags is not None, "core.BNGetUserAddressTagsOfType returned None" - try: - result = [] - for i in range(0, count.value): - tag_ref = core.BNNewTagReference(tags[i]) - assert tag_ref is not None, "core.BNNewTagReference returned None" - result.append(binaryview.Tag(tag_ref)) - return result - finally: - core.BNFreeTagList(tags, count.value) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tags_in_range` instead.') - def get_address_tags_in_range( - self, address_range: 'variable.AddressRange', arch: Optional['architecture.Architecture'] = None - ) -> List[Tuple['architecture.Architecture', int, 'binaryview.Tag']]: - if arch is None: - assert self.arch is not None, "Can't call get_address_tags_in_range for function with no architecture specified" - arch = self.arch - count = ctypes.c_ulonglong() - refs = core.BNGetAddressTagsInRange(self.handle, arch.handle, address_range.start, address_range.end, count) - assert refs is not None, "core.BNGetAddressTagsInRange returned None" - try: - result = [] - for i in range(0, count.value): - tag_ref = core.BNNewTagReference(refs[i].tag) - assert tag_ref is not None, "core.BNNewTagReference returned None" - tag = binaryview.Tag(tag_ref) - result.append((arch, refs[i].addr, tag)) - return result - finally: - core.BNFreeTagReferences(refs, count.value) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tags_in_range` instead.') - def get_auto_address_tags_in_range( - self, address_range: 'variable.AddressRange', arch: Optional['architecture.Architecture'] = None - ) -> List[Tuple['architecture.Architecture', int, 'binaryview.Tag']]: - if arch is None: - assert self.arch is not None, "Can't call get_auto_address_tags_in_range for function with no architecture specified" - arch = self.arch - count = ctypes.c_ulonglong() - refs = core.BNGetAutoAddressTagsInRange(self.handle, arch.handle, address_range.start, address_range.end, count) - assert refs is not None, "core.BNGetAutoAddressTagsInRange returned None" - try: - result = [] - for i in range(0, count.value): - tag_ref = core.BNNewTagReference(refs[i].tag) - assert tag_ref is not None, "core.BNNewTagReference returned None" - tag = binaryview.Tag(tag_ref) - result.append((arch, refs[i].addr, tag)) - return result - finally: - core.BNFreeTagReferences(refs, count.value) - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_tags_in_range` instead.') - def get_user_address_tags_in_range( - self, address_range: 'variable.AddressRange', arch: Optional['architecture.Architecture'] = None - ) -> List[Tuple['architecture.Architecture', int, 'binaryview.Tag']]: - if arch is None: - assert self.arch is not None, "Can't call get_user_address_tags_in_range for function with no architecture specified" - arch = self.arch - count = ctypes.c_ulonglong() - refs = core.BNGetUserAddressTagsInRange(self.handle, arch.handle, address_range.start, address_range.end, count) - assert refs is not None, "core.BNGetUserAddressTagsInRange returned None" - try: - result = [] - for i in range(0, count.value): - tag_ref = core.BNNewTagReference(refs[i].tag) - assert tag_ref is not None, "core.BNNewTagReference returned None" - tag = binaryview.Tag(tag_ref) - result.append((arch, refs[i].addr, tag)) - return result - finally: - core.BNFreeTagReferences(refs, count.value) - def remove_user_address_tags_of_type(self, addr: int, tag_type: str, arch=None): """ ``remove_user_address_tags_of_type`` removes all tags at the given address of the given type. @@ -1223,73 +891,6 @@ class Function: if tag_type is not None: core.BNRemoveAutoAddressTagsOfType(self.handle, arch.handle, addr, tag_type.handle) - @property - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_function_tags` instead.') - def auto_function_tags(self): - count = ctypes.c_ulonglong() - tags = core.BNGetAutoFunctionTags(self.handle, count) - assert tags is not None, "core.BNGetAutoFunctionTags returned None" - result = [] - for i in range(0, count.value): - tag_ref = core.BNNewTagReference(tags[i]) - assert tag_ref is not None, "core.BNNewTagReference returned None" - result.append(binaryview.Tag(tag_ref)) - core.BNFreeTagList(tags, count.value) - return result - - @property - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_function_tags` instead.') - def user_function_tags(self): - count = ctypes.c_ulonglong() - tags = core.BNGetUserFunctionTags(self.handle, count) - assert tags is not None, "core.BNGetUserFunctionTags returned None" - result = [] - for i in range(0, count.value): - tag_ref = core.BNNewTagReference(tags[i]) - assert tag_ref is not None, "core.BNNewTagReference returned None" - result.append(binaryview.Tag(tag_ref)) - core.BNFreeTagList(tags, count.value) - return result - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_function_tags` instead.') - def get_function_tags_of_type(self, tag_type): - count = ctypes.c_ulonglong() - tags = core.BNGetFunctionTagsOfType(self.handle, tag_type.handle, count) - assert tags is not None, "core.BNGetFunctionTagsOfType returned None" - result = [] - for i in range(0, count.value): - tag_ref = core.BNNewTagReference(tags[i]) - assert tag_ref is not None, "core.BNNewTagReference returned None" - result.append(binaryview.Tag(tag_ref)) - core.BNFreeTagList(tags, count.value) - return result - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_function_tags` instead.') - def get_auto_function_tags_of_type(self, tag_type): - count = ctypes.c_ulonglong() - tags = core.BNGetAutoFunctionTagsOfType(self.handle, tag_type.handle, count) - assert tags is not None, "core.BNGetAutoFunctionTagsOfType returned None" - result = [] - for i in range(0, count.value): - tag_ref = core.BNNewTagReference(tags[i]) - assert tag_ref is not None, "core.BNNewTagReference returned None" - result.append(binaryview.Tag(tag_ref)) - core.BNFreeTagList(tags, count.value) - return result - - @deprecation.deprecated(deprecated_in="3.4.4146", details='Use :py:func:`get_function_tags` instead.') - def get_user_function_tags_of_type(self, tag_type): - count = ctypes.c_ulonglong() - tags = core.BNGetUserFunctionTagsOfType(self.handle, tag_type.handle, count) - assert tags is not None, "core.BNGetUserFunctionTagsOfType returned None" - result = [] - for i in range(0, count.value): - tag_ref = core.BNNewTagReference(tags[i]) - assert tag_ref is not None, "core.BNNewTagReference returned None" - result.append(binaryview.Tag(tag_ref)) - core.BNFreeTagList(tags, count.value) - return result - def remove_user_function_tags_of_type(self, tag_type: str): """ ``remove_user_function_tags_of_type`` removes all function Tag objects on a function of a given type @@ -1468,20 +1069,6 @@ class Function: return highlevelil.HighLevelILFunction(self.arch, result, self) @property - @deprecation.deprecated(deprecated_in="3.4.3997", details="Use :py:attr:`type` instead", current_version=__version__) - def function_type(self) -> 'types.FunctionType': - """ - Function type object, can be set with either a string representing the function prototype - (`str(function)` shows examples) or a :py:class:`Type` object - """ - return self.type - - @function_type.setter - @deprecation.deprecated(deprecated_in="3.4.3997", details="Use :py:attr:`type` instead", current_version=__version__) - def function_type(self, value: Union['types.FunctionType', str]) -> None: - self.type = value - - @property def type(self) -> 'types.FunctionType': """ Function type object, can be set with either a string representing the function prototype @@ -1858,22 +1445,6 @@ class Function: start += i[1] @property - @deprecation.deprecated(deprecated_in="3.4.3997", details="Use :py:attr:`LowLevelIlFunction.instructions` instead.") - def llil_instructions(self) -> Generator['lowlevelil.LowLevelILInstruction', None, None]: - """ - .. note:: Use :py:meth:`LowLevelIlFunction.instructions` instead. - """ - return self.llil.instructions - - @property - @deprecation.deprecated(deprecated_in="3.4.3997", details="Use :py:attr:`MediumLevelIlFunction.instructions` instead.") - def mlil_instructions(self) -> Generator['mediumlevelil.MediumLevelILInstruction', None, None]: - """ - .. note:: Use :py:meth:`MediumLevelIlFunction.instructions` instead. - """ - return self.mlil.instructions - - @property def too_large(self) -> bool: """Whether the function is too large to automatically perform analysis (read-only)""" return core.BNIsFunctionTooLarge(self.handle) @@ -1967,13 +1538,6 @@ class Function: def get_comment_at(self, addr: int) -> str: return core.BNGetCommentForAddress(self.handle, addr) - @deprecation.deprecated(deprecated_in="3.4.3997", details="Use :py:func:`Function.set_comment_at` instead.") - def set_comment(self, addr: int, comment: str) -> None: - """ - .. note:: Use :py:meth:`set_comment_at` instead. - """ - self.set_comment_at(addr, comment) - def set_comment_at(self, addr: int, comment: str) -> None: """ ``set_comment_at`` sets a comment for the current function at the address specified diff --git a/python/highlevelil.py b/python/highlevelil.py index 27a38b2b..48cbd6cc 100644 --- a/python/highlevelil.py +++ b/python/highlevelil.py @@ -2400,25 +2400,6 @@ ILInstruction = { } -class HighLevelILExpr: - """ - ``class HighLevelILExpr`` hold the index of IL Expressions. - - .. note:: Use ExpressionIndex instead - """ - - @deprecation.deprecated(deprecated_in="3.4.3997", details='Use ExpressionIndex instead') - def __init__(self, index: ExpressionIndex): - self._index = index - - def __int__(self): - return self._index - - @property - def index(self) -> ExpressionIndex: - return self._index - - class HighLevelILFunction: """ ``class HighLevelILFunction`` contains the a HighLevelILInstruction object that makes up the abstract syntax tree of @@ -2478,11 +2459,9 @@ class HighLevelILFunction: def __len__(self): return int(core.BNGetHighLevelILInstructionCount(self.handle)) - def __getitem__(self, i: Union[HighLevelILExpr, int]) -> HighLevelILInstruction: + def __getitem__(self, i: int) -> HighLevelILInstruction: if isinstance(i, slice) or isinstance(i, tuple): - raise IndexError("expected integer instruction index") - if isinstance(i, HighLevelILExpr): - return HighLevelILInstruction.create(self, i.index) + raise IndexError("expected integer index") if i < -len(self) or i >= len(self): raise IndexError("index out of range") if i < 0: diff --git a/python/typeparser.py b/python/typeparser.py index 3e58d650..8b5e4b67 100644 --- a/python/typeparser.py +++ b/python/typeparser.py @@ -642,42 +642,3 @@ class CoreTypeParser(TypeParser): core.BNFreeTypeParserErrors(errors_cpp, error_count.value) return result, errors - -@deprecation.deprecated(deprecated_in="3.4.4271", details="Use TypeParser.preprocess_source instead.") -def preprocess_source(source: str, filename: str = None, - include_dirs: Optional[List[str]] = None) -> Tuple[Optional[str], str]: - """ - ``preprocess_source`` run the C preprocessor on the given source or source filename. - - :param str source: source to pre-process - :param str filename: optional filename to pre-process - :param include_dirs: list of string directories to use as include directories. - :type include_dirs: list(str) - :return: returns a tuple of (preprocessed_source, error_string) - :rtype: tuple(str,str) - :Example: - - >>> source = "#define TEN 10\\nint x[TEN];\\n" - >>> preprocess_source(source) - ('#line 1 "input"\\n\\n#line 2 "input"\\n int x [ 10 ] ;\\n', '') - >>> - """ - if filename is None: - filename = "input" - if include_dirs is None: - include_dirs = [] - dir_buf = (ctypes.c_char_p * len(include_dirs))() - for i in range(0, len(include_dirs)): - dir_buf[i] = include_dirs[i].encode('charmap') - output = ctypes.c_char_p() - errors = ctypes.c_char_p() - result = core.BNPreprocessSource(source, filename, output, errors, dir_buf, len(include_dirs)) - assert output.value is not None - assert errors.value is not None - output_str = output.value.decode('utf-8') - error_str = errors.value.decode('utf-8') - core.free_string(output) - core.free_string(errors) - if result: - return output_str, error_str - return None, error_str |
