diff options
| author | Glenn Smith <glenn@vector35.com> | 2021-12-08 21:43:12 -0500 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2022-01-13 15:56:38 -0500 |
| commit | 486a019282443ae5429b3c42ae132fe11f4f017f (patch) | |
| tree | c04bfd26989e1918f0bb92c9175be758c6966890 /python | |
| parent | 0444f19299b05c0e9feada89c9ef487e59b6cfcc (diff) | |
Fix a bunch of core function calls with bad args
Diffstat (limited to 'python')
| -rw-r--r-- | python/binaryview.py | 24 | ||||
| -rw-r--r-- | python/callingconvention.py | 10 | ||||
| -rw-r--r-- | python/filemetadata.py | 9 | ||||
| -rw-r--r-- | python/highlevelil.py | 2 | ||||
| -rw-r--r-- | python/platform.py | 4 | ||||
| -rw-r--r-- | python/pluginmanager.py | 6 | ||||
| -rw-r--r-- | python/types.py | 10 | ||||
| -rw-r--r-- | python/workflow.py | 4 |
8 files changed, 37 insertions, 32 deletions
diff --git a/python/binaryview.py b/python/binaryview.py index 3f3f1808..03b1f9e7 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -1067,7 +1067,7 @@ class Segment: try: return [(ranges[i].start, ranges[i].end) for i in range(count.value)] finally: - core.BNFreeRelocationRanges(ranges, count) + core.BNFreeRelocationRanges(ranges) def relocation_ranges_at(self, addr:int) -> List[Tuple[int, int]]: """List of relocation range tuples (read-only)""" @@ -1078,7 +1078,7 @@ class Segment: try: return [(ranges[i].start, ranges[i].end) for i in range(count.value)] finally: - core.BNFreeRelocationRanges(ranges, count) + core.BNFreeRelocationRanges(ranges) class Section: @@ -2386,7 +2386,7 @@ class BinaryView: try: return [(ranges[i].start, ranges[i].end) for i in range(count.value)] finally: - core.BNFreeRelocationRanges(ranges, count) + core.BNFreeRelocationRanges(ranges) def relocation_ranges_at(self, addr:int) -> List[Tuple[int, int]]: """List of relocation range tuples for a given address""" @@ -2397,7 +2397,7 @@ class BinaryView: try: return [(ranges[i].start, ranges[i].end) for i in range(count.value)] finally: - core.BNFreeRelocationRanges(ranges, count) + core.BNFreeRelocationRanges(ranges) def range_contains_relocation(self, addr:int, size:int) -> bool: """Checks if the specified range overlaps with a relocation""" @@ -3820,7 +3820,7 @@ class BinaryView: for i in range(0, count.value): yield refs[i] finally: - core.BNFreeDataReferences(refs, count.value) + core.BNFreeDataReferences(refs) def get_data_refs_from(self, addr:int, length:int=None) -> Generator[int, None, None]: """ @@ -3851,7 +3851,7 @@ class BinaryView: for i in range(0, count.value): yield refs[i] finally: - core.BNFreeDataReferences(refs, count.value) + core.BNFreeDataReferences(refs) def get_code_refs_for_type(self, name:str) -> Generator[ReferenceSource, None, None]: """ @@ -3944,7 +3944,7 @@ class BinaryView: for i in range(0, count.value): yield refs[i] finally: - core.BNFreeDataReferences(refs, count.value) + core.BNFreeDataReferences(refs) def get_data_refs_for_type_field(self, name:'_types.QualifiedNameType', offset:int) -> List[int]: @@ -3975,7 +3975,7 @@ class BinaryView: result.append(refs[i]) return result finally: - core.BNFreeDataReferences(refs, count.value) + core.BNFreeDataReferences(refs) def get_type_refs_for_type(self, name:'_types.QualifiedNameType') -> List['_types.TypeReferenceSource']: @@ -4157,7 +4157,7 @@ class BinaryView: result.append(refs[i]) return result finally: - core.BNFreeDataReferences(refs, count.value) + core.BNFreeDataReferences(refs) def get_all_sizes_referenced(self, name:'_types.QualifiedNameType') -> Mapping[int, List[int]]: """ @@ -4501,10 +4501,10 @@ class BinaryView: count = ctypes.c_ulonglong(0) if start is None: - syms = core.BNGetSymbolsOfType(self.handle, sym_type, count, _namespace) + syms = core.BNGetSymbolsOfType(self.handle, int(sym_type), count, _namespace) assert syms is not None, "core.BNGetSymbolsOfType returned None" else: - syms = core.BNGetSymbolsOfTypeInRange(self.handle, sym_type, start, length, count) + syms = core.BNGetSymbolsOfTypeInRange(self.handle, int(sym_type), start, length, count, _namespace) assert syms is not None, "core.BNGetSymbolsOfTypeInRange returned None" result = [] try: @@ -4610,7 +4610,7 @@ class BinaryView: >>> bv.create_user_data_tag(here, tt, "Get Crabbed") >>> """ - tag_handle = core.BNCreateTagType(self.handle, name, icon) + tag_handle = core.BNCreateTagType(self.handle) assert tag_handle is not None, "core.BNCreateTagType returned None" tag_type = TagType(tag_handle) tag_type.name = name diff --git a/python/callingconvention.py b/python/callingconvention.py index 8558ca96..89040119 100644 --- a/python/callingconvention.py +++ b/python/callingconvention.py @@ -100,7 +100,7 @@ class CallingConvention: arch = self.arch for i in range(0, count.value): result.append(arch.get_reg_name(regs[i])) - core.BNFreeRegisterList(regs, count.value) + core.BNFreeRegisterList(regs) self.__dict__["caller_saved_regs"] = result count = ctypes.c_ulonglong() @@ -110,7 +110,7 @@ class CallingConvention: arch = self.arch for i in range(0, count.value): result.append(arch.get_reg_name(regs[i])) - core.BNFreeRegisterList(regs, count.value) + core.BNFreeRegisterList(regs) self.__dict__["callee_saved_regs"] = result count = ctypes.c_ulonglong() @@ -120,7 +120,7 @@ class CallingConvention: arch = self.arch for i in range(0, count.value): result.append(arch.get_reg_name(regs[i])) - core.BNFreeRegisterList(regs, count.value) + core.BNFreeRegisterList(regs) self.__dict__["int_arg_regs"] = result count = ctypes.c_ulonglong() @@ -130,7 +130,7 @@ class CallingConvention: arch = self.arch for i in range(0, count.value): result.append(arch.get_reg_name(regs[i])) - core.BNFreeRegisterList(regs, count.value) + core.BNFreeRegisterList(regs) self.__dict__["float_arg_regs"] = result reg = core.BNGetIntegerReturnValueRegister(_handle) @@ -164,7 +164,7 @@ class CallingConvention: arch = self.arch for i in range(0, count.value): result.append(arch.get_reg_name(regs[i])) - core.BNFreeRegisterList(regs, count.value) + core.BNFreeRegisterList(regs) self.__dict__["implicitly_defined_regs"] = result assert _handle is not None self.handle = _handle diff --git a/python/filemetadata.py b/python/filemetadata.py index acf3beb8..5a36fde0 100644 --- a/python/filemetadata.py +++ b/python/filemetadata.py @@ -468,10 +468,15 @@ class FileMetadata: ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_ulonglong)( lambda ctxt, cur, total: _progress_func(cur, total)), _settings) - def merge_user_analysis(self, path:str, progress_func:ProgressFuncType): + def merge_user_analysis(self, path:str, progress_func:ProgressFuncType, excluded_hashes:Optional[List[str]]=None): + if excluded_hashes is None: + excluded_hashes = [] + excluded = (ctypes.c_char_p * len(excluded_hashes))() + for i in range(len(excluded_hashes)): + excluded[i] = core.cstr(excluded_hashes[i]) return core.BNMergeUserAnalysis(self.handle, str(path), None, ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_ulonglong)( - lambda ctxt, cur, total: progress_func(cur, total))) + lambda ctxt, cur, total: progress_func(cur, total)), excluded, len(excluded_hashes)) def get_view_of_type(self, name:str) -> Optional['binaryview.BinaryView']: view = core.BNGetFileViewOfType(self.handle, str(name)) diff --git a/python/highlevelil.py b/python/highlevelil.py index 4837323c..4298e91f 100644 --- a/python/highlevelil.py +++ b/python/highlevelil.py @@ -2171,7 +2171,7 @@ class HighLevelILFunction: @root.setter def root(self, value:HighLevelILInstruction) -> None: - core.BNSetHighLevelILRootExpr(value.expr_index) + core.BNSetHighLevelILRootExpr(self.handle, value.expr_index) def _basic_block_list(self): count = ctypes.c_ulonglong() diff --git a/python/platform.py b/python/platform.py index 41934776..84125456 100644 --- a/python/platform.py +++ b/python/platform.py @@ -128,10 +128,10 @@ class Platform(metaclass=_PlatformMetaClass): platforms = core.BNGetPlatformList(count) assert platforms is not None, "core.BNGetPlatformList returned None" elif arch is None: - platforms = core.BNGetPlatformListByOS(os) + platforms = core.BNGetPlatformListByOS(os, count) assert platforms is not None, "core.BNGetPlatformListByOS returned None" else: - platforms = core.BNGetPlatformListByArchitecture(os, arch.handle) + platforms = core.BNGetPlatformListByArchitecture(arch.handle, count) assert platforms is not None, "core.BNGetPlatformListByArchitecture returned None" result = [] for i in range(0, count.value): diff --git a/python/pluginmanager.py b/python/pluginmanager.py index ef9a9d1c..1b5e1b72 100644 --- a/python/pluginmanager.py +++ b/python/pluginmanager.py @@ -113,7 +113,7 @@ class RepoPlugin: assert platforms is not None, "core.BNPluginGetApis returned None" for i in range(count.value): result.append(platforms[i].decode("utf-8")) - core.BNFreePluginPlatforms(platforms, count) + core.BNFreePluginPlatforms(platforms, count.value) return result @property @@ -203,7 +203,7 @@ class RepoPlugin: assert platforms is not None, "core.BNPluginGetPlatforms returned None" for i in range(count.value): result.append(platforms[i].decode("utf-8")) - core.BNFreePluginPlatforms(platforms, count) + core.BNFreePluginPlatforms(platforms, count.value) return result @property @@ -300,7 +300,7 @@ class Repository: assert result is not None, "core.BNRepositoryGetPlugins returned None" for i in range(count.value): pluginlist.append(RepoPlugin(core.BNNewPluginReference(result[i]))) - core.BNFreeRepositoryPluginList(result, count.value) + core.BNFreeRepositoryPluginList(result) del result return pluginlist diff --git a/python/types.py b/python/types.py index ad3d4590..160d78f9 100644 --- a/python/types.py +++ b/python/types.py @@ -901,7 +901,7 @@ class FunctionBuilder(TypeBuilder): @property def can_return(self) -> bool: - return core.BNFunctionTypeBuilderCanReturn(self._handle) + return core.BNFunctionTypeBuilderCanReturn(self._handle).value @can_return.setter def can_return(self, value:BoolWithConfidenceType) -> None: # type: ignore @@ -1055,11 +1055,11 @@ class StructureBuilder(TypeBuilder): @members.setter def members(self, members:List[StructureMember]) -> None: for i in range(len(self.members)): - core.BNRemoveStructureBuilderMember(i) + core.BNRemoveStructureBuilderMember(self.builder_handle, i) for member in members: core.BNAddStructureBuilderMember(self.builder_handle, member.type._to_core_struct(), - member.name, member.access, member.scope) + member.name, int(member.access), int(member.scope)) @property def packed(self) -> bool: @@ -2043,7 +2043,7 @@ class EnumerationType(IntegerType): assert type_builder_handle is not None, "core.BNCreateTypeBuilderFromType returned None" enumeration_handle = core.BNGetTypeEnumeration(self._handle) assert enumeration_handle is not None, "core.BNGetTypeStructure returned None" - enumeration_builder_handle = core.BNCreateEnumerationBuilderFromEnumeration(enumeration_handle) + enumeration_builder_handle = core.BNCreateEnumerationTypeBuilder(self.platform.arch.handle, enumeration_handle, self.width, self.signed.value) assert enumeration_builder_handle is not None, "core.BNCreateEnumerationTypeBuilder returned None" return EnumerationBuilder(type_builder_handle, enumeration_builder_handle, self.platform, self.confidence) @@ -2466,4 +2466,4 @@ class TypeFieldReference: if self.arch: return f"<ref: {self.arch.name}@{self.address:#x}, size: {self.size:#x}, type: {self.incomingType}>" else: - return f"<ref: {self.address:#x}, size: {self.size:#x}, type: {self.incomingType}>"
\ No newline at end of file + return f"<ref: {self.address:#x}, size: {self.size:#x}, type: {self.incomingType}>" diff --git a/python/workflow.py b/python/workflow.py index 4ec890bb..b9c38e35 100644 --- a/python/workflow.py +++ b/python/workflow.py @@ -309,7 +309,7 @@ class Workflow(metaclass=_WorkflowMetaclass): out_list.append(result[i].decode('utf-8')) return out_list finally: - core.BNFreeStringList(result, length) + core.BNFreeStringList(result, length.value) def subactivities(self, activity:ActivityType = "", immediate:bool = True) -> List[str]: """ @@ -329,7 +329,7 @@ class Workflow(metaclass=_WorkflowMetaclass): out_list.append(result[i].decode('utf-8')) return out_list finally: - core.BNFreeStringList(result, length) + core.BNFreeStringList(result, length.value) def assign_subactivities(self, activity:Activity, activities:List[str]) -> bool: """ |
