Search in sources :

Example 11 with CDefaultProgressOperation

use of com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation in project binnavi by google.

the class CAddressSpaceFunctions method addModule.

/**
   * Adds a module to an address space.
   * 
   * @param parent Parent window used to display dialogs.
   * @param addressSpace The address space where the module is added.
   * @param module The module that is added to the address space.
   */
public static void addModule(final JFrame parent, final INaviAddressSpace addressSpace, final INaviModule module) {
    if (CMessageBox.showYesNoQuestion(parent, String.format("Do you really want to add the module '%s' to the address space '%s'?", module.getConfiguration().getName(), addressSpace.getConfiguration().getName())) == JOptionPane.YES_OPTION) {
        new Thread() {

            @Override
            public void run() {
                final CDefaultProgressOperation operation = new CDefaultProgressOperation("Adding modules to address space", false, true);
                operation.getProgressPanel().setMaximum(1);
                operation.getProgressPanel().setText("Adding module to address space" + ": '" + module.getConfiguration().getName() + "'");
                try {
                    addressSpace.getContent().addModule(module);
                } catch (final CouldntSaveDataException exception) {
                    CUtilityFunctions.logException(exception);
                    final String message = "E00026: " + "Module could not be added to address space";
                    final String description = CUtilityFunctions.createDescription(String.format("The module '%s' could not be added to the address space '%s'. Try adding the module to the address space again. If the problem persists, disconnect from and reconnect to the database, restart com.google.security.zynamics.binnavi, or contact the BinNavi support.", module.getConfiguration().getName(), addressSpace.getConfiguration().getName()), new String[] { "Database connection problems." }, new String[] { "The address space remains unchanged." });
                    NaviErrorDialog.show(parent, message, description, exception);
                }
                operation.stop();
            }
        }.start();
    }
}
Also used : CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)

Example 12 with CDefaultProgressOperation

use of com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation in project binnavi by google.

the class CAddressSpaceFunctions method removeModules.

/**
   * Removes a module from an address space.
   * 
   * @param parent Parent window used to display dialogs.
   * @param addressSpace The address space the module belongs to.
   * @param modules The modules to be removed from the address space.
   */
public static void removeModules(final JFrame parent, final INaviAddressSpace addressSpace, final INaviModule[] modules) {
    new Thread() {

        @Override
        public void run() {
            if (CMessageBox.showYesNoQuestion(parent, String.format("Do you really want to remove the following modules from the address space?\n\n%s", CNameListGenerators.getNameList(modules))) == JOptionPane.YES_OPTION) {
                final CDefaultProgressOperation operation = new CDefaultProgressOperation("Removing modules from address space", false, true);
                operation.getProgressPanel().setMaximum(modules.length);
                for (final INaviModule module : modules) {
                    operation.getProgressPanel().setText("Removing modules from address space" + ": '" + module.getConfiguration().getName() + "'");
                    try {
                        addressSpace.getContent().removeModule(module);
                    } catch (final CouldntDeleteException exception) {
                        CUtilityFunctions.logException(exception);
                        final String message = "E00027: " + "Module could not be removed from address space";
                        final String description = CUtilityFunctions.createDescription(String.format("The module '%s' could not be removed from the address space '%s'. Try removing the module from the address space again. If the problem persists, disconnect from and reconnect to the database, restart com.google.security.zynamics.binnavi, or contact the BinNavi support.", module.getConfiguration().getName(), addressSpace.getConfiguration().getName()), new String[] { "Database connection problems." }, new String[] { "The address space remains unchanged." });
                        NaviErrorDialog.show(parent, message, description, exception);
                    } catch (final CouldntSaveDataException exception) {
                        CUtilityFunctions.logException(exception);
                    }
                    operation.getProgressPanel().next();
                }
                operation.stop();
            }
        }
    }.start();
}
Also used : CouldntDeleteException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException) CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)

Example 13 with CDefaultProgressOperation

use of com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation in project binnavi by google.

the class CDatabaseFunctions method refreshRawModules.

/**
   * Refreshes the information about raw modules stored in the database.
   * 
   * @param parent Parent frame used for dialogs.
   * @param database The database where the raw modules are stored.
   */
public static void refreshRawModules(final JFrame parent, final IDatabase database) {
    new Thread() {

        @Override
        public void run() {
            final CDefaultProgressOperation operation = new CDefaultProgressOperation("", true, false);
            try {
                operation.getProgressPanel().setMaximum(1);
                operation.getProgressPanel().setText("Refreshing modules");
                try {
                    database.getContent().refreshRawModules();
                } catch (final CouldntLoadDataException exception) {
                    CUtilityFunctions.logException(exception);
                    final String message = "E00036: " + "Could not refresh raw modules";
                    final String description = CUtilityFunctions.createDescription("The list of raw modules could not be refreshed. " + "Try refreshing the raw modules again.", new String[] { "Database connection problems." }, new String[] { "More raw modules than those shown in " + "the raw modules list might exist in the database." });
                    NaviErrorDialog.show(parent, message, description, exception);
                }
            } finally {
                operation.getProgressPanel().next();
                operation.stop();
            }
        }
    }.start();
}
Also used : CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)

Example 14 with CDefaultProgressOperation

use of com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation in project binnavi by google.

the class CDatabaseFunctions method addDebugger.

/**
   * Adds a new debugger to the database.
   * 
   * @param parent Parent window used for dialogs.
   * @param database The database where the debugger is added.
   * @param name The name of the new debugger.
   * @param host The host information of the new debugger.
   * @param port The port information of the new debugger.
   * @param updater Updates the project tree after the action is complete.
   */
public static void addDebugger(final JFrame parent, final IDatabase database, final String name, final String host, final int port, final INodeSelectionUpdater updater) {
    new Thread() {

        @Override
        public void run() {
            final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, true);
            try {
                operation.getProgressPanel().setMaximum(1);
                operation.getProgressPanel().setText("Creating new debugger");
                final DebuggerTemplate template = database.getContent().getDebuggerTemplateManager().createDebugger(name, host, port);
                updater.setObject(template);
                updater.update();
            } catch (final CouldntSaveDataException exception) {
                CUtilityFunctions.logException(exception);
                final String message = "E00028: " + "Debugger could not be created";
                final String description = CUtilityFunctions.createDescription(String.format("The debugger '%s' could not be created. " + "Try creating the debugger again. " + "If the problem persists, disconnect from and reconnect " + "to the database, restart BinNavi, or contact the BinNavi support.", name), new String[] { "Database connection problems." }, new String[] { "The debugger was not created." });
                NaviErrorDialog.show(parent, message, description, exception);
            } finally {
                operation.getProgressPanel().next();
                operation.stop();
            }
        }
    }.start();
}
Also used : CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation) DebuggerTemplate(com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)

Example 15 with CDefaultProgressOperation

use of com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation in project binnavi by google.

the class CModuleFunctions method deleteModules.

/**
   * Deletes a module from the database.
   * 
   * @param parent Parent frame used for dialogs.
   * @param database The database where the module is stored.
   * @param modules The module to be deleted.
   * @param updater Updates the project tree if deletion was successful.
   */
public static void deleteModules(final JFrame parent, final IDatabase database, final INaviModule[] modules, final ITreeUpdater updater) {
    if (CMessageBox.showYesNoQuestion(parent, String.format("Do you really want to delete the following modules from the database?\n\n%s", CNameListGenerators.getNameList(modules))) == JOptionPane.YES_OPTION) {
        for (final INaviModule module : modules) {
            new Thread() {

                @Override
                public void run() {
                    final CDefaultProgressOperation operation = new CDefaultProgressOperation("", true, false);
                    operation.getProgressPanel().setMaximum(1);
                    operation.getProgressPanel().setText("Deleting module" + ": " + module.getConfiguration().getName());
                    try {
                        database.getContent().delete(module);
                        operation.getProgressPanel().next();
                        updater.update();
                    } catch (final CouldntDeleteException e) {
                        CUtilityFunctions.logException(e);
                        final String message = "E00031: " + "Module could not be deleted";
                        final String description = CUtilityFunctions.createDescription(String.format("The module '%s' could not be deleted. Try to delete the module again. If the problem persists, disconnect from and reconnect to the database, restart com.google.security.zynamics.binnavi, or contact the BinNavi support.", module.getConfiguration().getName()), new String[] { "Database connection problems." }, new String[] { "The module still exists." });
                        NaviErrorDialog.show(parent, message, description, e);
                    } finally {
                        operation.stop();
                    }
                }
            }.start();
        }
    }
}
Also used : CouldntDeleteException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException) CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule)

Aggregations

CDefaultProgressOperation (com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation)21 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)10 CouldntDeleteException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)8 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)5 LoadCancelledException (com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)4 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)4 DebuggerTemplate (com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate)2 INaviAddressSpace (com.google.security.zynamics.binnavi.disassembly.INaviAddressSpace)2 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)2 INaviProject (com.google.security.zynamics.binnavi.disassembly.INaviProject)2 CouldntConnectException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntConnectException)1 CouldntInitializeDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntInitializeDatabaseException)1 CouldntLoadDriverException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDriverException)1 CouldntUpdateDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntUpdateDatabaseException)1 InvalidDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseException)1 InvalidDatabaseVersionException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseVersionException)1 InvalidExporterDatabaseFormatException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidExporterDatabaseFormatException)1 CAddressSpace (com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace)1 SwingInvoker (com.google.security.zynamics.zylib.gui.SwingInvoker)1 ArrayList (java.util.ArrayList)1