Search in sources :

Example 1 with CDefaultProgressOperation

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

the class CTraceCombinationFunctions method differenceTraces.

/**
   * Creates a new trace that contains exactly those events that appear in the first trace but not
   * in the second trace.
   *
   * @param parent Parent window used for dialogs.
   * @param provider Creates the new trace.
   * @param trace1 The first input trace.
   * @param trace2 The second input trace.
   */
public static void differenceTraces(final JFrame parent, final ITraceListProvider provider, final TraceList trace1, final TraceList trace2) {
    new Thread() {

        @Override
        public void run() {
            try {
                final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, true);
                operation.getProgressPanel().setMaximum(3);
                operation.getProgressPanel().setText(String.format("Creating trace difference between '%s' and '%s'", trace1.getName(), trace2.getName()));
                final TraceList newTrace = provider.createTrace("Combined Trace", String.format("%s - %s", trace1.getName(), trace2.getName()));
                operation.getProgressPanel().next();
                createCombinedTrace(newTrace, Lists.newArrayList(trace1, trace2), getDifferenceAddresses(trace1, trace2));
                operation.getProgressPanel().next();
                newTrace.save();
                operation.getProgressPanel().next();
                operation.stop();
            } catch (final CouldntSaveDataException e) {
                CUtilityFunctions.logException(e);
                final String innerMessage = "E00191: " + "Could not combine debug traces";
                final String innerDescription = CUtilityFunctions.createDescription("The selected traces could not be combined into a larger trace.", new String[] { "There was a problem with the database connection." }, new String[] { "The trace list was not created. You could try to combine the lists again once the connection problem was resolved." });
                NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
            }
        }
    }.start();
}
Also used : CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList)

Example 2 with CDefaultProgressOperation

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

the class CTraceCombinationFunctions method intersectTraces.

/**
   * Creates a new trace that contains those events that appear in all of the input traces.
   *
   * @param parent Parent window used for dialogs.
   * @param provider Creates the new trace.
   * @param traces The input traces.
   */
public static void intersectTraces(final JFrame parent, final ITraceListProvider provider, final List<TraceList> traces) {
    new Thread() {

        @Override
        public void run() {
            try {
                final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, false);
                operation.getProgressPanel().setMaximum(3);
                operation.getProgressPanel().setText("Combining traces");
                final TraceList newTrace = provider.createTrace("Combined Trace", "");
                operation.next();
                createCombinedTrace(newTrace, traces, getIntersectedAddresses(traces));
                operation.next();
                newTrace.save();
                operation.next();
                operation.stop();
            } catch (final CouldntSaveDataException e) {
                CUtilityFunctions.logException(e);
                final String innerMessage = "E00196: " + "Could not combine debug traces";
                final String innerDescription = CUtilityFunctions.createDescription("The selected traces could not be combined into a larger trace.", new String[] { "There was a problem with the database connection." }, new String[] { "The trace list was not created. You could try to combine the lists again once the connection problem was resolved." });
                NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
            }
        }
    }.start();
}
Also used : CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList)

Example 3 with CDefaultProgressOperation

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

the class CModuleOverviewPanel method save.

/**
   * Saves the information from the GUI back into the module object.
   */
private void save() {
    final String fileBaseText = m_debuggerPanel.getFileBase();
    if (!Convert.isHexString(fileBaseText)) {
        CMessageBox.showError(this, "Could not save original base address. Value is not a valid hexadecimal address.");
        return;
    }
    final String imageBaseText = m_debuggerPanel.getImageBase();
    if (!Convert.isHexString(imageBaseText)) {
        CMessageBox.showError(this, "Could not save relocated base address. Value is not a valid hexadecimal address.");
        return;
    }
    new Thread() {

        // We are using a thread to save the information so that the GUI is not blocked
        // during database access.
        @Override
        public void run() {
            final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, true);
            operation.getProgressPanel().setMaximum(5);
            operation.getProgressPanel().setText("Saving module configuration" + ": " + "Saving Name");
            saveName();
            operation.getProgressPanel().next();
            operation.getProgressPanel().setText("Saving module configuration" + ": " + "Saving Description");
            saveDescription();
            operation.getProgressPanel().next();
            operation.getProgressPanel().setText("Saving module configuration" + ": " + "Saving Debugger");
            saveDebugger();
            operation.getProgressPanel().next();
            operation.getProgressPanel().setText("Saving module configuration" + ": " + "Saving File Base");
            saveFileBase();
            operation.getProgressPanel().next();
            operation.getProgressPanel().setText("Saving module configuration" + ": " + "Saving Image Base");
            saveImageBase();
            operation.getProgressPanel().next();
            operation.stop();
            updateSaveButton();
        }
    }.start();
}
Also used : CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation)

Example 4 with CDefaultProgressOperation

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

the class CAddressSpaceFunctions method loadAddressSpaces.

/**
   * Loads one or more address spaces.
   * 
   * @param projectTree Project tree of the main window.
   * @param addressSpaces The address spaces to load.
   */
public static void loadAddressSpaces(final JTree projectTree, final INaviAddressSpace[] addressSpaces) {
    new Thread() {

        @Override
        public void run() {
            final CDefaultProgressOperation operation = new CDefaultProgressOperation("Loading address spaces", false, true);
            operation.getProgressPanel().setMaximum(addressSpaces.length);
            for (final INaviAddressSpace addressSpace : addressSpaces) {
                operation.getProgressPanel().setText("Loading address spaces" + ": '" + addressSpace.getConfiguration().getName() + "'");
                try {
                    addressSpace.load();
                    new SwingInvoker() {

                        @Override
                        protected void operation() {
                            CNodeExpander.expandNode(projectTree, addressSpace);
                        }
                    }.invokeLater();
                } catch (final CouldntLoadDataException exception) {
                    CUtilityFunctions.logException(exception);
                    final String message = "E00109: " + "Address space could not be loaded";
                    final String description = CUtilityFunctions.createDescription(String.format("The address space '%s' could not be loaded. Try loading 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.", addressSpace.getConfiguration().getName()), new String[] { "Database connection problems." }, new String[] { "The address space was not loaded." });
                    NaviErrorDialog.show(SwingUtilities.getWindowAncestor(projectTree), message, description, exception);
                } catch (final LoadCancelledException e) {
                // Do nothing
                } 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) SwingInvoker(com.google.security.zynamics.zylib.gui.SwingInvoker) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) INaviAddressSpace(com.google.security.zynamics.binnavi.disassembly.INaviAddressSpace)

Example 5 with CDefaultProgressOperation

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

the class CProjectFunctions method removeAddressSpace.

/**
   * Removes an address spaces from a project.
   * 
   * @param parent Parent window used for dialogs.
   * @param project The project the address space belongs to.
   * @param addressSpaces The address spaces to be removed from the project.
   * @param updater Updates the project tree after the address space was removed.
   */
public static void removeAddressSpace(final JFrame parent, final INaviProject project, final INaviAddressSpace[] addressSpaces, final ITreeUpdater updater) {
    if (CMessageBox.showYesNoQuestion(parent, String.format("Do you really want to delete the following address spaces from the project?\n\n%s", CNameListGenerators.getNameList(addressSpaces))) == JOptionPane.YES_OPTION) {
        for (final INaviAddressSpace addressSpace : addressSpaces) {
            new Thread() {

                @Override
                public void run() {
                    final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, true);
                    operation.getProgressPanel().setMaximum(1);
                    operation.getProgressPanel().setText("Removing address space" + ": " + addressSpace.getConfiguration().getName());
                    operation.getProgressPanel().next();
                    if (addressSpace.isLoaded()) {
                        addressSpace.close();
                    }
                    if (addressSpace.isLoaded()) {
                        final String innerMessage = "E00123: " + "Address space could not be deleted";
                        final String innerDescription = CUtilityFunctions.createDescription(String.format("BinNavi could not delete the address space '%s'.", addressSpace.getConfiguration().getName()), new String[] { "BinNavi or one of the active plugins vetoed the deletion " + "operation." }, new String[] { "The address space can not be deleted until the delete " + "operation is not vetoed anymore." });
                        NaviErrorDialog.show(parent, innerMessage, innerDescription);
                    } else {
                        try {
                            project.getContent().removeAddressSpace(addressSpace);
                            updater.update();
                        } catch (final CouldntDeleteException exception) {
                            CUtilityFunctions.logException(exception);
                            final String innerMessage = "E00143: " + "Address space could not be deleted";
                            final String innerDescription = CUtilityFunctions.createDescription("The selected address space could not be deleted.", new String[] { "There was a problem with the database connection." }, new String[] { "The address space was not deleted." });
                            NaviErrorDialog.show(parent, innerMessage, innerDescription, exception);
                        }
                    }
                    operation.stop();
                }
            }.start();
        }
    }
}
Also used : CouldntDeleteException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException) CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation) INaviAddressSpace(com.google.security.zynamics.binnavi.disassembly.INaviAddressSpace)

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