From 254d5aa23c0d114e9a275f60538fcb3b76ac1c69 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Thu, 20 Oct 2016 00:14:41 -0400 Subject: Add API for multiple architectures distinguished by address --- architecture.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'architecture.cpp') diff --git a/architecture.cpp b/architecture.cpp index af7b0cba..3c7d9af8 100644 --- a/architecture.cpp +++ b/architecture.cpp @@ -111,6 +111,13 @@ size_t Architecture::GetOpcodeDisplayLengthCallback(void* ctxt) } +BNArchitecture* Architecture::GetAssociatedArchitectureByAddressCallback(void* ctxt, uint64_t* addr) +{ + Architecture* arch = (Architecture*)ctxt; + return arch->GetAssociatedArchitectureByAddress(*addr)->GetObject(); +} + + bool Architecture::GetInstructionInfoCallback(void* ctxt, const uint8_t* data, uint64_t addr, size_t maxLen, BNInstructionInfo* result) { @@ -408,6 +415,7 @@ void Architecture::Register(Architecture* arch) callbacks.getDefaultIntegerSize = GetDefaultIntegerSizeCallback; callbacks.getMaxInstructionLength = GetMaxInstructionLengthCallback; callbacks.getOpcodeDisplayLength = GetOpcodeDisplayLengthCallback; + callbacks.getAssociatedArchitectureByAddress = GetAssociatedArchitectureByAddressCallback; callbacks.getInstructionInfo = GetInstructionInfoCallback; callbacks.getInstructionText = GetInstructionTextCallback; callbacks.freeInstructionText = FreeInstructionTextCallback; @@ -499,6 +507,12 @@ size_t Architecture::GetOpcodeDisplayLength() const } +Ref Architecture::GetAssociatedArchitectureByAddress(uint64_t&) +{ + return this; +} + + bool Architecture::GetInstructionLowLevelIL(const uint8_t*, uint64_t, size_t&, LowLevelILFunction& il) { il.AddInstruction(il.Undefined()); @@ -919,6 +933,12 @@ size_t CoreArchitecture::GetOpcodeDisplayLength() const } +Ref CoreArchitecture::GetAssociatedArchitectureByAddress(uint64_t& addr) +{ + return new CoreArchitecture(BNGetAssociatedArchitectureByAddress(m_object, &addr)); +} + + bool CoreArchitecture::GetInstructionInfo(const uint8_t* data, uint64_t addr, size_t maxLen, InstructionInfo& result) { return BNGetInstructionInfo(m_object, data, addr, maxLen, &result); -- cgit v1.3.1