Search in sources :

Example 6 with IDatabase

use of com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase in project binnavi by google.

the class CDatabaseSortingHandler method drop.

@Override
public void drop(final DNDTree target, final DefaultMutableTreeNode parentNode, final DefaultMutableTreeNode draggedNode) {
    final IDatabase draggedDatabase = ((CDatabaseNode) draggedNode).getObject();
    final IDatabase parentDatabase = ((CDatabaseNode) parentNode).getObject();
    int pnIndex = 0;
    for (final IDatabase database : m_manager) {
        if (database == parentDatabase) {
            break;
        }
        pnIndex++;
    }
    m_manager.moveDatabase(draggedDatabase, pnIndex + 1);
}
Also used : IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) CDatabaseNode(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Database.CDatabaseNode)

Example 7 with IDatabase

use of com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase in project binnavi by google.

the class ConfigManager method saveSettings.

/**
   * Stores all relevant settings in the config file object and saves the config file to the disk.
   *
   * @param parent Parent window used for dialogs.
   */
public void saveSettings(final JFrame parent) {
    final Point location = parent.getLocation();
    final GeneralSettingsConfigItem.LastOpenWindowConfigItem window = generalSettings.getLastOpenWindow();
    window.setTop((int) location.getY());
    window.setLeft((int) location.getX());
    window.setHeight(parent.getHeight());
    window.setWidth(parent.getWidth());
    generalSettings.setMaximizeWindow((parent.getExtendedState() == Frame.ICONIFIED) || (parent.getExtendedState() == Frame.MAXIMIZED_BOTH));
    databases.clear();
    for (final IDatabase database : CDatabaseManager.instance()) {
        final DatabaseConfigItem databaseConfig = new DatabaseConfigItem();
        databaseConfig.setAutoConnect(database.getConfiguration().isAutoConnect());
        databaseConfig.setDescription(database.getConfiguration().getDescription());
        databaseConfig.setDriver(database.getConfiguration().getDriver());
        databaseConfig.setPassword(database.getConfiguration().isSavePassword() ? database.getConfiguration().getPassword() : "");
        databaseConfig.setSavePassword(database.getConfiguration().isSavePassword());
        databaseConfig.setHost(database.getConfiguration().getHost());
        databaseConfig.setName(database.getConfiguration().getName());
        databaseConfig.setUser(database.getConfiguration().getUser());
        databaseConfig.setIdentity(database.getConfiguration().getIdentity());
        databases.add(databaseConfig);
    }
    try {
        write();
    } catch (final FileWriteException e) {
        CUtilityFunctions.logException(e);
        final String innerMessage = "E00150: " + "Could not write configuration file";
        final String innerDescription = CUtilityFunctions.createDescription("The configuration file where the settings are stored could not be written.", new String[] { "There was a problem writing the file. Please see the stacktrace for more " + "information." }, new String[] { "The active configuration was not saved and will be lost." });
        NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
    }
}
Also used : IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) Point(java.awt.Point)

Example 8 with IDatabase

use of com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase in project binnavi by google.

the class DatabaseManagerTest method testLifecycle.

@Test
public void testLifecycle() {
    final MockDatabaseManagerListener listener = new MockDatabaseManagerListener();
    final DatabaseManager manager = new DatabaseManager(CDatabaseManager.instance());
    manager.addListener(listener);
    manager.addDatabase("Description", "Driver", "Host", "Name", "User", "Password", "identity", true, false);
    final IDatabase internalDatabase = CDatabaseManager.instance().iterator().next();
    assertEquals("Description", internalDatabase.getConfiguration().getDescription());
    assertEquals("Driver", internalDatabase.getConfiguration().getDriver());
    assertEquals("User", internalDatabase.getConfiguration().getUser());
    assertEquals("Password", internalDatabase.getConfiguration().getPassword());
    assertTrue(internalDatabase.getConfiguration().isSavePassword());
    assertFalse(internalDatabase.getConfiguration().isAutoConnect());
    assertEquals(1, manager.getDatabases().size());
    assertEquals("addedDatabase;", listener.events);
    assertEquals("Database Manager ['Description']", manager.toString());
    final Database database = manager.getDatabases().get(0);
    manager.removeDatabase(database);
    assertEquals(0, manager.getDatabases().size());
    assertEquals("addedDatabase;removedDatabase;", listener.events);
    manager.removeListener(listener);
}
Also used : IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) DatabaseManager(com.google.security.zynamics.binnavi.API.disassembly.DatabaseManager) CDatabaseManager(com.google.security.zynamics.binnavi.Database.CDatabaseManager) MockDatabaseManagerListener(com.google.security.zynamics.binnavi.disassembly.MockDatabaseManagerListener) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) Test(org.junit.Test)

Example 9 with IDatabase

use of com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase in project binnavi by google.

the class CGraphInliner method getFunctionToInline.

/**
   * Determines the function to inline with consideration of function forwarding.
   * 
   * @param parent Parent window used for dialogs.
   * @param viewContainer Contains the function to inline.
   * @param function The function to be inlined.
   * @param forwarderModuleId Module ID of the module the function is forwarded to.
   * @param forwarderAddress Address of the function the function is forwarded to. This argument can
   *        be null.
   * 
   * @return The function to be inlined.
   */
private static INaviFunction getFunctionToInline(final JFrame parent, final IViewContainer viewContainer, final INaviFunction function, final int forwarderModuleId, final IAddress forwarderAddress) {
    if (forwarderAddress == null) {
        return function;
    } else {
        final IDatabase database = viewContainer.getDatabase();
        final INaviModule module = database.getContent().getModule(forwarderModuleId);
        if (!viewContainer.containsModule(module)) {
            CMessageBox.showInformation(parent, String.format("You are trying to inline an external function into a module view. " + "This is not possible.\n" + "To inline external functions it is necessary to create projects."));
            return null;
        }
        if (!module.isLoaded()) {
            try {
                module.load();
            } catch (final CouldntLoadDataException | LoadCancelledException e) {
                CUtilityFunctions.logException(e);
                return null;
            }
        }
        return module.getContent().getFunctionContainer().getFunction(forwarderAddress);
    }
}
Also used : IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)

Aggregations

IDatabase (com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase)9 Database (com.google.security.zynamics.binnavi.API.disassembly.Database)3 Module (com.google.security.zynamics.binnavi.API.disassembly.Module)2 Project (com.google.security.zynamics.binnavi.API.disassembly.Project)2 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)2 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)2 DatabaseManager (com.google.security.zynamics.binnavi.API.disassembly.DatabaseManager)1 TagManager (com.google.security.zynamics.binnavi.API.disassembly.TagManager)1 View (com.google.security.zynamics.binnavi.API.disassembly.View)1 CDatabase (com.google.security.zynamics.binnavi.Database.CDatabase)1 CDatabaseManager (com.google.security.zynamics.binnavi.Database.CDatabaseManager)1 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)1 LoadCancelledException (com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)1 SQLProvider (com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider)1 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)1 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)1 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)1 CDatabaseNode (com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Database.CDatabaseNode)1 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)1 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)1