summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRusty Wagner <rusty@vector35.com>2015-07-29 23:35:48 -0400
committerRusty Wagner <rusty@vector35.com>2015-07-29 23:35:48 -0400
commit40192fa7adbf7b53e9d45343b0ae1b47cc5fef86 (patch)
tree13d7072fc95b3a594020fe81d1420c97354fe308
parenta1000948164a38f12a3348490ac13446ace196b7 (diff)
Show basic register data flow information on hover
-rw-r--r--architecture.cpp6
-rw-r--r--binaryninjaapi.h11
-rw-r--r--binaryview.cpp6
-rw-r--r--function.cpp69
4 files changed, 92 insertions, 0 deletions
diff --git a/architecture.cpp b/architecture.cpp
index a3ec56b7..2399e102 100644
--- a/architecture.cpp
+++ b/architecture.cpp
@@ -416,6 +416,12 @@ vector<uint32_t> Architecture::GetModifiedRegistersOnWrite(uint32_t reg)
}
+uint32_t Architecture::GetRegisterByName(const string& name)
+{
+ return BNGetArchitectureRegisterByName(m_arch, name.c_str());
+}
+
+
bool Architecture::Assemble(const std::string&, uint64_t, DataBuffer&, std::string& errors)
{
errors = "Architecture does not implement an assembler.\n";
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 2d230f6f..df2484df 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -562,6 +562,8 @@ namespace BinaryNinja
bool AlwaysBranch(Architecture* arch, uint64_t addr);
bool InvertBranch(Architecture* arch, uint64_t addr);
bool SkipAndReturnValue(Architecture* arch, uint64_t addr, uint64_t value);
+
+ size_t GetInstructionLength(Architecture* arch, uint64_t addr);
};
class BinaryData: public BinaryView
@@ -861,6 +863,7 @@ namespace BinaryNinja
virtual BNRegisterInfo GetRegisterInfo(uint32_t reg);
virtual uint32_t GetStackPointerRegister();
std::vector<uint32_t> GetModifiedRegistersOnWrite(uint32_t reg);
+ uint32_t GetRegisterByName(const std::string& name);
virtual bool Assemble(const std::string& code, uint64_t addr, DataBuffer& result, std::string& errors);
@@ -1069,6 +1072,14 @@ namespace BinaryNinja
Ref<LowLevelILFunction> GetLowLevelIL() const;
std::vector<Ref<BasicBlock>> GetLowLevelILBasicBlocks() const;
+ size_t GetLowLevelILForInstruction(Architecture* arch, uint64_t addr);
+ std::vector<size_t> GetLowLevelILExitsForInstruction(Architecture* arch, uint64_t addr);
+ BNRegisterValue GetRegisterValueAtInstruction(Architecture* arch, uint64_t addr, uint32_t reg);
+ BNRegisterValue GetRegisterValueAfterInstruction(Architecture* arch, uint64_t addr, uint32_t reg);
+ BNRegisterValue GetRegisterValueAtLowLevelILInstruction(size_t i, uint32_t reg);
+ BNRegisterValue GetRegisterValueAfterLowLevelILInstruction(size_t i, uint32_t reg);
+ std::vector<uint32_t> GetRegistersReadByInstruction(Architecture* arch, uint64_t addr);
+ std::vector<uint32_t> GetRegistersWrittenByInstruction(Architecture* arch, uint64_t addr);
Ref<Type> GetType() const;
diff --git a/binaryview.cpp b/binaryview.cpp
index 0e24f65e..12fa6548 100644
--- a/binaryview.cpp
+++ b/binaryview.cpp
@@ -829,6 +829,12 @@ bool BinaryView::SkipAndReturnValue(Architecture* arch, uint64_t addr, uint64_t
}
+size_t BinaryView::GetInstructionLength(Architecture* arch, uint64_t addr)
+{
+ return BNGetInstructionLength(m_view, arch->GetArchitectureObject(), addr);
+}
+
+
BinaryData::BinaryData(FileMetadata* file): BinaryView(BNCreateBinaryDataView(file->GetFileObject()))
{
}
diff --git a/function.cpp b/function.cpp
index 89b2dfbb..4e813916 100644
--- a/function.cpp
+++ b/function.cpp
@@ -99,6 +99,75 @@ vector<Ref<BasicBlock>> Function::GetLowLevelILBasicBlocks() const
}
+size_t Function::GetLowLevelILForInstruction(Architecture* arch, uint64_t addr)
+{
+ return BNGetLowLevelILForInstruction(m_func, arch->GetArchitectureObject(), addr);
+}
+
+
+vector<size_t> Function::GetLowLevelILExitsForInstruction(Architecture* arch, uint64_t addr)
+{
+ size_t count;
+ size_t* exits = BNGetLowLevelILExitsForInstruction(m_func, arch->GetArchitectureObject(), addr, &count);
+
+ vector<size_t> result;
+ result.insert(result.end(), exits, &exits[count]);
+
+ BNFreeLowLevelILInstructionList(exits);
+ return result;
+}
+
+
+BNRegisterValue Function::GetRegisterValueAtInstruction(Architecture* arch, uint64_t addr, uint32_t reg)
+{
+ return BNGetRegisterValueAtInstruction(m_func, arch->GetArchitectureObject(), addr, reg);
+}
+
+
+BNRegisterValue Function::GetRegisterValueAfterInstruction(Architecture* arch, uint64_t addr, uint32_t reg)
+{
+ return BNGetRegisterValueAfterInstruction(m_func, arch->GetArchitectureObject(), addr, reg);
+}
+
+
+BNRegisterValue Function::GetRegisterValueAtLowLevelILInstruction(size_t i, uint32_t reg)
+{
+ return BNGetRegisterValueAtLowLevelILInstruction(m_func, i, reg);
+}
+
+
+BNRegisterValue Function::GetRegisterValueAfterLowLevelILInstruction(size_t i, uint32_t reg)
+{
+ return BNGetRegisterValueAfterLowLevelILInstruction(m_func, i, reg);
+}
+
+
+vector<uint32_t> Function::GetRegistersReadByInstruction(Architecture* arch, uint64_t addr)
+{
+ size_t count;
+ uint32_t* regs = BNGetRegistersReadByInstruction(m_func, arch->GetArchitectureObject(), addr, &count);
+
+ vector<uint32_t> result;
+ result.insert(result.end(), regs, &regs[count]);
+
+ BNFreeRegisterList(regs);
+ return result;
+}
+
+
+vector<uint32_t> Function::GetRegistersWrittenByInstruction(Architecture* arch, uint64_t addr)
+{
+ size_t count;
+ uint32_t* regs = BNGetRegistersWrittenByInstruction(m_func, arch->GetArchitectureObject(), addr, &count);
+
+ vector<uint32_t> result;
+ result.insert(result.end(), regs, &regs[count]);
+
+ BNFreeRegisterList(regs);
+ return result;
+}
+
+
Ref<Type> Function::GetType() const
{
return new Type(BNGetFunctionType(m_func));