diff options
| author | Brian Potchik <brian@vector35.com> | 2021-04-06 11:13:51 -0400 |
|---|---|---|
| committer | Brian Potchik <brian@vector35.com> | 2021-04-06 11:13:51 -0400 |
| commit | ccc46ee23e8160231b1de739380bd7d808ec433d (patch) | |
| tree | 3208f74e38691890aa6d5a77b3448df86021c8cf /python | |
| parent | 1f70e7091d198662ddebcd2398f0e0c1b2ecff24 (diff) | |
Add support for duplicate symbol handling.
Diffstat (limited to 'python')
| -rw-r--r-- | python/binaryview.py | 13 | ||||
| -rw-r--r-- | python/types.py | 16 |
2 files changed, 6 insertions, 23 deletions
diff --git a/python/binaryview.py b/python/binaryview.py index 85fcd353..1fde4bcd 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -27,7 +27,7 @@ import numbers import json import inspect -from collections import OrderedDict +from collections import defaultdict, OrderedDict # Binary Ninja components from binaryninja import _binaryninjacore as core @@ -1912,13 +1912,10 @@ class BinaryView(object): """Dict of symbols (read-only)""" count = ctypes.c_ulonglong(0) syms = core.BNGetSymbols(self.handle, count, None) - result = {} + result = defaultdict(list) for i in range(0, count.value): sym = types.Symbol(None, None, None, handle=core.BNNewSymbolReference(syms[i])) - if sym.raw_name in result: - result[sym.raw_name] = [result[sym.raw_name], sym] - else: - result[sym.raw_name] = sym + result[sym.raw_name].append(sym) core.BNFreeSymbolList(syms, count.value) return result @@ -3875,7 +3872,7 @@ class BinaryView(object): :Example: >>> bv.get_symbols(0x1000200c, 1) - [<ImportAddressSymbol: "KERNEL32!IsProcessorFeaturePresent@IAT" @ 0x1000200c>] + [<ImportAddressSymbol: "KERNEL32!IsProcessorFeaturePresent" @ 0x1000200c>] >>> """ count = ctypes.c_ulonglong(0) @@ -3906,7 +3903,7 @@ class BinaryView(object): :Example: >>> bv.get_symbols_of_type(SymbolType.ImportAddressSymbol, 0x10002028, 1) - [<ImportAddressSymbol: "KERNEL32!GetCurrentThreadId@IAT" @ 0x10002028>] + [<ImportAddressSymbol: "KERNEL32!GetCurrentThreadId" @ 0x10002028>] >>> """ if isinstance(sym_type, str): diff --git a/python/types.py b/python/types.py index 76f8c7f0..39378963 100644 --- a/python/types.py +++ b/python/types.py @@ -151,7 +151,7 @@ class TypeReferenceSource(object): self._name = name self._offset = offset self._ref_type = ref_type - + def __str__(self): if self.ref_type == TypeReferenceType.DirectTypeReferenceType: s = 'direct' @@ -354,20 +354,6 @@ class Symbol(object): def auto(self): return core.BNIsSymbolAutoDefined(self.handle) - @property - def aliases(self): - """ - List of aliases tied to this symbol. - Aliases are the names of any other symbols that also happen to be at the same address. - """ - result = [] - count = ctypes.c_ulonglong(0) - aliases = core.BNGetSymbolAliases(self.handle, count) - for i in range(count.value): - result.append(aliases[i]) - core.BNFreeStringList(aliases, count) - return result - class FunctionParameter(object): def __init__(self, param_type, name = "", location = None): |
