Search in sources :

Example 36 with INaviModule

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

the class PostgreSQLTypesNotificationParser method informExpressionTypesNotification.

/**
   * Informs about necessary state changes related to {@link TypeSubstitution type substitutions}.
   *
   * @param container The {@link TypesNotificationContainer} holding the parsed
   *        {@link PGNotification notification} information.
   * @param provider The {@link SQLProvider} used to access the database with.
   *
   * @throws CouldntLoadDataException if the required information could not be loaded from the
   *         database.
   */
private void informExpressionTypesNotification(final TypesNotificationContainer container, final SQLProvider provider) throws CouldntLoadDataException {
    final INaviModule module = provider.findModule(container.getModuleId());
    final TypeManager typeManager = module.getTypeManager();
    final INaviOperandTreeNode node = findOperandTreeNode(provider, container.getModuleId(), new CAddress(container.getAddress().get()), container.position().get(), container.expressionId().get());
    if (node == null) {
        return;
    }
    if (container.getDatabaseOperation().equals("INSERT")) {
        final RawTypeSubstitution rawSubstitution = provider.loadTypeSubstitution(module, container.getAddress().get(), container.position().get(), container.expressionId().get());
        typeManager.initializeTypeSubstitution(node, rawSubstitution);
    } else if (container.getDatabaseOperation().equals("UPDATE")) {
        final RawTypeSubstitution rawSubstitution = provider.loadTypeSubstitution(module, container.getAddress().get(), container.position().get(), container.expressionId().get());
        typeManager.updateTypeSubstitution(node, rawSubstitution.getBaseTypeId(), rawSubstitution.getPath(), rawSubstitution.getOffset());
    } else if (container.getDatabaseOperation().equals("DELETE")) {
        typeManager.removeTypeSubstitutionInstance(node.getTypeSubstitution());
    } else {
        throw new IllegalStateException("Error: the database operation " + container.getDatabaseOperation() + " is currently not supported.");
    }
}
Also used : INaviOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) TypeManager(com.google.security.zynamics.binnavi.disassembly.types.TypeManager) RawTypeSubstitution(com.google.security.zynamics.binnavi.disassembly.types.RawTypeSubstitution) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 37 with INaviModule

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

the class PostgreSQLViewNotificationParser method parseModuleViewNotification.

/**
   * Parser for a bn_module_views notification. The function uses the moduleViewNotificationPattern
   * to parse the incoming {@link PGNotification} into a {@link ViewNotificationContainer}.
   *
   * @param notification The {@link PGNotification} to parse.
   * @param provider The {@link SQLProvider} to access the database.
   *
   * @return A {@link ViewNotificationContainer} with the parsed information.
   */
private ViewNotificationContainer parseModuleViewNotification(final PGNotification notification, final SQLProvider provider) {
    final Matcher matcher = moduleViewNotificationPattern.matcher(notification.getParameter());
    if (!matcher.find()) {
        throw new IllegalStateException("IE02743: compiled pattern: " + moduleViewNotificationPattern.toString() + " did not match notification: " + notification.getParameter());
    }
    final Integer viewId = Integer.parseInt(matcher.group(3));
    final Optional<INaviView> view = Optional.fromNullable(ViewManager.get(provider).getView(viewId));
    final Optional<Integer> moduleId = Optional.fromNullable(Integer.parseInt(matcher.group(4)));
    final Optional<INaviModule> module = Optional.fromNullable(provider.findModule(moduleId.get()));
    final String databaseOperation = matcher.group(2);
    return new ViewNotificationContainer(viewId, view, moduleId, module, Optional.<INaviProject>absent(), databaseOperation);
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) Matcher(java.util.regex.Matcher) ViewNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.ViewNotificationContainer)

Example 38 with INaviModule

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

the class CCodeNodeMenu method addOperandTreeNodeMenu.

/**
   * Adds menus for the clicked operand.
   *
   * @param model The graph model that provides information about the graph.
   * @param treeNode The clicked operand node.
   * @param extensions The extension menu items for the "Operands" menu.
   * @param instruction The instruction that was clicked.
   * @param node The basic block that contains the clicked instruction.
   */
private void addOperandTreeNodeMenu(final CGraphModel model, final COperandTreeNode treeNode, final NaviNode node, final INaviInstruction instruction, final List<ICodeNodeExtension> extensions) {
    final INaviCodeNode codeNode = (INaviCodeNode) node.getRawNode();
    final INaviModule module = model.getViewContainer().getModules().get(0);
    // We only show the goto address if we have no associated type instance for the given immediate.
    if (treeNode.getType() == ExpressionType.IMMEDIATE_INTEGER && treeNode.getTypeInstanceReferences().isEmpty()) {
        addImmediateOperandMenu(treeNode, module.getContent().getSections(), module);
    }
    if (treeNode.getType() == ExpressionType.REGISTER) {
        addRegisterOperandMenu(model, treeNode, instruction, extensions, codeNode);
    }
    final INaviReplacement replacement = treeNode.getReplacement();
    // precedence over type instances.
    if (!treeNode.getTypeInstanceReferences().isEmpty() && !(replacement instanceof CFunctionReplacement)) {
        addInstanceReferenceMenu(model, treeNode);
    }
    if (replacement instanceof CFunctionReplacement) {
        addFunctionOperandMenu(model, replacement);
    }
}
Also used : CFunctionReplacement(com.google.security.zynamics.binnavi.disassembly.CFunctionReplacement) INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) INaviReplacement(com.google.security.zynamics.binnavi.disassembly.INaviReplacement)

Example 39 with INaviModule

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

the class CCodeNodeMenu method addInstanceReferenceMenu.

private void addInstanceReferenceMenu(final CGraphModel model, final COperandTreeNode treeNode) {
    // We can possibly have more than one reference for a single tree node if we have multiple
    // instances of the same section.
    final INaviModule module = model.getViewContainer().getModules().get(0);
    final List<TypeInstanceReference> references = treeNode.getTypeInstanceReferences();
    add(new ShowTypeInstanceReferencesAction(model.getParent(), references, module));
    add(new GotoTypeInstanceAction(references.get(0).getTypeInstance()));
    add(new RenameTypeInstanceAction(model.getParent(), module.getContent().getTypeInstanceContainer(), references.get(0).getTypeInstance()));
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) TypeInstanceReference(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceReference)

Example 40 with INaviModule

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

the class CBreakpointPainter method paintBreakpoints.

/**
   * Paints breakpoints into a function node.
   * 
   * @param manager The breakpoint manager that provides breakpoint information.
   * @param node The visible BinNavi node where the breakpoint is painted.
   * @param functionNode The function node that contains the raw data for the BinNavi node.
   */
public static void paintBreakpoints(final BreakpointManager manager, final NaviNode node, final INaviFunctionNode functionNode) {
    Preconditions.checkNotNull(manager, "IE02374: Manager argument can not be null");
    Preconditions.checkNotNull(node, "IE02375: Node argument can not be null");
    Preconditions.checkNotNull(functionNode, "IE02376: Code node argument can not be null");
    final INaviFunction function = functionNode.getFunction();
    final INaviModule module = function.getModule();
    final int FUNCTION_BREAKPOINT_LINE = 1;
    final BreakpointAddress address = new BreakpointAddress(module, new UnrelocatedAddress(function.getAddress()));
    if (manager.hasBreakpoint(BreakpointType.REGULAR, address)) {
        node.setHighlighting(CHighlightLayers.BREAKPOINT_LAYER, FUNCTION_BREAKPOINT_LINE, BreakpointManager.getBreakpointColor(manager.getBreakpointStatus(address, BreakpointType.REGULAR)));
    } else {
        // If there is no breakpoint, clear potential older breakpoint line.
        node.clearHighlighting(500, FUNCTION_BREAKPOINT_LINE);
    }
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

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