## Writing BinNavi Plugins

### Overview

One of BinNavi's main features is its extensibility through plugins written in the Java programming language and other languages. The general idea behind BinNavi plugins is that each BinNavi plugin implements one or more of the plugin interfaces provided by the BinNavi plugin API. Depending on what interfaces a plugin implements, BinNavi gives the plugin access to itself through a well-defined plugin interface.

### Writing plugins in Java

Java is the preferred programming language for writing plugins in BinNavi. While plugins written in other languages are not limited in any way by BinNavi, there might be speed concerns when implementing plugins in a language like Ruby for example.

To write your own plugins you need to know the following things:

- Plugin files are placed in the plugins directory of BinNavi or a subdirectory of it
- Plugin files can be either CLASS files (simple plugins) or JAR files (more complex plugins or plugin collections)
- CLASS file plugins only need to implement one or more of the Plugin interfaces. The CLASS file is instantiated when BinNavi starts and if a valid plugin is found, the plugin is loaded and given access to BinNavi.
- JAR plugin files must define a main class in their manifest file and this main class must implement the IPluginServer interface. The method getPlugins of this PluginServer object returns a list of all plugins that can be found in the JAR file. These plugins are loaded and given access to BinNavi.

To find out what can be done through plugins please consult the Plugin API section of this manual.

### Writing plugins in scripting languages

In principle, all languages that can be used to write BinNavi scripts can also be used to write BinNavi plugins. By default this includes Python, Ruby, and ECMAScript.

To write plugins in any of the supported scripting languages, you need to know the following things:

- Script files must have the same extension as regular scripts in your language (e.g. .py for Jython scripts, .js for JavaScript scripts, and so on).
- Scripts that implement BinNavi Plugin interfaces must be stored in scripts subdirectory of BinNavi. These scripts are automatically loaded when BinNavi starts.
- Each script has access to an object called navi of type PluginInterface. This object gives scripts access to BinNavi. Please consult the section about the Plugin API to find out what you can do with the navi object.

Since accessing Java classes and objects from languages other than Java has some quirks, BinNavi comes with two small sample scripts written in Python and Ruby that can be used as the starting point for new plugins written in these languages. You can find these sample scripts in the scripts subdirectory of your BinNavi installation.