Search in sources :

Example 61 with INaviFunction

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

the class PostgreSQLFunctionNotificationParserTest method testFunctionInform3Resolve.

@Test
public void testFunctionInform3Resolve() throws CouldntLoadDataException {
    final INaviFunction forwardFunction = new MockFunction(provider);
    function.setForwardedFunctionInternal(forwardFunction);
    assertTrue(function.isForwarded());
    assertEquals(forwardFunction.getAddress(), function.getForwardedFunctionAddress());
    assertEquals(forwardFunction.getModule().getConfiguration().getId(), function.getForwardedFunctionModuleId());
    final FunctionNotificationContainer container = new FunctionNotificationContainer(module.getConfiguration().getId(), module, function.getAddress(), "UPDATE");
    final PostgreSQLFunctionNotificationParser parser = new PostgreSQLFunctionNotificationParser();
    parser.inform(Lists.newArrayList(container), provider);
    assertFalse(function.isForwarded());
    assertNull(function.getForwardedFunctionAddress());
    assertEquals(0, function.getForwardedFunctionModuleId());
}
Also used : MockFunction(com.google.security.zynamics.binnavi.disassembly.MockFunction) FunctionNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer) PostgreSQLFunctionNotificationParser(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLFunctionNotificationParser) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) Test(org.junit.Test)

Example 62 with INaviFunction

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

the class PostgreSQLProviderTest method testFunctionFunctionsSetDescription.

@Test
public void testFunctionFunctionsSetDescription() throws CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException {
    final INaviModule module1 = getProvider().loadModules().get(0);
    module1.load();
    final INaviFunction function1 = module1.getContent().getFunctionContainer().getFunctions().get(25);
    getProvider().setDescription(function1, "description");
    module1.close();
    final INaviModule module2 = getProvider().loadModules().get(0);
    module2.load();
    final INaviFunction function2 = module2.getContent().getFunctionContainer().getFunctions().get(25);
    assertEquals("description", function2.getDescription());
    module2.close();
}
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 63 with INaviFunction

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

the class PostgreSQLProviderTest method testInstructionFunctionsSetReplacement1.

@Test
public void testInstructionFunctionsSetReplacement1() throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException, MaybeNullException, CouldntSaveDataException {
    final INaviModule module = getProvider().loadModules().get(0);
    module.load();
    final INaviFunction function = module.getContent().getFunctionContainer().getFunction("sub_1004565");
    final INaviView view = module.getContent().getViewContainer().getView(function);
    view.load();
    final IInstruction instruction = Iterables.get(view.getContent().getBasicBlocks().get(0).getInstructions(), 7);
    final IOperandTreeNode node = instruction.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().get(0).getChildren().get(0).getChildren().get(1);
    PostgreSQLInstructionFunctions.setReplacement((AbstractSQLProvider) getProvider(), (COperandTreeNode) node, "replacement4");
    view.close();
    final INaviModule module2 = getProvider().loadModules().get(0);
    module2.load();
    final INaviFunction function2 = module2.getContent().getFunctionContainer().getFunction("sub_1004565");
    final INaviView view2 = module2.getContent().getViewContainer().getView(function2);
    view2.load();
    final IInstruction instruction2 = Iterables.get(view2.getContent().getBasicBlocks().get(0).getInstructions(), 7);
    instruction2.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().get(0).getChildren().get(0).getChildren().get(1);
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) IInstruction(com.google.security.zynamics.zylib.disassembly.IInstruction) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 64 with INaviFunction

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

the class PostgreSQLProviderTest method testInstructionFunctionsAddReference5.

@Test(expected = NullPointerException.class)
public void testInstructionFunctionsAddReference5() 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();
    final IAddress address = instruction.getAddress();
    PostgreSQLInstructionFunctions.addReference(getProvider(), node, address, 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) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 65 with INaviFunction

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

the class PostgreSQLProviderTest method testFunctionFunctionsSetName.

@Test
public void testFunctionFunctionsSetName() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
    INaviModule module1 = getProvider().loadModules().get(0);
    module1.load();
    INaviFunction function1 = module1.getContent().getFunctionContainer().getFunctions().get(25);
    getProvider().setName(function1, "name");
    module1 = getProvider().loadModules().get(0);
    module1.load();
    function1 = module1.getContent().getFunctionContainer().getFunctions().get(25);
    assertEquals("name", function1.getName());
}
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)

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