From 0cf59807fa364b11de65dc3f1e1c2d2bc7dd87a2 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Fri, 8 May 2020 05:26:56 -0400 Subject: Modifications for supporting jemalloc in the core --- highlevelilinstruction.h | 80 ++++++++++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 33 deletions(-) (limited to 'highlevelilinstruction.h') diff --git a/highlevelilinstruction.h b/highlevelilinstruction.h index fd140e24..497cf122 100644 --- a/highlevelilinstruction.h +++ b/highlevelilinstruction.h @@ -142,6 +142,16 @@ namespace BinaryNinjaCore namespace BinaryNinja #endif { +#ifdef BINARYNINJACORE_LIBRARY +#define _STD_VECTOR vector +#define _STD_SET set +#define _STD_UNORDERED_MAP unordered_map +#else +#define _STD_VECTOR std::vector +#define _STD_SET std::set +#define _STD_UNORDERED_MAP std::unordered_map +#endif + class HighLevelILInstructionAccessException: public std::exception { public: @@ -181,7 +191,7 @@ namespace BinaryNinja size_t size() const; uint64_t operator[](size_t i) const; - operator std::vector() const; + operator _STD_VECTOR() const; }; class HighLevelILIndexList @@ -208,7 +218,7 @@ namespace BinaryNinja size_t size() const; size_t operator[](size_t i) const; - operator std::vector() const; + operator _STD_VECTOR() const; }; class HighLevelILInstructionList @@ -240,7 +250,7 @@ namespace BinaryNinja size_t size() const; const HighLevelILInstruction operator[](size_t i) const; - operator std::vector() const; + operator _STD_VECTOR() const; }; class HighLevelILSSAVariableList @@ -267,7 +277,7 @@ namespace BinaryNinja size_t size() const; const SSAVariable operator[](size_t i) const; - operator std::vector() const; + operator _STD_VECTOR() const; }; struct HighLevelILInstructionBase: public BNHighLevelILInstruction @@ -280,11 +290,11 @@ namespace BinaryNinja size_t exprIndex, instructionIndex; bool ast; - static std::unordered_map operandTypeForUsage; - static std::unordered_map> operationOperandUsage; - static std::unordered_map> operationOperandIndex; + static _STD_UNORDERED_MAP operandTypeForUsage; + static _STD_UNORDERED_MAP> operationOperandUsage; + static _STD_UNORDERED_MAP> operationOperandIndex; HighLevelILOperandList GetOperands() const; @@ -299,13 +309,13 @@ namespace BinaryNinja void UpdateRawOperand(size_t operandIndex, ExprId value); void UpdateRawOperandAsInteger(size_t operandIndex, uint64_t value); - void UpdateRawOperandAsSSAVariableList(size_t operandIndex, const std::vector& vars); - void UpdateRawOperandAsExprList(size_t operandIndex, const std::vector& exprs); - void UpdateRawOperandAsExprList(size_t operandIndex, const std::vector& exprs); + void UpdateRawOperandAsSSAVariableList(size_t operandIndex, const _STD_VECTOR& vars); + void UpdateRawOperandAsExprList(size_t operandIndex, const _STD_VECTOR& exprs); + void UpdateRawOperandAsExprList(size_t operandIndex, const _STD_VECTOR& exprs); RegisterValue GetValue() const; - PossibleValueSet GetPossibleValues(const std::set& options = - std::set()) const; + PossibleValueSet GetPossibleValues(const _STD_SET& options = + _STD_SET()) const; Confidence> GetType() const; size_t GetMediumLevelILExprIndex() const; @@ -426,17 +436,17 @@ namespace BinaryNinja template void SetSSAVersion(size_t version) { As().SetSSAVersion(version); } template void SetDestSSAVersion(size_t version) { As().SetDestSSAVersion(version); } - template void SetParameterExprs(const std::vector& params) { As().SetParameterExprs(params); } - template void SetParameterExprs(const std::vector& params) { As().SetParameterExprs(params); } - template void SetSourceExprs(const std::vector& params) { As().SetSourceExprs(params); } - template void SetSourceExprs(const std::vector& params) { As().SetSourceExprs(params); } - template void SetDestExprs(const std::vector& params) { As().SetDestExprs(params); } - template void SetDestExprs(const std::vector& params) { As().SetDestExprs(params); } - template void SetBlockExprs(const std::vector& params) { As().SetBlockExprs(params); } - template void SetBlockExprs(const std::vector& params) { As().SetBlockExprs(params); } - template void SetCases(const std::vector& params) { As().SetCases(params); } - template void SetCases(const std::vector& params) { As().SetCases(params); } - template void SetSourceSSAVariables(const std::vector& vars) { As().SetSourceSSAVariables(vars); } + template void SetParameterExprs(const _STD_VECTOR& params) { As().SetParameterExprs(params); } + template void SetParameterExprs(const _STD_VECTOR& params) { As().SetParameterExprs(params); } + template void SetSourceExprs(const _STD_VECTOR& params) { As().SetSourceExprs(params); } + template void SetSourceExprs(const _STD_VECTOR& params) { As().SetSourceExprs(params); } + template void SetDestExprs(const _STD_VECTOR& params) { As().SetDestExprs(params); } + template void SetDestExprs(const _STD_VECTOR& params) { As().SetDestExprs(params); } + template void SetBlockExprs(const _STD_VECTOR& params) { As().SetBlockExprs(params); } + template void SetBlockExprs(const _STD_VECTOR& params) { As().SetBlockExprs(params); } + template void SetCases(const _STD_VECTOR& params) { As().SetCases(params); } + template void SetCases(const _STD_VECTOR& params) { As().SetCases(params); } + template void SetSourceSSAVariables(const _STD_VECTOR& vars) { As().SetSourceSSAVariables(vars); } template void SetSourceMemoryVersion(size_t version) { return As().SetSourceMemoryVersion(version); } template void SetDestMemoryVersion(size_t version) { return As().SetDestMemoryVersion(version); } template void SetTarget(uint64_t target) { As().SetTarget(target); } @@ -513,7 +523,7 @@ namespace BinaryNinja struct ListIterator { const HighLevelILOperandList* owner; - std::vector::const_iterator pos; + _STD_VECTOR::const_iterator pos; bool operator==(const ListIterator& a) const { return pos == a.pos; } bool operator!=(const ListIterator& a) const { return pos != a.pos; } bool operator<(const ListIterator& a) const { return pos < a.pos; } @@ -522,22 +532,22 @@ namespace BinaryNinja }; HighLevelILInstruction m_instr; - const std::vector& m_usageList; - const std::unordered_map& m_operandIndexMap; + const _STD_VECTOR& m_usageList; + const _STD_UNORDERED_MAP& m_operandIndexMap; public: typedef ListIterator const_iterator; HighLevelILOperandList(const HighLevelILInstruction& instr, - const std::vector& usageList, - const std::unordered_map& operandIndexMap); + const _STD_VECTOR& usageList, + const _STD_UNORDERED_MAP& operandIndexMap); const_iterator begin() const; const_iterator end() const; size_t size() const; const HighLevelILOperand operator[](size_t i) const; - operator std::vector() const; + operator _STD_VECTOR() const; }; struct HighLevelILConstantInstruction: public HighLevelILInstructionBase @@ -638,7 +648,7 @@ namespace BinaryNinja template <> struct HighLevelILInstructionAccessor: public HighLevelILInstructionBase { HighLevelILInstructionList GetSourceExprs() const { return GetRawOperandAsExprList(0); } - void SetSourceExprs(const std::vector& exprs) { UpdateRawOperandAsExprList(0, exprs); } + void SetSourceExprs(const _STD_VECTOR& exprs) { UpdateRawOperandAsExprList(0, exprs); } }; template <> struct HighLevelILInstructionAccessor: public HighLevelILInstructionBase @@ -742,7 +752,7 @@ namespace BinaryNinja { SSAVariable GetDestSSAVariable() const { return GetRawOperandAsSSAVariable(0); } HighLevelILSSAVariableList GetSourceSSAVariables() const { return GetRawOperandAsSSAVariableList(2); } - void SetSourceSSAVariables(const std::vector& vars) { UpdateRawOperandAsSSAVariableList(2, vars); } + void SetSourceSSAVariables(const _STD_VECTOR& vars) { UpdateRawOperandAsSSAVariableList(2, vars); } }; template <> struct HighLevelILInstructionAccessor: public HighLevelILInstructionBase { @@ -897,4 +907,8 @@ namespace BinaryNinja template <> struct HighLevelILInstructionAccessor: public HighLevelILOneOperandInstruction {}; template <> struct HighLevelILInstructionAccessor: public HighLevelILOneOperandInstruction {}; template <> struct HighLevelILInstructionAccessor: public HighLevelILOneOperandInstruction {}; + +#undef _STD_VECTOR +#undef _STD_SET +#undef _STD_UNORDERED_MAP } -- cgit v1.3.1