Search in sources :

Example 1 with DatabaseManager

use of com.google.security.zynamics.binnavi.API.disassembly.DatabaseManager in project binnavi by google.

the class CAddressSpaceNodeMenuBuilder method getPluginAddressSpaces.

/**
   * Returns the API address space objects for the address spaces for which the menu was built.
   *
   * @return The API address space objects.
   */
private List<AddressSpace> getPluginAddressSpaces() {
    final DatabaseManager manager = PluginInterface.instance().getDatabaseManager();
    for (final Database database : manager) {
        if (database.getNative() == m_database) {
            for (final Project project : database.getProjects()) {
                if (project.getNative() == m_project) {
                    final List<AddressSpace> allSpaces = project.getAddressSpaces();
                    final List<AddressSpace> menuSpaces = new ArrayList<AddressSpace>();
                    for (final INaviAddressSpace addressSpace : m_addressSpaces) {
                        menuSpaces.add(ObjectFinders.getObject(addressSpace, allSpaces));
                    }
                    return menuSpaces;
                }
            }
        }
    }
    throw new IllegalStateException("IE01159: Unknown database");
}
Also used : Project(com.google.security.zynamics.binnavi.API.disassembly.Project) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) INaviAddressSpace(com.google.security.zynamics.binnavi.disassembly.INaviAddressSpace) AddressSpace(com.google.security.zynamics.binnavi.API.disassembly.AddressSpace) DatabaseManager(com.google.security.zynamics.binnavi.API.disassembly.DatabaseManager) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) ArrayList(java.util.ArrayList) INaviAddressSpace(com.google.security.zynamics.binnavi.disassembly.INaviAddressSpace)

Example 2 with DatabaseManager

use of com.google.security.zynamics.binnavi.API.disassembly.DatabaseManager in project binnavi by google.

the class CModuleNodeMenuBuilder method getPluginModules.

/**
   * Returns the API module objects for the modules for which the menu was built.
   *
   * @return The API module objects.
   */
private List<Module> getPluginModules() {
    final DatabaseManager manager = PluginInterface.instance().getDatabaseManager();
    for (final Database database : manager) {
        if (database.getNative() == m_database) {
            final List<Module> allModules = database.getModules();
            final List<Module> menuModules = new ArrayList<Module>();
            for (final INaviModule module : m_modules) {
                menuModules.add(ObjectFinders.getObject(module, allModules));
            }
            return menuModules;
        }
    }
    throw new IllegalStateException("IE01165: Unknown database");
}
Also used : DatabaseManager(com.google.security.zynamics.binnavi.API.disassembly.DatabaseManager) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) ArrayList(java.util.ArrayList) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) Module(com.google.security.zynamics.binnavi.API.disassembly.Module)

Example 3 with DatabaseManager

use of com.google.security.zynamics.binnavi.API.disassembly.DatabaseManager in project binnavi by google.

the class CProjectNodeMenuBuilder method getPluginProjects.

/**
   * Returns the API project objects for the projects for which the menu was built.
   * 
   * @return The API project objects.
   */
private List<Project> getPluginProjects() {
    final DatabaseManager manager = PluginInterface.instance().getDatabaseManager();
    for (final Database database : manager) {
        if (database.getNative() == m_database) {
            final List<Project> allProjects = database.getProjects();
            final List<Project> menuProjects = new ArrayList<Project>();
            for (final INaviProject project : m_projects) {
                menuProjects.add(ObjectFinders.getObject(project, allProjects));
            }
            return menuProjects;
        }
    }
    throw new IllegalStateException("IE01168: Unknown database");
}
Also used : Project(com.google.security.zynamics.binnavi.API.disassembly.Project) CProject(com.google.security.zynamics.binnavi.disassembly.CProject) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) DatabaseManager(com.google.security.zynamics.binnavi.API.disassembly.DatabaseManager) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) ArrayList(java.util.ArrayList)

Example 4 with DatabaseManager

use of com.google.security.zynamics.binnavi.API.disassembly.DatabaseManager 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)

Aggregations

Database (com.google.security.zynamics.binnavi.API.disassembly.Database)4 DatabaseManager (com.google.security.zynamics.binnavi.API.disassembly.DatabaseManager)4 IDatabase (com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase)4 ArrayList (java.util.ArrayList)3 Project (com.google.security.zynamics.binnavi.API.disassembly.Project)2 INaviProject (com.google.security.zynamics.binnavi.disassembly.INaviProject)2 AddressSpace (com.google.security.zynamics.binnavi.API.disassembly.AddressSpace)1 Module (com.google.security.zynamics.binnavi.API.disassembly.Module)1 CDatabaseManager (com.google.security.zynamics.binnavi.Database.CDatabaseManager)1 CProject (com.google.security.zynamics.binnavi.disassembly.CProject)1 INaviAddressSpace (com.google.security.zynamics.binnavi.disassembly.INaviAddressSpace)1 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)1 MockDatabaseManagerListener (com.google.security.zynamics.binnavi.disassembly.MockDatabaseManagerListener)1 Test (org.junit.Test)1