summaryrefslogtreecommitdiff
path: root/lowlevelil.cpp
diff options
context:
space:
mode:
authorRusty Wagner <rusty@vector35.com>2015-09-03 01:20:10 -0400
committerRusty Wagner <rusty@vector35.com>2015-09-03 01:20:10 -0400
commitfd5865d110b484e7841713a679024c78ca4105c9 (patch)
treedc1d2acfbe8b2044d02391e4fa68087d107ba7e0 /lowlevelil.cpp
parent183385ae0c88ad5d8c070560bad4bd937129fb45 (diff)
Implement low level IL from Python
Diffstat (limited to 'lowlevelil.cpp')
-rw-r--r--lowlevelil.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/lowlevelil.cpp b/lowlevelil.cpp
index e4c65b3a..7c30df9d 100644
--- a/lowlevelil.cpp
+++ b/lowlevelil.cpp
@@ -1,6 +1,7 @@
#include "binaryninjaapi.h"
using namespace BinaryNinja;
+using namespace std;
LowLevelILLabel::LowLevelILLabel()
@@ -117,6 +118,12 @@ ExprId LowLevelILFunction::Flag(uint32_t reg)
}
+ExprId LowLevelILFunction::FlagBit(size_t size, uint32_t flag, uint32_t bitIndex)
+{
+ return AddExpr(LLIL_FLAG_BIT, size, 0, flag, bitIndex);
+}
+
+
ExprId LowLevelILFunction::Add(size_t size, ExprId a, ExprId b, uint32_t flags)
{
return AddExpr(LLIL_ADD, size, flags, a, b);
@@ -381,6 +388,12 @@ ExprId LowLevelILFunction::CompareUnsignedGreaterThan(size_t size, ExprId a, Exp
}
+ExprId LowLevelILFunction::TestBit(size_t size, ExprId a, ExprId b)
+{
+ return AddExpr(LLIL_TEST_BIT, size, 0, a, b);
+}
+
+
ExprId LowLevelILFunction::SystemCall()
{
return AddExpr(LLIL_SYSCALL, 0, 0);
@@ -469,3 +482,47 @@ void LowLevelILFunction::Finalize()
{
BNFinalizeLowLevelILFunction(m_func);
}
+
+
+bool LowLevelILFunction::GetExprText(Architecture* arch, ExprId expr, vector<InstructionTextToken>& tokens)
+{
+ size_t count;
+ BNInstructionTextToken* list;
+ if (!BNGetLowLevelILExprText(m_func, arch->GetArchitectureObject(), expr, &list, &count))
+ return false;
+
+ tokens.clear();
+ for (size_t i = 0; i < count; i++)
+ {
+ InstructionTextToken token;
+ token.type = list[i].type;
+ token.text = list[i].text;
+ token.value = list[i].value;
+ tokens.push_back(token);
+ }
+
+ BNFreeInstructionText(list, count);
+ return true;
+}
+
+
+bool LowLevelILFunction::GetInstructionText(Architecture* arch, size_t instr, vector<InstructionTextToken>& tokens)
+{
+ size_t count;
+ BNInstructionTextToken* list;
+ if (!BNGetLowLevelILInstructionText(m_func, arch->GetArchitectureObject(), instr, &list, &count))
+ return false;
+
+ tokens.clear();
+ for (size_t i = 0; i < count; i++)
+ {
+ InstructionTextToken token;
+ token.type = list[i].type;
+ token.text = list[i].text;
+ token.value = list[i].value;
+ tokens.push_back(token);
+ }
+
+ BNFreeInstructionText(list, count);
+ return true;
+}