@@ -18575,7 +18575,6 @@ namespace BinaryNinja {
1857518575 */
1857618576 class FirmwareNinjaReferenceNode : public CoreRefCountObject<BNFirmwareNinjaReferenceNode, BNNewFirmwareNinjaReferenceNodeReference, BNFreeFirmwareNinjaReferenceNode>
1857718577 {
18578- BNFirmwareNinjaReferenceNode* m_object;
1857918578 public:
1858018579 FirmwareNinjaReferenceNode(BNFirmwareNinjaReferenceNode* node);
1858118580 ~FirmwareNinjaReferenceNode();
@@ -18619,6 +18618,197 @@ namespace BinaryNinja {
1861918618 std::vector<Ref<FirmwareNinjaReferenceNode>> GetChildren();
1862018619 };
1862118620
18621+ /*! FirmwareNinjaRelationship is a class used to represent inter-binary and cross-binary relationships. This class is
18622+ only available in the Ultimate Edition of Binary Ninja.
18623+
18624+ \ingroup firmwareninja
18625+ */
18626+ class FirmwareNinjaRelationship : public CoreRefCountObject<BNFirmwareNinjaRelationship, BNNewFirmwareNinjaRelationshipReference, BNFreeFirmwareNinjaRelationship>
18627+ {
18628+ public:
18629+ FirmwareNinjaRelationship(Ref<BinaryView> view, BNFirmwareNinjaRelationship* relationship = nullptr);
18630+ ~FirmwareNinjaRelationship();
18631+
18632+ /*! Set the primary relationship object to an address
18633+
18634+ \param address Address in current binary view
18635+ */
18636+ void SetPrimaryAddress(uint64_t address);
18637+
18638+ /*! Set the primary relationship object to a data variable
18639+
18640+ \param var DataVariable in current binary view
18641+ */
18642+ void SetPrimaryDataVariable(DataVariable& variable);
18643+
18644+ /*! Set the primary relationship object to a function
18645+
18646+ \param function Function in current binary view
18647+ */
18648+ void SetPrimaryFunction(Ref<Function> function);
18649+
18650+ /*! Determine if the primary object is an address
18651+
18652+ \return true if the primary object is an address, false otherwise
18653+ */
18654+ bool PrimaryIsAddress() const;
18655+
18656+ /*! Determine if the primary object is a data variable
18657+
18658+ \return true if the primary object is a data variable, false otherwise
18659+ */
18660+ bool PrimaryIsDataVariable() const;
18661+
18662+ /*! Determine if the primary object is a function
18663+
18664+ \return true if the primary object is a function, false otherwise
18665+ */
18666+ bool PrimaryIsFunction() const;
18667+
18668+ /*! Query the primary object as a data variable from the relationship
18669+
18670+ \param var Output data variable
18671+ \return true if the data variable was queried successfully, false otherwise
18672+ */
18673+ bool GetPrimaryDataVariable(DataVariable& var);
18674+
18675+ /*! Query the primary object as an address from the relationship
18676+
18677+ \return Optional address, if it can be queried
18678+ */
18679+ std::optional<uint64_t> GetPrimaryAddress() const;
18680+
18681+ /*! Query the primary object as a function from the relationship
18682+
18683+ \return Function object
18684+ */
18685+ Ref<Function> GetPrimaryFunction() const;
18686+
18687+ /*! Set the secondary relationship object to an address
18688+
18689+ \param address Address in current binary view
18690+ */
18691+ void SetSecondaryAddress(uint64_t address);
18692+
18693+ /*! Set the secondary relationship object to a data variable
18694+
18695+ \param var DataVariable in current binary view
18696+ */
18697+ void SetSecondaryDataVariable(DataVariable& variable);
18698+
18699+ /*! Set the secondary relationship object to a function
18700+
18701+ \param function Function in current binary view
18702+ */
18703+ void SetSecondaryFunction(Ref<Function> function);
18704+
18705+ /*! Set the secondary relationship object to an external address
18706+
18707+ \param projectFile External project file
18708+ \param address Address in external library
18709+ */
18710+ void SetSecondaryExternalAddress(Ref<ProjectFile> projectFile, uint64_t address);
18711+
18712+ /*! Set the secondary relationship object to an external symbol
18713+
18714+ \param projectFile External project file
18715+ \param sybmol Symbol in external library
18716+ */
18717+ void SetSecondaryExternalSymbol(Ref<ProjectFile> projectFile, const std::string& symbol);
18718+
18719+ /*! Determine if the secondary object is an address in the current binary view
18720+
18721+ \return true if the secondary object is an address in the current binary view, false otherwise
18722+ */
18723+ bool SecondaryIsAddress() const;
18724+
18725+ /*! Determine if the secondary object is a data variable in the current binary view
18726+
18727+ \return true if the secondary object is a data variable in the current binary view, false otherwise
18728+ */
18729+ bool SecondaryIsDataVariable() const;
18730+
18731+ /*! Determine if the secondary object is a function in the current binary view
18732+
18733+ \return true if the secondary object is a function in the current binary view, false otherwise
18734+ */
18735+ bool SecondaryIsFunction() const;
18736+
18737+ /*! Determine if the secondary object is an address contained in another binary in the project
18738+
18739+ \return true if the secondary object is an external address, false otherwise
18740+ */
18741+ bool SecondaryIsExternalAddress() const;
18742+
18743+ /*! Determine if the secondary object is a symbol contained in another binary in the project
18744+
18745+ \return true if the secondary object is an external symbol, false otherwise
18746+ */
18747+ bool SecondaryIsExternalSymbol() const;
18748+
18749+ /*! Query the secondary object's external project file
18750+
18751+ \return The secondary object's external project file or nullptr if it is not an external address
18752+ */
18753+ Ref<ProjectFile> GetSecondaryExternalProjectFile() const;
18754+
18755+ /*! Query the secondary object as an address from the relationship
18756+
18757+ \return Optional address, if the secondary object is an address
18758+ */
18759+ std::optional<uint64_t> GetSecondaryAddress() const;
18760+
18761+ /*! Query the secondary object as a data variable from the relationship
18762+
18763+ \param var Output data variable
18764+ \return true if the data variable was queried successfully, false otherwise
18765+ */
18766+ bool GetSecondaryDataVariable(DataVariable& variable);
18767+
18768+ /*! Query the secondary object as a function from the relationship
18769+
18770+ \return Function object
18771+ */
18772+ Ref<Function> GetSecondaryFunction() const;
18773+
18774+
18775+ /*! Query the secondary object as an external symbol from the relationship
18776+
18777+ \return External symbol string, or empty string if the secondary object is not an external symbol
18778+ */
18779+ std::string GetSecondaryExternalSymbol() const;
18780+
18781+
18782+ /*! Set the description of the relationship
18783+
18784+ \param description Description string
18785+ */
18786+ void SetDescription(const std::string& description);
18787+
18788+ /*! Query the description of the relationship
18789+
18790+ \return Description string, or empty string if not set
18791+ */
18792+ std::string GetDescription() const;
18793+
18794+ /*! Set the provenance of the relationship
18795+
18796+ \param provenance Provenance string
18797+ */
18798+ void SetProvenance(const std::string& provenance);
18799+
18800+ /*! Query the relationship provenance
18801+
18802+ \return Provenance string, or empty string if not set
18803+ */
18804+ std::string GetProvenance() const;
18805+
18806+ /*! Query the relationship GUID
18807+
18808+ \return Relationship GUID string
18809+ */
18810+ std::string GetGuid() const;
18811+ };
1862218812
1862318813 /*! FirmwareNinja is a class containing features specific to embedded firmware analysis. This class is only
1862418814 available in the Ultimate Edition of Binary Ninja.
@@ -18749,6 +18939,31 @@ namespace BinaryNinja {
1874918939 const std::vector<FirmwareNinjaFunctionMemoryAccesses>& fma,
1875018940 uint64_t* value = nullptr
1875118941 );
18942+
18943+ /*! Query Firmware Ninja relationships from the binary view metadata
18944+
18945+ \return Vector of Firmware Ninja relationships
18946+ */
18947+ std::vector<Ref<FirmwareNinjaRelationship>> QueryRelationships();
18948+
18949+ /*! Store a Firmware Ninja relationship in the binary view metadata
18950+
18951+ \param relationship Firmware Ninja relationship
18952+ */
18953+ void AddRelationship(Ref<FirmwareNinjaRelationship> relationship);
18954+
18955+ /* Query a Firmware Ninja relationship by GUID
18956+
18957+ \param guid GUID of the relationship to query
18958+ \return Firmware Ninja relationship
18959+ */
18960+ Ref<FirmwareNinjaRelationship> GetRelationshipByGuid(const std::string& guid);
18961+
18962+ /*! Remove a Firmware Ninja relationship from the binary view metadata
18963+
18964+ \param guid GUID of the relationship to remove
18965+ */
18966+ void RemoveRelationshipByGuid(const std::string& guid);
1875218967 };
1875318968
1875418969
0 commit comments