Search in sources :

Example 1 with IFlowgraphView

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

the class MockSqlProvider method loadNativeFlowgraphs.

@Override
public ImmutableList<IFlowgraphView> loadNativeFlowgraphs(final CModule module) {
    final IFlowgraphView view = MockCreator.createView(this, module, ViewType.Native);
    flowGraphViews.add(view);
    return new ImmutableList.Builder<IFlowgraphView>().add(view).build();
}
Also used : IFlowgraphView(com.google.security.zynamics.binnavi.disassembly.IFlowgraphView)

Example 2 with IFlowgraphView

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

the class PostgreSQLViewsLoader method checkArguments.

/**
   * Validates arguments.
   * 
   * @param provider Provider argument to validate.
   * @param module Module argument to validate.
   * @param flowgraphs Flowgraphs argument to validate.
   * @param functions Functions argument to validate.
   */
private static void checkArguments(final AbstractSQLProvider provider, final CModule module, final List<IFlowgraphView> flowgraphs, final List<INaviFunction> functions) {
    Preconditions.checkNotNull(provider, "IE00630: Provider argument can not be null");
    Preconditions.checkNotNull(module, "IE00631: Module argument can not be null");
    Preconditions.checkArgument(module.inSameDatabase(provider), "IE00632: Module is not part of this database");
    Preconditions.checkNotNull(flowgraphs, "IE00633: Flowgraphs argument can not be null");
    for (final IFlowgraphView view : flowgraphs) {
        Preconditions.checkNotNull(view, "IE00634: View list contains a null-element");
        Preconditions.checkArgument(view.inSameDatabase(provider), "IE00635: View is not part of this database");
    }
    Preconditions.checkNotNull(functions, "IE00636: Functions argument can not be null");
    for (final INaviFunction function : functions) {
        Preconditions.checkNotNull(function, "IE00637: Function list contains a null-element");
        Preconditions.checkArgument(function.inSameDatabase(provider), "IE00638: Function is not part of this database");
    }
}
Also used : IFlowgraphView(com.google.security.zynamics.binnavi.disassembly.IFlowgraphView) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Example 3 with IFlowgraphView

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

the class CFunctionViewsModel method delete.

@Override
public void delete() {
    m_module.removeListener(m_moduleListener);
    if (m_activeDebugger != null) {
        final BreakpointManager manager = m_activeDebugger.getBreakpointManager();
        manager.removeListener(m_breakpointManagerListener);
    }
    if (m_module.isLoaded()) {
        for (final IFlowgraphView view : m_module.getContent().getViewContainer().getNativeFlowgraphViews()) {
            view.removeListener(m_viewListener);
        }
        for (final INaviFunction function : m_module.getContent().getFunctionContainer().getFunctions()) {
            function.removeListener(m_viewListener);
        }
    }
}
Also used : IFlowgraphView(com.google.security.zynamics.binnavi.disassembly.IFlowgraphView) BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Example 4 with IFlowgraphView

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

the class CModule method load.

@Override
public void load() throws CouldntLoadDataException, LoadCancelledException {
    synchronized (m_loadReporter) {
        if (isLoaded()) {
            return;
        }
        if (!isInitialized()) {
            throw new IllegalStateException("IE02617: The module is not initialized yet");
        }
        m_isLoading = true;
        try {
            if (!m_loadReporter.report(ModuleLoadEvents.Starting)) {
                throw new LoadCancelledException();
            }
            if (!m_loadReporter.report(ModuleLoadEvents.LoadingCallgraphView)) {
                throw new LoadCancelledException();
            }
            final ICallgraphView nativeCallgraph = m_provider.loadNativeCallgraph(this);
            if (!m_loadReporter.report(ModuleLoadEvents.LoadingFlowgraphs)) {
                throw new LoadCancelledException();
            }
            // When loading views, an empty flow graph (imported function) can not
            // be distinguished
            // from an empty call graph. This leads to problems in modules without
            // functions. In
            // these cases, the empty call graph is loaded as an imported function
            // view. This is
            // obviously wrong, so we are correcting this here.
            final ImmutableList<IFlowgraphView> nativeFlowgraphs = nativeCallgraph.getNodeCount() == 0 ? new ImmutableList.Builder<IFlowgraphView>().build() : m_provider.loadNativeFlowgraphs(this);
            if (!m_loadReporter.report(ModuleLoadEvents.LoadingCallgraphViews)) {
                throw new LoadCancelledException();
            }
            final List<ICallgraphView> userCallgraphs = m_provider.loadCallgraphViews(this);
            if (!m_loadReporter.report(ModuleLoadEvents.LoadingFlowgraphViews)) {
                throw new LoadCancelledException();
            }
            final ImmutableList<IFlowgraphView> userFlowgraphs = m_provider.loadFlowgraphs(this);
            if (!m_loadReporter.report(ModuleLoadEvents.LoadingMixedViews)) {
                throw new LoadCancelledException();
            }
            final List<INaviView> userMixedGraphs = m_provider.loadMixedgraphs(this);
            if (!m_loadReporter.report(ModuleLoadEvents.LoadingCallgraph)) {
                throw new LoadCancelledException();
            }
            if (!m_loadReporter.report(ModuleLoadEvents.LoadingFunctions)) {
                throw new LoadCancelledException();
            }
            // Note: the type manager needs to be loaded prior to functions, since a function might
            // have an associated stack frame, which in turn needs the type system.
            typeManager = new TypeManager(new TypeManagerDatabaseBackend(m_provider, this));
            final List<INaviFunction> functions = m_provider.loadFunctions(this, nativeFlowgraphs);
            final ImmutableBiMap<INaviView, INaviFunction> viewFunctionMap = m_provider.loadViewFunctionMapping(nativeFlowgraphs, functions, this);
            final CCallgraph callgraph = m_provider.loadCallgraph(this, nativeCallgraph.getConfiguration().getId(), functions);
            if (!m_loadReporter.report(ModuleLoadEvents.LoadingTraces)) {
                throw new LoadCancelledException();
            }
            final List<TraceList> traces = m_provider.loadTraces(this);
            if (!m_loadReporter.report(ModuleLoadEvents.LoadingGlobalVariables)) {
                throw new LoadCancelledException();
            }
            final List<INaviView> customViews = new ArrayList<INaviView>();
            customViews.addAll(userCallgraphs);
            customViews.addAll(userFlowgraphs);
            customViews.addAll(userMixedGraphs);
            final List<INaviView> currentViews = new ArrayList<INaviView>(nativeFlowgraphs);
            currentViews.addAll(customViews);
            Collections.sort(currentViews, new Comparator<INaviView>() {

                @Override
                public int compare(final INaviView lhs, final INaviView rhs) {
                    return lhs.getConfiguration().getId() - rhs.getConfiguration().getId();
                }
            });
            // Map viewId to corresponding index in currentViews.
            final Map<Integer, Integer> viewIdToIndex = new HashMap<Integer, Integer>();
            for (int i = 0; i < currentViews.size(); ++i) {
                viewIdToIndex.put(currentViews.get(i).getConfiguration().getId(), i);
            }
            if (!m_loadReporter.report(ModuleLoadEvents.LoadingTypes)) {
                throw new LoadCancelledException();
            }
            final SectionContainer sections = new SectionContainer(new SectionContainerBackend(m_provider, this));
            final TypeInstanceContainer typeInstances = new TypeInstanceContainer(new TypeInstanceContainerBackend(m_provider, this, typeManager, sections), m_provider);
            m_content = new CModuleContent(this, m_provider, m_listeners, callgraph, functions, nativeCallgraph, nativeFlowgraphs, customViews, viewFunctionMap, traces, sections, typeInstances);
            typeInstances.initialize();
        } catch (final CouldntLoadDataException e) {
            m_isLoading = false;
            throw e;
        } catch (final LoadCancelledException e) {
            m_isLoading = false;
            throw e;
        } finally {
            m_loadReporter.report(ModuleLoadEvents.Finished);
        }
        for (final IModuleListener listener : m_listeners) {
            try {
                listener.loadedModule(this);
            } catch (final Exception exception) {
                CUtilityFunctions.logException(exception);
            }
        }
        m_isLoading = false;
    }
}
Also used : IFlowgraphView(com.google.security.zynamics.binnavi.disassembly.IFlowgraphView) HashMap(java.util.HashMap) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) ArrayList(java.util.ArrayList) TypeInstanceContainerBackend(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceContainerBackend) SectionContainerBackend(com.google.security.zynamics.binnavi.disassembly.types.SectionContainerBackend) CCallgraph(com.google.security.zynamics.binnavi.disassembly.CCallgraph) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) ICallgraphView(com.google.security.zynamics.binnavi.disassembly.ICallgraphView) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) TypeManagerDatabaseBackend(com.google.security.zynamics.binnavi.disassembly.types.TypeManagerDatabaseBackend) SectionContainer(com.google.security.zynamics.binnavi.disassembly.types.SectionContainer) TypeManager(com.google.security.zynamics.binnavi.disassembly.types.TypeManager) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) TypeInstanceContainer(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceContainer) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Example 5 with IFlowgraphView

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

the class CModule method close.

/**
   * Closes the module.
   *
   * @return True, if the module was closed. False, if the module was vetoed.
   */
@Override
public boolean close() {
    if (!isLoaded()) {
        throw new IllegalStateException("IE00156: Module is not loaded");
    }
    for (final IModuleListener listener : m_listeners) {
        try {
            if (!listener.closingModule(this)) {
                return false;
            }
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
    final ICallgraphView oldNativeCallgraphView = m_content.getViewContainer().getNativeCallgraphView();
    final List<IFlowgraphView> oldFlowgraphs = m_content.getViewContainer().getNativeFlowgraphViews();
    if (!m_content.close()) {
        return false;
    }
    m_content = null;
    for (final IModuleListener listener : m_listeners) {
        try {
            listener.closedModule(this, oldNativeCallgraphView, oldFlowgraphs);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
    return true;
}
Also used : ICallgraphView(com.google.security.zynamics.binnavi.disassembly.ICallgraphView) IFlowgraphView(com.google.security.zynamics.binnavi.disassembly.IFlowgraphView) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)

Aggregations

IFlowgraphView (com.google.security.zynamics.binnavi.disassembly.IFlowgraphView)7 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)5 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)3 ICallgraphView (com.google.security.zynamics.binnavi.disassembly.ICallgraphView)3 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)3 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)2 LoadCancelledException (com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)2 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)2 CCallgraph (com.google.security.zynamics.binnavi.disassembly.CCallgraph)2 SectionContainer (com.google.security.zynamics.binnavi.disassembly.types.SectionContainer)2 SectionContainerBackend (com.google.security.zynamics.binnavi.disassembly.types.SectionContainerBackend)2 TypeInstanceContainer (com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceContainer)2 TypeInstanceContainerBackend (com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceContainerBackend)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ImmutableBiMap (com.google.common.collect.ImmutableBiMap)1 CConnection (com.google.security.zynamics.binnavi.Database.CConnection)1 BreakpointManager (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager)1 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)1 TypeManager (com.google.security.zynamics.binnavi.disassembly.types.TypeManager)1