summaryrefslogtreecommitdiff
path: root/binaryninjaapi.h
diff options
context:
space:
mode:
authorRusty Wagner <rusty.wagner@gmail.com>2025-07-14 22:14:21 -0400
committerRusty Wagner <rusty.wagner@gmail.com>2025-07-15 13:55:34 -0400
commitc41b80eae54efed5cef8f9ebb32f9a7177e9fe72 (patch)
treee7ff79b5e4d38c8f52b791a8b1c3a6093813525a /binaryninjaapi.h
parent6894a946b1fa5ad24e64d24bb7f606bae14c300a (diff)
Add the ability to limit the number of results in the cross reference APIs
Diffstat (limited to 'binaryninjaapi.h')
-rw-r--r--binaryninjaapi.h98
1 files changed, 76 insertions, 22 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 8d3fed9c..595c827e 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -5520,9 +5520,27 @@ namespace BinaryNinja {
*/
std::vector<ReferenceSource> GetCodeReferences(uint64_t addr, uint64_t len);
+ /*! Get a list of references made from code (instructions) to a virtual address
+
+ \param addr Address to check
+ \param maxItems Optional maximum number of items to fetch
+ \return vector of ReferenceSources referencing the virtual address
+ */
+ std::vector<ReferenceSource> GetCodeReferencesWithLimit(uint64_t addr, std::optional<size_t> maxItems = std::nullopt);
+
+ /*! Get a list of references from code (instructions) to a range of addresses
+
+ \param addr Address to check
+ \param len Length of query
+ \param maxItems Optional maximum number of items to fetch
+ \return vector of ReferenceSources referencing the virtual address range
+ */
+ std::vector<ReferenceSource> GetCodeReferencesInRangeWithLimit(
+ uint64_t addr, uint64_t len, std::optional<size_t> maxItems = std::nullopt);
+
/*! Get code references made by a particular "ReferenceSource"
- A ReferenceSource contains a given function, architecture of that function, and an address within it.
+ A ReferenceSource contains a given function, architecture of that function, and an address within it.
\param src reference source
\return List of virtual addresses referenced by this source
@@ -5556,6 +5574,24 @@ namespace BinaryNinja {
*/
std::vector<uint64_t> GetDataReferences(uint64_t addr, uint64_t len);
+ /*! Get references made by data ('DataVariables') to a virtual address
+
+ \param addr Address to check
+ \param maxItems Optional maximum number of items to fetch
+ \return vector of virtual addresses referencing the virtual address
+ */
+ std::vector<uint64_t> GetDataReferencesWithLimit(uint64_t addr, std::optional<size_t> maxItems = std::nullopt);
+
+ /*! Get references made by data ('DataVariables') in a given range, to a virtual address
+
+ \param addr Address to check
+ \param len Length of query
+ \param maxItems Optional maximum number of items to fetch
+ \return vector of virtual addresses referencing the virtual address range
+ */
+ std::vector<uint64_t> GetDataReferencesInRangeWithLimit(
+ uint64_t addr, uint64_t len, std::optional<size_t> maxItems = std::nullopt);
+
/*! Get references made by data ('DataVariables') located at a virtual address.
\param src reference source
@@ -5605,43 +5641,53 @@ namespace BinaryNinja {
/*! Get code references to a Type
\param type QualifiedName for a Type
+ \param maxItems Optional maximum number of items to fetch
\return vector of ReferenceSources
*/
- std::vector<ReferenceSource> GetCodeReferencesForType(const QualifiedName& type);
+ std::vector<ReferenceSource> GetCodeReferencesForType(
+ const QualifiedName& type, std::optional<size_t> maxItems = std::nullopt);
/*! Get data references to a Type
\param type QualifiedName for a Type
+ \param maxItems Optional maximum number of items to fetch
\return vector of virtual addresses referencing this Type
*/
- std::vector<uint64_t> GetDataReferencesForType(const QualifiedName& type);
+ std::vector<uint64_t> GetDataReferencesForType(
+ const QualifiedName& type, std::optional<size_t> maxItems = std::nullopt);
/*! Get Type references to a Type
\param type QualifiedName for a Type
+ \param maxItems Optional maximum number of items to fetch
\return vector of TypeReferenceSources to this Type
*/
- std::vector<TypeReferenceSource> GetTypeReferencesForType(const QualifiedName& type);
+ std::vector<TypeReferenceSource> GetTypeReferencesForType(
+ const QualifiedName& type, std::optional<size_t> maxItems = std::nullopt);
/*! Returns a list of references to a specific type field
- \param type QualifiedName of the type
- \param offset Offset of the field, relative to the start of the type
- \return vector of TypeFieldReferences
+ \param type QualifiedName of the type
+ \param offset Offset of the field, relative to the start of the type
+ \param maxItems Optional maximum number of items to fetch
+ \return vector of TypeFieldReferences
*/
- std::vector<TypeFieldReference> GetCodeReferencesForTypeField(const QualifiedName& type, uint64_t offset);
+ std::vector<TypeFieldReference> GetCodeReferencesForTypeField(
+ const QualifiedName& type, uint64_t offset, std::optional<size_t> maxItems = std::nullopt);
/*! Returns a list of virtual addresses of data which references the type \c type .
- Note, the returned addresses are the actual start of the queried type field. For example, suppose there is a
- DataVariable at \c 0x1000 that has type \c A , and type \c A contains type \c B at offset \c 0x10 .
- Then <tt>GetDataReferencesForTypeField(bQualifiedName, 0x8)</tt> will return \c 0x1018 for it.
+ Note, the returned addresses are the actual start of the queried type field. For example, suppose there is a
+ DataVariable at \c 0x1000 that has type \c A , and type \c A contains type \c B at offset \c 0x10 .
+ Then <tt>GetDataReferencesForTypeField(bQualifiedName, 0x8)</tt> will return \c 0x1018 for it.
- \param type QualifiedName of the type
- \param offset Offset of the field, relative to the start of the type
- \return List of DataVariable start addresses containing references to the type field
+ \param type QualifiedName of the type
+ \param offset Offset of the field, relative to the start of the type
+ \param maxItems Optional maximum number of items to fetch
+ \return List of DataVariable start addresses containing references to the type field
*/
- std::vector<uint64_t> GetDataReferencesForTypeField(const QualifiedName& type, uint64_t offset);
+ std::vector<uint64_t> GetDataReferencesForTypeField(
+ const QualifiedName& type, uint64_t offset, std::optional<size_t> maxItems = std::nullopt);
/*! Returns a list of virtual addresses of data which are referenced from the type \c type .
@@ -5649,32 +5695,40 @@ namespace BinaryNinja {
\param type QualifiedName of the type
\param offset Offset of the field, relative to the start of the type
+ \param maxItems Optional maximum number of items to fetch
\return List of addresses referenced from the type field
*/
- std::vector<uint64_t> GetDataReferencesFromForTypeField(const QualifiedName& type, uint64_t offset);
+ std::vector<uint64_t> GetDataReferencesFromForTypeField(
+ const QualifiedName& type, uint64_t offset, std::optional<size_t> maxItems = std::nullopt);
/*! Returns a list of type references to a specific type field
- \param type QualifiedName of the type
- \param offset Offset of the field, relative to the start of the type
- \return vector of TypeReferenceSources
+ \param type QualifiedName of the type
+ \param offset Offset of the field, relative to the start of the type
+ \param maxItems Optional maximum number of items to fetch
+ \return vector of TypeReferenceSources
*/
- std::vector<TypeReferenceSource> GetTypeReferencesForTypeField(const QualifiedName& type, uint64_t offset);
+ std::vector<TypeReferenceSource> GetTypeReferencesForTypeField(
+ const QualifiedName& type, uint64_t offset, std::optional<size_t> maxItems = std::nullopt);
/*! Returns a all references to a specific type. This includes code, data, and type references.
\param type QualifiedName of the type
+ \param maxItems Optional maximum number of items to fetch
\return AllTypeReferences structure with all references
*/
- AllTypeReferences GetAllReferencesForType(const QualifiedName& type);
+ AllTypeReferences GetAllReferencesForType(
+ const QualifiedName& type, std::optional<size_t> maxItems = std::nullopt);
/*! Returns a all references to a specific type field. This includes code, data, and type references.
\param type QualifiedName of the type
\param offset Offset of the field, relative to the start of the type
+ \param maxItems Optional maximum number of items to fetch
\return AllTypeFieldReferences structure with all references
*/
- AllTypeFieldReferences GetAllReferencesForTypeField(const QualifiedName& type, uint64_t offset);
+ AllTypeFieldReferences GetAllReferencesForTypeField(
+ const QualifiedName& type, uint64_t offset, std::optional<size_t> maxItems = std::nullopt);
/*! Returns a list of types referenced by code at ReferenceSource \c src