Search in sources :

Example 1 with IDatabase

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

the class CProjectMainFrame method setVisible.

@Override
public void setVisible(final boolean visible) {
    super.setVisible(visible);
    if (m_firstStart) {
        CFirstStartDialog.show(this);
        CMessageBox.showInformation(getRootPane(), "Please configure your IDA Pro settings and install the required IDA Pro plugins now." + "\n\nIf you want to reconfigure these settings later you can find them in the " + "Settings dialog of this window.");
        final String file = CActionProvider.selectIDADirectory(getRootPane(), ConfigManager.instance().getGeneralSettings().getIdaDirectory());
        if (file != null) {
            ConfigManager.instance().getGeneralSettings().setIdaDirectory(file);
        }
    }
    if (insufficientMemory()) {
        CMessageBox.showInformation(this, "You are using BinNavi with less than the recommended 512 MB of memory.\n" + "Please check binnavi.bat in your BinNavi directory to find out how to increase " + "the available memory.");
    }
    // Connect the databases to be connected automatically.
    for (final IDatabase database : CDatabaseManager.instance()) {
        if (database.getConfiguration().isAutoConnect()) {
            CDatabaseConnectionFunctions.openDatabase(this, database);
        }
    }
}
Also used : IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase)

Example 2 with IDatabase

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

the class TraceLoggerTest method setUp.

@Before
public void setUp() throws CouldntLoadDataException, InvalidDatabaseVersionException {
    final SQLProvider mockProvider = new MockSqlProvider();
    // CDatabase("", "", "", "", "", false,
    final IDatabase internalDatabase = new MockDatabase();
    // false);
    final Database database = new Database(internalDatabase);
    database.load();
    final MockProject mockProject = new MockProject();
    final ITreeNode<CTag> nodeRootNode = new TreeNode<CTag>(new CTag(0, "", "", TagType.NODE_TAG, mockProvider));
    final Tree<CTag> nodeTagTree = new Tree<CTag>(nodeRootNode);
    final TagManager nodeTagManager = new TagManager(new CTagManager(nodeTagTree, TagType.NODE_TAG, mockProvider));
    final ITreeNode<CTag> viewRootNode = new TreeNode<CTag>(new CTag(0, "", "", TagType.VIEW_TAG, mockProvider));
    final Tree<CTag> viewTagTree = new Tree<CTag>(viewRootNode);
    final TagManager viewTagManager = new TagManager(new CTagManager(viewTagTree, TagType.VIEW_TAG, mockProvider));
    final Module module = new Module(database, mockModule, nodeTagManager, viewTagManager);
    final Project project = new Project(database, mockProject, nodeTagManager, viewTagManager);
    m_mockModule = new Module(database, mockModule, viewTagManager, nodeTagManager);
    m_debugSettings = new ModuleTargetSettings(m_mockModule.getNative());
    m_mockDebugger = new MockDebugger(m_debugSettings);
    m_mockDebugger.setAddressTranslator(mockModule, new CAddress(0), new CAddress(0x1000));
    final Debugger debugger = new Debugger(m_mockDebugger);
    m_logger = new TraceLogger(debugger, module);
    m_projectLogger = new TraceLogger(debugger, project);
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) SQLProvider(com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) Project(com.google.security.zynamics.binnavi.API.disassembly.Project) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) TagManager(com.google.security.zynamics.binnavi.API.disassembly.TagManager) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) TreeNode(com.google.security.zynamics.zylib.types.trees.TreeNode) ITreeNode(com.google.security.zynamics.zylib.types.trees.ITreeNode) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Tree(com.google.security.zynamics.zylib.types.trees.Tree) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) Module(com.google.security.zynamics.binnavi.API.disassembly.Module) Before(org.junit.Before)

Example 3 with IDatabase

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

the class DatabaseManager method addDatabase.

// ESCA-JAVA0138: Takes more than 5 arguments to define the whole database in one step.
// ! Adds a new database.
/**
   * Adds a new database configuration to the database manager.
   * 
   * @param description The description of the new database configuration. This is the text that is
   *        displayed in the project tree.
   * @param driver The driver that is used to connect to the database.
   * @param host Host address of the database server.
   * @param name The name of the database on the database server.
   * @param user The user that is used to connect to the database.
   * @param password The password that is used to connect to the database.
   * @param identity The identity under which the current user operates.
   * @param savePassword Flag that indicates whether the password should be saved in the
   *        configuration file.
   * @param autoConnect Flag that indicates whether this a connection to this database is
   *        established automatically when BinNavi starts.
   * @return The created database.
   * 
   * @throws IllegalArgumentException Thrown if any of the passed arguments are null.
   */
public Database addDatabase(final String description, final String driver, final String host, final String name, final String user, final String password, final String identity, final boolean savePassword, final boolean autoConnect) {
    Preconditions.checkNotNull(description, "Error: description argument can not be null");
    Preconditions.checkNotNull(driver, "Error: driver argument can not be null");
    Preconditions.checkNotNull(host, "Error: host argument can not be null");
    Preconditions.checkNotNull(name, "Error: name argument can not be null");
    final IDatabase newDatabase = m_manager.addDatabase(new CDatabase(description, driver, host, name, user, password, identity, savePassword, autoConnect));
    return ObjectFinders.getObject(newDatabase, m_databases);
}
Also used : CDatabase(com.google.security.zynamics.binnavi.Database.CDatabase) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase)

Example 4 with IDatabase

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

the class View2D method findView.

/**
   * Searches for the API view that wraps a given internal view.
   *
   * @param database Database to search for.
   * @param internalView Internal view to search for.
   * @param databases Databases to search through.
   *
   * @return The API view that wraps the given internal view.
   */
private static View findView(final IDatabase database, final INaviView internalView, final List<Database> databases) {
    final Database apiDatabase = ObjectFinders.getObject(database, databases);
    View view = null;
    for (final Module m : apiDatabase.getModules()) {
        if (!m.isLoaded()) {
            continue;
        }
        view = ObjectFinders.getObject(internalView, m.getViews());
        if (view != null) {
            return view;
        }
    }
    for (final Project project : apiDatabase.getProjects()) {
        if (!project.isLoaded()) {
            continue;
        }
        view = ObjectFinders.getObject(internalView, project.getViews());
        if (view != null) {
            return view;
        }
    }
    throw new IllegalStateException("Error: Unknown view");
}
Also used : Project(com.google.security.zynamics.binnavi.API.disassembly.Project) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) Module(com.google.security.zynamics.binnavi.API.disassembly.Module) View(com.google.security.zynamics.binnavi.API.disassembly.View) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView)

Example 5 with IDatabase

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

the class CViewOpener method showForwardedFunction.

/**
   * Shows a forwarded function in a graph window.
   * 
   * @param parent Parent window that is used as the parent of all dialogs.
   * @param container View container that provides the context in which a view is opened.
   * @param view The view to show.
   * @param function The imported function to show.
   * @param window Graph window where the graph is shown. If this value is null, the graph is shown
   *        in a new window.
   */
private static void showForwardedFunction(final Window parent, final IViewContainer container, final INaviView view, final INaviFunction function, final CGraphWindow window) {
    if (container instanceof CModuleContainer) {
        CMessageBox.showInformation(parent, "Please open forwarded views from inside a project.");
        return;
    }
    final IDatabase database = container.getDatabase();
    final int moduleId = function.getForwardedFunctionModuleId();
    final INaviModule forwardedModule = database.getContent().getModule(moduleId);
    if (forwardedModule == null) {
        final String message = "E00019: " + "Forwarded view can not be loaded (Unknown module)";
        final String description = CUtilityFunctions.createDescription("BinNavi could not open the forwarded view because the module of " + "the forwarding target is unknown.", new String[] { "Probably the result of a bug in BinNavi" }, new String[] { "The view can not be opened. Try to update the " + "forwarding target again. Restart BinNavi if the view " + "can still not be opened. Contact the BinNavi support if necessary." });
        NaviErrorDialog.show(parent, message, description);
    } else if (forwardedModule.isLoaded()) {
        final IAddress address = function.getForwardedFunctionAddress();
        final INaviFunction forwardedFunction = forwardedModule.getContent().getFunctionContainer().getFunction(address);
        if (forwardedFunction == null) {
            final String message = "E00020: " + "Forwarded view can not be loaded (Unknown function)";
            final String description = CUtilityFunctions.createDescription("BinNavi could not open the forwarded view because the target function is unknown.", new String[] { "Probably the result of a bug in BinNavi" }, new String[] { "The view can not be opened. Try to update the forwarding target " + "again. Restart BinNavi if the view can still not be opened. Contact the " + "BinNavi support if necessary." });
            NaviErrorDialog.show(parent, message, description);
        } else {
            final INaviView forwardedView = forwardedModule.getContent().getViewContainer().getView(forwardedFunction);
            if (forwardedView == null) {
                final String message = "E00107: " + "Forwarded view can not be loaded (Unknown view)";
                final String description = CUtilityFunctions.createDescription("BinNavi could not open the forwarded view because the target view is unknown.", new String[] { "Probably the result of a bug in BinNavi" }, new String[] { "The view can not be opened. Try to update the forwarding target " + "again. Restart BinNavi if the view can still not be opened. Contact the " + "BinNavi support if necessary." });
                NaviErrorDialog.show(parent, message, description);
            } else {
                CGraphOpener.showGraph(container, forwardedView, window, parent);
            }
        }
    } else {
        if (CMessageBox.showYesNoQuestion(parent, "The view can not be opened because it is forwarded to an unloaded module.\n\n" + "Do you want to load the forwarded module now?") == JOptionPane.YES_OPTION) {
            CModuleLoader.loadModule(parent, forwardedModule);
            if (forwardedModule.isLoaded()) {
                // Just call this function recursively now that the module is loaded.
                showForwardedFunction(parent, container, view, function, window);
            }
        }
    }
}
Also used : IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) CModuleContainer(com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress)

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