summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXusheng <xusheng@vector35.com>2021-02-16 18:34:59 +0800
committerXusheng <xusheng@vector35.com>2021-04-16 13:40:55 +0800
commitb6feff3f3d3bdcb4bea983a085f4ed794e186940 (patch)
treeb41a84f4dac229f21609932c7b5ec0d29507fa4f
parente8b9e5e4520522bcfcd5b2ed2b343892f171d750 (diff)
add a DisassemblySettings* parameter to MLIL/HLIL functions that retrieve instruction/expr text
-rw-r--r--binaryninjaapi.h15
-rw-r--r--binaryninjacore.h11
-rw-r--r--highlevelil.cpp16
-rw-r--r--mediumlevelil.cpp11
-rw-r--r--python/highlevelil.py2
-rw-r--r--python/mediumlevelil.py4
6 files changed, 35 insertions, 24 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 5e74d17d..4209b1b6 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -4089,9 +4089,11 @@ __attribute__ ((format (printf, 1, 2)))
const std::set<Variable>& knownNotAliases = std::set<Variable>(),
const std::set<Variable>& knownAliases = std::set<Variable>());
- bool GetExprText(Architecture* arch, ExprId expr, std::vector<InstructionTextToken>& tokens);
+ bool GetExprText(Architecture* arch, ExprId expr,
+ std::vector<InstructionTextToken>& tokens,
+ DisassemblySettings* settings = nullptr);
bool GetInstructionText(Function* func, Architecture* arch, size_t i,
- std::vector<InstructionTextToken>& tokens);
+ std::vector<InstructionTextToken>& tokens, DisassemblySettings* settings = nullptr);
void VisitInstructions(const std::function<void(BasicBlock* block, const MediumLevelILInstruction& instr)>& func);
void VisitAllExprs(const std::function<bool(BasicBlock* block, const MediumLevelILInstruction& expr)>& func);
@@ -4421,9 +4423,12 @@ __attribute__ ((format (printf, 1, 2)))
void Finalize();
- std::vector<DisassemblyTextLine> GetExprText(ExprId expr, bool asFullAst = true);
- std::vector<DisassemblyTextLine> GetExprText(const HighLevelILInstruction& instr, bool asFullAst = true);
- std::vector<DisassemblyTextLine> GetInstructionText(size_t i, bool asFullAst = true);
+ std::vector<DisassemblyTextLine> GetExprText(ExprId expr,
+ bool asFullAst = true, DisassemblySettings* settings = nullptr);
+ std::vector<DisassemblyTextLine> GetExprText(const HighLevelILInstruction& instr,
+ bool asFullAst = true, DisassemblySettings* settings = nullptr);
+ std::vector<DisassemblyTextLine> GetInstructionText(size_t i,
+ bool asFullAst = true, DisassemblySettings* settings = nullptr);
Confidence<Ref<Type>> GetExprType(size_t expr);
Confidence<Ref<Type>> GetExprType(const HighLevelILInstruction& expr);
diff --git a/binaryninjacore.h b/binaryninjacore.h
index f5ea815b..47e0d69d 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -28,14 +28,14 @@
// Current ABI version for linking to the core. This is incremented any time
// there are changes to the API that affect linking, including new functions,
// new types, or modifications to existing functions or types.
-#define BN_CURRENT_CORE_ABI_VERSION 3
+#define BN_CURRENT_CORE_ABI_VERSION 4
// Minimum ABI version that is supported for loading of plugins. Plugins that
// are linked to an ABI version less than this will not be able to load and
// will require rebuilding. The minimum version is increased when there are
// incompatible changes that break binary compatibility, such as changes to
// existing types or functions.
-#define BN_MINIMUM_CORE_ABI_VERSION 2
+#define BN_MINIMUM_CORE_ABI_VERSION 3
#ifdef __GNUC__
# ifdef BINARYNINJACORE_LIBRARY
@@ -4024,9 +4024,10 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI void BNReplaceMediumLevelILExpr(BNMediumLevelILFunction* func, size_t expr, size_t newExpr);
BINARYNINJACOREAPI bool BNGetMediumLevelILExprText(BNMediumLevelILFunction* func, BNArchitecture* arch, size_t i,
- BNInstructionTextToken** tokens, size_t* count);
+ BNInstructionTextToken** tokens, size_t* count,
+ BNDisassemblySettings* settings);
BINARYNINJACOREAPI bool BNGetMediumLevelILInstructionText(BNMediumLevelILFunction* il, BNFunction* func,
- BNArchitecture* arch, size_t i, BNInstructionTextToken** tokens, size_t* count);
+ BNArchitecture* arch, size_t i, BNInstructionTextToken** tokens, size_t* count, BNDisassemblySettings* settings);
BINARYNINJACOREAPI BNBasicBlock** BNGetMediumLevelILBasicBlockList(BNMediumLevelILFunction* func, size_t* count);
BINARYNINJACOREAPI BNBasicBlock* BNGetMediumLevelILBasicBlockForInstruction(BNMediumLevelILFunction* func, size_t i);
@@ -4149,7 +4150,7 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI void BNReplaceHighLevelILExpr(BNHighLevelILFunction* func, size_t expr, size_t newExpr);
BINARYNINJACOREAPI BNDisassemblyTextLine* BNGetHighLevelILExprText(BNHighLevelILFunction* func, size_t expr,
- bool asFullAst, size_t* count);
+ bool asFullAst, size_t* count, BNDisassemblySettings* settings);
BINARYNINJACOREAPI BNTypeWithConfidence BNGetHighLevelILExprType(BNHighLevelILFunction* func, size_t expr);
diff --git a/highlevelil.cpp b/highlevelil.cpp
index a355c561..f5b7fba2 100644
--- a/highlevelil.cpp
+++ b/highlevelil.cpp
@@ -416,10 +416,12 @@ void HighLevelILFunction::Finalize()
}
-vector<DisassemblyTextLine> HighLevelILFunction::GetExprText(ExprId expr, bool asFullAst)
+vector<DisassemblyTextLine> HighLevelILFunction::GetExprText(ExprId expr,
+ bool asFullAst, DisassemblySettings* settings)
{
size_t count;
- BNDisassemblyTextLine* lines = BNGetHighLevelILExprText(m_object, expr, asFullAst, &count);
+ BNDisassemblyTextLine* lines = BNGetHighLevelILExprText(m_object, expr, asFullAst, &count,
+ settings ? settings->GetObject() : nullptr);
vector<DisassemblyTextLine> result;
result.reserve(count);
@@ -439,16 +441,18 @@ vector<DisassemblyTextLine> HighLevelILFunction::GetExprText(ExprId expr, bool a
}
-vector<DisassemblyTextLine> HighLevelILFunction::GetExprText(const HighLevelILInstruction& instr, bool asFullAst)
+vector<DisassemblyTextLine> HighLevelILFunction::GetExprText(const HighLevelILInstruction& instr,
+ bool asFullAst, DisassemblySettings* settings)
{
- return GetExprText(instr.exprIndex, asFullAst);
+ return GetExprText(instr.exprIndex, asFullAst, settings);
}
-vector<DisassemblyTextLine> HighLevelILFunction::GetInstructionText(size_t i, bool asFullAst)
+vector<DisassemblyTextLine> HighLevelILFunction::GetInstructionText(size_t i,
+ bool asFullAst, DisassemblySettings* settings)
{
HighLevelILInstruction instr = GetInstruction(i);
- return GetExprText(instr, asFullAst);
+ return GetExprText(instr, asFullAst, settings);
}
diff --git a/mediumlevelil.cpp b/mediumlevelil.cpp
index e5d9c106..3cf3c5d9 100644
--- a/mediumlevelil.cpp
+++ b/mediumlevelil.cpp
@@ -338,11 +338,12 @@ void MediumLevelILFunction::GenerateSSAForm(bool analyzeConditionals, bool handl
}
-bool MediumLevelILFunction::GetExprText(Architecture* arch, ExprId expr, vector<InstructionTextToken>& tokens)
+bool MediumLevelILFunction::GetExprText(Architecture* arch, ExprId expr, vector<InstructionTextToken>& tokens, DisassemblySettings* settings)
{
size_t count;
BNInstructionTextToken* list;
- if (!BNGetMediumLevelILExprText(m_object, arch->GetObject(), expr, &list, &count))
+ if (!BNGetMediumLevelILExprText(m_object, arch->GetObject(), expr, &list, &count,
+ settings ? settings->GetObject() : nullptr))
return false;
tokens = InstructionTextToken::ConvertAndFreeInstructionTextTokenList(list, count);
@@ -351,12 +352,12 @@ bool MediumLevelILFunction::GetExprText(Architecture* arch, ExprId expr, vector<
bool MediumLevelILFunction::GetInstructionText(Function* func, Architecture* arch, size_t instr,
- vector<InstructionTextToken>& tokens)
+ vector<InstructionTextToken>& tokens, DisassemblySettings* settings)
{
size_t count;
BNInstructionTextToken* list;
- if (!BNGetMediumLevelILInstructionText(m_object, func ? func->GetObject() : nullptr, arch->GetObject(),
- instr, &list, &count))
+ if (!BNGetMediumLevelILInstructionText(m_object, func ? func->GetObject() : nullptr, arch->GetObject(), instr, &list, &count,
+ settings ? settings->GetObject() : nullptr))
return false;
tokens = InstructionTextToken::ConvertAndFreeInstructionTextTokenList(list, count);
diff --git a/python/highlevelil.py b/python/highlevelil.py
index 1dc8a077..046d73a6 100644
--- a/python/highlevelil.py
+++ b/python/highlevelil.py
@@ -378,7 +378,7 @@ class HighLevelILInstruction(object):
def lines(self):
"""HLIL text lines (read-only)"""
count = ctypes.c_ulonglong()
- lines = core.BNGetHighLevelILExprText(self._function.handle, self._expr_index, self._as_ast, count)
+ lines = core.BNGetHighLevelILExprText(self._function.handle, self._expr_index, self._as_ast, count, None)
result = []
for i in range(0, count.value):
addr = lines[i].addr
diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py
index 65b90177..8d552b64 100644
--- a/python/mediumlevelil.py
+++ b/python/mediumlevelil.py
@@ -403,11 +403,11 @@ class MediumLevelILInstruction(object):
if ((self._instr_index is not None) and (self._function.source_function is not None) and
(self._expr_index == core.BNGetMediumLevelILIndexForInstruction(self._function.handle, self._instr_index))):
if not core.BNGetMediumLevelILInstructionText(self._function.handle, self._function.source_function.handle,
- self._function.arch.handle, self._instr_index, tokens, count):
+ self._function.arch.handle, self._instr_index, tokens, count, None):
return None
else:
if not core.BNGetMediumLevelILExprText(self._function.handle, self._function.arch.handle,
- self._expr_index, tokens, count):
+ self._expr_index, tokens, count, None):
return None
result = binaryninja.function.InstructionTextToken.get_instruction_lines(tokens, count.value)
core.BNFreeInstructionText(tokens, count.value)