Search in sources :

Example 16 with INaviOperandTreeNode

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

the class TypeManagerTest method testNotifySubstitutionUpdated.

@Test
public void testNotifySubstitutionUpdated() throws CouldntSaveDataException {
    final IAddress address = new CAddress(0x1000);
    final INaviOperandTreeNode node = new MockOperandTreeNode();
    final TypeSubstitution substitution = typeManager.createTypeSubstitution(node, typeSystem.intType, 0, 0, address);
    final TypeSubstitutionChangedEventCollector events = new TypeSubstitutionChangedEventCollector();
    typeManager.addListener(events);
    typeManager.updateTypeSubstitution(node, substitution, typeSystem.uintType, new ArrayList<TypeMember>(), 0);
    typeManager.updateTypeSubstitution(node, typeSystem.uintType.getId(), new Integer[0], 0);
    final TypeSubstitutionChangedEventCollector expectedEvents = new TypeSubstitutionChangedEventCollector();
    expectedEvents.substitutionsChanged(Sets.newHashSet(substitution));
    expectedEvents.substitutionsChanged(Sets.newHashSet(substitution));
    Assert.assertEquals(expectedEvents, events);
}
Also used : INaviOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode) MockOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 17 with INaviOperandTreeNode

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

the class CFollowInDumpMenu method addFollowInDumpMenu.

/**
 * Checks what follow in dump menus are needed and adds those that are missing.
 *
 * @param menu The popup menu to extend.
 * @param viewModel Debug perspective model that shows the memory.
 * @param debugger Provides the register values.
 * @param activeThread The thread whose register values should be considered.
 * @param module Needed for relocation information.
 * @param treeNode The clicked operand tree node.
 *
 * @return True, if at least one menu was added. False, otherwise.
 */
private static boolean addFollowInDumpMenu(final JPopupMenu menu, final CDebugPerspectiveModel viewModel, final IDebugger debugger, final TargetProcessThread activeThread, final INaviModule module, final COperandTreeNode treeNode) {
    final BigInteger simpleAddress = getSimpleAddress(treeNode, activeThread.getRegisterValues(), debugger, module);
    if ((simpleAddress != null) && needsSimpleFollowMenu(debugger, treeNode, simpleAddress)) {
        menu.add(new CGotoOperandExpressionAction(viewModel, treeNode.getValue(), simpleAddress));
        return true;
    }
    final BigInteger expressionAddress = getExpressionAddress(treeNode, activeThread.getRegisterValues(), debugger, module);
    // Don't show menu twice for instructions like "mov eax, [someSymbol]"
    if ((expressionAddress != null) && !expressionAddress.equals(simpleAddress) && needsAddressExpressionMenu(debugger, treeNode, expressionAddress)) {
        final INaviOperandTreeNode addressExpression = getAddressExpression(treeNode);
        menu.add(new CGotoOperandExpressionAction(viewModel, toString(addressExpression), expressionAddress));
        return true;
    }
    return false;
}
Also used : INaviOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode) CGotoOperandExpressionAction(com.google.security.zynamics.binnavi.ZyGraph.Menus.Actions.CGotoOperandExpressionAction) BigInteger(java.math.BigInteger)

Example 18 with INaviOperandTreeNode

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

the class PostgreSQLTypeInstancesNotificationParserTest method setUp.

@Before
public void setUp() throws NumberFormatException, CouldntSaveDataException, CouldntLoadDataException {
    view = MockViewGenerator.generate(provider, module, function);
    baseType = module.getTypeManager().getTypes().get(0);
    final Section section = module.getContent().getSections().createSection("TEST_SECTION", new CAddress("01000000", 16), new CAddress("0100FFFF", 16), SectionPermission.READ_WRITE_EXECUTE, null);
    final TypeInstanceContainer container = module.getContent().getTypeInstanceContainer();
    instance = container.createInstance("TEST_INSTANCE", null, baseType, section, new Long("11143"));
    final CCodeNode node = view.getBasicBlocks().get(0);
    final INaviInstruction instruction = node.getInstructions().iterator().next();
    final INaviOperandTreeNode operandNode = instruction.getOperands().get(0).getNodes().get(0);
    reference = container.createReference(instruction.getAddress(), 0, operandNode, instance, view);
    assertNotNull(reference);
}
Also used : INaviOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) TypeInstanceContainer(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceContainer) Section(com.google.security.zynamics.binnavi.disassembly.types.Section) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) Before(org.junit.Before)

Example 19 with INaviOperandTreeNode

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

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

the class PostgreSQLProviderTest method testInstructionFunctionSetGlobalReplacement1.

@Test
public void testInstructionFunctionSetGlobalReplacement1() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException, CPartialLoadException, MaybeNullException {
    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(), 4);
    final INaviOperandTreeNode node = (INaviOperandTreeNode) instruction.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().get(0).getChildren().get(0);
    getProvider().setGlobalReplacement(node, "replacement");
    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(), 4);
    instruction2.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().get(0).getChildren().get(0);
}
Also used : INaviOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) 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)

Aggregations

INaviOperandTreeNode (com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode)25 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)9 Test (org.junit.Test)8 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)7 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)7 COperandTree (com.google.security.zynamics.binnavi.disassembly.COperandTree)6 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)6 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)6 IBlockNode (com.google.security.zynamics.binnavi.disassembly.IBlockNode)5 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)5 BigInteger (java.math.BigInteger)4 MockOperandTreeNode (com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode)3 ReferenceType (com.google.security.zynamics.zylib.disassembly.ReferenceType)3 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)2 INaviOperandTree (com.google.security.zynamics.binnavi.disassembly.INaviOperandTree)2 TypeInstanceContainer (com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceContainer)2 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)2 OperandOrderIterator (com.google.security.zynamics.zylib.disassembly.OperandOrderIterator)2 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)1 CGotoOperandExpressionAction (com.google.security.zynamics.binnavi.ZyGraph.Menus.Actions.CGotoOperandExpressionAction)1