diff options
| author | Rusty Wagner <rusty@vector35.com> | 2016-10-10 18:24:38 -0400 |
|---|---|---|
| committer | Rusty Wagner <rusty@vector35.com> | 2016-10-10 18:24:38 -0400 |
| commit | 98d187d9d86506ea915731266b8faaaa2dc0c9d6 (patch) | |
| tree | fa1ee82d342c12ed5d42e7caf9397312edf7cf63 /binaryview.cpp | |
| parent | 4598adb7ae961e69fb6ed3e594c0244c49eef511 (diff) | |
| parent | 55ac7a184b7956c0c2e2ca41d512e7c4a81267d9 (diff) | |
Merge commit '55ac7a184b7956c0c2e2ca41d512e7c4a81267d9'
Diffstat (limited to 'binaryview.cpp')
| -rw-r--r-- | binaryview.cpp | 100 |
1 files changed, 93 insertions, 7 deletions
diff --git a/binaryview.cpp b/binaryview.cpp index 8a2d1c2d..863d57b2 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -258,6 +258,7 @@ BinaryView::BinaryView(const std::string& typeName, FileMetadata* file) view.isOffsetReadable = IsOffsetReadableCallback; view.isOffsetWritable = IsOffsetWritableCallback; view.isOffsetExecutable = IsOffsetExecutableCallback; + view.isOffsetBackedByFile = IsOffsetBackedByFileCallback; view.getNextValidOffset = GetNextValidOffsetCallback; view.getStart = GetStartCallback; view.getLength = GetLengthCallback; @@ -357,6 +358,13 @@ bool BinaryView::IsOffsetExecutableCallback(void* ctxt, uint64_t offset) } +bool BinaryView::IsOffsetBackedByFileCallback(void* ctxt, uint64_t offset) +{ + BinaryView* view = (BinaryView*)ctxt; + return view->PerformIsOffsetBackedByFile(offset); +} + + uint64_t BinaryView::GetNextValidOffsetCallback(void* ctxt, uint64_t offset) { BinaryView* view = (BinaryView*)ctxt; @@ -439,6 +447,12 @@ bool BinaryView::PerformIsOffsetExecutable(uint64_t offset) } +bool BinaryView::PerformIsOffsetBackedByFile(uint64_t offset) +{ + return PerformIsValidOffset(offset); +} + + uint64_t BinaryView::PerformGetNextValidOffset(uint64_t offset) { if (offset < PerformGetStart()) @@ -518,12 +532,25 @@ bool BinaryView::CreateDatabase(const string& path) } +bool BinaryView::CreateDatabase(const string& path, + const function<void(size_t progress, size_t total)>& progressCallback) +{ + return m_file->CreateDatabase(path, this, progressCallback); +} + + bool BinaryView::SaveAutoSnapshot() { return m_file->SaveAutoSnapshot(this); } +bool BinaryView::SaveAutoSnapshot(const function<void(size_t progress, size_t total)>& progressCallback) +{ + return m_file->SaveAutoSnapshot(this, progressCallback); +} + + void BinaryView::BeginUndoActions() { m_file->BeginUndoActions(); @@ -683,6 +710,12 @@ bool BinaryView::IsOffsetExecutable(uint64_t offset) const } +bool BinaryView::IsOffsetBackedByFile(uint64_t offset) const +{ + return BNIsOffsetBackedByFile(m_object, offset); +} + + uint64_t BinaryView::GetNextValidOffset(uint64_t offset) const { return BNGetNextValidOffset(m_object, offset); @@ -954,6 +987,20 @@ vector<Ref<BasicBlock>> BinaryView::GetBasicBlocksForAddress(uint64_t addr) } +vector<Ref<BasicBlock>> BinaryView::GetBasicBlocksStartingAtAddress(uint64_t addr) +{ + size_t count; + BNBasicBlock** blocks = BNGetBasicBlocksStartingAtAddress(m_object, addr, &count); + + vector<Ref<BasicBlock>> result; + for (size_t i = 0; i < count; i++) + result.push_back(new BasicBlock(BNNewBasicBlockReference(blocks[i]))); + + BNFreeBasicBlockList(blocks, count); + return result; +} + + vector<ReferenceSource> BinaryView::GetCodeReferences(uint64_t addr) { size_t count; @@ -1082,31 +1129,31 @@ vector<Ref<Symbol>> BinaryView::GetSymbolsOfType(BNSymbolType type, uint64_t sta } -void BinaryView::DefineAutoSymbol(Symbol* sym) +void BinaryView::DefineAutoSymbol(Ref<Symbol> sym) { BNDefineAutoSymbol(m_object, sym->GetObject()); } -void BinaryView::UndefineAutoSymbol(Symbol* sym) +void BinaryView::UndefineAutoSymbol(Ref<Symbol> sym) { BNUndefineAutoSymbol(m_object, sym->GetObject()); } -void BinaryView::DefineUserSymbol(Symbol* sym) +void BinaryView::DefineUserSymbol(Ref<Symbol> sym) { BNDefineUserSymbol(m_object, sym->GetObject()); } -void BinaryView::UndefineUserSymbol(Symbol* sym) +void BinaryView::UndefineUserSymbol(Ref<Symbol> sym) { BNUndefineUserSymbol(m_object, sym->GetObject()); } -void BinaryView::DefineImportedFunction(Symbol* importAddressSym, Function* func) +void BinaryView::DefineImportedFunction(Ref<Symbol> importAddressSym, Ref<Function> func) { BNDefineImportedFunction(m_object, importAddressSym->GetObject(), func->GetObject()); } @@ -1397,13 +1444,13 @@ bool BinaryView::IsTypeAutoDefined(const std::string& name) } -void BinaryView::DefineType(const std::string& name, Type* type) +void BinaryView::DefineType(const std::string& name, Ref<Type> type) { BNDefineAnalysisType(m_object, name.c_str(), type->GetObject()); } -void BinaryView::DefineUserType(const std::string& name, Type* type) +void BinaryView::DefineUserType(const std::string& name, Ref<Type> type) { BNDefineUserAnalysisType(m_object, name.c_str(), type->GetObject()); } @@ -1427,6 +1474,45 @@ bool BinaryView::FindNextData(uint64_t start, const DataBuffer& data, uint64_t& } +void BinaryView::Reanalyze() +{ + BNReanalyzeAllFunctions(m_object); +} + + +void BinaryView::ShowPlainTextReport(const string& title, const string& contents) +{ + BNShowPlainTextReport(m_object, title.c_str(), contents.c_str()); +} + + +void BinaryView::ShowMarkdownReport(const string& title, const string& contents, const string& plainText) +{ + BNShowMarkdownReport(m_object, title.c_str(), contents.c_str(), plainText.c_str()); +} + + +void BinaryView::ShowHTMLReport(const string& title, const string& contents, const string& plainText) +{ + BNShowHTMLReport(m_object, title.c_str(), contents.c_str(), plainText.c_str()); +} + + +bool BinaryView::GetAddressInput(uint64_t& result, const string& prompt, const string& title) +{ + uint64_t currentAddress = 0; + if (m_file) + currentAddress = m_file->GetCurrentOffset(); + return BNGetAddressInput(&result, prompt.c_str(), title.c_str(), m_object, currentAddress); +} + + +bool BinaryView::GetAddressInput(uint64_t& result, const string& prompt, const string& title, uint64_t currentAddress) +{ + return BNGetAddressInput(&result, prompt.c_str(), title.c_str(), m_object, currentAddress); +} + + BinaryData::BinaryData(FileMetadata* file): BinaryView(BNCreateBinaryDataView(file->GetObject())) { } |
