Search in sources :

Example 1 with INaviReplacement

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

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

the class CCodeNodeParser method createNewOperand.

/**
 * Creates a new operand tree node object from data from a code node provider.
 *
 * @param module The module the loaded function belongs to.
 * @param dataset Provides the operand data.
 *
 * @return The created operand tree node object.
 *
 * @throws ParserException Thrown if not all data for the operand tree node object could be read.
 */
private static OperandTreeNode createNewOperand(final INaviModule module, final ICodeNodeProvider dataset) throws ParserException {
    final int expressionId = dataset.getExpressionTreeId();
    final int type = dataset.getExpressionTreeType();
    final String value = getValue(dataset, type);
    final Integer parentId = dataset.getParentId();
    final String replacementString = dataset.getReplacement();
    final IAddress functionAddress = dataset.getFunctionAddress();
    final Integer typeId = dataset.getSubstitutionTypeId();
    RawTypeSubstitution substitution = null;
    if (typeId != null) {
        substitution = new RawTypeSubstitution(dataset.getInstructionAddress(), dataset.getSubstitutionPosition(), expressionId, typeId, dataset.getSubstitutionPath(), dataset.getSubstitutionOffset());
    }
    final Integer instanceId = dataset.getTypeInstanceId() == null ? null : dataset.getTypeInstanceId();
    final int operandPosition = dataset.getOperandPosition();
    final IAddress address = dataset.getInstructionAddress();
    // The function parse references moves the dataset around quite heavily therefore all direct
    // access to the dataset must be done before.
    final List<CReference> references = parseReferences(expressionId, dataset);
    final INaviReplacement replacement = lookupReplacement(replacementString, module, functionAddress);
    return new OperandTreeNode(expressionId, type, value, getParentId(parentId), replacement, references, substitution, instanceId, operandPosition, address);
}
Also used : INaviReplacement(com.google.security.zynamics.binnavi.disassembly.INaviReplacement) RawTypeSubstitution(com.google.security.zynamics.binnavi.disassembly.types.RawTypeSubstitution) INaviOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode) CReference(com.google.security.zynamics.binnavi.disassembly.CReference) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress)

Aggregations

INaviReplacement (com.google.security.zynamics.binnavi.disassembly.INaviReplacement)2 CFunctionReplacement (com.google.security.zynamics.binnavi.disassembly.CFunctionReplacement)1 CReference (com.google.security.zynamics.binnavi.disassembly.CReference)1 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)1 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)1 INaviOperandTreeNode (com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode)1 RawTypeSubstitution (com.google.security.zynamics.binnavi.disassembly.types.RawTypeSubstitution)1 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)1