From 7829801632556958526537447495764541534147 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Tue, 14 Feb 2023 17:48:23 -0500 Subject: Add DisassemblySettings to LLIL::GetExprText To make possible the next commit --- binaryninjaapi.h | 8 ++++++-- binaryninjacore.h | 9 +++++---- lowlevelil.cpp | 11 +++++++---- python/lowlevelil.py | 2 +- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/binaryninjaapi.h b/binaryninjaapi.h index c5724621..637aeb10 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -10700,9 +10700,11 @@ namespace BinaryNinja { \param[in] arch Architecture for the expression \param[in] expr Expression to get the text for \param[out] tokens Output reference to write the instruction tokens to + \param[in] settings Optional structure with settings for rendering text \return True/False on success or failure */ - bool GetExprText(Architecture* arch, ExprId expr, std::vector& tokens); + bool GetExprText(Architecture* arch, ExprId expr, std::vector& tokens, + DisassemblySettings* settings = nullptr); /*! Get the list of InstructionTextTokens for a given instruction @@ -10710,10 +10712,12 @@ namespace BinaryNinja { \param[in] arch Architecture for the instruction \param[in] i Index of the instruction \param[out] tokens Output reference to write the instruction tokens to + \param[in] settings Optional structure with settings for rendering text \return True/False on success or failure */ bool GetInstructionText( - Function* func, Architecture* arch, size_t i, std::vector& tokens); + Function* func, Architecture* arch, size_t i, std::vector& tokens, + DisassemblySettings* settings = nullptr); uint32_t GetTemporaryRegisterCount(); uint32_t GetTemporaryFlagCount(); diff --git a/binaryninjacore.h b/binaryninjacore.h index 153d1c78..496dec68 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -36,14 +36,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 32 +#define BN_CURRENT_CORE_ABI_VERSION 33 // 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 32 +#define BN_MINIMUM_CORE_ABI_VERSION 33 #ifdef __GNUC__ #ifdef BINARYNINJACORE_LIBRARY @@ -4846,9 +4846,10 @@ extern "C" BNLowLevelILFunction* func, BNArchitecture* arch, uint64_t addr); BINARYNINJACOREAPI bool BNGetLowLevelILExprText( - BNLowLevelILFunction* func, BNArchitecture* arch, size_t i, BNInstructionTextToken** tokens, size_t* count); + BNLowLevelILFunction* func, BNArchitecture* arch, size_t i, BNDisassemblySettings* settings, + BNInstructionTextToken** tokens, size_t* count); BINARYNINJACOREAPI bool BNGetLowLevelILInstructionText(BNLowLevelILFunction* il, BNFunction* func, - BNArchitecture* arch, size_t i, BNInstructionTextToken** tokens, size_t* count); + BNArchitecture* arch, size_t i, BNDisassemblySettings* settings, BNInstructionTextToken** tokens, size_t* count); BINARYNINJACOREAPI uint32_t BNGetLowLevelILTemporaryRegisterCount(BNLowLevelILFunction* func); BINARYNINJACOREAPI uint32_t BNGetLowLevelILTemporaryFlagCount(BNLowLevelILFunction* func); diff --git a/lowlevelil.cpp b/lowlevelil.cpp index dfb53e5b..fdb59535 100644 --- a/lowlevelil.cpp +++ b/lowlevelil.cpp @@ -623,11 +623,13 @@ void LowLevelILFunction::GenerateSSAForm() } -bool LowLevelILFunction::GetExprText(Architecture* arch, ExprId expr, vector& tokens) +bool LowLevelILFunction::GetExprText(Architecture* arch, ExprId expr, vector& tokens, + DisassemblySettings* settings) { size_t count; BNInstructionTextToken* list; - if (!BNGetLowLevelILExprText(m_object, arch->GetObject(), expr, &list, &count)) + if (!BNGetLowLevelILExprText(m_object, arch->GetObject(), expr, settings ? settings->GetObject() : nullptr, + &list, &count)) return false; tokens = InstructionTextToken::ConvertAndFreeInstructionTextTokenList(list, count); @@ -636,12 +638,13 @@ bool LowLevelILFunction::GetExprText(Architecture* arch, ExprId expr, vector& tokens) + Function* func, Architecture* arch, size_t instr, vector& tokens, DisassemblySettings* settings) { size_t count; BNInstructionTextToken* list; if (!BNGetLowLevelILInstructionText( - m_object, func ? func->GetObject() : nullptr, arch->GetObject(), instr, &list, &count)) + m_object, func ? func->GetObject() : nullptr, arch->GetObject(), instr, + settings ? settings->GetObject() : nullptr, &list, &count)) return false; tokens = InstructionTextToken::ConvertAndFreeInstructionTextTokenList(list, count); diff --git a/python/lowlevelil.py b/python/lowlevelil.py index 0b112331..23830acb 100644 --- a/python/lowlevelil.py +++ b/python/lowlevelil.py @@ -549,7 +549,7 @@ class LowLevelILInstruction(BaseILInstruction): assert self.function.arch is not None, f"self.function.arch is None" tokens = ctypes.POINTER(core.BNInstructionTextToken)() result = core.BNGetLowLevelILExprText( - self.function.handle, self.function.arch.handle, self.expr_index, tokens, count + self.function.handle, self.function.arch.handle, self.expr_index, None, tokens, count ) assert result, "core.BNGetLowLevelILExprText returned False" try: -- cgit v1.3.1