diff options
| author | Peter LaFosse <peter@vector35.com> | 2018-08-14 17:14:44 -0400 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2018-08-14 17:14:44 -0400 |
| commit | 1ce780cd6a66a289b0422298871d61392ad3ec2a (patch) | |
| tree | 1b180e6bce65fd50a757e4f19852de873f83a9e5 | |
| parent | 454bcf8314833269ae8be9111b2c1035fe8999d6 (diff) | |
Adding LLIL_RELOC_PTR
| -rw-r--r-- | binaryninjacore.h | 1 | ||||
| -rw-r--r-- | examples/llil_parser/src/llil_parser.cpp | 8 | ||||
| -rw-r--r-- | lowlevelilinstruction.cpp | 9 | ||||
| -rw-r--r-- | lowlevelilinstruction.h | 1 | ||||
| -rw-r--r-- | python/lowlevelil.py | 12 |
5 files changed, 31 insertions, 0 deletions
diff --git a/binaryninjacore.h b/binaryninjacore.h index e73256e6..e7eb3922 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -312,6 +312,7 @@ extern "C" LLIL_REG_STACK_FREE_REL, // Not valid in SSA from (see LLIL_REG_STACK_FREE_REL_SSA) LLIL_CONST, LLIL_CONST_PTR, + LLIL_RELOC_PTR, LLIL_FLOAT_CONST, LLIL_FLAG, // Not valid in SSA form (see LLIL_FLAG_SSA) LLIL_FLAG_BIT, // Not valid in SSA form (see LLIL_FLAG_BIT_SSA) diff --git a/examples/llil_parser/src/llil_parser.cpp b/examples/llil_parser/src/llil_parser.cpp index 75029d19..3b9bfe3c 100644 --- a/examples/llil_parser/src/llil_parser.cpp +++ b/examples/llil_parser/src/llil_parser.cpp @@ -56,6 +56,7 @@ static void PrintOperation(BNLowLevelILOperation operation) ENUM_PRINTER(LLIL_REG) ENUM_PRINTER(LLIL_CONST) ENUM_PRINTER(LLIL_CONST_PTR) + ENUM_PRINTER(LLIL_RELOC_PTR) ENUM_PRINTER(LLIL_FLAG) ENUM_PRINTER(LLIL_FLAG_BIT) ENUM_PRINTER(LLIL_ADD) @@ -378,6 +379,7 @@ int main(int argc, char *argv[]) { case LLIL_CONST: case LLIL_CONST_PTR: + case LLIL_RELOC_PTR: printf(" Found constant 0x%" PRIx64 "\n", expr.GetConstant()); return false; // Done parsing this default: @@ -397,6 +399,12 @@ int main(int argc, char *argv[]) expr.GetSourceExpr<LLIL_LOAD>().GetConstant<LLIL_CONST_PTR>()); return false; // Done parsing this } + else if (expr.GetSourceExpr<LLIL_LOAD>().operation == LLIL_RELOC_PTR) + { + printf(" Loading from address 0x%" PRIx64 "\n", + expr.GetSourceExpr<LLIL_LOAD>().GetConstant<LLIL_RELOC_PTR>()); + return false; // Done parsing this + } break; default: break; diff --git a/lowlevelilinstruction.cpp b/lowlevelilinstruction.cpp index 5f5dc397..4e0901f3 100644 --- a/lowlevelilinstruction.cpp +++ b/lowlevelilinstruction.cpp @@ -171,6 +171,7 @@ unordered_map<BNLowLevelILOperation, vector<LowLevelILOperandUsage>> {LLIL_MEM_PHI, {DestMemoryVersionLowLevelOperandUsage, SourceMemoryVersionsLowLevelOperandUsage}}, {LLIL_CONST, {ConstantLowLevelOperandUsage}}, {LLIL_CONST_PTR, {ConstantLowLevelOperandUsage}}, + {LLIL_RELOC_PTR, {ConstantLowLevelOperandUsage}}, {LLIL_FLOAT_CONST, {ConstantLowLevelOperandUsage}}, {LLIL_ADD, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}}, {LLIL_SUB, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}}, @@ -2113,6 +2114,8 @@ ExprId LowLevelILInstruction::CopyTo(LowLevelILFunction* dest, return dest->Const(size, GetConstant<LLIL_CONST>(), *this); case LLIL_CONST_PTR: return dest->ConstPointer(size, GetConstant<LLIL_CONST_PTR>(), *this); + case LLIL_RELOC_PTR: + return dest->ConstPointer(size, GetConstant<LLIL_RELOC_PTR>(), *this); case LLIL_FLOAT_CONST: return dest->FloatConstRaw(size, GetConstant<LLIL_FLOAT_CONST>(), *this); case LLIL_POP: @@ -2894,6 +2897,12 @@ ExprId LowLevelILFunction::ConstPointer(size_t size, uint64_t val, const ILSourc } +ExprId LowLevelILFunction::RelocationPointer(size_t size, uint64_t val, const ILSourceLocation& loc) +{ + return AddExprWithLocation(LLIL_RELOC_PTR, loc, size, 0, val); +} + + ExprId LowLevelILFunction::FloatConstRaw(size_t size, uint64_t val, const ILSourceLocation& loc) { return AddExprWithLocation(LLIL_FLOAT_CONST, loc, size, 0, val); diff --git a/lowlevelilinstruction.h b/lowlevelilinstruction.h index e845bcd0..2d1429c9 100644 --- a/lowlevelilinstruction.h +++ b/lowlevelilinstruction.h @@ -1226,6 +1226,7 @@ namespace BinaryNinja template <> struct LowLevelILInstructionAccessor<LLIL_CONST>: public LowLevelILConstantInstruction {}; template <> struct LowLevelILInstructionAccessor<LLIL_CONST_PTR>: public LowLevelILConstantInstruction {}; + template <> struct LowLevelILInstructionAccessor<LLIL_RELOC_PTR>: public LowLevelILConstantInstruction {}; template <> struct LowLevelILInstructionAccessor<LLIL_FLOAT_CONST>: public LowLevelILConstantInstruction {}; template <> struct LowLevelILInstructionAccessor<LLIL_ADD>: public LowLevelILTwoOperandInstruction {}; diff --git a/python/lowlevelil.py b/python/lowlevelil.py index bd1e9349..ceae1617 100644 --- a/python/lowlevelil.py +++ b/python/lowlevelil.py @@ -223,6 +223,7 @@ class LowLevelILInstruction(object): LowLevelILOperation.LLIL_REG_STACK_FREE_REL: [("stack", "reg_stack"), ("dest", "expr")], LowLevelILOperation.LLIL_CONST: [("constant", "int")], LowLevelILOperation.LLIL_CONST_PTR: [("constant", "int")], + LowLevelILOperation.LLIL_RELOC_PTR: [("constant", "int")], LowLevelILOperation.LLIL_FLOAT_CONST: [("constant", "float")], LowLevelILOperation.LLIL_FLAG: [("src", "flag")], LowLevelILOperation.LLIL_FLAG_BIT: [("src", "flag"), ("bit", "int")], @@ -1091,6 +1092,17 @@ class LowLevelILFunction(object): """ return self.expr(LowLevelILOperation.LLIL_CONST_PTR, value, size=size) + def reloc_pointer(self, size, value): + """ + ``reloc_pointer`` returns an expression for the constant relocated pointer ``value`` with size ``size`` + + :param int size: the size of the pointer in bytes + :param int value: address referenced by pointer + :return: A constant expression of given value and size + :rtype: LowLevelILExpr + """ + return self.expr(LowLevelILOperation.LLIL_RELOC_PTR, value, size=size) + def float_const_raw(self, size, value): """ ``float_const_raw`` returns an expression for the constant raw binary floating point |
