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();
}
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);
}
}
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);
}
}
Aggregations