Vector35/binaryninja-api

Need a BNGetCurrentPluginPath()

ehennenfent opened this issue · 2 comments

Currently, the API exposes user_plugin_path and bundled_plugin_path. On a typical OSX installation, these point to ~/Library/Application Support/Binary Ninja/plugins and /Applications/Binary Ninja.app/Contents/MacOS/plugins respectively. Plugins that were installed by the user will end up in the user_plugin_path directory, whereas plugins that were installed by the plugin manager will end up in the bundled_plugin_path directory. This causes a problem because plugins have no consistent way of knowing in which of these directories they were installed. If a plugin needs to access files relative to itself, the only currently reliable method is to calculate relative paths from the __file__ attribute Python provides.

It would be useful if the API exposed a plugin path that would always correspond to the path under which the current plugin had been installed, so that authors would not need to fall back on __file__

Thats a good suggestion, I'm going to change the issue name to be reflective of the API that should exist. BNGetCurrentPluginPath()

Because we have to support both C, Python, and other plugins, this is not something we can safely implement in the core. In short -- your proposed workaround is actually the only right solution.