diff options
| author | Jordan Wiens <jordan@psifertex.com> | 2021-07-15 03:39:25 -0400 |
|---|---|---|
| committer | Jordan Wiens <jordan@psifertex.com> | 2021-07-29 10:42:06 -0400 |
| commit | 1a4a0f56dc17e68e5743fa3a550b46992ec461e1 (patch) | |
| tree | 33fbee198f54af7fa173a016b3ef71b3c7e49e28 | |
| parent | c08ddcab02433cb5078b6cfea11bf972e47b3169 (diff) | |
support for repository plugins loaded from a subdirectory
| -rw-r--r-- | binaryninjaapi.h | 1 | ||||
| -rw-r--r-- | binaryninjacore.h | 1 | ||||
| -rw-r--r-- | pluginmanager.cpp | 5 | ||||
| -rw-r--r-- | python/pluginmanager.py | 5 | ||||
| -rw-r--r-- | python/scriptingprovider.py | 5 |
5 files changed, 16 insertions, 1 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index f415f82c..1d731218 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -5391,6 +5391,7 @@ __attribute__ ((format (printf, 1, 2))) std::vector<std::string> GetApis() const; std::vector<std::string> GetInstallPlatforms() const; std::string GetPath() const; + std::string GetSubdir() const; std::string GetDependencies() const; std::string GetPluginDirectory() const; std::string GetAuthor() const; diff --git a/binaryninjacore.h b/binaryninjacore.h index 1037114d..d4e85e47 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -5092,6 +5092,7 @@ __attribute__ ((format (printf, 1, 2))) BINARYNINJACOREAPI BNRepoPlugin* BNNewPluginReference(BNRepoPlugin* r); BINARYNINJACOREAPI void BNFreePlugin(BNRepoPlugin* plugin); BINARYNINJACOREAPI const char* BNPluginGetPath(BNRepoPlugin* p); + BINARYNINJACOREAPI const char* BNPluginGetSubdir(BNRepoPlugin* p); BINARYNINJACOREAPI const char* BNPluginGetDependencies(BNRepoPlugin* p); BINARYNINJACOREAPI bool BNPluginIsInstalled(BNRepoPlugin* p); BINARYNINJACOREAPI bool BNPluginIsEnabled(BNRepoPlugin* p); diff --git a/pluginmanager.cpp b/pluginmanager.cpp index 1500c78e..d3108907 100644 --- a/pluginmanager.cpp +++ b/pluginmanager.cpp @@ -20,6 +20,11 @@ string RepoPlugin::GetPath() const RETURN_STRING(BNPluginGetPath(m_object)); } +string RepoPlugin::GetSubdir() const +{ + RETURN_STRING(BNPluginGetSubdir(m_object)); +} + string RepoPlugin::GetDependencies() const { RETURN_STRING(BNPluginGetDependencies(m_object)); diff --git a/python/pluginmanager.py b/python/pluginmanager.py index 15b98b55..31e63620 100644 --- a/python/pluginmanager.py +++ b/python/pluginmanager.py @@ -50,6 +50,11 @@ class RepoPlugin(object): return core.BNPluginGetPath(self.handle) @property + def subdir(self): + """Optional sub-directory the plugin code lives in as a relative path from the plugin root""" + return core.BNPluginGetSubdir(self.handle) + + @property def dependencies(self): """Dependencies required for installing this plugin""" return core.BNPluginGetDependencies(self.handle) diff --git a/python/scriptingprovider.py b/python/scriptingprovider.py index 51972ae9..473cd36f 100644 --- a/python/scriptingprovider.py +++ b/python/scriptingprovider.py @@ -831,7 +831,10 @@ class PythonScriptingProvider(ScriptingProvider): if plugin_full_path not in sys.path: sys.path.append(plugin_full_path) - __import__(module) + if plugin.subdir: + __import__(module + "." + plugin.subdir.replace("/", ".")) + else: + __import__(module) return True except KeyError: log.log_error(f"Failed to find python plugin: {repo_path}/{module}") |
