From fd51307c7fa5baff29860b1e3be09aafca13c2f0 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Wed, 31 Jan 2018 21:08:05 -0500 Subject: Allow intrinsics to write flags --- binaryninjaapi.h | 3 ++- lowlevelilinstruction.cpp | 6 +++--- python/lowlevelil.py | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/binaryninjaapi.h b/binaryninjaapi.h index d1ca9cdb..3decc4e9 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -2671,7 +2671,8 @@ namespace BinaryNinja ExprId BoolToInt(size_t size, ExprId a, const ILSourceLocation& loc = ILSourceLocation()); ExprId SystemCall(const ILSourceLocation& loc = ILSourceLocation()); ExprId Intrinsic(const std::vector& outputs, uint32_t intrinsic, - const std::vector& params, const ILSourceLocation& loc = ILSourceLocation()); + const std::vector& params, uint32_t flags = 0, + const ILSourceLocation& loc = ILSourceLocation()); ExprId IntrinsicSSA(const std::vector& outputs, uint32_t intrinsic, const std::vector& params, const ILSourceLocation& loc = ILSourceLocation()); ExprId Breakpoint(const ILSourceLocation& loc = ILSourceLocation()); diff --git a/lowlevelilinstruction.cpp b/lowlevelilinstruction.cpp index 2c00db68..1a834435 100644 --- a/lowlevelilinstruction.cpp +++ b/lowlevelilinstruction.cpp @@ -2139,7 +2139,7 @@ ExprId LowLevelILInstruction::CopyTo(LowLevelILFunction* dest, for (auto& i : GetParameterExprs()) params.push_back(subExprHandler(i)); return dest->Intrinsic(GetOutputRegisterOrFlagList(), GetIntrinsic(), - params, *this); + params, flags, *this); case LLIL_INTRINSIC_SSA: for (auto& i : GetParameterExprs()) params.push_back(subExprHandler(i)); @@ -3212,9 +3212,9 @@ ExprId LowLevelILFunction::SystemCall(const ILSourceLocation& loc) ExprId LowLevelILFunction::Intrinsic(const vector& outputs, uint32_t intrinsic, - const vector& params, const ILSourceLocation& loc) + const vector& params, uint32_t flags, const ILSourceLocation& loc) { - return AddExprWithLocation(LLIL_INTRINSIC, loc, 0, 0, + return AddExprWithLocation(LLIL_INTRINSIC, loc, 0, flags, outputs.size(), AddRegisterOrFlagList(outputs), intrinsic, AddExprWithLocation(LLIL_CALL_PARAM, loc, 0, 0, params.size(), AddOperandList(params))); } diff --git a/python/lowlevelil.py b/python/lowlevelil.py index 33296ce8..273d3aeb 100644 --- a/python/lowlevelil.py +++ b/python/lowlevelil.py @@ -1770,7 +1770,7 @@ class LowLevelILFunction(object): """ return self.expr(LowLevelILOperation.LLIL_SYSCALL) - def intrinsic(self, outputs, intrinsic, params): + def intrinsic(self, outputs, intrinsic, params, flags=None): """ ``intrinsic`` return an intrinsic expression. @@ -1787,7 +1787,7 @@ class LowLevelILFunction(object): for param in params: param_list.append(param.index) return self.expr(LowLevelILOperation.LLIL_INTRINSIC, len(outputs), self.add_operand_list(output_list), - self.arch.get_intrinsic_index(intrinsic), len(params), self.add_operand_list(param_list)) + self.arch.get_intrinsic_index(intrinsic), len(params), self.add_operand_list(param_list), flags = flags) def breakpoint(self): """ -- cgit v1.3.1