summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRusty Wagner <rusty@vector35.com>2016-10-31 22:51:44 -0400
committerRusty Wagner <rusty@vector35.com>2016-10-31 22:51:44 -0400
commiteef9d1eff05975c31862db4157ac2f1b2bb30502 (patch)
tree48001392e6311609f2ff4d81aec26b00d268a05d
parentfd626094e77d384a4bc8f5d5fde06d552600b879 (diff)
Added APIs for dealing with Thumb more easily
-rw-r--r--binaryninjaapi.h2
-rw-r--r--binaryninjacore.h3
-rw-r--r--binaryview.cpp7
-rw-r--r--platform.cpp9
-rw-r--r--python/__init__.py21
5 files changed, 42 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 6311271c..a918fc42 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -926,6 +926,7 @@ namespace BinaryNinja
std::vector<Ref<Symbol>> GetSymbolsOfType(BNSymbolType type, uint64_t start, uint64_t len);
void DefineAutoSymbol(Ref<Symbol> sym);
+ void DefineAutoSymbolAndVariableOrFunction(Ref<Platform> platform, Ref<Symbol> sym, Ref<Type> type);
void UndefineAutoSymbol(Ref<Symbol> sym);
void DefineUserSymbol(Ref<Symbol> sym);
@@ -2243,6 +2244,7 @@ namespace BinaryNinja
Ref<Platform> GetRelatedPlatform(Architecture* arch);
void AddRelatedPlatform(Architecture* arch, Platform* platform);
+ Ref<Platform> GetAssociatedPlatformByAddress(uint64_t& addr);
};
class ScriptingOutputListener
diff --git a/binaryninjacore.h b/binaryninjacore.h
index ea81c388..b2ed7cd3 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -1877,6 +1877,8 @@ extern "C"
BINARYNINJACOREAPI void BNDefineUserSymbol(BNBinaryView* view, BNSymbol* sym);
BINARYNINJACOREAPI void BNUndefineUserSymbol(BNBinaryView* view, BNSymbol* sym);
BINARYNINJACOREAPI void BNDefineImportedFunction(BNBinaryView* view, BNSymbol* importAddressSym, BNFunction* func);
+ BINARYNINJACOREAPI void BNDefineAutoSymbolAndVariableOrFunction(BNBinaryView* view, BNPlatform* platform,
+ BNSymbol* sym, BNType* type);
BINARYNINJACOREAPI BNSymbol* BNImportedFunctionFromImportAddressSymbol(BNSymbol* sym, uint64_t addr);
@@ -2135,6 +2137,7 @@ extern "C"
BINARYNINJACOREAPI BNPlatform* BNGetRelatedPlatform(BNPlatform* platform, BNArchitecture* arch);
BINARYNINJACOREAPI void BNAddRelatedPlatform(BNPlatform* platform, BNArchitecture* arch, BNPlatform* related);
+ BINARYNINJACOREAPI BNPlatform* BNGetAssociatedPlatformByAddress(BNPlatform* platform, uint64_t* addr);
//Demangler
BINARYNINJACOREAPI bool BNDemangleMS(BNArchitecture* arch,
diff --git a/binaryview.cpp b/binaryview.cpp
index ff19de18..cc6667c5 100644
--- a/binaryview.cpp
+++ b/binaryview.cpp
@@ -1156,6 +1156,13 @@ void BinaryView::DefineAutoSymbol(Ref<Symbol> sym)
}
+void BinaryView::DefineAutoSymbolAndVariableOrFunction(Ref<Platform> platform, Ref<Symbol> sym, Ref<Type> type)
+{
+ BNDefineAutoSymbolAndVariableOrFunction(m_object, platform ? platform->GetObject() : nullptr, sym->GetObject(),
+ type ? type->GetObject() : nullptr);
+}
+
+
void BinaryView::UndefineAutoSymbol(Ref<Symbol> sym)
{
BNUndefineAutoSymbol(m_object, sym->GetObject());
diff --git a/platform.cpp b/platform.cpp
index 9b4053db..7a6571cc 100644
--- a/platform.cpp
+++ b/platform.cpp
@@ -244,3 +244,12 @@ void Platform::AddRelatedPlatform(Architecture* arch, Platform* platform)
{
BNAddRelatedPlatform(m_object, arch->GetObject(), platform->GetObject());
}
+
+
+Ref<Platform> Platform::GetAssociatedPlatformByAddress(uint64_t& addr)
+{
+ BNPlatform* platform = BNGetAssociatedPlatformByAddress(m_object, &addr);
+ if (!platform)
+ return nullptr;
+ return new Platform(platform);
+}
diff --git a/python/__init__.py b/python/__init__.py
index 6c7e298c..1751fefa 100644
--- a/python/__init__.py
+++ b/python/__init__.py
@@ -2630,6 +2630,21 @@ class BinaryView(object):
"""
core.BNDefineAutoSymbol(self.handle, sym.handle)
+ def define_auto_symbol_and_var_or_function(self, sym, sym_type, platform = None):
+ """
+ ``define_auto_symbol`` adds a symbol to the internal list of automatically discovered Symbol objects.
+
+ :param Symbol sym: the symbol to define
+ :rtype: None
+ """
+ if platform is None:
+ platform = self.platform
+ if platform is not None:
+ platform = platform.handle
+ if sym_type is not None:
+ sym_type = sym_type.handle
+ core.BNDefineAutoSymbolAndVariableOrFunction(self.handle, platform, sym.handle, sym_type)
+
def undefine_auto_symbol(self, sym):
"""
``undefine_auto_symbol`` removes a symbol from the internal list of automatically discovered Symbol objects.
@@ -9730,6 +9745,12 @@ class Platform(object):
def add_related_platform(self, arch, platform):
core.BNAddRelatedPlatform(self.handle, arch.handle, platform.handle)
+ def get_associated_platform_by_address(self, addr):
+ new_addr = ctypes.c_ulonglong()
+ new_addr.value = addr
+ result = core.BNGetAssociatedPlatformByAddress(self.handle, new_addr)
+ return Platform(None, handle = result), new_addr.value
+
class ScriptingOutputListener(object):
def _register(self, handle):
self._cb = core.BNScriptingOutputListener()