Search in sources :

Example 36 with INaviCodeNode

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

the class GlobalCodeNodeCommentSynchronizer method updateOpenViews.

/**
 * Pushes a new global code node comment to all open views.
 *
 * @param module The module whose views require updating.
 * @param codeNode The code node that has the new comment.
 * @param comments The new comment of the code node.
 *
 * @throws CouldntSaveDataException Thrown if updating the code node comments failed.
 */
public static void updateOpenViews(final INaviModule module, final INaviCodeNode codeNode, final ArrayList<IComment> comments) throws CouldntSaveDataException {
    if (module.isLoaded()) {
        final List<INaviCodeNode> nodelist = new ArrayList<INaviCodeNode>();
        for (final INaviView view : module.getContent().getViewContainer().getViews()) {
            if (view.isLoaded()) {
                nodelist.addAll(collectNodes(view, codeNode));
            }
        }
        final List<IComment> codeNodeComments = codeNode.getComments().getGlobalCodeNodeComment();
        for (final INaviCodeNode currentCodeNode : nodelist) {
            final List<IComment> currentNodeComments = currentCodeNode.getComments().getGlobalCodeNodeComment();
            if (codeNodeComments.equals(currentNodeComments)) {
                continue;
            } else {
                currentCodeNode.getComments().initializeGlobalCodeNodeComment(comments);
            }
        }
    }
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) ArrayList(java.util.ArrayList)

Example 37 with INaviCodeNode

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

the class CGlobalEdgeCommentSynchronizer method getModules.

/**
 * Returns the modules the nodes of the edge belong to.
 *
 * @param edge The edge to check.
 *
 * @return Source module and target module of the edge.
 *
 * @throws MaybeNullException Thrown if the edge does not have source module or target module.
 */
private static Pair<INaviModule, INaviModule> getModules(final INaviEdge edge) throws MaybeNullException {
    INaviModule srcModule = null;
    INaviModule tarModule = null;
    if (edge.getSource() instanceof INaviCodeNode) {
        srcModule = ((INaviCodeNode) edge.getSource()).getParentFunction().getModule();
    } else if (edge.getSource() instanceof INaviFunctionNode) {
        srcModule = ((INaviFunctionNode) edge.getSource()).getFunction().getModule();
    }
    if (edge.getTarget() instanceof INaviCodeNode) {
        tarModule = ((INaviCodeNode) edge.getTarget()).getParentFunction().getModule();
    } else if (edge.getTarget() instanceof INaviFunctionNode) {
        tarModule = ((INaviFunctionNode) edge.getTarget()).getFunction().getModule();
    }
    return new Pair<INaviModule, INaviModule>(srcModule, tarModule);
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) INaviFunctionNode(com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode) Pair(com.google.security.zynamics.zylib.general.Pair)

Example 38 with INaviCodeNode

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

the class BreakpointableNodeCounter method next.

@Override
public IterationMode next(final NaviNode node) {
    final INaviViewNode viewNode = node.getRawNode();
    if (viewNode instanceof INaviCodeNode) {
        final INaviCodeNode codeNode = (INaviCodeNode) viewNode;
        final INaviInstruction instruction = Iterables.getFirst(codeNode.getInstructions(), null);
        final INaviModule module = instruction.getModule();
        final BreakpointAddress address = new BreakpointAddress(module, new UnrelocatedAddress(instruction.getAddress()));
        if (EchoBreakpointCollector.isBlocked(breakpointManager, address)) {
            return IterationMode.CONTINUE;
        }
        ++breakpointAbleNodeCount;
    } else if (viewNode instanceof INaviFunctionNode) {
        final INaviFunctionNode functionNode = (INaviFunctionNode) viewNode;
        final INaviModule module = functionNode.getFunction().getModule();
        final BreakpointAddress address = new BreakpointAddress(module, new UnrelocatedAddress(functionNode.getFunction().getAddress()));
        if (EchoBreakpointCollector.isBlocked(breakpointManager, address)) {
            return IterationMode.CONTINUE;
        }
        ++breakpointAbleNodeCount;
    }
    return IterationMode.CONTINUE;
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviFunctionNode(com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Example 39 with INaviCodeNode

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

the class EchoBreakpointCollector method next.

@Override
public IterationMode next(final NaviNode node) {
    final INaviViewNode viewNode = node.getRawNode();
    if (viewNode instanceof INaviCodeNode) {
        final INaviCodeNode codeNode = (INaviCodeNode) viewNode;
        final INaviInstruction instruction = Iterables.getFirst(codeNode.getInstructions(), null);
        final INaviModule module = instruction.getModule();
        final BreakpointAddress address = new BreakpointAddress(module, new UnrelocatedAddress(instruction.getAddress()));
        if (isBlocked(manager, address)) {
            return IterationMode.CONTINUE;
        }
        NaviLogger.info("Adding Echo breakpoint %s to the active list", address.getAddress().getAddress().toHexString());
        // Add the echo breakpoint to the list of active echo breakpoints
        echoBreakpointAbleAddresses.add(address);
    } else if (viewNode instanceof INaviFunctionNode) {
        final INaviFunctionNode functionNode = (INaviFunctionNode) viewNode;
        final INaviModule module = functionNode.getFunction().getModule();
        final BreakpointAddress address = new BreakpointAddress(module, new UnrelocatedAddress(functionNode.getFunction().getAddress()));
        if (isBlocked(manager, address)) {
            return IterationMode.CONTINUE;
        }
        NaviLogger.info("Adding Echo breakpoint %s to the active list", address.getAddress().getAddress().toHexString());
        // Add the echo breakpoint to the list of active echo breakpoints
        echoBreakpointAbleAddresses.add(address);
    }
    return IterationMode.CONTINUE;
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviFunctionNode(com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Example 40 with INaviCodeNode

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

the class PostgreSQLTextNodeCommentTests method setupTextNode.

private INaviTextNode setupTextNode() throws CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
    final INaviModule module = getProvider().loadModules().get(1);
    module.load();
    final INaviFunction function = module.getContent().getFunctionContainer().getFunction("SetCommState");
    final INaviView view = module.getContent().getViewContainer().getView(function);
    view.load();
    final INaviCodeNode codeNode = view.getContent().getBasicBlocks().get(5);
    final INaviTextNode textNode = view.getContent().createTextNode(null);
    view.getContent().createEdge(codeNode, textNode, EdgeType.TEXTNODE_EDGE);
    final ZyGraph graph = CGraphBuilder.buildGraph(view);
    globalView = graph.saveAs(new CModuleContainer(getDatabase(), module), " TEST TEXT NODE COMMENTS ", " TESTING TEXT NODE COMMENTS ");
    INaviTextNode savedTextNode = null;
    for (final INaviViewNode node : globalView.getGraph().getNodes()) {
        if (node instanceof INaviTextNode) {
            savedTextNode = (INaviTextNode) node;
        }
    }
    return savedTextNode;
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) INaviTextNode(com.google.security.zynamics.binnavi.disassembly.INaviTextNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) CModuleContainer(com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Aggregations

INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)70 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)25 Test (org.junit.Test)23 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)21 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)18 INaviFunctionNode (com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode)17 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)14 ArrayList (java.util.ArrayList)13 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)12 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)12 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)11 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)9 INaviEdge (com.google.security.zynamics.binnavi.disassembly.INaviEdge)9 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)9 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)9 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)8 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)8 CodeNodeCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.CodeNodeCommentNotificationContainer)6 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)5 CommentNotification (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification)5