use of com.google.security.zynamics.binnavi.api2.plugins.IPlugin in project binnavi by google.
the class CGraphWindowMenuBar method dipose.
/**
* Frees allocated resources.
*/
public void dipose() {
m_synchronizer.dispose();
m_selectionMenu.dispose();
final List<IGraphMenuPlugin> plugins = Lists.newArrayList();
for (final IPlugin<IPluginInterface> plugin : PluginInterface.instance().getPluginRegistry()) {
if (plugin instanceof IGraphMenuPlugin) {
plugins.add((IGraphMenuPlugin) plugin);
}
}
for (final IGraphMenuPlugin plugin : plugins) {
try {
plugin.closed(m_model.getGraphFrame());
} catch (final Exception exception) {
CUtilityFunctions.logException(exception);
final String innerMessage = "E00106: " + "Plugin caused an unexpected exception";
final String innerDescription = CUtilityFunctions.createDescription(String.format("The plugin %s caused an unexpected exception.", plugin.getName()), new String[] { "The plugin contains a bug." }, new String[] { "The plugin probably behaves erroneously from this point on but it remains active" });
NaviErrorDialog.show(m_model.getParent(), innerMessage, innerDescription, exception);
}
}
m_pluginsMenu.dispose();
}
use of com.google.security.zynamics.binnavi.api2.plugins.IPlugin in project binnavi by google.
the class CPluginsMenu method fillPluginsMenu.
/**
* Creates the menu items of the Plugins menu.
*/
private void fillPluginsMenu() {
final List<IGraphMenuPlugin> plugins = new ArrayList<IGraphMenuPlugin>();
for (@SuppressWarnings("rawtypes") final IPlugin plugin : PluginInterface.instance().getPluginRegistry()) {
if (plugin instanceof IGraphMenuPlugin) {
plugins.add((IGraphMenuPlugin) plugin);
}
}
add(CActionProxy.proxy(new CActionGraphScripting(m_model.getGraphPanel())));
add(CActionProxy.proxy(new CActionOpenLogConsole()));
addSeparator();
for (final IGraphMenuPlugin plugin : plugins) {
extendPluginMenu(plugin);
}
}
use of com.google.security.zynamics.binnavi.api2.plugins.IPlugin in project binnavi by google.
the class CModuleNodeMenuBuilder method addPluginMenus.
/**
* Adds the plugin-generated menus to the context menu.
*
* @param menu The context menu where the menu items are added.
*/
private void addPluginMenus(final JComponent menu) {
final List<IModuleMenuPlugin> plugins = new ArrayList<>();
for (final IPlugin<IPluginInterface> plugin : PluginInterface.instance().getPluginRegistry()) {
if (plugin instanceof IModuleMenuPlugin) {
plugins.add((IModuleMenuPlugin) plugin);
}
}
boolean addedSeparator = false;
for (final IModuleMenuPlugin plugin : plugins) {
try {
final List<JComponent> menuItems = plugin.extendModuleMenu(getPluginModules());
if (menuItems != null) {
for (final JComponent menuItem : menuItems) {
if (!addedSeparator) {
menu.add(new JSeparator());
addedSeparator = true;
}
menu.add(menuItem);
}
}
} catch (final Exception exception) {
CUtilityFunctions.logException(exception);
final String innerMessage = "E00093: " + "Plugin caused an unexpected exception";
final String innerDescription = CUtilityFunctions.createDescription(String.format("The plugin %s caused an unexpected exception.", plugin.getName()), new String[] { "The plugin contains a bug." }, new String[] { "The plugin probably behaves erroneously from this point on but it remains active" });
NaviErrorDialog.show(getParent(), innerMessage, innerDescription, exception);
}
}
}
use of com.google.security.zynamics.binnavi.api2.plugins.IPlugin in project binnavi by google.
the class CAbstractMenuBuilder method createPluginsMenu.
/**
* Creates the plugin menu.
*
* @return The created menu.
*/
private JMenu createPluginsMenu() {
final List<IMainWindowMenuPlugin> plugins = new ArrayList<IMainWindowMenuPlugin>();
for (@SuppressWarnings("rawtypes") final IPlugin plugin : PluginInterface.instance().getPluginRegistry()) {
if (plugin instanceof IMainWindowMenuPlugin) {
plugins.add((IMainWindowMenuPlugin) plugin);
}
}
final JMenu menu = new JMenu("Plugins");
menu.setMnemonic('U');
menu.add(CActionProxy.proxy(new CActionOpenScriptingDialog(getParent())));
menu.add(CActionProxy.proxy(new CActionOpenLogConsole()));
menu.addSeparator();
menu.add(CActionProxy.proxy(new CPluginManagementAction(getParent())));
menu.add(CActionProxy.proxy(new CPluginsReloadAction()));
menu.addSeparator();
for (final IMainWindowMenuPlugin plugin : plugins) {
// ESCA-JAVA0166: Catch Exception because we are calling a plugin function.
try {
final List<JMenuItem> menus = plugin.extendPluginMenu();
for (final JMenuItem m : menus) {
menu.add(m);
}
} catch (final Exception exception) {
CUtilityFunctions.logException(exception);
final String innerMessage = "E00092: " + "Plugin caused an unexpected exception";
final String innerDescription = CUtilityFunctions.createDescription(String.format("The plugin %s caused an unexpected exception.", plugin.getName()), new String[] { "The plugin contains a bug." }, new String[] { "The plugin probably behaves erroneously from this point on but it remains active" });
NaviErrorDialog.show(getParent(), innerMessage, innerDescription, exception);
}
}
return menu;
}
use of com.google.security.zynamics.binnavi.api2.plugins.IPlugin in project binnavi by google.
the class PluginLoaderThread method runExpensiveCommand.
@Override
protected void runExpensiveCommand() throws Exception {
setDescription("Loading JAR files");
final Set<File> jarFiles = JarLoader.collectJars(rootPath);
JarLoader.loadJars(jarFiles, this);
final Set<File> scriptFiles = ScriptLoader.collectScripts(rootPath);
ScriptLoader.init(scriptFiles, pluginInterface, this);
final List<IPlugin<T>> scriptPlugins = registry.getPlugins();
for (final String pluginPath : pluginPaths) {
final Set<File> pluginFiles = PluginLoader.collectPluginFiles(pluginPath);
final LoadResult<T> plugins = PluginLoader.loadPlugins(pluginPath, pluginFiles, this);
for (final Pair<String, Throwable> failedPlugin : plugins.getFailedPlugins()) {
CUtilityFunctions.logException(failedPlugin.second());
final String message = "E00007: " + "Loading a plugin failed";
final String description = CUtilityFunctions.createDescription(String.format("BinNavi could not load the plugin file file '%s' because the plugin " + "caused an exception.", failedPlugin.first()), new String[] { "The plugin file contains a bug that caused the exception" }, new String[] { "The plugin file was not loaded and the functionality of " + "the script will not be available in BinNavi" });
NaviErrorDialog.show(parent, message, description, failedPlugin.second());
}
for (final Pair<IPlugin<T>, PluginStatus> pair : plugins.getLoadedPlugins()) {
final IPlugin<T> plugin = pair.first();
final PluginStatus status = pair.second();
if (status != PluginStatus.Valid) {
showError(plugins, plugin, status);
}
}
PluginInitializer.initializePlugins(pluginInterface, registry, plugins.getLoadedPlugins(), configFile);
for (final IPlugin<T> plugin : scriptPlugins) {
try {
plugin.init(pluginInterface);
} catch (final Exception exception) {
CUtilityFunctions.logException(exception);
registry.removePlugin(plugin, DisabledPluginReason.ThrewOnInit);
}
}
for (final Pair<IPlugin<T>, DisabledPluginReason> disabledPair : registry.getDisabledPlugins()) {
final IPlugin<T> plugin = disabledPair.first();
final DisabledPluginReason reason = disabledPair.second();
if (reason == DisabledPluginReason.ThrewOnInit) {
final String message = "E00102: " + "Error during plugin initialization";
final String description = CUtilityFunctions.createDescription(String.format("BinNavi could not initialize the plugin '%s' because the plugin " + "caused an exception.", plugin.getName()), new String[] { "A bug in the plugin caused an exception." }, new String[] { "The plugin could not be initialized properly and was removed " + "from the list of loaded plugins." });
NaviErrorDialog.show(parent, message, description);
}
}
}
}
Aggregations