Search in sources :

Example 71 with INaviView

use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.

the class PostgreSQLTypeInstanceFunctionsTests method deleteTypeInstanceReferenceTest5.

@Test
public void deleteTypeInstanceReferenceTest5() throws CouldntDeleteException, CouldntLoadDataException, LoadCancelledException, CPartialLoadException, CouldntSaveDataException {
    module.load();
    final TypeInstance typeInstance = module.getContent().getTypeInstanceContainer().getTypeInstances().get(0);
    final TypeInstanceAddress address1 = typeInstance.getAddress();
    final INaviFunction function = module.getContent().getFunctionContainer().getFunction(new CAddress("1001929", 16));
    final INaviView view = module.getContent().getViewContainer().getView(function);
    view.load();
    final INaviInstruction instruction = view.getBasicBlocks().get(2).getInstructions().iterator().next();
    Assert.assertNotNull(typeInstance);
    provider.createTypeInstanceReference(typeInstance.getModule().getConfiguration().getId(), instruction.getAddress().toLong(), instruction.getOperandPosition(instruction.getOperands().get(1)), instruction.getOperands().get(0).getNodes().get(0).getId(), typeInstance.getId());
    view.close();
    module.close();
    module.load();
    view.load();
    final TypeInstance typeInstance2 = module.getContent().getTypeInstanceContainer().getTypeInstance(typeInstance.getAddress());
    Assert.assertEquals(address1, typeInstance2.getAddress());
    final List<TypeInstanceReference> references = module.getContent().getTypeInstanceContainer().getReferences(typeInstance2);
    Assert.assertTrue(!references.isEmpty());
    final TypeInstanceReference reference = Iterables.find(references, new Predicate<TypeInstanceReference>() {

        @Override
        public boolean apply(final TypeInstanceReference reference) {
            return reference.getAddress().equals(instruction.getAddress());
        }
    });
    Assert.assertNotNull(reference);
    provider.deleteTypeInstanceReference(module.getConfiguration().getId(), reference.getAddress().toBigInteger(), reference.getPosition(), reference.getTreeNode().get().getId());
}
Also used : TypeInstanceAddress(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceAddress) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) TypeInstanceReference(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceReference) RawTypeInstanceReference(com.google.security.zynamics.binnavi.disassembly.types.RawTypeInstanceReference) RawTypeInstance(com.google.security.zynamics.binnavi.disassembly.types.RawTypeInstance) TypeInstance(com.google.security.zynamics.binnavi.disassembly.types.TypeInstance) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) Test(org.junit.Test)

Example 72 with INaviView

use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.

the class PostgreSQLVerifyCalcTest method verifyViews.

private static void verifyViews(final INaviModule module) throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException {
    final List<INaviView> views = module.getContent().getViewContainer().getViews();
    final INaviView callgraph = views.get(0);
    assertEquals(null, module.getContent().getViewContainer().getFunction(callgraph));
    assertEquals(ViewType.Native, callgraph.getType());
    assertEquals(GraphType.CALLGRAPH, callgraph.getGraphType());
    callgraph.load();
    callgraph.close();
    for (int i = 1; i < views.size(); i++) {
        final INaviView view = views.get(i);
        final INaviFunction function = module.getContent().getViewContainer().getFunction(view);
        assertEquals(view.getName(), function.getName());
        assertEquals(ViewType.Native, view.getType());
        assertEquals(GraphType.FLOWGRAPH, view.getGraphType());
        assertEquals(view.getNodeCount(), function.getBasicBlockCount());
        assertEquals(view.getEdgeCount(), function.getEdgeCount());
        view.load();
        function.load();
        assertEquals(view.getNodeCount(), function.getBasicBlockCount());
        assertEquals(view.getEdgeCount(), function.getEdgeCount());
        view.close();
        function.close();
    }
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Example 73 with INaviView

use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.

the class PostgreSQLVerifyNotepadTest method verifyViews.

@Test
public void verifyViews() throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    final SQLProvider provider = (SQLProvider) ReflectionHelpers.getField(m_database, "provider");
    final INaviModule module = m_database.getContent().getModules().get(0);
    module.load();
    final List<INaviView> views = module.getContent().getViewContainer().getViews();
    final INaviView callgraph = views.get(0);
    assertEquals(null, module.getContent().getViewContainer().getFunction(callgraph));
    assertEquals(ViewType.Native, callgraph.getType());
    assertEquals(GraphType.CALLGRAPH, callgraph.getGraphType());
    assertEquals(287, callgraph.getNodeCount());
    assertEquals(848, callgraph.getEdgeCount());
    callgraph.load();
    assertEquals(287, callgraph.getNodeCount());
    assertEquals(848, callgraph.getEdgeCount());
    callgraph.close();
    final LinkedHashSet<?> cgListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(CommentManager.get(provider), "listeners"), "m_listeners");
    assertEquals(module.getContent().getFunctionContainer().getFunctions().size() + 1, // the +1 here is the listener in the type instance container.
    cgListeners.size());
    for (int i = 1; i < views.size(); i++) {
        final INaviView view = views.get(i);
        final INaviFunction function = module.getContent().getViewContainer().getFunction(view);
        assertEquals(view.getName(), function.getName());
        assertEquals(ViewType.Native, view.getType());
        assertEquals(GraphType.FLOWGRAPH, view.getGraphType());
        assertEquals(view.getNodeCount(), function.getBasicBlockCount());
        assertEquals(view.getEdgeCount(), function.getEdgeCount());
        view.load();
        function.load();
        assertEquals(view.getNodeCount(), function.getBasicBlockCount());
        assertEquals(view.getEdgeCount(), function.getEdgeCount());
        if (function.getAddress().toBigInteger().equals(BigInteger.valueOf(0x1001929))) {
            assertEquals(view.getNodeCount(), 5);
            assertEquals(view.getEdgeCount(), 6);
        } else if (function.getAddress().toBigInteger().equals(BigInteger.valueOf(16790571))) {
            assertEquals(view.getNodeCount(), 92);
            assertEquals(view.getEdgeCount(), 144);
        } else if (i == 1) {
            assertEquals(view.getNodeCount(), 0);
            assertEquals(view.getEdgeCount(), 0);
        }
        view.close();
        function.close();
    }
    module.close();
}
Also used : LinkedHashSet(java.util.LinkedHashSet) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) SQLProvider(com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) Test(org.junit.Test)

Example 74 with INaviView

use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.

the class PostgreSQLProviderTest method testCModuleFunctionsgetViewsWithAddresses1.

@Test
public void testCModuleFunctionsgetViewsWithAddresses1() throws CouldntLoadDataException, LoadCancelledException {
    final INaviModule module = getProvider().loadModules().get(0);
    module.load();
    final IFilledList<UnrelocatedAddress> addresses = new FilledList<UnrelocatedAddress>();
    List<INaviView> views = PostgreSQLModuleFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), module, addresses, true);
    assertEquals(0, views.size());
    addresses.add(new UnrelocatedAddress(new CAddress(0x10033DCL)));
    views = PostgreSQLModuleFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), module, addresses, true);
    assertEquals(1, views.size());
    addresses.add(new UnrelocatedAddress(new CAddress(0x1003429)));
    views = PostgreSQLModuleFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), module, addresses, true);
    assertEquals(0, views.size());
    views = PostgreSQLModuleFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), module, addresses, false);
    assertEquals(2, views.size());
}
Also used : AbstractSQLProvider(com.google.security.zynamics.binnavi.Database.AbstractSQLProvider) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 75 with INaviView

use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.

the class PostgreSQLProviderTest method testCProjectFunctionsgetViewsWithAddresses1.

@Test
public void testCProjectFunctionsgetViewsWithAddresses1() throws CouldntLoadDataException, LoadCancelledException {
    final INaviProject project = getProvider().loadProjects().get(0);
    project.load();
    final IFilledList<UnrelocatedAddress> addresses = new FilledList<UnrelocatedAddress>();
    List<INaviView> views = PostgreSQLProjectFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), project, addresses, true);
    assertEquals(0, views.size());
    addresses.add(new UnrelocatedAddress(new CAddress(0x10033DCL)));
    views = PostgreSQLProjectFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), project, addresses, true);
    assertEquals(0, views.size());
    addresses.add(new UnrelocatedAddress(new CAddress(0x1003429)));
    views = PostgreSQLProjectFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), project, addresses, true);
    assertEquals(0, views.size());
    views = PostgreSQLProjectFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), project, addresses, false);
    assertEquals(0, views.size());
}
Also used : AbstractSQLProvider(com.google.security.zynamics.binnavi.Database.AbstractSQLProvider) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Aggregations

INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)121 Test (org.junit.Test)54 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)29 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)26 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)18 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)14 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)13 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)11 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)10 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)10 ArrayList (java.util.ArrayList)10 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)9 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)8 HashMap (java.util.HashMap)8 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)7 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)7 CProjectContainer (com.google.security.zynamics.binnavi.disassembly.CProjectContainer)7 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)7 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)7 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)6