Search in sources :

Example 51 with INaviFunction

use of com.google.security.zynamics.binnavi.disassembly.INaviFunction 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 52 with INaviFunction

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

the class PostgreSQLVerifyNotepadTest method verifyReferences.

@Test
public void verifyReferences() throws CouldntLoadDataException, LoadCancelledException {
    final INaviModule module = m_database.getContent().getModules().get(0);
    module.load();
    final INaviFunction function = module.getContent().getFunctionContainer().getFunction(new CAddress(BigInteger.valueOf(0x01006F10)));
    function.load();
    final List<IBlockNode> blocks = function.getBasicBlocks();
    final IBlockNode block = blocks.get(12);
    assertEquals(BigInteger.valueOf(0x100702B), block.getAddress().toBigInteger());
    final Iterable<INaviInstruction> instructions = block.getInstructions();
    assertEquals(1, Iterables.get(instructions, 10).getOperands().get(0).getRootNode().getChildren().get(0).getReferences().size());
    module.close();
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) IBlockNode(com.google.security.zynamics.binnavi.disassembly.IBlockNode) 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 53 with INaviFunction

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

the class PostgreSQLProviderTest method testInstructionFunctionsDeleteReference4.

@Test
public void testInstructionFunctionsDeleteReference4() throws CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException, CouldntDeleteException, MaybeNullException {
    final INaviModule module = getProvider().loadModules().get(1);
    module.load();
    final INaviFunction function = module.getContent().getFunctionContainer().getFunction("DelayLoadFailureHook");
    function.load();
    final IBlockNode basicBlock = function.getBasicBlocks().get(0);
    final INaviInstruction instruction = Iterables.get(basicBlock.getInstructions(), 1);
    final COperandTree tree = instruction.getOperands().get(0);
    final INaviOperandTreeNode node = tree.getRootNode();
    final IAddress address = instruction.getAddress();
    final ReferenceType type = ReferenceType.DATA;
    final int references = node.getReferences().size();
    PostgreSQLInstructionFunctions.addReference(getProvider(), node, address, type);
    final INaviModule module2 = getProvider().loadModules().get(1);
    module2.load();
    final INaviFunction function2 = module2.getContent().getFunctionContainer().getFunction("DelayLoadFailureHook");
    function2.load();
    final IBlockNode basicBlock2 = function2.getBasicBlocks().get(0);
    final INaviInstruction instruction2 = Iterables.get(basicBlock2.getInstructions(), 1);
    final COperandTree tree2 = instruction2.getOperands().get(0);
    final INaviOperandTreeNode node2 = tree2.getRootNode();
    assertEquals(references + 1, node2.getReferences().size());
    PostgreSQLInstructionFunctions.deleteReference(getProvider(), node2, address, type);
    final INaviModule module3 = getProvider().loadModules().get(1);
    module3.load();
    final INaviFunction function3 = module3.getContent().getFunctionContainer().getFunction("DelayLoadFailureHook");
    function3.load();
    final IBlockNode basicBlock3 = function3.getBasicBlocks().get(0);
    final INaviInstruction instruction3 = Iterables.get(basicBlock3.getInstructions(), 1);
    final COperandTree tree3 = instruction3.getOperands().get(0);
    final INaviOperandTreeNode node3 = tree3.getRootNode();
    assertEquals(references, node3.getReferences().size());
}
Also used : INaviOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) IBlockNode(com.google.security.zynamics.binnavi.disassembly.IBlockNode) COperandTree(com.google.security.zynamics.binnavi.disassembly.COperandTree) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) ReferenceType(com.google.security.zynamics.zylib.disassembly.ReferenceType) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 54 with INaviFunction

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

the class PostgreSQLProviderTest method testInstructionFunctionsAddReference4.

@Test(expected = NullPointerException.class)
public void testInstructionFunctionsAddReference4() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
    final INaviModule module = getProvider().loadModules().get(1);
    module.load();
    final INaviFunction function = module.getContent().getFunctionContainer().getFunctions().get(1800);
    function.load();
    final IBlockNode basicBlock = function.getBasicBlocks().get(0);
    final INaviInstruction instruction = Iterables.get(basicBlock.getInstructions(), 1);
    final COperandTree tree = instruction.getOperands().get(0);
    final INaviOperandTreeNode node = tree.getRootNode();
    PostgreSQLInstructionFunctions.addReference(getProvider(), node, null, null);
}
Also used : INaviOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) IBlockNode(com.google.security.zynamics.binnavi.disassembly.IBlockNode) COperandTree(com.google.security.zynamics.binnavi.disassembly.COperandTree) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 55 with INaviFunction

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

the class CModuleTest method test_C_getFunction2.

@Test
public void test_C_getFunction2() throws CouldntLoadDataException, LoadCancelledException {
    try {
        m_module.getContent().getViewContainer().getFunction((INaviView) null);
        fail();
    } catch (final NullPointerException exception) {
    }
    m_module.load();
    int counter = 0;
    final List<INaviFunction> functions = m_module.getContent().getFunctionContainer().getFunctions();
    for (final INaviView view : m_module.getContent().getViewContainer().getNativeFlowgraphViews()) {
        assertEquals(functions.get(counter), m_module.getContent().getViewContainer().getFunction(view));
        counter++;
    }
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) Test(org.junit.Test)

Aggregations

INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)94 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)39 Test (org.junit.Test)38 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)26 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)20 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)16 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)16 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)14 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)14 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)12 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)12 ArrayList (java.util.ArrayList)12 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)11 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)10 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)9 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)9 HashMap (java.util.HashMap)9 CFunctionNode (com.google.security.zynamics.binnavi.disassembly.CFunctionNode)8 COperandTree (com.google.security.zynamics.binnavi.disassembly.COperandTree)8 INaviEdge (com.google.security.zynamics.binnavi.disassembly.INaviEdge)8