diff options
| author | rollsafe <rollsafe@users.noreply.github.com> | 2019-07-18 17:58:31 -0400 |
|---|---|---|
| committer | rollsafe <rollsafe@users.noreply.github.com> | 2019-07-18 17:58:31 -0400 |
| commit | 941a7368a137e6d67708d006485ae193fd39c813 (patch) | |
| tree | efbec09a69f4407c3217475b6be6b1e797deebf6 | |
| parent | eef2069f43fc1820502d8b2565411c476b7ffade (diff) | |
Add Symbol aliases to cope with duplicate symbols
| -rw-r--r-- | binaryninjaapi.h | 1 | ||||
| -rw-r--r-- | binaryninjacore.h | 1 | ||||
| -rw-r--r-- | binaryview.cpp | 14 | ||||
| -rw-r--r-- | python/types.py | 14 |
4 files changed, 30 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 3fb60a84..76595ca7 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -1067,6 +1067,7 @@ namespace BinaryNinja uint64_t GetOrdinal() const; bool IsAutoDefined() const; NameSpace GetNameSpace() const; + std::vector<std::string> GetAliases() const; static Ref<Symbol> ImportedFunctionFromImportAddressSymbol(Symbol* sym, uint64_t addr); }; diff --git a/binaryninjacore.h b/binaryninjacore.h index b154b4d1..c6244cba 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -3003,6 +3003,7 @@ extern "C" BINARYNINJACOREAPI uint64_t BNGetSymbolAddress(BNSymbol* sym); BINARYNINJACOREAPI uint64_t BNGetSymbolOrdinal(BNSymbol* sym); BINARYNINJACOREAPI bool BNIsSymbolAutoDefined(BNSymbol* sym); + BINARYNINJACOREAPI char** BNGetSymbolAliases(BNSymbol* sym, size_t* count); BINARYNINJACOREAPI BNSymbol* BNGetSymbolByAddress(BNBinaryView* view, uint64_t addr, const BNNameSpace* nameSpace); BINARYNINJACOREAPI BNSymbol* BNGetSymbolByRawName(BNBinaryView* view, const char* name, const BNNameSpace* nameSpace); diff --git a/binaryview.cpp b/binaryview.cpp index 85d09721..97f4a542 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -274,6 +274,20 @@ Ref<Symbol> Symbol::ImportedFunctionFromImportAddressSymbol(Symbol* sym, uint64_ } +vector<string> Symbol::GetAliases() const +{ + vector<string> result; + size_t count = 0; + char** aliases = BNGetSymbolAliases(m_object, &count); + result.reserve(count); + for (size_t i = 0; i < count; i++) + result.push_back(aliases[i]); + + BNFreeStringList(aliases, count); + return result; +} + + AnalysisCompletionEvent::AnalysisCompletionEvent(BinaryView* view, const std::function<void()>& callback): m_callback(callback) { diff --git a/python/types.py b/python/types.py index 8880d152..b3403f6d 100644 --- a/python/types.py +++ b/python/types.py @@ -255,6 +255,20 @@ 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 + def __repr__(self): return "<%s: \"%s\" @ %#x>" % (self.type, self.full_name, self.address) |
