From 62cb5abc9cc7aedbfbb4e89b7ae55c36026cc527 Mon Sep 17 00:00:00 2001 From: Brandon Miller Date: Fri, 17 Jan 2025 14:38:36 -0500 Subject: Firmware Ninja reference tree API --- binaryninjaapi.h | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) (limited to 'binaryninjaapi.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 8b41ea76..2a2e5e9b 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -18397,6 +18397,59 @@ namespace BinaryNinja { size_t unique; }; + + /*! FirmwareNinjaReferenceNode is a class used to build reference trees to memory regions, functions, and data + variables. This class is only available in the Ultimate Edition of Binary Ninja. + + \ingroup firmwareninja + */ + class FirmwareNinjaReferenceNode : public CoreRefCountObject + { + BNFirmwareNinjaReferenceNode* m_object; + public: + FirmwareNinjaReferenceNode(BNFirmwareNinjaReferenceNode* node); + ~FirmwareNinjaReferenceNode(); + + /*! Determine if the reference tree node is for a function + + \return true if the reference tree node is for a function, false otherwise + */ + bool IsFunction(); + + /*! Determine if the reference tree node is for a data variable + + \return true if the reference tree node is for a data variable, false otherwise + */ + bool IsDataVariable(); + + /*! Determine if the reference tree node contains child nodes + + \return true if the reference tree node contains child nodes, false otherwise + */ + bool HasChildren(); + + /*! Query the function contained in the reference tree node + + \param function Output function object + \return true if the function was queried successfully, false otherwise + */ + bool GetFunction(Ref& function); + + /*! Query the data variable contained in the reference tree node + + \param function Output data variable object + \return true if the data variable was queried successfully, false otherwise + */ + bool GetDataVariable(DataVariable& variable); + + /*! Query the child nodes contained in the reference tree node + + \return Vector of child reference tree nodes + */ + std::vector> GetChildren(); + }; + + /*! FirmwareNinja is a class containing features specific to embedded firmware analysis. This class is only available in the Ultimate Edition of Binary Ninja. @@ -18485,6 +18538,47 @@ namespace BinaryNinja { */ std::vector GetBoardDeviceAccesses( const std::vector& fma); + + + /*! Returns a tree of reference nodes that reference the memory region represented by the given device + + \param device Firmware Ninja device + \param fma Vector of Firmware Ninja function memory accesses information + \param value (Optional) only include components that originate with a write of this value to the device + \return Root reference node of tree + */ + Ref GetReferenceTree( + FirmwareNinjaDevice& device, + const std::vector& fma, + uint64_t* value = nullptr + ); + + /*! Returns a tree of reference nodes that reference the memory region represented by the given section + + \param device Firmware Ninja device + \param fma Vector of Firmware Ninja function memory accesses information + \param value (Optional) only include components that originate with a write of this value to the device + \return Root reference node of tree + */ + Ref GetReferenceTree( + Section& section, + const std::vector& fma, + uint64_t* value = nullptr + ); + + + /*! Returns a tree of reference nodes that reference the given address + + \param device Firmware Ninja device + \param fma Vector of Firmware Ninja function memory accesses information + \param value (Optional) only include components that originate with a write of this value to the device + \return Root reference node of tree + */ + Ref GetReferenceTree( + uint64_t address, + const std::vector& fma, + uint64_t* value = nullptr + ); }; -- cgit v1.3.1