GeezerVison is showing github.com — Update SymbolQueue API to support types with confidence. · Vector35/binaryninja-api@5cab99a
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: binaryninjaapi.h +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -5758,7 +5758,7 @@ namespace BinaryNinja { | 5758 | 5758 | \param type Type being defined | 5759 | 5759 | \return The defined symbol | 5760 | 5760 | */ | 5761 | | - Ref<Symbol> DefineAutoSymbolAndVariableOrFunction(Ref<Platform> platform, Ref<Symbol> sym, Ref<Type> type); | | 5761 | + Ref<Symbol> DefineAutoSymbolAndVariableOrFunction(Ref<Platform> platform, Ref<Symbol> sym, const Confidence<Ref<Type>>& type); | 5762 | 5762 |
| 5763 | 5763 | /*! Undefine an automatically defined symbol | 5764 | 5764 |
| @@ -18819,14 +18819,14 @@ namespace BinaryNinja { | 18819 | 18819 | { | 18820 | 18820 | BNSymbolQueue* m_object; | 18821 | 18821 |
| 18822 | | - static void ResolveCallback(void* ctxt, BNSymbol** symbol, BNType** type); | 18823 | | - static void AddCallback(void* ctxt, BNSymbol* symbol, BNType* type); | | 18822 | + static void ResolveCallback(void* ctxt, BNSymbol** symbol, BNTypeWithConfidence* type); | | 18823 | + static void AddCallback(void* ctxt, BNSymbol* symbol, BNTypeWithConfidence* type); | 18824 | 18824 |
| 18825 | 18825 | public: | 18826 | 18826 | SymbolQueue(); | 18827 | 18827 | ~SymbolQueue(); | 18828 | | - void Append(const std::function<std::pair<Ref<Symbol>, Ref<Type>>()>& resolve, | 18829 | | - const std::function<void(Symbol*, Type*)>& add); | | 18828 | + void Append(const std::function<std::pair<Ref<Symbol>, Confidence<Ref<Type>>>()>& resolve, | | 18829 | + const std::function<void(Symbol*, const Confidence<Ref<Type>>&)>& add); | 18830 | 18830 | void Process(); | 18831 | 18831 | }; | 18832 | 18832 |
| |
Collapse file Copy file name to clipboardExpand all lines: binaryninjacore.h +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 37 | 37 | // Current ABI version for linking to the core. This is incremented any time | 38 | 38 | // there are changes to the API that affect linking, including new functions, | 39 | 39 | // new types, or modifications to existing functions or types. | 40 | | -#define BN_CURRENT_CORE_ABI_VERSION 111 | | 40 | +#define BN_CURRENT_CORE_ABI_VERSION 112 | 41 | 41 |
| 42 | 42 | // Minimum ABI version that is supported for loading of plugins. Plugins that | 43 | 43 | // are linked to an ABI version less than this will not be able to load and | @@ -5807,7 +5807,7 @@ extern "C" | 5807 | 5807 | BINARYNINJACOREAPI void BNDefineImportedFunction( | 5808 | 5808 | BNBinaryView* view, BNSymbol* importAddressSym, BNFunction* func, BNType* type); | 5809 | 5809 | BINARYNINJACOREAPI BNSymbol* BNDefineAutoSymbolAndVariableOrFunction( | 5810 | | - BNBinaryView* view, BNPlatform* platform, BNSymbol* sym, BNType* type); | | 5810 | + BNBinaryView* view, BNPlatform* platform, BNSymbol* sym, BNTypeWithConfidence* type); | 5811 | 5811 | BINARYNINJACOREAPI void BNBeginBulkModifySymbols(BNBinaryView* view); | 5812 | 5812 | BINARYNINJACOREAPI void BNEndBulkModifySymbols(BNBinaryView* view); | 5813 | 5813 |
| @@ -7721,8 +7721,8 @@ extern "C" | 7721 | 7721 | BINARYNINJACOREAPI BNSymbolQueue* BNCreateSymbolQueue(void); | 7722 | 7722 | BINARYNINJACOREAPI void BNDestroySymbolQueue(BNSymbolQueue* queue); | 7723 | 7723 | BINARYNINJACOREAPI void BNAppendSymbolQueue(BNSymbolQueue* queue, | 7724 | | - void (*resolve)(void* ctxt, BNSymbol** symbol, BNType** type), void* resolveContext, | 7725 | | - void (*add)(void* ctxt, BNSymbol* symbol, BNType* type), void* addContext); | | 7724 | + void (*resolve)(void* ctxt, BNSymbol** symbol, BNTypeWithConfidence* type), void* resolveContext, | | 7725 | + void (*add)(void* ctxt, BNSymbol* symbol, BNTypeWithConfidence* type), void* addContext); | 7726 | 7726 | BINARYNINJACOREAPI void BNProcessSymbolQueue(BNSymbolQueue* queue); | 7727 | 7727 |
| 7728 | 7728 | BINARYNINJACOREAPI bool BNCoreEnumToString(const char* enumName, size_t value, char** result); | |
Collapse file Copy file name to clipboardExpand all lines: binaryview.cpp +11-9Lines changed: 11 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -29,12 +29,12 @@ using namespace std; | 29 | 29 |
| 30 | 30 | struct SymbolQueueResolveContext | 31 | 31 | { | 32 | | - std::function<std::pair<Ref<Symbol>, Ref<Type>>()> resolve; | | 32 | + std::function<std::pair<Ref<Symbol>, Confidence<Ref<Type>>>()> resolve; | 33 | 33 | }; | 34 | 34 |
| 35 | 35 | struct SymbolQueueAddContext | 36 | 36 | { | 37 | | - std::function<void(Symbol*, Type*)> add; | | 37 | + std::function<void(Symbol*, const Confidence<Ref<Type>>&)> add; | 38 | 38 | }; | 39 | 39 |
| 40 | 40 |
| @@ -3130,10 +3130,11 @@ void BinaryView::DefineAutoSymbol(Ref<Symbol> sym) | 3130 | 3130 | } | 3131 | 3131 |
| 3132 | 3132 |
| 3133 | | -Ref<Symbol> BinaryView::DefineAutoSymbolAndVariableOrFunction(Ref<Platform> platform, Ref<Symbol> sym, Ref<Type> type) | | 3133 | +Ref<Symbol> BinaryView::DefineAutoSymbolAndVariableOrFunction(Ref<Platform> platform, Ref<Symbol> sym, const Confidence<Ref<Type>>& type) | 3134 | 3134 | { | | 3135 | + BNTypeWithConfidence apiType = {type.GetValue() ? type.GetValue()->GetObject() : nullptr, type.GetConfidence()}; | 3135 | 3136 | BNSymbol* result = BNDefineAutoSymbolAndVariableOrFunction( | 3136 | | - m_object, platform ? platform->GetObject() : nullptr, sym->GetObject(), type ? type->GetObject() : nullptr); | | 3137 | + m_object, platform ? platform->GetObject() : nullptr, sym->GetObject(), &apiType); | 3137 | 3138 | if (!result) | 3138 | 3139 | return nullptr; | 3139 | 3140 | return new Symbol(result); | @@ -5694,28 +5695,29 @@ SymbolQueue::~SymbolQueue() | 5694 | 5695 | } | 5695 | 5696 |
| 5696 | 5697 |
| 5697 | | -void SymbolQueue::ResolveCallback(void* ctxt, BNSymbol** symbol, BNType** type) | | 5698 | +void SymbolQueue::ResolveCallback(void* ctxt, BNSymbol** symbol, BNTypeWithConfidence* type) | 5698 | 5699 | { | 5699 | 5700 | SymbolQueueResolveContext* resolve = (SymbolQueueResolveContext*)ctxt; | 5700 | 5701 | auto result = resolve->resolve(); | 5701 | 5702 | delete resolve; | 5702 | 5703 | *symbol = result.first ? BNNewSymbolReference(result.first->GetObject()) : nullptr; | 5703 | | - *type = result.second ? BNNewTypeReference(result.second->GetObject()) : nullptr; | | 5704 | + type->type = result.second.GetValue() ? BNNewTypeReference(result.second.GetValue()->GetObject()) : nullptr; | | 5705 | + type->confidence = result.second.GetConfidence(); | 5704 | 5706 | } | 5705 | 5707 |
| 5706 | 5708 |
| 5707 | | -void SymbolQueue::AddCallback(void* ctxt, BNSymbol* symbol, BNType* type) | | 5709 | +void SymbolQueue::AddCallback(void* ctxt, BNSymbol* symbol, BNTypeWithConfidence* type) | 5708 | 5710 | { | 5709 | 5711 | SymbolQueueAddContext* add = (SymbolQueueAddContext*)ctxt; | 5710 | 5712 | Ref<Symbol> apiSymbol = new Symbol(symbol); | 5711 | | - Ref<Type> apiType = new Type(type); | | 5713 | + Confidence<Ref<Type>> apiType(type->type ? new Type(type->type) : nullptr, type->confidence); | 5712 | 5714 | add->add(apiSymbol, apiType); | 5713 | 5715 | delete add; | 5714 | 5716 | } | 5715 | 5717 |
| 5716 | 5718 |
| 5717 | 5719 | void SymbolQueue::Append( | 5718 | | - const std::function<std::pair<Ref<Symbol>, Ref<Type>>()>& resolve, const std::function<void(Symbol*, Type*)>& add) | | 5720 | + const std::function<std::pair<Ref<Symbol>, Confidence<Ref<Type>>>()>& resolve, const std::function<void(Symbol*, const Confidence<Ref<Type>>&)>& add) | 5719 | 5721 | { | 5720 | 5722 | SymbolQueueResolveContext* resolveCtxt = new SymbolQueueResolveContext {resolve}; | 5721 | 5723 | SymbolQueueAddContext* addCtxt = new SymbolQueueAddContext {add}; | |
Collapse file Copy file name to clipboardExpand all lines: rust/src/binary_view.rs +8-5Lines changed: 8 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -528,18 +528,21 @@ pub trait BinaryViewExt: BinaryViewBase { | 528 | 528 | plat: &Platform, | 529 | 529 | ty: T, | 530 | 530 | ) -> Result<Ref<Symbol>> { | 531 | | - let raw_type = if let Some(t) = ty.into() { | 532 | | - t.handle | 533 | | - } else { | 534 | | - std::ptr::null_mut() | | 531 | + let mut type_with_conf = BNTypeWithConfidence { | | 532 | + type_: if let Some(t) = ty.into() { | | 533 | + t.handle | | 534 | + } else { | | 535 | + std::ptr::null_mut() | | 536 | + }, | | 537 | + confidence: 255, // BN_FULL_CONFIDENCE | 535 | 538 | }; | 536 | 539 |
| 537 | 540 | unsafe { | 538 | 541 | let raw_sym = BNDefineAutoSymbolAndVariableOrFunction( | 539 | 542 | self.as_ref().handle, | 540 | 543 | plat.handle, | 541 | 544 | sym.handle, | 542 | | - raw_type, | | 545 | + &mut type_with_conf, | 543 | 546 | ); | 544 | 547 |
| 545 | 548 | if raw_sym.is_null() { | |
|