diff options
| author | Rusty Wagner <rusty@vector35.com> | 2021-01-25 16:45:06 -0500 |
|---|---|---|
| committer | Rusty Wagner <rusty@vector35.com> | 2021-01-27 18:39:42 -0500 |
| commit | 12f916450b444427685688bf34de65e11bf849e2 (patch) | |
| tree | bd13651d872c1fc7ad5933e9a38a77da82235cd3 /ui | |
| parent | 51d0f18eb4df16263867ef157b5293bb1b44f77a (diff) | |
Add ABI version verification for plugins
Diffstat (limited to 'ui')
| -rw-r--r-- | ui/uicontext.h | 1 | ||||
| -rw-r--r-- | ui/uitypes.h | 28 |
2 files changed, 29 insertions, 0 deletions
diff --git a/ui/uicontext.h b/ui/uicontext.h index 5fbd2ca2..df016462 100644 --- a/ui/uicontext.h +++ b/ui/uicontext.h @@ -12,6 +12,7 @@ typedef bool (*UIPluginInitFunction)(void); typedef void (*UIPluginDependencyFunction)(void); +typedef uint32_t (*UIPluginABIVersionFunction)(void); class ViewFrame; class UIActionHandler; diff --git a/ui/uitypes.h b/ui/uitypes.h index dd91d0ae..2daf6f4f 100644 --- a/ui/uitypes.h +++ b/ui/uitypes.h @@ -2,6 +2,19 @@ #include "binaryninjaapi.h" +// Current ABI version for linking to the UI API. This is incremented any time +// there are changes to the API that affect linking, including new functions, +// new types, modifications to existing functions or types, or new versions +// of the Qt libraries. +#define BN_CURRENT_UI_ABI_VERSION 1 + +// Minimum ABI version that is supported for loading of plugins. Plugins that +// are linked to an ABI version less than this will not be able to load and +// will require rebuilding. The minimum version is increased when there are +// incompatible changes that break binary compatibility, such as changes to +// existing types or functions, or a new version of Qt. +#define BN_MINIMUM_UI_ABI_VERSION 1 + #ifdef __GNUC__ # ifdef BINARYNINJAUI_LIBRARY # define BINARYNINJAUIAPI __attribute__((visibility("default"))) @@ -28,6 +41,21 @@ #include "bindings.h" #endif +// The BN_DECLARE_UI_ABI_VERSION must be included in native UI plugin modules. If +// the ABI version is not declared, the UI will not load the plugin. +#ifdef DEMO_VERSION +#define BN_DECLARE_UI_ABI_VERSION +#else +#define BN_DECLARE_UI_ABI_VERSION \ + extern "C" \ + { \ + BINARYNINJAPLUGIN uint32_t UIPluginABIVersion() \ + { \ + return BN_CURRENT_UI_ABI_VERSION; \ + } \ + } +#endif + // The Python bindings generator does not recognize automatic conversion of API types into their // Python equivalents if using templates (Ref<*>), so we typedef all API references so that // the Python bindings can be easily generated for them. |
