diff options
| author | Alexander Taylor <alex@vector35.com> | 2024-07-11 11:00:58 -0400 |
|---|---|---|
| committer | Alexander Taylor <alex@vector35.com> | 2024-07-11 11:00:58 -0400 |
| commit | f7f05179bd9063fad6d3d2e243a7a6d44d6e7f94 (patch) | |
| tree | 6dcd774375bb1f399b3a31fada36f24a1b05a8ab /docs/dev | |
| parent | 290e44dc0dad5ad655e71dc18d9f031c6301c563 (diff) | |
Additional header import documentation.
Diffstat (limited to 'docs/dev')
| -rw-r--r-- | docs/dev/annotation.md | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/docs/dev/annotation.md b/docs/dev/annotation.md index c75ca775..c61cd0aa 100644 --- a/docs/dev/annotation.md +++ b/docs/dev/annotation.md @@ -439,6 +439,8 @@ Note that most of the APIs that take a Type object also take a C-style type stri ### Headers +#### Importing a Header + Importing a header goes through the same code path as parsing source directly. You will just have to read the file and specify the appropriate command-line arguments as an array. See [user type guide](../guide/types/typeimportexport.md#import-header-file) for directions for choosing arguments. ```python @@ -447,6 +449,16 @@ Importing a header goes through the same code path as parsing source directly. Y (<types: [...], variables: [...], functions: [...]>, []) ``` +Using these APIs will give you a Python object with all of the results, but won't actually apply them to the analysis in any way. If you want to replicate the importing behavior seen in the UI widget, there are a few additional steps you will need to take: + +1. Use `BinaryView.define_user_types()` to add all the created types to the analysis +1. Update the function and data variable types + 1. Look up matching functions and symbols by using `BinaryView.get_symbol_by_raw_name`. Also look up potentially modified function names starting with `_` or `__` + 1. Once you have found a function whose name matches one found in the header file, set its type using `Function.type = ftype` + 1. Similarly for Data Variables, once one is found with a matching name, set its type using `DataVariable.type = dvtype` + +#### Exporting a Header + Exporting a header uses the `TypePrinter.print_all_types` api, and outputs a string. ```python |
