From 1a7d06b3b8044ccdee4e3ff0883a33bf8cce487f Mon Sep 17 00:00:00 2001 From: Brian Potchik Date: Sat, 4 Feb 2023 15:23:52 -0500 Subject: Initial support for constant data expressions. --- binaryninjaapi.h | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'binaryninjaapi.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 59b41e63..5be1d760 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -4379,13 +4379,6 @@ namespace BinaryNinja { */ size_t GetInstructionLength(Architecture* arch, uint64_t addr); - /*! Get the constant data at an address. Temporary API for debug only. - - \param[in] addr Address of the constant data - \return DataBuffer containing the constant data - */ - DataBuffer GetConstantData(uint64_t addr); - /*! Get the string at an address \param[in] addr Address of the string @@ -8367,6 +8360,7 @@ namespace BinaryNinja { BNRegisterValueType state; int64_t value; int64_t offset; + size_t size; RegisterValue(); @@ -8376,6 +8370,18 @@ namespace BinaryNinja { BNRegisterValue ToAPIObject(); }; + struct ConstantData : public BNRegisterValue + { + Ref func = nullptr; + + ConstantData(); + ConstantData(BNRegisterValueType state, uint64_t value); + ConstantData(BNRegisterValueType state, uint64_t value, size_t size, Ref func = nullptr); + + DataBuffer ToDataBuffer() const; + RegisterValue ToRegisterValue() const; + }; + /*! \ingroup function */ @@ -8384,6 +8390,7 @@ namespace BinaryNinja { BNRegisterValueType state; int64_t value; int64_t offset; + size_t size; std::vector ranges; std::set valueSet; std::vector table; @@ -8620,6 +8627,9 @@ namespace BinaryNinja { size_t GetLowLevelILForInstruction(Architecture* arch, uint64_t addr); std::set GetLowLevelILInstructionsForAddress(Architecture* arch, uint64_t addr); std::vector GetLowLevelILExitsForInstruction(Architecture* arch, uint64_t addr); + + DataBuffer GetConstantData(BNRegisterValueType state, uint64_t value, size_t size = 0); + RegisterValue GetRegisterValueAtInstruction(Architecture* arch, uint64_t addr, uint32_t reg); RegisterValue GetRegisterValueAfterInstruction(Architecture* arch, uint64_t addr, uint32_t reg); RegisterValue GetStackContentsAtInstruction(Architecture* arch, uint64_t addr, int64_t offset, size_t size); @@ -10848,7 +10858,6 @@ namespace BinaryNinja { ExprId AddressOf(const Variable& var, const ILSourceLocation& loc = ILSourceLocation()); ExprId AddressOfField(const Variable& var, uint64_t offset, const ILSourceLocation& loc = ILSourceLocation()); ExprId Const(size_t size, uint64_t val, const ILSourceLocation& loc = ILSourceLocation()); - ExprId ConstData(size_t size, uint64_t addr, const ILSourceLocation& loc = ILSourceLocation()); ExprId ConstPointer(size_t size, uint64_t val, const ILSourceLocation& loc = ILSourceLocation()); ExprId ExternPointer( size_t size, uint64_t val, uint64_t offset, const ILSourceLocation& loc = ILSourceLocation()); @@ -10856,6 +10865,7 @@ namespace BinaryNinja { ExprId FloatConstSingle(float val, const ILSourceLocation& loc = ILSourceLocation()); ExprId FloatConstDouble(double val, const ILSourceLocation& loc = ILSourceLocation()); ExprId ImportedAddress(size_t size, uint64_t val, const ILSourceLocation& loc = ILSourceLocation()); + ExprId ConstData(size_t size, const ConstantData& data, const ILSourceLocation& loc = ILSourceLocation()); ExprId Add(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation()); ExprId AddWithCarry( size_t size, ExprId left, ExprId right, ExprId carry, const ILSourceLocation& loc = ILSourceLocation()); @@ -11218,7 +11228,6 @@ namespace BinaryNinja { const ILSourceLocation& loc = ILSourceLocation()); ExprId AddressOf(ExprId src, const ILSourceLocation& loc = ILSourceLocation()); ExprId Const(size_t size, uint64_t val, const ILSourceLocation& loc = ILSourceLocation()); - ExprId ConstData(size_t size, uint64_t addr, const ILSourceLocation& loc = ILSourceLocation()); ExprId ConstPointer(size_t size, uint64_t val, const ILSourceLocation& loc = ILSourceLocation()); ExprId ExternPointer( size_t size, uint64_t val, uint64_t offset, const ILSourceLocation& loc = ILSourceLocation()); @@ -11226,6 +11235,7 @@ namespace BinaryNinja { ExprId FloatConstSingle(float val, const ILSourceLocation& loc = ILSourceLocation()); ExprId FloatConstDouble(double val, const ILSourceLocation& loc = ILSourceLocation()); ExprId ImportedAddress(size_t size, uint64_t val, const ILSourceLocation& loc = ILSourceLocation()); + ExprId ConstData(size_t size, const ConstantData& data, const ILSourceLocation& loc = ILSourceLocation()); ExprId Add(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation()); ExprId AddWithCarry( size_t size, ExprId left, ExprId right, ExprId carry, const ILSourceLocation& loc = ILSourceLocation()); -- cgit v1.3.1