From b8f49d5fecc354ad25533efad8660f4c07b9879b Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 27 Jul 2018 20:24:10 -0400 Subject: Expose the ability to suppress analysis of auto-discovered functions --- binaryninjacore.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'binaryninjacore.h') diff --git a/binaryninjacore.h b/binaryninjacore.h index fda26d47..99f14f4e 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -1509,6 +1509,7 @@ extern "C" uint64_t maxFunctionAnalysisTime; size_t maxFunctionUpdateCount; size_t maxFunctionSubmitCount; + bool suppressNewAutoFunctionAnalysis; }; struct BNDownloadInstanceOutputCallbacks @@ -1820,7 +1821,8 @@ extern "C" NoSkipReason, AlwaysSkipReason, ExceedFunctionSizeSkipReason, - ExceedFunctionAnalysisTimeSkipReason + ExceedFunctionAnalysisTimeSkipReason, + NewAutoFunctionAnalysisSuppressedReason }; BINARYNINJACOREAPI char* BNAllocString(const char* contents); @@ -2520,6 +2522,8 @@ extern "C" BINARYNINJACOREAPI void BNSetParametersForAnalysis(BNBinaryView* view, BNAnalysisParameters params); BINARYNINJACOREAPI uint64_t BNGetMaxFunctionSizeForAnalysis(BNBinaryView* view); BINARYNINJACOREAPI void BNSetMaxFunctionSizeForAnalysis(BNBinaryView* view, uint64_t size); + BINARYNINJACOREAPI bool BNGetNewAutoFunctionAnalysisSuppressed(BNBinaryView* view); + BINARYNINJACOREAPI void BNSetNewAutoFunctionAnalysisSuppressed(BNBinaryView* view, bool suppress); BINARYNINJACOREAPI BNAnalysisCompletionEvent* BNAddAnalysisCompletionEvent(BNBinaryView* view, void* ctxt, void (*callback)(void* ctxt)); -- cgit v1.3.1 From c83c029027c153b6c9c60d1e8f35b68023e93522 Mon Sep 17 00:00:00 2001 From: Josh Ferrell Date: Mon, 30 Jul 2018 18:56:40 -0400 Subject: Added WideCharTypeClass to BNTypeClass enum --- binaryninjacore.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'binaryninjacore.h') diff --git a/binaryninjacore.h b/binaryninjacore.h index 99f14f4e..58f53997 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -502,7 +502,8 @@ extern "C" FunctionTypeClass = 8, VarArgsTypeClass = 9, ValueTypeClass = 10, - NamedTypeReferenceClass = 11 + NamedTypeReferenceClass = 11, + WideCharTypeClass = 12 }; enum BNNamedTypeReferenceClass -- cgit v1.3.1 From b7ed97940ec4a5b7b7588356b54122bec9e73334 Mon Sep 17 00:00:00 2001 From: Josh Ferrell Date: Wed, 15 Aug 2018 15:10:34 -0400 Subject: Added UTF8 string to stringtype enum --- binaryninjacore.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'binaryninjacore.h') diff --git a/binaryninjacore.h b/binaryninjacore.h index 58f53997..e5949066 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -655,7 +655,8 @@ extern "C" { AsciiString = 0, Utf16String = 1, - Utf32String = 2 + Utf32String = 2, + Utf8String = 3 }; enum BNIntegerDisplayType -- cgit v1.3.1 From cecb2af5e8ec590500379e4b103531649de4e5a2 Mon Sep 17 00:00:00 2001 From: Ryan Snyder Date: Mon, 20 Aug 2018 18:58:00 -0400 Subject: api: add methods to get basic block objects from IL instrs --- binaryninjaapi.h | 2 ++ binaryninjacore.h | 2 ++ lowlevelil.cpp | 9 +++++++++ mediumlevelil.cpp | 9 +++++++++ python/lowlevelil.py | 5 +++++ python/mediumlevelil.py | 5 +++++ 6 files changed, 32 insertions(+) (limited to 'binaryninjacore.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 620c0472..b00689e0 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -2937,6 +2937,7 @@ namespace BinaryNinja uint32_t GetTemporaryFlagCount(); std::vector> GetBasicBlocks() const; + Ref GetBasicBlockForInstruction(size_t i) const; Ref GetSSAForm() const; Ref GetNonSSAForm() const; @@ -3256,6 +3257,7 @@ namespace BinaryNinja void VisitAllExprs(const std::function& func); std::vector> GetBasicBlocks() const; + Ref GetBasicBlockForInstruction(size_t i) const; Ref GetSSAForm() const; Ref GetNonSSAForm() const; diff --git a/binaryninjacore.h b/binaryninjacore.h index e5949066..c2d9f9f7 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -2768,6 +2768,7 @@ extern "C" BINARYNINJACOREAPI uint32_t BNGetLowLevelILTemporaryFlagCount(BNLowLevelILFunction* func); BINARYNINJACOREAPI BNBasicBlock** BNGetLowLevelILBasicBlockList(BNLowLevelILFunction* func, size_t* count); + BINARYNINJACOREAPI BNBasicBlock* BNGetLowLevelILBasicBlockForInstruction(BNLowLevelILFunction* func, size_t i); BINARYNINJACOREAPI BNLowLevelILFunction* BNGetLowLevelILSSAForm(BNLowLevelILFunction* func); BINARYNINJACOREAPI BNLowLevelILFunction* BNGetLowLevelILNonSSAForm(BNLowLevelILFunction* func); @@ -2889,6 +2890,7 @@ extern "C" BNArchitecture* arch, size_t i, BNInstructionTextToken** tokens, size_t* count); BINARYNINJACOREAPI BNBasicBlock** BNGetMediumLevelILBasicBlockList(BNMediumLevelILFunction* func, size_t* count); + BINARYNINJACOREAPI BNBasicBlock* BNGetMediumLevelILBasicBlockForInstruction(BNMediumLevelILFunction* func, size_t i); BINARYNINJACOREAPI BNMediumLevelILFunction* BNGetMediumLevelILSSAForm(BNMediumLevelILFunction* func); BINARYNINJACOREAPI BNMediumLevelILFunction* BNGetMediumLevelILNonSSAForm(BNMediumLevelILFunction* func); diff --git a/lowlevelil.cpp b/lowlevelil.cpp index 79138159..40748327 100644 --- a/lowlevelil.cpp +++ b/lowlevelil.cpp @@ -491,6 +491,15 @@ vector> LowLevelILFunction::GetBasicBlocks() const } +Ref LowLevelILFunction::GetBasicBlockForInstruction(size_t i) const +{ + BNBasicBlock* block = BNGetLowLevelILBasicBlockForInstruction(m_object, i); + if (!block) + return nullptr; + return new BasicBlock(block); +} + + Ref LowLevelILFunction::GetSSAForm() const { BNLowLevelILFunction* func = BNGetLowLevelILSSAForm(m_object); diff --git a/mediumlevelil.cpp b/mediumlevelil.cpp index 1795a54d..cac45dd6 100644 --- a/mediumlevelil.cpp +++ b/mediumlevelil.cpp @@ -404,6 +404,15 @@ vector> MediumLevelILFunction::GetBasicBlocks() const } +Ref MediumLevelILFunction::GetBasicBlockForInstruction(size_t i) const +{ + BNBasicBlock* block = BNGetMediumLevelILBasicBlockForInstruction(m_object, i); + if (!block) + return nullptr; + return new BasicBlock(block); +} + + Ref MediumLevelILFunction::GetSSAForm() const { BNMediumLevelILFunction* func = BNGetMediumLevelILSSAForm(m_object); diff --git a/python/lowlevelil.py b/python/lowlevelil.py index e714eb48..41579719 100644 --- a/python/lowlevelil.py +++ b/python/lowlevelil.py @@ -536,6 +536,11 @@ class LowLevelILInstruction(object): core.BNFreeInstructionText(tokens, count.value) return result + @property + def il_basic_block(self): + """IL basic block object containing this expression (read-only) (only available on finalized functions)""" + return LowLevelILBasicBlock(self.function.source_function.view, core.BNGetLowLevelILBasicBlockForInstruction(self.function.handle, self.instr_index), self.function) + @property def ssa_form(self): """SSA form of expression (read-only)""" diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py index cfa8f900..c024d287 100644 --- a/python/mediumlevelil.py +++ b/python/mediumlevelil.py @@ -333,6 +333,11 @@ class MediumLevelILInstruction(object): core.BNFreeInstructionText(tokens, count.value) return result + @property + def il_basic_block(self): + """IL basic block object containing this expression (read-only) (only available on finalized functions)""" + return MediumLevelILBasicBlock(self.function.source_function.view, core.BNGetMediumLevelILBasicBlockForInstruction(self.function.handle, self.instr_index), self.function) + @property def ssa_form(self): """SSA form of expression (read-only)""" -- cgit v1.3.1 From ebed7129ba102453f04f99e2f78278ff8aeef6f9 Mon Sep 17 00:00:00 2001 From: Jordan Wiens Date: Thu, 23 Aug 2018 00:57:06 -0400 Subject: add support for original_filename property --- binaryninjaapi.h | 3 +++ binaryninjacore.h | 3 +++ filemetadata.cpp | 15 +++++++++++++++ python/filemetadata.py | 11 ++++++++++- 4 files changed, 31 insertions(+), 1 deletion(-) (limited to 'binaryninjacore.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index b00689e0..a3db346a 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -821,6 +821,9 @@ namespace BinaryNinja void SetNavigationHandler(NavigationHandler* handler); + std::string GetOriginalFilename() const; + void SetOriginalFilename(const std::string& name); + std::string GetFilename() const; void SetFilename(const std::string& name); diff --git a/binaryninjacore.h b/binaryninjacore.h index c2d9f9f7..45ffc077 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -1950,6 +1950,9 @@ extern "C" BINARYNINJACOREAPI bool BNSaveAutoSnapshotWithProgress(BNBinaryView* data, void* ctxt, void (*progress)(void* ctxt, size_t progress, size_t total)); + BINARYNINJACOREAPI char* BNGetOriginalFilename(BNFileMetadata* file); + BINARYNINJACOREAPI void BNSetOriginalFilename(BNFileMetadata* file, const char* name); + BINARYNINJACOREAPI char* BNGetFilename(BNFileMetadata* file); BINARYNINJACOREAPI void BNSetFilename(BNFileMetadata* file, const char* name); diff --git a/filemetadata.cpp b/filemetadata.cpp index dc08fe30..bbde5d72 100644 --- a/filemetadata.cpp +++ b/filemetadata.cpp @@ -208,6 +208,21 @@ void FileMetadata::SetNavigationHandler(NavigationHandler* handler) } +string FileMetadata::GetOriginalFilename() const +{ + char* str = BNGetOriginalFilename(m_object); + string result = str; + BNFreeString(str); + return result; +} + + +void FileMetadata::SetOriginalFilename(const string& name) +{ + BNSetOriginalFilename(m_object, name.c_str()); +} + + string FileMetadata::GetFilename() const { char* str = BNGetFilename(m_object); diff --git a/python/filemetadata.py b/python/filemetadata.py index cafe1d67..4d51f4d9 100644 --- a/python/filemetadata.py +++ b/python/filemetadata.py @@ -113,9 +113,18 @@ class FileMetadata(object): def set_default_session_data(cls, name, value): _FileMetadataAssociatedDataStore.set_default(name, value) + @property + def original_filename(self): + """The original name of the binary opened if a bndb, otherwise reads or sets the current filename (read/write)""" + return core.BNGetOriginalFilename(self.handle) + + @original_filename.setter + def original_filename(self, value): + core.BNSetOriginalFilename(self.handle, str(value)) + @property def filename(self): - """The name of the file (read/write)""" + """The name of the open bndb or binary filename (read/write)""" return core.BNGetFilename(self.handle) @filename.setter -- cgit v1.3.1