Search in sources :

Example 1 with CFunctionReplacement

use of com.google.security.zynamics.binnavi.disassembly.CFunctionReplacement 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 2 with CFunctionReplacement

use of com.google.security.zynamics.binnavi.disassembly.CFunctionReplacement 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 3 with CFunctionReplacement

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

the class ZyOperandBuilder method addOperand.

/**
   * Adds an operand to the instruction line.
   *
   * @param line The operand is added to this string.
   * @param styleRuns The style run for the operand is added to this list.
   * @param treeNode Provides the operand information.
   * @param modifier Calculates the address string (this argument can be null).
   */
private static void addOperand(final StringBuffer line, final List<CStyleRunData> styleRuns, final COperandTreeNode treeNode, final INodeModifier modifier) {
    final ColorsConfigItem colors = ConfigManager.instance().getColorSettings();
    final String typeSubstitution = getTypeSubstitution(treeNode);
    if (!typeSubstitution.isEmpty()) {
        // TODO(jannewger): we might want to introduce an additional setting so the user is able to
        // customize the way types are displayed.
        styleRuns.add(new CStyleRunData(line.length(), typeSubstitution.length(), colors.getVariableColor(), treeNode));
        line.append(typeSubstitution);
        return;
    }
    final IReplacement replacement = treeNode.getDisplayStyle() == OperandDisplayStyle.OFFSET ? treeNode.getReplacement() : null;
    // Colorize the current part of the operand
    if (replacement == null) {
        final Color color = getOperandColor(treeNode.getType());
        final String value = adjustValue(treeNode, modifier);
        styleRuns.add(new CStyleRunData(line.length(), value.length(), color, treeNode));
        line.append(value);
    } else {
        final String replacementString = determineReplacementString(treeNode, replacement);
        if (replacementString.equalsIgnoreCase("")) {
            final Color color = getOperandColor(treeNode.getType());
            final String value = adjustValue(treeNode, modifier);
            styleRuns.add(new CStyleRunData(line.length(), value.length(), color, treeNode));
            line.append(value);
            return;
        }
        if (treeNode.getType() == ExpressionType.IMMEDIATE_INTEGER) {
            if (replacement instanceof CFunctionReplacement) {
                styleRuns.add(new CStyleRunData(line.length(), replacementString.length(), colors.getFunctionColor(), treeNode));
            } else {
                styleRuns.add(new CStyleRunData(line.length(), replacementString.length(), colors.getVariableColor(), treeNode));
            }
        } else {
            final Color color = getOperandColor(treeNode.getType());
            styleRuns.add(new CStyleRunData(line.length(), replacementString.length(), color, treeNode));
        }
        line.append(replacementString);
    }
}
Also used : ColorsConfigItem(com.google.security.zynamics.binnavi.config.ColorsConfigItem) CFunctionReplacement(com.google.security.zynamics.binnavi.disassembly.CFunctionReplacement) CStyleRunData(com.google.security.zynamics.zylib.gui.zygraph.realizers.CStyleRunData) Color(java.awt.Color) IReplacement(com.google.security.zynamics.zylib.disassembly.IReplacement)

Aggregations

CFunctionReplacement (com.google.security.zynamics.binnavi.disassembly.CFunctionReplacement)3 CChangeFunctionNameAction (com.google.security.zynamics.binnavi.ZyGraph.Menus.Actions.CChangeFunctionNameAction)1 ColorsConfigItem (com.google.security.zynamics.binnavi.config.ColorsConfigItem)1 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)1 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)1 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)1 INaviReplacement (com.google.security.zynamics.binnavi.disassembly.INaviReplacement)1 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)1 IReplacement (com.google.security.zynamics.zylib.disassembly.IReplacement)1 CStyleRunData (com.google.security.zynamics.zylib.gui.zygraph.realizers.CStyleRunData)1 Color (java.awt.Color)1