Search in sources :

Example 71 with INaviFunction

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

the class PostgreSQLProviderTest method testFunctionFunctionsSetDescriptionConstructor2.

@Test(expected = NullPointerException.class)
public void testFunctionFunctionsSetDescriptionConstructor2() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
    final INaviModule module1 = getProvider().loadModules().get(0);
    module1.load();
    final INaviFunction function1 = module1.getContent().getFunctionContainer().getFunctions().get(25);
    getProvider().setDescription(function1, null);
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 72 with INaviFunction

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

the class Module method convertData.

/**
   * Converts internal module data to API module data.
   */
private void convertData() {
    m_traces = new ArrayList<Trace>();
    for (final TraceList trace : m_module.getContent().getTraceContainer().getTraces()) {
        m_traces.add(new Trace(trace));
    }
    m_module.getContent().getTraceContainer().addListener(m_traceListener);
    m_functions = new ArrayList<Function>();
    for (final INaviFunction function : m_module.getContent().getFunctionContainer().getFunctions()) {
        m_functions.add(new Function(this, function));
    }
    for (final Function function : m_functions) {
        m_functionMap.put(function.getNative(), function);
    }
    m_views = new ArrayList<View>();
    for (final INaviView view : m_module.getContent().getViewContainer().getViews()) {
        m_views.add(new View(this, view, m_nodeTagManager, m_viewTagManager));
    }
    createCallgraph();
}
Also used : INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) CView(com.google.security.zynamics.binnavi.disassembly.views.CView) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) IFlowgraphView(com.google.security.zynamics.binnavi.disassembly.IFlowgraphView) ICallgraphView(com.google.security.zynamics.binnavi.disassembly.ICallgraphView)

Example 73 with INaviFunction

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

the class CViewOpener method showForwardedFunction.

/**
   * Shows a forwarded function in a graph window.
   * 
   * @param parent Parent window that is used as the parent of all dialogs.
   * @param container View container that provides the context in which a view is opened.
   * @param view The view to show.
   * @param function The imported function to show.
   * @param window Graph window where the graph is shown. If this value is null, the graph is shown
   *        in a new window.
   */
private static void showForwardedFunction(final Window parent, final IViewContainer container, final INaviView view, final INaviFunction function, final CGraphWindow window) {
    if (container instanceof CModuleContainer) {
        CMessageBox.showInformation(parent, "Please open forwarded views from inside a project.");
        return;
    }
    final IDatabase database = container.getDatabase();
    final int moduleId = function.getForwardedFunctionModuleId();
    final INaviModule forwardedModule = database.getContent().getModule(moduleId);
    if (forwardedModule == null) {
        final String message = "E00019: " + "Forwarded view can not be loaded (Unknown module)";
        final String description = CUtilityFunctions.createDescription("BinNavi could not open the forwarded view because the module of " + "the forwarding target is unknown.", new String[] { "Probably the result of a bug in BinNavi" }, new String[] { "The view can not be opened. Try to update the " + "forwarding target again. Restart BinNavi if the view " + "can still not be opened. Contact the BinNavi support if necessary." });
        NaviErrorDialog.show(parent, message, description);
    } else if (forwardedModule.isLoaded()) {
        final IAddress address = function.getForwardedFunctionAddress();
        final INaviFunction forwardedFunction = forwardedModule.getContent().getFunctionContainer().getFunction(address);
        if (forwardedFunction == null) {
            final String message = "E00020: " + "Forwarded view can not be loaded (Unknown function)";
            final String description = CUtilityFunctions.createDescription("BinNavi could not open the forwarded view because the target function is unknown.", new String[] { "Probably the result of a bug in BinNavi" }, new String[] { "The view can not be opened. Try to update the forwarding target " + "again. Restart BinNavi if the view can still not be opened. Contact the " + "BinNavi support if necessary." });
            NaviErrorDialog.show(parent, message, description);
        } else {
            final INaviView forwardedView = forwardedModule.getContent().getViewContainer().getView(forwardedFunction);
            if (forwardedView == null) {
                final String message = "E00107: " + "Forwarded view can not be loaded (Unknown view)";
                final String description = CUtilityFunctions.createDescription("BinNavi could not open the forwarded view because the target view is unknown.", new String[] { "Probably the result of a bug in BinNavi" }, new String[] { "The view can not be opened. Try to update the forwarding target " + "again. Restart BinNavi if the view can still not be opened. Contact the " + "BinNavi support if necessary." });
                NaviErrorDialog.show(parent, message, description);
            } else {
                CGraphOpener.showGraph(container, forwardedView, window, parent);
            }
        }
    } else {
        if (CMessageBox.showYesNoQuestion(parent, "The view can not be opened because it is forwarded to an unloaded module.\n\n" + "Do you want to load the forwarded module now?") == JOptionPane.YES_OPTION) {
            CModuleLoader.loadModule(parent, forwardedModule);
            if (forwardedModule.isLoaded()) {
                // Just call this function recursively now that the module is loaded.
                showForwardedFunction(parent, container, view, function, window);
            }
        }
    }
}
Also used : IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) CModuleContainer(com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress)

Example 74 with INaviFunction

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

the class CCallgraphCombiner method createCombinedCallgraph.

/**
   * Combines the call graphs of the modules of an address space.
   * 
   * @param project The project where the combined view is created.
   * @param addressSpace Provides the modules whose call graphs are combined.
   * 
   * @return The view that contains the combined call graph.
   */
public static INaviView createCombinedCallgraph(final INaviProject project, final INaviAddressSpace addressSpace) {
    final INaviView view = project.getContent().createView("Combined Callgraph", "");
    final Map<INaviFunction, CFunctionNode> nodeMap = new HashMap<INaviFunction, CFunctionNode>();
    final Map<INaviFunction, INaviFunction> resolvedMap = new HashMap<INaviFunction, INaviFunction>();
    final List<INaviModule> modules = addressSpace.getContent().getModules();
    // functions that are not forwarded.
    for (final INaviModule module : modules) {
        final CCallgraph callgraph = module.getContent().getNativeCallgraph();
        for (final ICallgraphNode callgraphNode : callgraph) {
            final INaviFunction function = callgraphNode.getFunction();
            final INaviFunction resolvedFunction = getResolvedFunction(function, modules);
            if (resolvedFunction == null) {
                final CFunctionNode node = view.getContent().createFunctionNode(function);
                node.setColor(CFunctionNodeColorizer.getFunctionColor(function.getType()));
                nodeMap.put(function, node);
            } else {
                resolvedMap.put(function, resolvedFunction);
            }
        }
    }
    // for the forwarded functions.
    for (final INaviModule module : modules) {
        final CCallgraph callgraph = module.getContent().getNativeCallgraph();
        for (final ICallgraphEdge callgraphEdge : callgraph.getEdges()) {
            final INaviFunction source = resolvedMap.containsKey(callgraphEdge.getSource().getFunction()) ? resolvedMap.get(callgraphEdge.getSource().getFunction()) : callgraphEdge.getSource().getFunction();
            final INaviFunction target = resolvedMap.containsKey(callgraphEdge.getTarget().getFunction()) ? resolvedMap.get(callgraphEdge.getTarget().getFunction()) : callgraphEdge.getTarget().getFunction();
            view.getContent().createEdge(nodeMap.get(source), nodeMap.get(target), EdgeType.JUMP_UNCONDITIONAL);
        }
    }
    return view;
}
Also used : ICallgraphEdge(com.google.security.zynamics.binnavi.disassembly.ICallgraphEdge) CFunctionNode(com.google.security.zynamics.binnavi.disassembly.CFunctionNode) ICallgraphNode(com.google.security.zynamics.binnavi.disassembly.ICallgraphNode) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) HashMap(java.util.HashMap) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) CCallgraph(com.google.security.zynamics.binnavi.disassembly.CCallgraph)

Example 75 with INaviFunction

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

the class CFunctionHelpers method resolveFunction.

/**
   * Shows a dialog where the user can resolve a function.
   *
   * @param parent Parent window used for dialogs.
   * @param database Database the function belongs to.
   * @param function Function to be forwarded to another module.
   */
public static void resolveFunction(final Window parent, final IDatabase database, final INaviFunction function) {
    final CFunctionSelectionDialog dlg = new CFunctionSelectionDialog(parent, database);
    GuiHelper.centerChildToParent(parent, dlg, true);
    dlg.setVisible(true);
    final INaviFunction selectedFunction = dlg.getSelectedFunction();
    if (selectedFunction != null) {
        try {
            function.setForwardedFunction(selectedFunction);
        } catch (final CouldntSaveDataException e) {
            CUtilityFunctions.logException(e);
        }
    }
}
Also used : CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CFunctionSelectionDialog(com.google.security.zynamics.binnavi.Gui.FunctionSelection.CFunctionSelectionDialog) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

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