Search in sources :

Example 36 with ZyLineContent

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.

the class CInsertKeyBehavior method updateUndoHistory.

@Override
protected void updateUndoHistory() {
    if (isPaste()) {
        if (m_editableObject != null) {
            final int x = getCaretEndPosX();
            final int y = getCaretMouseReleasedY();
            final ZyLineContent lineContent = getLineContent(y);
            final IZyEditableObject lineFragmentObject = lineContent.getLineFragmentObjectAt(x);
            if (lineFragmentObject != null) {
                String text = lineContent.getText().substring(lineFragmentObject.getStart(), lineFragmentObject.getEnd());
                if (isComment(x, y)) {
                    text = getMultiLineComment(y);
                }
                udpateUndolist(getLabelContent(), lineContent.getLineObject().getPersistentModel(), lineFragmentObject, text, m_isAboveComment, m_isBehindComment, m_isLabelComment, getCaretStartPosX(), getCaretMousePressedX(), getCaretMousePressedY(), getCaretEndPosX(), getCaretMouseReleasedX(), getCaretMouseReleasedY());
            }
        }
    }
}
Also used : IZyEditableObject(com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) Point(java.awt.Point)

Example 37 with ZyLineContent

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.

the class CCodeNodeUpdater method generateContent.

@Override
public void generateContent(final IZyNodeRealizer realizer, final ZyLabelContent content) {
    ZyCodeNodeBuilder.buildContent(content, codeNode, graph.getSettings(), nodeModifier);
    for (final INaviInstruction instruction : codeNode.getInstructions()) {
        final INaviModule module = instruction.getModule();
        if ((provider != null) && (provider.getDebugger(module) != null) && graph.getSettings().getDisplaySettings().getShowMemoryAddresses(provider.getDebugger(module))) {
            final int line = CCodeNodeHelpers.instructionToLine(codeNode, instruction);
            if (line != -1) {
                final ZyLineContent lineContent = this.realizer.getNodeContent().getLineContent(line);
                // TODO(timkornau) x64
                lineContent.setTextColor(0, 8, Color.RED);
            }
        }
    }
    // Set highlighting for breakpoints and the instruction pointer.
    final INaviInstruction instruction = codeNode.getInstructions().iterator().next();
    if (instruction != null) {
        final INaviModule module = instruction.getModule();
        final IDebugger debugger = provider.getDebugger(module);
        if (debugger == null) {
            return;
        }
        final BreakpointManager manager = debugger.getBreakpointManager();
        CBreakpointPainter.paintBreakpoints(manager, node, codeNode);
        if (debugger.getProcessManager().getActiveThread() != null) {
            final RelocatedAddress instructionPointer = debugger.getProcessManager().getActiveThread().getCurrentAddress();
            final MemoryModule memoryModule = debugger.getProcessManager().getModule(instructionPointer);
            final UnrelocatedAddress unrelocatedIP = new DefaultAddressConverter(memoryModule.getBaseAddress().getAddress(), module.getConfiguration().getFileBase()).memoryToFile(instructionPointer);
            CDebuggerPainter.updateSingleNodeDebuggerHighlighting(graph, unrelocatedIP, node);
        }
    }
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) DefaultAddressConverter(com.google.security.zynamics.binnavi.debug.debugger.DefaultAddressConverter) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) MemoryModule(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Example 38 with ZyLineContent

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.

the class ZyCodeNodeBuilder method insertLines.

/**
   * Inserts the previously created lines into the content with consideration for the comments.
   * 
   * @param content The content to which the lines are added.
   * @param lines The instruction lines to add to the content.
   * @param comments Information about the instruction comments for each line.
   * @param maxLineWidth The maximum line width of all instruction lines in characters.
   */
private static void insertLines(final ZyLabelContent content, final List<Pair<String, List<CStyleRunData>>> lines, final HashMap<Pair<String, List<CStyleRunData>>, ArrayList<CommentContainer>> comments, final int maxLineWidth) {
    for (final Pair<String, List<CStyleRunData>> lineContent : lines) {
        final ArrayList<CommentContainer> instructionComments = comments.get(lineContent);
        final StringBuilder lineBuilder = new StringBuilder(lineContent.first());
        final List<CStyleRunData> styleRuns = lineContent.second();
        if ((instructionComments == null) || instructionComments.isEmpty()) {
            final ZyLineContent instructionLine = new ZyLineContent(lineBuilder.toString(), NORMAL_FONT, styleRuns, null);
            content.addLineContent(instructionLine);
            continue;
        }
        final String instructionFirstCommentLine = instructionComments.get(0).getCommentingString() != null ? instructionComments.get(0).getCommentingString().get(0) : null;
        if (instructionFirstCommentLine != null) {
            lineBuilder.append(Strings.repeat(" ", (maxLineWidth - lineBuilder.length()) + 1));
            lineBuilder.append(instructionFirstCommentLine);
        }
        final ZyLineContent instructionLine = new ZyLineContent(lineBuilder.toString(), NORMAL_FONT, styleRuns, null);
        if (instructionFirstCommentLine != null) {
            instructionLine.setFont(maxLineWidth + 1, instructionFirstCommentLine.length(), ITALIC_FONT);
            instructionLine.setTextColor(maxLineWidth + 1, instructionFirstCommentLine.length(), Color.BLACK);
            instructionLine.setTextColor(maxLineWidth + 1, instructionComments.get(0).getCommentUserNameLength(), instructionComments.get(0).getCommentColor());
        }
        content.addLineContent(instructionLine);
        boolean firstCommentContainer = true;
        for (final CommentContainer commentContainer : instructionComments) {
            boolean firstCommentLine = true;
            for (final String partialCommentString : commentContainer.getCommentingString()) {
                if (firstCommentContainer) {
                    firstCommentContainer = false;
                    continue;
                }
                final ZyLineContent commentLine = new ZyLineContent(Strings.repeat(" ", maxLineWidth + 1) + partialCommentString, ITALIC_FONT, null);
                commentLine.setTextColor(Color.BLACK);
                if (firstCommentLine) {
                    firstCommentLine = false;
                    commentLine.setTextColor(maxLineWidth + 1, commentContainer.getCommentUserNameLength(), commentContainer.getCommentColor());
                }
                content.addLineContent(commentLine);
            }
        }
    }
}
Also used : CStyleRunData(com.google.security.zynamics.zylib.gui.zygraph.realizers.CStyleRunData) ArrayList(java.util.ArrayList) List(java.util.List) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)

Example 39 with ZyLineContent

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.

the class ZyFunctionNodeBuilder method buildNameLine.

/**
   * Builds the name line of a function node.
   *
   * @param node The function node which provides the raw data.
   * @param content The node content object where the name line is added.
   * @param showFunctionInformation True, to show function information in the node. False, to hide
   *        it.
   */
private static void buildNameLine(final INaviFunctionNode node, final ZyLabelContent content, final boolean showFunctionInformation) {
    final INaviFunction function = node.getFunction();
    String informationString = "";
    if (function.getBasicBlockCount() > 0) {
        final StringBuilder builder = new StringBuilder();
        builder.append(" (");
        builder.append(function.getBasicBlockCount());
        builder.append(" basic block");
        if (function.getBasicBlockCount() > 1) {
            builder.append('s');
        }
        if (function.getEdgeCount() > 0) {
            builder.append(", ");
            builder.append(function.getEdgeCount());
            builder.append(" edge");
            if (function.getEdgeCount() > 1) {
                builder.append('s');
            }
        }
        builder.append(')');
        informationString = builder.toString();
    }
    final ZyLineContent nameLine = new ZyLineContent(function.getName() + informationString, NORMAL_FONT, null);
    content.addLineContent(nameLine);
}
Also used : ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Example 40 with ZyLineContent

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.

the class ZyFunctionNodeBuilder method buildAddressLine.

/**
   * Builds the address line of a function node.
   *
   * @param node The function node which provides the raw data.
   * @param content The node content object where the address line is added.
   * @param modifier
   */
private static void buildAddressLine(final INaviFunctionNode node, final ZyLabelContent content, final INodeModifier modifier) {
    final String module = node.getFunction().getModule().getConfiguration().getName();
    final String standardAddress = node.getFunction().getAddress().toHexString();
    final String address = modifier == null ? standardAddress : modifier.getAddress(node);
    final CStyleRunData styleRun = address.equals(standardAddress) ? new CStyleRunData(0, -1, Color.BLACK) : new CStyleRunData(0, -1, Color.RED);
    final ZyLineContent addressLine = new ZyLineContent(module + "::" + address, BOLD_FONT, Lists.newArrayList(styleRun), null);
    content.addLineContent(addressLine);
}
Also used : CStyleRunData(com.google.security.zynamics.zylib.gui.zygraph.realizers.CStyleRunData) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)

Aggregations

ZyLineContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)56 IZyEditableObject (com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject)24 Point (java.awt.Point)15 GraphSearcher (com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher)8 NaviEdge (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge)8 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)8 ZyNormalNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer)8 Test (org.junit.Test)8 ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)5 CStyleRunData (com.google.security.zynamics.zylib.gui.zygraph.realizers.CStyleRunData)3 IZyNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer)3 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)2 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)2 ArrayList (java.util.ArrayList)2 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)1 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)1 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)1 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)1 DefaultAddressConverter (com.google.security.zynamics.binnavi.debug.debugger.DefaultAddressConverter)1 IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)1