Search in sources :

Example 1 with Project

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

the class PluginInterface method showInWindow.

/**
 * Shows a view in a given window.
 *
 * @param window The window where the view is shown.
 * @param view The view to show.
 *
 * @return The view2d object that is shown.
 */
public View2D showInWindow(final GraphWindow window, final View view) {
    Preconditions.checkNotNull(view, "Error: View argument can not be null");
    final ViewContainer container = view.getContainer();
    if (container instanceof Module) {
        final Module module = (Module) container;
        return show(window.getNative(), view, new CModuleContainer(container.getDatabase().getNative(), module.getNative()));
    } else {
        final Project project = (Project) container;
        return show(window.getNative(), view, new CProjectContainer(container.getDatabase().getNative(), project.getNative()));
    }
}
Also used : Project(com.google.security.zynamics.binnavi.API.disassembly.Project) CProjectContainer(com.google.security.zynamics.binnavi.disassembly.CProjectContainer) Module(com.google.security.zynamics.binnavi.API.disassembly.Module) CModuleContainer(com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer) IViewContainer(com.google.security.zynamics.binnavi.disassembly.views.IViewContainer) ViewContainer(com.google.security.zynamics.binnavi.API.disassembly.ViewContainer)

Example 2 with Project

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

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

the class DatabaseTest method testCreateProject.

@Test
public void testCreateProject() throws CouldntSaveDataException, CouldntDeleteException {
    final MockDatabaseListener listener = new MockDatabaseListener();
    final MockDatabase mockDatabase = new MockDatabase();
    final Database database = new Database(mockDatabase);
    database.addListener(listener);
    final Project newProject = database.createProject("Hannes");
    mockDatabase.getContent().addProject("Fork");
    assertEquals("addedProject;addedProject;", listener.events);
    assertEquals(2, database.getProjects().size());
    database.deleteProject(newProject);
    assertEquals("addedProject;addedProject;deletedProject;", listener.events);
    assertEquals(1, database.getProjects().size());
    database.removeListener(listener);
}
Also used : Project(com.google.security.zynamics.binnavi.API.disassembly.Project) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Test(org.junit.Test)

Example 4 with Project

use of com.google.security.zynamics.binnavi.API.disassembly.Project 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 5 with Project

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

the class ProjectFactory method get.

public static Project get() {
    final MockSqlProvider provider = new MockSqlProvider();
    final Date creationDate = new Date();
    final Date modificationDate = new Date();
    final CProject internalProject = new CProject(123, "Name", "Comment", creationDate, modificationDate, 55, new FilledList<DebuggerTemplate>(), provider);
    final TagManager nodeTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(0, "", "", TagType.NODE_TAG, provider))), TagType.NODE_TAG, provider));
    final TagManager viewTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(0, "", "", TagType.VIEW_TAG, provider))), TagType.VIEW_TAG, provider));
    final Database db = new Database(new MockDatabase());
    return new Project(db, internalProject, nodeTagManager, viewTagManager);
}
Also used : CProject(com.google.security.zynamics.binnavi.disassembly.CProject) DebuggerTemplate(com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) Date(java.util.Date) Project(com.google.security.zynamics.binnavi.API.disassembly.Project) CProject(com.google.security.zynamics.binnavi.disassembly.CProject) TagManager(com.google.security.zynamics.binnavi.API.disassembly.TagManager) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) Tree(com.google.security.zynamics.zylib.types.trees.Tree) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)

Aggregations

Project (com.google.security.zynamics.binnavi.API.disassembly.Project)9 Database (com.google.security.zynamics.binnavi.API.disassembly.Database)6 Module (com.google.security.zynamics.binnavi.API.disassembly.Module)5 IDatabase (com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase)4 ViewContainer (com.google.security.zynamics.binnavi.API.disassembly.ViewContainer)3 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)3 CProjectContainer (com.google.security.zynamics.binnavi.disassembly.CProjectContainer)3 CModuleContainer (com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer)3 IViewContainer (com.google.security.zynamics.binnavi.disassembly.views.IViewContainer)3 DatabaseManager (com.google.security.zynamics.binnavi.API.disassembly.DatabaseManager)2 TagManager (com.google.security.zynamics.binnavi.API.disassembly.TagManager)2 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)2 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)2 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)2 CProject (com.google.security.zynamics.binnavi.disassembly.CProject)2 INaviProject (com.google.security.zynamics.binnavi.disassembly.INaviProject)2 Tree (com.google.security.zynamics.zylib.types.trees.Tree)2 ArrayList (java.util.ArrayList)2 AddressSpace (com.google.security.zynamics.binnavi.API.disassembly.AddressSpace)1 View (com.google.security.zynamics.binnavi.API.disassembly.View)1