From fcfa33a14fc309984880b535b9f9b4fcfc316466 Mon Sep 17 00:00:00 2001 From: kat Date: Tue, 3 Jan 2023 14:29:32 -0500 Subject: Allow DataVariables to be added to Components --- binaryninjaapi.h | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'binaryninjaapi.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 34a45160..a364e5d9 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -2017,7 +2017,8 @@ namespace BinaryNinja { void* ctxt, BNBinaryView* data, BNComponent* formerParent, BNComponent* newParent, BNComponent* component); static void ComponentFunctionAddedCallback(void* ctxt, BNBinaryView* data, BNComponent* component, BNFunction* function); static void ComponentFunctionRemovedCallback(void* ctxt, BNBinaryView* data, BNComponent* component, BNFunction* function); - + static void ComponentDataVariableAddedCallback(void* ctxt, BNBinaryView* data, BNComponent* component, BNDataVariable* var); + static void ComponentDataVariableRemovedCallback(void* ctxt, BNBinaryView* data, BNComponent* component, BNDataVariable* var); public: BinaryDataNotification(); @@ -2271,6 +2272,32 @@ namespace BinaryNinja { (void)component; (void)function; } + + /*! This notification is posted whenever a DataVariable is added to a Component + + \param data BinaryView containing the Component and DataVariable + \param component Component the DataVariable was added to + \param var The DataVariable which was added + */ + virtual void OnComponentDataVariableAdded(BinaryView* data, Component* component, const DataVariable& var) + { + (void)data; + (void)component; + (void)var; + } + + /*! This notification is posted whenever a DataVariable is removed from a Component + + \param data BinaryView containing the Component and DataVariable + \param component Component the DataVariable was removed from + \param var The DataVariable which was removed + */ + virtual void OnComponentDataVariableRemoved(BinaryView* data, Component* component, const DataVariable& var) + { + (void)data; + (void)component; + (void)var; + } }; /*! @@ -4279,6 +4306,9 @@ namespace BinaryNinja { */ bool RemoveComponent(std::string guid); + std::vector> GetFunctionParentComponents(Ref function) const; + std::vector> GetDataVariableParentComponents(DataVariable var) const; + /*! Check whether the given architecture supports assembling instructions \param arch Architecture to check @@ -8483,7 +8513,6 @@ namespace BinaryNinja { \return Whether this function needs update */ bool NeedsUpdate() const; - std::vector> GetParentComponents() const; /*! Get a list of Basic Blocks for this function @@ -14723,6 +14752,8 @@ namespace BinaryNinja { */ bool AddComponent(Ref component); + bool AddDataVariable(DataVariable dataVariable); + /*! Remove a Component from this Component, moving it to the root component. This will not remove a component from the tree entirely. @@ -14741,6 +14772,8 @@ namespace BinaryNinja { */ bool RemoveFunction(Ref func); + bool RemoveDataVariable(DataVariable dataVariable); + /*! Get a list of types referenced by the functions in this Component. \return vector of Type objects @@ -14759,6 +14792,12 @@ namespace BinaryNinja { */ std::vector> GetContainedFunctions(); + /*! Get a list of datavariables added to this component + + \return list of DataVariables + */ + std::vector GetContainedDataVariables(); + /*! Get a list of DataVariables referenced by the functions in this Component. \return vector of DataVariable objects -- cgit v1.3.1