Search in sources :

Example 1 with CStyleRunData

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

the class CLineGrayer method grayLine.

/**
 * Grays or ungrays a line in a code node.
 *
 * @param model The model of the graph the node belongs to.
 * @param node The node where the user clicked.
 * @param codeNode The node that provides the raw data for the node.
 * @param y The y location where the user clicked.
 */
private void grayLine(final CGraphModel model, final NaviNode node, final INaviCodeNode codeNode, final double y) {
    final double yPos = y - node.getY();
    final int row = node.positionToRow(yPos);
    final INaviInstruction instruction = CCodeNodeHelpers.lineToInstruction(codeNode, row);
    if (instruction == null) {
        return;
    }
    if (m_grayedInstructions.contains(instruction)) {
        final Pair<String, List<CStyleRunData>> content = ZyInstructionBuilder.buildInstructionLine(instruction, model.getGraph().getSettings(), new CDefaultModifier(model.getGraph().getSettings(), model.getDebuggerProvider()));
        for (final CStyleRunData style : content.second()) {
            node.setColor(row, style.getStart(), style.getLength(), style.getColor());
        }
        m_grayedInstructions.remove(instruction);
    } else {
        node.setColor(row, Color.LIGHT_GRAY);
        m_grayedInstructions.add(instruction);
    }
}
Also used : CStyleRunData(com.google.security.zynamics.zylib.gui.zygraph.realizers.CStyleRunData) List(java.util.List) CDefaultModifier(com.google.security.zynamics.binnavi.ZyGraph.Builders.Modifiers.CDefaultModifier) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Example 2 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 3 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 4 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 5 with CStyleRunData

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

the class ZyOperandBuilder method addCommaSeparator.

/**
 * Adds a comma separator to the created line if necessary.
 *
 * @param line The comma is added to this string.
 * @param styleRuns The style run for the comma is added to this list.
 * @param operands Number of operands used to determine whether a comma is necessary.
 * @param operandIndex Index of the current operand.
 */
private static void addCommaSeparator(final StringBuffer line, final List<CStyleRunData> styleRuns, final List<? extends INaviOperandTree> operands, final int operandIndex) {
    // Separate individual operands with a comma.
    if (operandIndex < operands.size() - 1) {
        styleRuns.add(new CStyleRunData(line.length(), 2, ConfigManager.instance().getColorSettings().getOperandSeparatorColor()));
        line.append(", ");
    }
}
Also used : CStyleRunData(com.google.security.zynamics.zylib.gui.zygraph.realizers.CStyleRunData)

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