From 4cdb1af22efb7374470668919bb19795a64622fd Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Wed, 23 Feb 2022 21:17:31 -0500 Subject: Move stack var refs and constant refs behind advanced analysis requests for significant memory savings --- function.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'function.cpp') diff --git a/function.cpp b/function.cpp index fd6ea568..712c8155 100644 --- a/function.cpp +++ b/function.cpp @@ -570,6 +570,33 @@ vector Function::GetStackVariablesReferencedByInstructio } +vector Function::GetStackVariablesReferencedByInstructionIfAvailable( + Architecture* arch, uint64_t addr) +{ + size_t count; + BNStackVariableReference* refs = + BNGetStackVariablesReferencedByInstructionIfAvailable(m_object, arch->GetObject(), addr, &count); + + vector result; + result.reserve(count); + for (size_t i = 0; i < count; i++) + { + StackVariableReference ref; + ref.sourceOperand = refs[i].sourceOperand; + ref.type = Confidence>( + refs[i].type ? new Type(BNNewTypeReference(refs[i].type)) : nullptr, refs[i].typeConfidence); + ref.name = refs[i].name; + ref.var = Variable::FromIdentifier(refs[i].varIdentifier); + ref.referencedOffset = refs[i].referencedOffset; + ref.size = refs[i].size; + result.push_back(ref); + } + + BNFreeStackVariableReferenceList(refs, count); + return result; +} + + vector Function::GetConstantsReferencedByInstruction(Architecture* arch, uint64_t addr) { size_t count; @@ -583,6 +610,20 @@ vector Function::GetConstantsReferencedByInstruction(Archit } +vector Function::GetConstantsReferencedByInstructionIfAvailable(Architecture* arch, uint64_t addr) +{ + size_t count; + BNConstantReference* refs = + BNGetConstantsReferencedByInstructionIfAvailable(m_object, arch->GetObject(), addr, &count); + + vector result; + result.insert(result.end(), &refs[0], &refs[count]); + + BNFreeConstantReferenceList(refs); + return result; +} + + Ref Function::GetLiftedIL() const { return new LowLevelILFunction(BNGetFunctionLiftedIL(m_object)); -- cgit v1.3.1