diff options
| author | Glenn Smith <glenn@vector35.com> | 2026-03-11 15:30:52 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2026-03-11 15:30:52 -0400 |
| commit | 5515911371308970241726538535924045973500 (patch) | |
| tree | c6ace8b77f943c242bc9694264de57ab78089d65 /docs/guide | |
| parent | 6b57ef1d2c82d263655364588546e6211b0a99a8 (diff) | |
Add docs for `__attr`
Diffstat (limited to 'docs/guide')
| -rw-r--r-- | docs/guide/types/attributes.md | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/docs/guide/types/attributes.md b/docs/guide/types/attributes.md index b4453108..c2f01992 100644 --- a/docs/guide/types/attributes.md +++ b/docs/guide/types/attributes.md @@ -345,3 +345,27 @@ struct BaseClassDescriptor struct BaseClassDescriptor* __ptr32 __based(start) `type_info::\`RTTI Base Class Array'`[0x1]; ``` + +## Custom Attributes + +Binary Ninja allows you to add custom attributes to types, which do not affect analysis but can be used by plugins and scripts. You can add these with the `__attr` annotation. Scripts can then query a `Type` object's `annotations` field to see the annotation keys and values. + +### Examples + +``` C +typedef int __attr("a") test; +typedef int __attr("a", "b") test; +``` + +```py +>>> TypeParser.default.parse_type_string('int __attr("a", "b") test', Platform["windows-x86"])[0][1].attributes +{'a': 'b'} +``` + +Attributes on function pointers can be applied to many different places: +``` C +typedef void (*__attr("ptr", "attr") test)(); // Applies to the pointer +typedef void (__attr("function", "attr")* test)(); // Applies to the function +typedef __attr("return", "attr") void (* test)(); // Applies to the return type +typedef void __attr("return", "attr") (* test)(); // Applies to the return type +```
\ No newline at end of file |
