diff options
Diffstat (limited to 'mediumlevelilinstruction.cpp')
| -rw-r--r-- | mediumlevelilinstruction.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/mediumlevelilinstruction.cpp b/mediumlevelilinstruction.cpp index 29a58de7..49a5eed9 100644 --- a/mediumlevelilinstruction.cpp +++ b/mediumlevelilinstruction.cpp @@ -18,6 +18,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. +#include <string.h> #ifdef BINARYNINJACORE_LIBRARY #include "mediumlevelilfunction.h" #include "mediumlevelilssafunction.h" @@ -1059,6 +1060,43 @@ Confidence<Ref<Type>> MediumLevelILInstructionBase::GetType() const } +char* MediumLevelILInstructionBase::Dump() const +{ + vector<InstructionTextToken> tokens; +#ifdef BINARYNINJACORE_LIBRARY + bool success = function->GetExprText(function->GetFunction(), function->GetArchitecture(), *this, tokens, new DisassemblySettings()); +#else + bool success = function->GetExprText(function->GetArchitecture(), exprIndex, tokens); +#endif + if (success) + { + string text; + if (exprIndex != BN_INVALID_EXPR && (exprIndex & 0xffff000000000000) == 0) + { + text += "[expr " + to_string(exprIndex) + "] "; + } + if (instructionIndex != BN_INVALID_EXPR && (instructionIndex & 0xffff000000000000) == 0) + { + text += "[instr " + to_string(instructionIndex) + "] "; + } + Ref<Type> type = GetType(); + if (type) + { + text += "[type: " + type->GetString() + "] "; + } + for (auto& token: tokens) + { + text += token.text; + } + return strdup(text.c_str()); + } + else + { + return strdup("???"); + } +} + + size_t MediumLevelILInstructionBase::GetSSAVarVersion(const Variable& var) { return function->GetSSAVarVersionAtInstruction(var, instructionIndex); |
