Search in sources :

Example 1 with INaviFunction

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

the class CEventTableModel method getValueAt.

@Override
public Object getValueAt(final int row, final int col) {
    final ITraceEvent debugEvent = getEvents().get(row);
    final BreakpointAddress address = debugEvent.getOffset();
    switch(col) {
        case INDEX_COLUMN:
            return row + 1;
        case THREAD_COLUMN:
            return Long.valueOf(debugEvent.getThreadId());
        case MODULE_COLUMN:
            return address.getModule() == null ? "-" : address.getModule().getConfiguration().getName();
        case ADDRESS_COLUMN:
            {
                if (address.getModule() == null) {
                    return address.getAddress().getAddress().toHexString();
                } else {
                    final INaviFunction function = address.getModule().isLoaded() ? address.getModule().getContent().getFunctionContainer().getFunction(address.getAddress().getAddress()) : null;
                    if (function == null) {
                        return address.getAddress().getAddress().toHexString();
                    } else {
                        return function.getName();
                    }
                }
            }
        default:
            throw new IllegalStateException("IE01121: Unknown column");
    }
}
Also used : BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) ITraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent)

Example 2 with INaviFunction

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

the class CTraceFilterExpression method evaluate.

@Override
public boolean evaluate(final CTraceEventWrapper element) {
    final ITraceEvent event = element.unwrap();
    final INaviModule currentModule = event.getOffset().getModule();
    String functionName = "";
    String moduleName = "";
    if (currentModule != null) {
        final INaviFunction function = currentModule.isLoaded() ? currentModule.getContent().getFunctionContainer().getFunction(event.getOffset().getAddress().getAddress()) : null;
        if (function != null) {
            functionName = function.getName();
        }
        moduleName = currentModule.getConfiguration().getName();
    }
    return String.valueOf(event.getThreadId()).contains(m_text) || event.getOffset().getAddress().getAddress().toHexString().contains(m_text) || moduleName.contains(m_text) || functionName.contains(m_text);
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) ITraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent)

Example 3 with INaviFunction

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

the class CEventTableMenu method addOpenFunction.

/**
   * Adds a menu item to open the selected trace.
   *
   * @param parent Parent window of the menu.
   * @param traces The selected traces.
   */
private void addOpenFunction(final Window parent, final List<ITraceEvent> traces) {
    if (traces.size() == 1) {
        final ITraceEvent trace = traces.get(0);
        final INaviModule module = trace.getOffset().getModule();
        if (module.isLoaded()) {
            final INaviFunction function = module.getContent().getFunctionContainer().getFunction(trace.getOffset().getAddress().getAddress());
            if (function != null) {
                final IViewContainer container = graphModel.getViewContainer();
                final INaviView view = container.getView(function);
                if (view != null) {
                    add(new JMenuItem(CActionProxy.proxy(new COpenInLastWindowAction(parent, container, new INaviView[] { view }))));
                    addSeparator();
                }
            }
        }
    }
}
Also used : IViewContainer(com.google.security.zynamics.binnavi.disassembly.views.IViewContainer) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) COpenInLastWindowAction(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Views.Component.Actions.COpenInLastWindowAction) JMenuItem(javax.swing.JMenuItem) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) ITraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent)

Example 4 with INaviFunction

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

the class CViewOpener method showView.

/**
   * Shows a view in a graph window.
   * 
   * @param parent Parent window that is used as the parent of all dialogs.
   * @param viewContainer View container that provides the context in which a view is opened.
   * @param view The view to show.
   * @param window Graph window where the graph is shown. If this value is null, the graph is shown
   *        in a new window.
   */
public static void showView(final Window parent, final IViewContainer viewContainer, final INaviView view, final CGraphWindow window) {
    Preconditions.checkNotNull(parent, "IE00015: Parent argument can not be null");
    Preconditions.checkNotNull(viewContainer, "IE00016: View container argument can not be null");
    Preconditions.checkNotNull(view, "IE00018: View argument can not be null");
    Preconditions.checkState(viewContainer.isLoaded(), "IE00017: View container must be loaded");
    Preconditions.checkState(viewContainer.getViews().contains(view), "IE00019: View is not part of the given view container");
    final INaviFunction function = viewContainer.getFunction(view);
    if (isPureImportedFunction(function)) {
        CMessageBox.showInformation(parent, "Imported functions are not part of a module and can not be opened.\n" + "Note that it is possible to open imported functions once they " + "are forwarded to real functions in other modules.");
        return;
    } else if (isForwardedImportedFunction(function)) {
        // Imported functions must be treated specially, because a forwarded
        // functions could be opened instead of the view.
        showForwardedFunction(parent, viewContainer, view, function, window);
    } else {
        CGraphOpener.showGraph(viewContainer, view, window, parent);
    }
}
Also used : INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Example 5 with INaviFunction

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

the class PostgreSQLCallgraphLoader method loadNodes.

/**
   * Loads the nodes of a call graph.
   * 
   * @param connection Connection to the database.
   * @param callgraphId ID of the call graph view to load.
   * @param functions List of functions in the module whose call graph is loaded.
   * 
   * @return <Call graph nodes, Call graph node IDs => Call graph nodes>
   * 
   * @throws SQLException Thrown if loading the nodes failed.
   */
private static Pair<List<ICallgraphNode>, Map<Integer, CCallgraphNode>> loadNodes(final CConnection connection, final int callgraphId, final Collection<INaviFunction> functions) throws SQLException {
    // TODO: Simplify the return value of this method.
    // For performance reasons, we need a quick way to look up functions by their address.
    final Map<IAddress, INaviFunction> functionMap = getFunctionMap(functions);
    final List<ICallgraphNode> nodes = new ArrayList<ICallgraphNode>();
    final String nodeQuery = "SELECT nodes.id, function FROM " + CTableNames.NODES_TABLE + " AS nodes JOIN " + CTableNames.FUNCTION_NODES_TABLE + " AS function_nodes ON nodes.id = function_nodes.node_id WHERE nodes.view_id = " + callgraphId;
    final ResultSet nodeResult = connection.executeQuery(nodeQuery, true);
    final HashMap<Integer, CCallgraphNode> nodeMap = new HashMap<Integer, CCallgraphNode>();
    try {
        while (nodeResult.next()) {
            final int nodeId = nodeResult.getInt("id");
            final IAddress functionAddress = PostgreSQLHelpers.loadAddress(nodeResult, "function");
            final INaviFunction function = functionMap.get(functionAddress);
            final CCallgraphNode cgnode = new CCallgraphNode(function);
            nodeMap.put(nodeId, cgnode);
            nodes.add(cgnode);
        }
    } finally {
        nodeResult.close();
    }
    return new Pair<List<ICallgraphNode>, Map<Integer, CCallgraphNode>>(nodes, nodeMap);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CCallgraphNode(com.google.security.zynamics.binnavi.disassembly.CCallgraphNode) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) ICallgraphNode(com.google.security.zynamics.binnavi.disassembly.ICallgraphNode) ResultSet(java.sql.ResultSet) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) Pair(com.google.security.zynamics.zylib.general.Pair)

Aggregations

INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)94 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)39 Test (org.junit.Test)38 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)26 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)20 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)16 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)16 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)14 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)14 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)12 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)12 ArrayList (java.util.ArrayList)12 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)11 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)10 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)9 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)9 HashMap (java.util.HashMap)9 CFunctionNode (com.google.security.zynamics.binnavi.disassembly.CFunctionNode)8 COperandTree (com.google.security.zynamics.binnavi.disassembly.COperandTree)8 INaviEdge (com.google.security.zynamics.binnavi.disassembly.INaviEdge)8