Search in sources :

Example 6 with CStyleRunData

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.CStyleRunData 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 7 with CStyleRunData

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

the class ZyInstructionBuilder method buildAddress.

/**
   * Builds the address of an instruction.
   *
   * @param instruction The instruction in question.
   * @param line String buffer where the address string is added.
   * @param styleRun Style runs list where the formatting information is added.
   * @param modifier Calculates the address string (this argument can be null).
   */
private static void buildAddress(final INaviInstruction instruction, final StringBuffer line, final List<CStyleRunData> styleRun, final INodeModifier modifier) {
    final String normalAddress = instruction.getAddress().toHexString();
    final String address = modifier == null ? normalAddress : modifier.getAddress(instruction);
    line.append(address);
    if (address.equals(normalAddress)) {
        styleRun.add(new CStyleRunData(0, address.length(), ConfigManager.instance().getColorSettings().getAddressColor()));
    } else {
        styleRun.add(new CStyleRunData(0, address.length(), Color.RED));
    }
    line.append(PADDING_AFTER_ADDRESS);
}
Also used : CStyleRunData(com.google.security.zynamics.zylib.gui.zygraph.realizers.CStyleRunData)

Example 8 with CStyleRunData

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

the class ZyInstructionBuilder method buildMnemonic.

/**
   * Builds the mnemonic of an instruction.
   *
   * @param instruction The instruction in question.
   * @param line String buffer where the mnemonic string is added.
   * @param styleRun Style runs list where the formatting information is added.
   */
private static void buildMnemonic(final IInstruction instruction, final StringBuffer line, final List<CStyleRunData> styleRun) {
    final String mnemonic = instruction.getMnemonic();
    styleRun.add(new CStyleRunData(line.length(), mnemonic.length(), ConfigManager.instance().getColorSettings().getMnemonicColor()));
    line.append(Strings.padEnd(mnemonic, MINIMUM_MNEMONIC_SIZE, ' '));
}
Also used : CStyleRunData(com.google.security.zynamics.zylib.gui.zygraph.realizers.CStyleRunData)

Example 9 with CStyleRunData

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.CStyleRunData 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 10 with CStyleRunData

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.CStyleRunData 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

CStyleRunData (com.google.security.zynamics.zylib.gui.zygraph.realizers.CStyleRunData)10 ColorsConfigItem (com.google.security.zynamics.binnavi.config.ColorsConfigItem)3 ZyLineContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)3 List (java.util.List)2 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)1 CDefaultModifier (com.google.security.zynamics.binnavi.ZyGraph.Builders.Modifiers.CDefaultModifier)1 CFunctionReplacement (com.google.security.zynamics.binnavi.disassembly.CFunctionReplacement)1 COperandTreeNode (com.google.security.zynamics.binnavi.disassembly.COperandTreeNode)1 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)1 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)1 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)1 IReplacement (com.google.security.zynamics.zylib.disassembly.IReplacement)1 OperandOrderIterator (com.google.security.zynamics.zylib.disassembly.OperandOrderIterator)1 Color (java.awt.Color)1 ArrayList (java.util.ArrayList)1