From ba4bb6dbee0476d5c30d942ae978621af790d518 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Thu, 23 Feb 2017 22:56:47 -0500 Subject: Add APIs for definitions and uses of SSA variables --- lowlevelil.cpp | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) (limited to 'lowlevelil.cpp') diff --git a/lowlevelil.cpp b/lowlevelil.cpp index 1a353b51..d09db62c 100644 --- a/lowlevelil.cpp +++ b/lowlevelil.cpp @@ -658,3 +658,84 @@ Ref LowLevelILFunction::GetSSAForm() const return nullptr; return new LowLevelILFunction(func); } + + +Ref LowLevelILFunction::GetNonSSAForm() const +{ + BNLowLevelILFunction* func = BNGetLowLevelILNonSSAForm(m_object); + if (!func) + return nullptr; + return new LowLevelILFunction(func); +} + + +size_t LowLevelILFunction::GetSSAInstructionIndex(size_t instr) const +{ + return BNGetLowLevelILNonSSAInstructionIndex(m_object, instr); +} + + +size_t LowLevelILFunction::GetNonSSAInstructionIndex(size_t instr) const +{ + return BNGetLowLevelILNonSSAInstructionIndex(m_object, instr); +} + + +size_t LowLevelILFunction::GetSSARegisterDefinition(uint32_t reg, size_t idx) const +{ + return BNGetLowLevelILSSARegisterDefinition(m_object, reg, idx); +} + + +size_t LowLevelILFunction::GetSSAFlagDefinition(uint32_t flag, size_t idx) const +{ + return BNGetLowLevelILSSAFlagDefinition(m_object, flag, idx); +} + + +size_t LowLevelILFunction::GetSSAMemoryDefinition(size_t idx) const +{ + return BNGetLowLevelILSSAMemoryDefinition(m_object, idx); +} + + +set LowLevelILFunction::GetSSARegisterUses(uint32_t reg, size_t idx) const +{ + size_t count; + size_t* instrs = BNGetLowLevelILSSARegisterUses(m_object, reg, idx, &count); + + set result; + for (size_t i = 0; i < count; i++) + result.insert(instrs[i]); + + BNFreeLowLevelILInstructionList(instrs); + return result; +} + + +set LowLevelILFunction::GetSSAFlagUses(uint32_t flag, size_t idx) const +{ + size_t count; + size_t* instrs = BNGetLowLevelILSSAFlagUses(m_object, flag, idx, &count); + + set result; + for (size_t i = 0; i < count; i++) + result.insert(instrs[i]); + + BNFreeLowLevelILInstructionList(instrs); + return result; +} + + +set LowLevelILFunction::GetSSAMemoryUses(size_t idx) const +{ + size_t count; + size_t* instrs = BNGetLowLevelILSSAMemoryUses(m_object, idx, &count); + + set result; + for (size_t i = 0; i < count; i++) + result.insert(instrs[i]); + + BNFreeLowLevelILInstructionList(instrs); + return result; +} -- cgit v1.3.1