From ccc46ee23e8160231b1de739380bd7d808ec433d Mon Sep 17 00:00:00 2001 From: Brian Potchik Date: Tue, 6 Apr 2021 11:13:51 -0400 Subject: Add support for duplicate symbol handling. --- python/binaryview.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'python/binaryview.py') 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) - [] + [] >>> """ count = ctypes.c_ulonglong(0) @@ -3906,7 +3903,7 @@ class BinaryView(object): :Example: >>> bv.get_symbols_of_type(SymbolType.ImportAddressSymbol, 0x10002028, 1) - [] + [] >>> """ if isinstance(sym_type, str): -- cgit v1.3.1