diff options
| author | Mark Rowe <mark@vector35.com> | 2026-02-25 19:45:00 -0800 |
|---|---|---|
| committer | Mark Rowe <mark@vector35.com> | 2026-03-16 15:47:00 -0700 |
| commit | 25213a836b1423cbc1aeef1f23aebc2167154e56 (patch) | |
| tree | 84bf36f1ba46de9419cfbd1411712192c1d3fb12 | |
| parent | 8f6762f742ed48d7d8400f2d1b4bf4774d7b0fd1 (diff) | |
Represent operand lists and label maps more efficiently within IL instructions
Rather than using chains of `UNDEF` instructions, the contents of these
lists are in a vector alongside the instructions. The instruction itself
stores the entry count and offset into this second vector at which the
associated items can be found.
This improves analysis performance by around 2% and decreases memory
usage by around 5%.
| -rw-r--r-- | binaryninjacore.h | 6 | ||||
| -rw-r--r-- | highlevelilinstruction.cpp | 46 | ||||
| -rw-r--r-- | highlevelilinstruction.h | 12 | ||||
| -rw-r--r-- | lowlevelilinstruction.cpp | 84 | ||||
| -rw-r--r-- | lowlevelilinstruction.h | 23 | ||||
| -rw-r--r-- | mediumlevelilinstruction.cpp | 58 | ||||
| -rw-r--r-- | mediumlevelilinstruction.h | 16 |
7 files changed, 107 insertions, 138 deletions
diff --git a/binaryninjacore.h b/binaryninjacore.h index 80694ce2..0f2e0a60 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -6445,6 +6445,8 @@ extern "C" BINARYNINJACOREAPI uint64_t* BNLowLevelILGetOperandList( BNLowLevelILFunction* func, size_t expr, size_t operand, size_t* count); BINARYNINJACOREAPI void BNLowLevelILFreeOperandList(uint64_t* operands); + BINARYNINJACOREAPI const uint64_t* BNLowLevelILGetOperandPointer( + BNLowLevelILFunction* func, size_t offset); BINARYNINJACOREAPI size_t BNCacheLowLevelILPossibleValueSet(BNLowLevelILFunction* func, BNPossibleValueSet* pvs); BINARYNINJACOREAPI BNPossibleValueSet BNGetCachedLowLevelILPossibleValueSet(BNLowLevelILFunction* func, size_t idx); @@ -6602,6 +6604,8 @@ extern "C" BINARYNINJACOREAPI uint64_t* BNMediumLevelILGetOperandList( BNMediumLevelILFunction* func, size_t expr, size_t operand, size_t* count); BINARYNINJACOREAPI void BNMediumLevelILFreeOperandList(uint64_t* operands); + BINARYNINJACOREAPI const uint64_t* BNMediumLevelILGetOperandPointer( + BNMediumLevelILFunction* func, size_t offset); BINARYNINJACOREAPI size_t BNCacheMediumLevelILPossibleValueSet(BNMediumLevelILFunction* func, BNPossibleValueSet* pvs); BINARYNINJACOREAPI BNPossibleValueSet BNGetCachedMediumLevelILPossibleValueSet(BNMediumLevelILFunction* func, size_t idx); @@ -6763,6 +6767,8 @@ extern "C" BINARYNINJACOREAPI uint64_t* BNHighLevelILGetOperandList( BNHighLevelILFunction* func, size_t expr, size_t operand, size_t* count); BINARYNINJACOREAPI void BNHighLevelILFreeOperandList(uint64_t* operands); + BINARYNINJACOREAPI const uint64_t* BNHighLevelILGetOperandPointer( + BNHighLevelILFunction* func, size_t offset); BINARYNINJACOREAPI size_t BNCacheHighLevelILPossibleValueSet(BNHighLevelILFunction* func, BNPossibleValueSet* pvs); BINARYNINJACOREAPI BNPossibleValueSet BNGetCachedHighLevelILPossibleValueSet(BNHighLevelILFunction* func, size_t idx); diff --git a/highlevelilinstruction.cpp b/highlevelilinstruction.cpp index 03204807..ad8f416d 100644 --- a/highlevelilinstruction.cpp +++ b/highlevelilinstruction.cpp @@ -288,31 +288,26 @@ bool HighLevelILIntegerList::ListIterator::operator<(const ListIterator& a) cons HighLevelILIntegerList::ListIterator& HighLevelILIntegerList::ListIterator::operator++() { count--; - if (count == 0) - return *this; - - operand++; - if (operand >= 4) - { - operand = 0; - instr = function->GetRawExpr((size_t)instr.operands[4]); - } + cur++; return *this; } uint64_t HighLevelILIntegerList::ListIterator::operator*() { - return instr.operands[operand]; + return *cur; } HighLevelILIntegerList::HighLevelILIntegerList( - HighLevelILFunction* func, const BNHighLevelILInstruction& instr, size_t count) + HighLevelILFunction* func, size_t offset, size_t count) { m_start.function = func; - m_start.instr = instr; - m_start.operand = 0; +#ifdef BINARYNINJACORE_LIBRARY + m_start.cur = func->GetOperandPointer(offset); +#else + m_start.cur = BNHighLevelILGetOperandPointer(func->GetObject(), offset); +#endif m_start.count = count; } @@ -327,7 +322,7 @@ HighLevelILIntegerList::const_iterator HighLevelILIntegerList::end() const { const_iterator result; result.function = m_start.function; - result.operand = 0; + result.cur = m_start.cur + m_start.count; result.count = 0; return result; } @@ -343,10 +338,7 @@ uint64_t HighLevelILIntegerList::operator[](size_t i) const { if (i >= size()) throw HighLevelILInstructionAccessException(); - auto iter = begin(); - for (size_t j = 0; j < i; j++) - ++iter; - return *iter; + return m_start.cur[i]; } @@ -367,8 +359,8 @@ size_t HighLevelILIndexList::ListIterator::operator*() HighLevelILIndexList::HighLevelILIndexList( - HighLevelILFunction* func, const BNHighLevelILInstruction& instr, size_t count) : - m_list(func, instr, count) + HighLevelILFunction* func, size_t offset, size_t count) : + m_list(func, offset, count) {} @@ -427,9 +419,9 @@ const HighLevelILInstruction HighLevelILInstructionList::ListIterator::operator* } -HighLevelILInstructionList::HighLevelILInstructionList(HighLevelILFunction* func, const BNHighLevelILInstruction& instr, +HighLevelILInstructionList::HighLevelILInstructionList(HighLevelILFunction* func, size_t offset, size_t count, bool asFullAst, size_t instructionIndex) : - m_list(func, instr, count), + m_list(func, offset, count), m_ast(asFullAst), m_instructionIndex(instructionIndex) {} @@ -492,8 +484,8 @@ const SSAVariable HighLevelILSSAVariableList::ListIterator::operator*() HighLevelILSSAVariableList::HighLevelILSSAVariableList( - HighLevelILFunction* func, const BNHighLevelILInstruction& instr, size_t count) : - m_list(func, instr, count & (~1)) + HighLevelILFunction* func, size_t offset, size_t count) : + m_list(func, offset, count & (~1)) {} @@ -800,19 +792,19 @@ SSAVariable HighLevelILInstructionBase::GetRawOperandAsSSAVariable(size_t operan HighLevelILInstructionList HighLevelILInstructionBase::GetRawOperandAsExprList(size_t operand) const { return HighLevelILInstructionList( - function, function->GetRawExpr(operands[operand + 1]), operands[operand], ast, instructionIndex); + function, (size_t)operands[operand + 1], (size_t)operands[operand], ast, instructionIndex); } HighLevelILSSAVariableList HighLevelILInstructionBase::GetRawOperandAsSSAVariableList(size_t operand) const { - return HighLevelILSSAVariableList(function, function->GetRawExpr(operands[operand + 1]), operands[operand]); + return HighLevelILSSAVariableList(function, (size_t)operands[operand + 1], (size_t)operands[operand]); } HighLevelILIndexList HighLevelILInstructionBase::GetRawOperandAsIndexList(size_t operand) const { - return HighLevelILIndexList(function, function->GetRawExpr(operands[operand + 1]), operands[operand]); + return HighLevelILIndexList(function, (size_t)operands[operand + 1], (size_t)operands[operand]); } diff --git a/highlevelilinstruction.h b/highlevelilinstruction.h index 15f2ef8f..93152241 100644 --- a/highlevelilinstruction.h +++ b/highlevelilinstruction.h @@ -196,8 +196,8 @@ namespace BinaryNinja #else Ref<HighLevelILFunction> function; #endif - BNHighLevelILInstruction instr; - size_t operand, count; + const uint64_t* cur; + size_t count; bool operator==(const ListIterator& a) const; bool operator!=(const ListIterator& a) const; @@ -212,7 +212,7 @@ namespace BinaryNinja public: typedef ListIterator const_iterator; - HighLevelILIntegerList(HighLevelILFunction* func, const BNHighLevelILInstruction& instr, size_t count); + HighLevelILIntegerList(HighLevelILFunction* func, size_t offset, size_t count); const_iterator begin() const; const_iterator end() const; @@ -252,7 +252,7 @@ namespace BinaryNinja public: typedef ListIterator const_iterator; - HighLevelILIndexList(HighLevelILFunction* func, const BNHighLevelILInstruction& instr, size_t count); + HighLevelILIndexList(HighLevelILFunction* func, size_t offset, size_t count); const_iterator begin() const; const_iterator end() const; @@ -296,7 +296,7 @@ namespace BinaryNinja public: typedef ListIterator const_iterator; - HighLevelILInstructionList(HighLevelILFunction* func, const BNHighLevelILInstruction& instr, size_t count, + HighLevelILInstructionList(HighLevelILFunction* func, size_t offset, size_t count, bool asFullAst, size_t instructionIndex); const_iterator begin() const; @@ -338,7 +338,7 @@ namespace BinaryNinja public: typedef ListIterator const_iterator; - HighLevelILSSAVariableList(HighLevelILFunction* func, const BNHighLevelILInstruction& instr, size_t count); + HighLevelILSSAVariableList(HighLevelILFunction* func, size_t offset, size_t count); const_iterator begin() const; const_iterator end() const; diff --git a/lowlevelilinstruction.cpp b/lowlevelilinstruction.cpp index 8b943dd1..33c556bd 100644 --- a/lowlevelilinstruction.cpp +++ b/lowlevelilinstruction.cpp @@ -597,43 +597,26 @@ bool LowLevelILIntegerList::ListIterator::operator<(const ListIterator& a) const LowLevelILIntegerList::ListIterator& LowLevelILIntegerList::ListIterator::operator++() { count--; - if (count == 0) - return *this; - - operand++; - if (operand >= 3) - { - operand = 0; -#ifdef BINARYNINJACORE_LIBRARY - instr = &function->GetRawExpr((size_t)instr->operands[3]); -#else - instr = function->GetRawExpr((size_t)instr.operands[3]); -#endif - } + cur++; return *this; } uint64_t LowLevelILIntegerList::ListIterator::operator*() { -#ifdef BINARYNINJACORE_LIBRARY - return instr->operands[operand]; -#else - return instr.operands[operand]; -#endif + return *cur; } LowLevelILIntegerList::LowLevelILIntegerList( - LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count) + LowLevelILFunction* func, size_t offset, size_t count) { m_start.function = func; #ifdef BINARYNINJACORE_LIBRARY - m_start.instr = &instr; + m_start.cur = func->GetOperandPointer(offset); #else - m_start.instr = instr; + m_start.cur = BNLowLevelILGetOperandPointer(func->GetObject(), offset); #endif - m_start.operand = 0; m_start.count = count; } @@ -648,7 +631,7 @@ LowLevelILIntegerList::const_iterator LowLevelILIntegerList::end() const { const_iterator result; result.function = m_start.function; - result.operand = 0; + result.cur = m_start.cur + m_start.count; result.count = 0; return result; } @@ -664,10 +647,7 @@ uint64_t LowLevelILIntegerList::operator[](size_t i) const { if (i >= size()) throw LowLevelILInstructionAccessException(); - auto iter = begin(); - for (size_t j = 0; j < i; j++) - ++iter; - return *iter; + return m_start.cur[i]; } @@ -687,8 +667,8 @@ size_t LowLevelILIndexList::ListIterator::operator*() } -LowLevelILIndexList::LowLevelILIndexList(LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count) : - m_list(func, instr, count) +LowLevelILIndexList::LowLevelILIndexList(LowLevelILFunction* func, size_t offset, size_t count) : + m_list(func, offset, count) {} @@ -745,8 +725,8 @@ const pair<uint64_t, size_t> LowLevelILIndexMap::ListIterator::operator*() } -LowLevelILIndexMap::LowLevelILIndexMap(LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count) : - m_list(func, instr, count & (~1)) +LowLevelILIndexMap::LowLevelILIndexMap(LowLevelILFunction* func, size_t offset, size_t count) : + m_list(func, offset, count & (~1)) {} @@ -800,8 +780,8 @@ const LowLevelILInstruction LowLevelILInstructionList::ListIterator::operator*() LowLevelILInstructionList::LowLevelILInstructionList( - LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count, size_t instrIndex) : - m_list(func, instr, count), + LowLevelILFunction* func, size_t offset, size_t count, size_t instrIndex) : + m_list(func, offset, count), m_instructionIndex(instrIndex) {} @@ -858,8 +838,8 @@ const RegisterOrFlag LowLevelILRegisterOrFlagList::ListIterator::operator*() LowLevelILRegisterOrFlagList::LowLevelILRegisterOrFlagList( - LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count) : - m_list(func, instr, count) + LowLevelILFunction* func, size_t offset, size_t count) : + m_list(func, offset, count) {} @@ -917,8 +897,8 @@ const SSARegister LowLevelILSSARegisterList::ListIterator::operator*() LowLevelILSSARegisterList::LowLevelILSSARegisterList( - LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count) : - m_list(func, instr, count & (~1)) + LowLevelILFunction* func, size_t offset, size_t count) : + m_list(func, offset, count & (~1)) {} @@ -976,8 +956,8 @@ const SSARegisterStack LowLevelILSSARegisterStackList::ListIterator::operator*() LowLevelILSSARegisterStackList::LowLevelILSSARegisterStackList( - LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count) : - m_list(func, instr, count & (~1)) + LowLevelILFunction* func, size_t offset, size_t count) : + m_list(func, offset, count & (~1)) {} @@ -1035,8 +1015,8 @@ const SSAFlag LowLevelILSSAFlagList::ListIterator::operator*() LowLevelILSSAFlagList::LowLevelILSSAFlagList( - LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count) : - m_list(func, instr, count & (~1)) + LowLevelILFunction* func, size_t offset, size_t count) : + m_list(func, offset, count & (~1)) {} @@ -1094,8 +1074,8 @@ const SSARegisterOrFlag LowLevelILSSARegisterOrFlagList::ListIterator::operator* LowLevelILSSARegisterOrFlagList::LowLevelILSSARegisterOrFlagList( - LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count) : - m_list(func, instr, count & (~1)) + LowLevelILFunction* func, size_t offset, size_t count) : + m_list(func, offset, count & (~1)) {} @@ -1520,56 +1500,56 @@ SSAFlag LowLevelILInstructionBase::GetRawOperandAsSSAFlag(size_t operand) const LowLevelILIndexList LowLevelILInstructionBase::GetRawOperandAsIndexList(size_t operand) const { - return LowLevelILIndexList(function, function->GetRawExpr(operands[operand + 1]), operands[operand]); + return LowLevelILIndexList(function, (size_t)operands[operand + 1], (size_t)operands[operand]); } LowLevelILIndexMap LowLevelILInstructionBase::GetRawOperandAsIndexMap(size_t operand) const { - return LowLevelILIndexMap(function, function->GetRawExpr(operands[operand + 1]), operands[operand]); + return LowLevelILIndexMap(function, (size_t)operands[operand + 1], (size_t)operands[operand]); } LowLevelILInstructionList LowLevelILInstructionBase::GetRawOperandAsExprList(size_t operand) const { return LowLevelILInstructionList( - function, function->GetRawExpr(operands[operand + 1]), operands[operand], instructionIndex); + function, (size_t)operands[operand + 1], (size_t)operands[operand], instructionIndex); } LowLevelILRegisterOrFlagList LowLevelILInstructionBase::GetRawOperandAsRegisterOrFlagList(size_t operand) const { - return LowLevelILRegisterOrFlagList(function, function->GetRawExpr(operands[operand + 1]), operands[operand]); + return LowLevelILRegisterOrFlagList(function, (size_t)operands[operand + 1], (size_t)operands[operand]); } LowLevelILSSARegisterList LowLevelILInstructionBase::GetRawOperandAsSSARegisterList(size_t operand) const { - return LowLevelILSSARegisterList(function, function->GetRawExpr(operands[operand + 1]), operands[operand]); + return LowLevelILSSARegisterList(function, (size_t)operands[operand + 1], (size_t)operands[operand]); } LowLevelILSSARegisterStackList LowLevelILInstructionBase::GetRawOperandAsSSARegisterStackList(size_t operand) const { - return LowLevelILSSARegisterStackList(function, function->GetRawExpr(operands[operand + 1]), operands[operand]); + return LowLevelILSSARegisterStackList(function, (size_t)operands[operand + 1], (size_t)operands[operand]); } LowLevelILSSAFlagList LowLevelILInstructionBase::GetRawOperandAsSSAFlagList(size_t operand) const { - return LowLevelILSSAFlagList(function, function->GetRawExpr(operands[operand + 1]), operands[operand]); + return LowLevelILSSAFlagList(function, (size_t)operands[operand + 1], (size_t)operands[operand]); } LowLevelILSSARegisterOrFlagList LowLevelILInstructionBase::GetRawOperandAsSSARegisterOrFlagList(size_t operand) const { - return LowLevelILSSARegisterOrFlagList(function, function->GetRawExpr(operands[operand + 1]), operands[operand]); + return LowLevelILSSARegisterOrFlagList(function, (size_t)operands[operand + 1], (size_t)operands[operand]); } map<uint32_t, int32_t> LowLevelILInstructionBase::GetRawOperandAsRegisterStackAdjustments(size_t operand) const { - LowLevelILIntegerList list(function, function->GetRawExpr(operands[operand + 1]), operands[operand]); + LowLevelILIntegerList list(function, (size_t)operands[operand + 1], (size_t)operands[operand]); map<uint32_t, int32_t> result; for (auto i = list.begin(); i != list.end();) { diff --git a/lowlevelilinstruction.h b/lowlevelilinstruction.h index 6decedd8..5feef433 100644 --- a/lowlevelilinstruction.h +++ b/lowlevelilinstruction.h @@ -382,12 +382,11 @@ namespace BinaryNinja #ifdef BINARYNINJACORE_LIBRARY LowLevelILFunction* function; - const BNLowLevelILInstruction* instr; #else Ref<LowLevelILFunction> function; - BNLowLevelILInstruction instr; #endif - size_t operand, count; + const uint64_t* cur; + size_t count; bool operator==(const ListIterator& a) const; bool operator!=(const ListIterator& a) const; @@ -402,7 +401,7 @@ namespace BinaryNinja public: typedef ListIterator const_iterator; - LowLevelILIntegerList(LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count); + LowLevelILIntegerList(LowLevelILFunction* func, size_t offset, size_t count); const_iterator begin() const; const_iterator end() const; @@ -442,7 +441,7 @@ namespace BinaryNinja public: typedef ListIterator const_iterator; - LowLevelILIndexList(LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count); + LowLevelILIndexList(LowLevelILFunction* func, size_t offset, size_t count); const_iterator begin() const; const_iterator end() const; @@ -483,7 +482,7 @@ namespace BinaryNinja public: typedef ListIterator const_iterator; - LowLevelILIndexMap(LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count); + LowLevelILIndexMap(LowLevelILFunction* func, size_t offset, size_t count); const_iterator begin() const; const_iterator end() const; @@ -526,7 +525,7 @@ namespace BinaryNinja typedef ListIterator const_iterator; LowLevelILInstructionList( - LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count, size_t instrIndex); + LowLevelILFunction* func, size_t offset, size_t count, size_t instrIndex); const_iterator begin() const; const_iterator end() const; @@ -566,7 +565,7 @@ namespace BinaryNinja public: typedef ListIterator const_iterator; - LowLevelILRegisterOrFlagList(LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count); + LowLevelILRegisterOrFlagList(LowLevelILFunction* func, size_t offset, size_t count); const_iterator begin() const; const_iterator end() const; @@ -607,7 +606,7 @@ namespace BinaryNinja public: typedef ListIterator const_iterator; - LowLevelILSSARegisterList(LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count); + LowLevelILSSARegisterList(LowLevelILFunction* func, size_t offset, size_t count); const_iterator begin() const; const_iterator end() const; @@ -648,7 +647,7 @@ namespace BinaryNinja public: typedef ListIterator const_iterator; - LowLevelILSSARegisterStackList(LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count); + LowLevelILSSARegisterStackList(LowLevelILFunction* func, size_t offset, size_t count); const_iterator begin() const; const_iterator end() const; @@ -689,7 +688,7 @@ namespace BinaryNinja public: typedef ListIterator const_iterator; - LowLevelILSSAFlagList(LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count); + LowLevelILSSAFlagList(LowLevelILFunction* func, size_t offset, size_t count); const_iterator begin() const; const_iterator end() const; @@ -730,7 +729,7 @@ namespace BinaryNinja public: typedef ListIterator const_iterator; - LowLevelILSSARegisterOrFlagList(LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count); + LowLevelILSSARegisterOrFlagList(LowLevelILFunction* func, size_t offset, size_t count); const_iterator begin() const; const_iterator end() const; diff --git a/mediumlevelilinstruction.cpp b/mediumlevelilinstruction.cpp index 07272602..c7dc7a5a 100644 --- a/mediumlevelilinstruction.cpp +++ b/mediumlevelilinstruction.cpp @@ -320,31 +320,26 @@ bool MediumLevelILIntegerList::ListIterator::operator<(const ListIterator& a) co MediumLevelILIntegerList::ListIterator& MediumLevelILIntegerList::ListIterator::operator++() { count--; - if (count == 0) - return *this; - - operand++; - if (operand >= 4) - { - operand = 0; - instr = function->GetRawExpr((size_t)instr.operands[4]); - } + cur++; return *this; } uint64_t MediumLevelILIntegerList::ListIterator::operator*() { - return instr.operands[operand]; + return *cur; } MediumLevelILIntegerList::MediumLevelILIntegerList( - MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count) + MediumLevelILFunction* func, size_t offset, size_t count) { m_start.function = func; - m_start.instr = instr; - m_start.operand = 0; +#ifdef BINARYNINJACORE_LIBRARY + m_start.cur = func->GetOperandPointer(offset); +#else + m_start.cur = BNMediumLevelILGetOperandPointer(func->GetObject(), offset); +#endif m_start.count = count; } @@ -359,7 +354,7 @@ MediumLevelILIntegerList::const_iterator MediumLevelILIntegerList::end() const { const_iterator result; result.function = m_start.function; - result.operand = 0; + result.cur = m_start.cur + m_start.count; result.count = 0; return result; } @@ -375,10 +370,7 @@ uint64_t MediumLevelILIntegerList::operator[](size_t i) const { if (i >= size()) throw MediumLevelILInstructionAccessException(); - auto iter = begin(); - for (size_t j = 0; j < i; j++) - ++iter; - return *iter; + return m_start.cur[i]; } @@ -399,8 +391,8 @@ size_t MediumLevelILIndexList::ListIterator::operator*() MediumLevelILIndexList::MediumLevelILIndexList( - MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count) : - m_list(func, instr, count) + MediumLevelILFunction* func, size_t offset, size_t count) : + m_list(func, offset, count) {} @@ -458,8 +450,8 @@ const pair<uint64_t, size_t> MediumLevelILIndexMap::ListIterator::operator*() MediumLevelILIndexMap::MediumLevelILIndexMap( - MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count) : - m_list(func, instr, count & (~1)) + MediumLevelILFunction* func, size_t offset, size_t count) : + m_list(func, offset, count & (~1)) {} @@ -512,8 +504,8 @@ const Variable MediumLevelILVariableList::ListIterator::operator*() MediumLevelILVariableList::MediumLevelILVariableList( - MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count) : - m_list(func, instr, count) + MediumLevelILFunction* func, size_t offset, size_t count) : + m_list(func, offset, count) {} @@ -571,8 +563,8 @@ const SSAVariable MediumLevelILSSAVariableList::ListIterator::operator*() MediumLevelILSSAVariableList::MediumLevelILSSAVariableList( - MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count) : - m_list(func, instr, count & (~1)) + MediumLevelILFunction* func, size_t offset, size_t count) : + m_list(func, offset, count & (~1)) {} @@ -627,8 +619,8 @@ const MediumLevelILInstruction MediumLevelILInstructionList::ListIterator::opera MediumLevelILInstructionList::MediumLevelILInstructionList( - MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count, size_t instrIndex) : - m_list(func, instr, count), + MediumLevelILFunction* func, size_t offset, size_t count, size_t instrIndex) : + m_list(func, offset, count), m_instructionIndex(instrIndex) {} @@ -960,32 +952,32 @@ SSAVariable MediumLevelILInstructionBase::GetRawOperandAsPartialSSAVariableSourc MediumLevelILIndexList MediumLevelILInstructionBase::GetRawOperandAsIndexList(size_t operand) const { - return MediumLevelILIndexList(function, function->GetRawExpr(operands[operand + 1]), operands[operand]); + return MediumLevelILIndexList(function, (size_t)operands[operand + 1], (size_t)operands[operand]); } MediumLevelILIndexMap MediumLevelILInstructionBase::GetRawOperandAsIndexMap(size_t operand) const { - return MediumLevelILIndexMap(function, function->GetRawExpr(operands[operand + 1]), operands[operand]); + return MediumLevelILIndexMap(function, (size_t)operands[operand + 1], (size_t)operands[operand]); } MediumLevelILVariableList MediumLevelILInstructionBase::GetRawOperandAsVariableList(size_t operand) const { - return MediumLevelILVariableList(function, function->GetRawExpr(operands[operand + 1]), operands[operand]); + return MediumLevelILVariableList(function, (size_t)operands[operand + 1], (size_t)operands[operand]); } MediumLevelILSSAVariableList MediumLevelILInstructionBase::GetRawOperandAsSSAVariableList(size_t operand) const { - return MediumLevelILSSAVariableList(function, function->GetRawExpr(operands[operand + 1]), operands[operand]); + return MediumLevelILSSAVariableList(function, (size_t)operands[operand + 1], (size_t)operands[operand]); } MediumLevelILInstructionList MediumLevelILInstructionBase::GetRawOperandAsExprList(size_t operand) const { return MediumLevelILInstructionList( - function, function->GetRawExpr(operands[operand + 1]), operands[operand], instructionIndex); + function, (size_t)operands[operand + 1], (size_t)operands[operand], instructionIndex); } diff --git a/mediumlevelilinstruction.h b/mediumlevelilinstruction.h index 2b495010..bbc8f432 100644 --- a/mediumlevelilinstruction.h +++ b/mediumlevelilinstruction.h @@ -247,8 +247,8 @@ namespace BinaryNinja #else Ref<MediumLevelILFunction> function; #endif - BNMediumLevelILInstruction instr; - size_t operand, count; + const uint64_t* cur; + size_t count; bool operator==(const ListIterator& a) const; bool operator!=(const ListIterator& a) const; @@ -263,7 +263,7 @@ namespace BinaryNinja public: typedef ListIterator const_iterator; - MediumLevelILIntegerList(MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count); + MediumLevelILIntegerList(MediumLevelILFunction* func, size_t offset, size_t count); const_iterator begin() const; const_iterator end() const; @@ -303,7 +303,7 @@ namespace BinaryNinja public: typedef ListIterator const_iterator; - MediumLevelILIndexList(MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count); + MediumLevelILIndexList(MediumLevelILFunction* func, size_t offset, size_t count); const_iterator begin() const; const_iterator end() const; @@ -344,7 +344,7 @@ namespace BinaryNinja public: typedef ListIterator const_iterator; - MediumLevelILIndexMap(MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count); + MediumLevelILIndexMap(MediumLevelILFunction* func, size_t offset, size_t count); const_iterator begin() const; const_iterator end() const; @@ -384,7 +384,7 @@ namespace BinaryNinja public: typedef ListIterator const_iterator; - MediumLevelILVariableList(MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count); + MediumLevelILVariableList(MediumLevelILFunction* func, size_t offset, size_t count); const_iterator begin() const; const_iterator end() const; @@ -426,7 +426,7 @@ namespace BinaryNinja typedef ListIterator const_iterator; MediumLevelILSSAVariableList( - MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count); + MediumLevelILFunction* func, size_t offset, size_t count); const_iterator begin() const; const_iterator end() const; @@ -468,7 +468,7 @@ namespace BinaryNinja public: typedef ListIterator const_iterator; - MediumLevelILInstructionList(MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count, + MediumLevelILInstructionList(MediumLevelILFunction* func, size_t offset, size_t count, size_t instructionIndex); const_iterator begin() const; |
