Search in sources :

Example 16 with INaviFunction

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

the class CCodeNodeMenu method addFunctionOperandMenu.

private void addFunctionOperandMenu(final CGraphModel model, final INaviReplacement replacement) {
    final INaviFunction function = ((CFunctionReplacement) replacement).getFunction();
    final INaviView view = function.getModule().getContent().getViewContainer().getView(function);
    add(new CChangeFunctionNameAction(model.getParent(), view));
    addSeparator();
}
Also used : CChangeFunctionNameAction(com.google.security.zynamics.binnavi.ZyGraph.Menus.Actions.CChangeFunctionNameAction) CFunctionReplacement(com.google.security.zynamics.binnavi.disassembly.CFunctionReplacement) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Example 17 with INaviFunction

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

the class CCodeNodeMenu method addRenameFunctionMenu.

private void addRenameFunctionMenu(final INaviCodeNode codeNode, final CGraphModel model) {
    try {
        final INaviFunction function = codeNode.getParentFunction();
        final INaviView view = function.getModule().getContent().getViewContainer().getView(function);
        add(new CChangeFunctionNameAction(model.getParent(), view));
    } catch (final MaybeNullException e) {
    // no parent function no menu entry we are ok with this.
    }
}
Also used : CChangeFunctionNameAction(com.google.security.zynamics.binnavi.ZyGraph.Menus.Actions.CChangeFunctionNameAction) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) MaybeNullException(com.google.security.zynamics.binnavi.Exceptions.MaybeNullException) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Example 18 with INaviFunction

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

Example 19 with INaviFunction

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

the class ZyCodeNodeBuilder method buildFunctionLine.

/**
   * Builds the function line of a code node. This line gives information about the function from
   * where the code node originally came from.
   * 
   * @param node The node that provides the raw data.
   * @param content The node content where the function line is added.
   * @param modifier Calculates the address strings. This argument can be null.
   */
private static void buildFunctionLine(final INaviCodeNode node, final ZyLabelContent content, final INodeModifier modifier) {
    try {
        final INaviFunction parentFunction = node.getParentFunction();
        final String address = modifier == null ? parentFunction.getAddress().toHexString() : modifier.getAddress(parentFunction.getModule(), new UnrelocatedAddress(parentFunction.getAddress()), true);
        final String name = parentFunction.getName();
        content.addLineContent(new ZyLineContent(address + PADDING_AFTER_FUNCTION_ADDRESS + parentFunction.getModule().getConfiguration().getName() + "::" + name, BOLD_FONT, Lists.newArrayList(new CStyleRunData(0, -1, Color.BLACK)), null));
    } catch (final MaybeNullException exception) {
    // If there is no parent function, the parent function is not shown in the code node.
    }
}
Also used : CStyleRunData(com.google.security.zynamics.zylib.gui.zygraph.realizers.CStyleRunData) MaybeNullException(com.google.security.zynamics.binnavi.Exceptions.MaybeNullException) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Example 20 with INaviFunction

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

the class ZyCodeNodeBuilder method createLines.

/**
   * Creates the instructions lines for a code node.
   * 
   * @param node The node that provides the instructions.
   * @param lines The created lines will be stored here.
   * @param commentsToLineAssociation Information about the required comments is stored here.
   * @param graphSettings Provides settings that influence node formatting.
   * @param modifier Calculates the address strings. This argument can be null.
   * 
   * @return The maximum size in characters of all lines put into the lines list.
   */
private static int createLines(final INaviCodeNode node, final List<Pair<String, List<CStyleRunData>>> lines, final HashMap<Pair<String, List<CStyleRunData>>, ArrayList<CommentContainer>> commentsToLineAssociation, final ZyGraphViewSettings graphSettings, final INodeModifier modifier) {
    int maxLineWidth = 0;
    final Map<INaviInstruction, INaviFunction> instructionToFunctionReferences = CReferenceFinder.getCodeReferenceMap(node);
    for (final INaviInstruction instruction : node.getInstructions()) {
        final Pair<String, List<CStyleRunData>> zyLineContent = ZyInstructionBuilder.buildInstructionLine(instruction, graphSettings, modifier);
        final ArrayList<CommentContainer> commentLineContainerList = new ArrayList<CommentContainer>();
        final List<IComment> localComments = node.getComments().getLocalInstructionComment(instruction);
        if (localComments != null) {
            for (final IComment localComment : localComments) {
                commentLineContainerList.add(new CommentContainer(localComment));
            }
        }
        final List<IComment> globalComments = instruction.getGlobalComment();
        if (globalComments != null) {
            for (final IComment globalComment : globalComments) {
                commentLineContainerList.add(new CommentContainer(globalComment));
            }
        }
        final List<IComment> functionComments = instructionToFunctionReferences.get(instruction) == null ? null : instructionToFunctionReferences.get(instruction).getGlobalComment();
        if (functionComments != null) {
            for (final IComment functionComment : functionComments) {
                commentLineContainerList.add(new CommentContainer(functionComment));
            }
        }
        commentsToLineAssociation.put(zyLineContent, commentLineContainerList);
        final int lineWidth = zyLineContent.first().length();
        if (lineWidth > maxLineWidth) {
            maxLineWidth = lineWidth;
        }
        lines.add(zyLineContent);
    }
    return maxLineWidth;
}
Also used : IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

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