Search in sources :

Example 56 with INaviModule

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

the class PostgreSQLProviderTest method testCViewLoaderLoadView3.

@Test(expected = NullPointerException.class)
public void testCViewLoaderLoadView3() throws CouldntLoadDataException, LoadCancelledException, CPartialLoadException {
    final INaviModule module = getProvider().loadModules().get(0);
    module.load();
    final CView view = (CView) module.getContent().getViewContainer().getViews().get(224);
    PostgreSQLViewLoader.loadView((AbstractSQLProvider) getProvider(), view, null, null);
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 57 with INaviModule

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

the class PostgreSQLProviderTest method testSave.

@Test
public void testSave() throws CouldntSaveDataException, CouldntLoadDataException, CouldntDeleteException, CPartialLoadException, InternalTranslationException, LoadCancelledException, MaybeNullException {
    final CTagManager tagManager = getProvider().loadTagManager(TagType.NODE_TAG);
    tagManager.addTag(tagManager.getRootTag(), "Node Tag I");
    tagManager.addTag(tagManager.getRootTag(), "Node Tag II");
    final ITreeNode<CTag> tag1 = tagManager.getRootTag().getChildren().get(0);
    final ITreeNode<CTag> tag2 = tagManager.getRootTag().getChildren().get(1);
    final INaviModule module = getProvider().loadModules().get(0);
    module.load();
    final CView view = module.getContent().getViewContainer().createView("Save View", "Save View Description");
    final INaviFunction function = module.getContent().getFunctionContainer().getFunction("sub_1002B87");
    function.load();
    final List<COperandTree> operands = new ArrayList<COperandTree>();
    final COperandTreeNode root1 = module.createOperandExpression("dword", ExpressionType.SIZE_PREFIX);
    final COperandTreeNode child1 = module.createOperandExpression("eax", ExpressionType.REGISTER);
    COperandTreeNode.link(root1, child1);
    final COperandTreeNode root2 = module.createOperandExpression("dword", ExpressionType.SIZE_PREFIX);
    final COperandTreeNode child2 = module.createOperandExpression("16", ExpressionType.IMMEDIATE_INTEGER);
    COperandTreeNode.link(root2, child2);
    final COperandTree operand1 = module.createOperand(root1);
    final COperandTree operand2 = module.createOperand(root2);
    operands.add(operand1);
    operands.add(operand2);
    final Iterable<INaviInstruction> instructions = function.getBasicBlocks().get(0).getInstructions();
    final Iterable<INaviInstruction> instructions2 = function.getBasicBlocks().get(1).getInstructions();
    final CCodeNode codeNode = view.getContent().createCodeNode(function, Lists.newArrayList(instructions));
    codeNode.tagNode(tag1.getObject());
    codeNode.getComments().appendLocalCodeNodeComment("XXX");
    codeNode.getComments().appendLocalInstructionComment(Iterables.getLast(codeNode.getInstructions()), "YYY");
    Iterables.getLast(codeNode.getInstructions()).appendGlobalComment(" GLOBAL INSTRUCTION COMMENT ");
    @SuppressWarnings("unused") final CCodeNode codeNode2 = view.getContent().createCodeNode(null, Lists.newArrayList(instructions2));
    final CFunctionNode functionNode = view.getContent().createFunctionNode(function);
    functionNode.tagNode(tag2.getObject());
    functionNode.appendLocalFunctionComment("ZZZ");
    @SuppressWarnings("unused") final CNaviViewEdge edge = view.getContent().createEdge(codeNode, functionNode, EdgeType.JUMP_UNCONDITIONAL);
    view.save();
    view.close();
    view.load();
    assertEquals(3, view.getGraph().getNodes().size());
    assertEquals(1, view.getGraph().getEdges().size());
    assertTrue(view.getGraph().getNodes().get(0).isTagged(tag1.getObject()));
    assertTrue(view.getGraph().getNodes().get(2).isTagged(tag2.getObject()));
    final CCodeNode loadedCodeNode = (CCodeNode) view.getGraph().getNodes().get(0);
    final CCodeNode loadedCodeNode2 = (CCodeNode) view.getGraph().getNodes().get(1);
    assertEquals("XXX", loadedCodeNode.getComments().getLocalCodeNodeComment().get(0).getComment());
    final INaviInstruction customInstruction = Iterables.getLast(loadedCodeNode.getInstructions());
    assertEquals(" GLOBAL INSTRUCTION COMMENT ", customInstruction.getGlobalComment().get(0).getComment());
    assertEquals("YYY", loadedCodeNode.getComments().getLocalInstructionComment(customInstruction).get(0).getComment());
    final ReilTranslator<INaviInstruction> translator = new ReilTranslator<INaviInstruction>();
    translator.translate(new StandardEnvironment(), loadedCodeNode);
    translator.translate(new StandardEnvironment(), loadedCodeNode2);
    final CFunctionNode loadedFunctionNode = (CFunctionNode) view.getGraph().getNodes().get(2);
    assertEquals("ZZZ", loadedFunctionNode.getLocalFunctionComment().get(0).getComment());
    tagManager.deleteTag(tag1);
    tagManager.deleteTag(tag2);
}
Also used : CFunctionNode(com.google.security.zynamics.binnavi.disassembly.CFunctionNode) COperandTreeNode(com.google.security.zynamics.binnavi.disassembly.COperandTreeNode) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) ArrayList(java.util.ArrayList) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) CView(com.google.security.zynamics.binnavi.disassembly.views.CView) CNaviViewEdge(com.google.security.zynamics.binnavi.disassembly.CNaviViewEdge) ReilTranslator(com.google.security.zynamics.reil.translators.ReilTranslator) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) COperandTree(com.google.security.zynamics.binnavi.disassembly.COperandTree) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) StandardEnvironment(com.google.security.zynamics.reil.translators.StandardEnvironment) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 58 with INaviModule

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

the class PostgreSQLProviderTest method testFunctionFunctionsResolveFunction1.

@Test
public void testFunctionFunctionsResolveFunction1() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
    final INaviModule module = getProvider().loadModules().get(0);
    module.load();
    final INaviFunction function1 = module.getContent().getFunctionContainer().getFunctions().get(0);
    final INaviFunction function2 = module.getContent().getFunctionContainer().getFunctions().get(1);
    PostgreSQLFunctionFunctions.resolveFunction((AbstractSQLProvider) getProvider(), function1, function2);
    PostgreSQLFunctionFunctions.resolveFunction((AbstractSQLProvider) getProvider(), function1, null);
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 59 with INaviModule

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

the class PostgreSQLProviderTest method testCViewFunctionsGetDerivedViews1.

@Test
public void testCViewFunctionsGetDerivedViews1() throws CouldntLoadDataException, LoadCancelledException, CPartialLoadException {
    final INaviModule module = getProvider().loadModules().get(0);
    module.load();
    final List<INaviView> views = module.getContent().getViewContainer().getViews();
    final INaviView view = views.get(264);
    view.load();
    PostgreSQLViewFunctions.getDerivedViews((AbstractSQLProvider) getProvider(), view);
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 60 with INaviModule

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

the class PostgreSQLProviderTest method testCviewSaverSave1.

@Test
public void testCviewSaverSave1() throws CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException, CPartialLoadException {
    final INaviModule module = getProvider().loadModules().get(0);
    module.load();
    final INaviView view = module.getContent().getViewContainer().getViews().get(0);
    PostgreSQLViewFunctions.setName((AbstractSQLProvider) getProvider(), view, "furzel");
    view.load();
    PostgreSQLViewSaver.save((AbstractSQLProvider) getProvider(), (CView) view);
    module.close();
    final INaviModule module2 = getProvider().loadModules().get(0);
    module2.load();
    final INaviView view2 = module2.getContent().getViewContainer().getViews().get(0);
    assertEquals("furzel", view2.getName());
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Aggregations

INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)180 Test (org.junit.Test)105 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)69 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)39 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)39 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)29 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)28 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)28 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)24 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)22 ArrayList (java.util.ArrayList)19 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)18 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)13 BigInteger (java.math.BigInteger)13 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)12 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)11 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)11 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)9 CAddressSpace (com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace)9 COperandTree (com.google.security.zynamics.binnavi.disassembly.COperandTree)9