Search in sources :

Example 11 with IFilledList

use of com.google.security.zynamics.zylib.types.lists.IFilledList in project binnavi by google.

the class PostgreSQLProviderTest method testCProjectFunctionsgetViewsWithAddresses1.

@Test
public void testCProjectFunctionsgetViewsWithAddresses1() throws CouldntLoadDataException, LoadCancelledException {
    final INaviProject project = getProvider().loadProjects().get(0);
    project.load();
    final IFilledList<UnrelocatedAddress> addresses = new FilledList<UnrelocatedAddress>();
    List<INaviView> views = PostgreSQLProjectFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), project, addresses, true);
    assertEquals(0, views.size());
    addresses.add(new UnrelocatedAddress(new CAddress(0x10033DCL)));
    views = PostgreSQLProjectFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), project, addresses, true);
    assertEquals(0, views.size());
    addresses.add(new UnrelocatedAddress(new CAddress(0x1003429)));
    views = PostgreSQLProjectFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), project, addresses, true);
    assertEquals(0, views.size());
    views = PostgreSQLProjectFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), project, addresses, false);
    assertEquals(0, views.size());
}
Also used : AbstractSQLProvider(com.google.security.zynamics.binnavi.Database.AbstractSQLProvider) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 12 with IFilledList

use of com.google.security.zynamics.zylib.types.lists.IFilledList in project binnavi by google.

the class CPostgreSQLModuleContentTest method testCModuleContentConstructor.

@Test
public void testCModuleContentConstructor() throws LoadCancelledException, CouldntLoadDataException {
    final CModule module = (CModule) getDatabase().getContent().getModules().get(0);
    module.load();
    final ListenerProvider<IModuleListener> listeners = new ListenerProvider<IModuleListener>();
    final CCallgraph callgraph = module.getContent().getNativeCallgraph();
    final IFilledList<INaviFunction> functions = new FilledList<INaviFunction>();
    functions.add(module.getContent().getFunctionContainer().getFunctions().get(0));
    final ICallgraphView nativeCallgraph = module.getContent().getViewContainer().getNativeCallgraphView();
    final ImmutableList<IFlowgraphView> nativeFlowgraphs = module.getContent().getViewContainer().getNativeFlowgraphViews();
    final List<INaviView> customViews = new ArrayList<INaviView>();
    final ImmutableBiMap<INaviView, INaviFunction> viewFunctionMap = new ImmutableBiMap.Builder<INaviView, INaviFunction>().build();
    new Pair<HashMap<INaviView, INaviFunction>, HashMap<INaviFunction, INaviView>>(null, null);
    final IFilledList<TraceList> traces = new FilledList<TraceList>();
    final SectionContainer sections = new SectionContainer(new SectionContainerBackend(getProvider(), module));
    final TypeInstanceContainer instances = new TypeInstanceContainer(new TypeInstanceContainerBackend(getProvider(), module, module.getTypeManager(), sections), getProvider());
    final CModuleContent moduleContent1 = new CModuleContent(module, getProvider(), listeners, callgraph, functions, nativeCallgraph, nativeFlowgraphs, customViews, viewFunctionMap, traces, sections, instances);
    assertNotNull(moduleContent1);
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(null, null, null, null, null, null, null, null, null, null, sections, instances);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, null, null, null, null, null, null, null, null, null, null, null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), null, null, null, null, null, null, null, null, null, null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, null, null, null, null, null, null, null, null, null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, null, null, null, null, null, null, null, null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, functions, null, null, null, null, null, null, null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, functions, nativeCallgraph, null, null, null, null, null, null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, functions, nativeCallgraph, nativeFlowgraphs, null, null, null, null, null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, functions, nativeCallgraph, nativeFlowgraphs, customViews, null, null, null, null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, functions, nativeCallgraph, nativeFlowgraphs, customViews, viewFunctionMap, null, null, null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, functions, nativeCallgraph, nativeFlowgraphs, customViews, viewFunctionMap, traces, null, null);
        fail();
    } catch (final NullPointerException e) {
    }
}
Also used : IFlowgraphView(com.google.security.zynamics.binnavi.disassembly.IFlowgraphView) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) ArrayList(java.util.ArrayList) TypeInstanceContainerBackend(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceContainerBackend) Pair(com.google.security.zynamics.zylib.general.Pair) SectionContainerBackend(com.google.security.zynamics.binnavi.disassembly.types.SectionContainerBackend) CCallgraph(com.google.security.zynamics.binnavi.disassembly.CCallgraph) ICallgraphView(com.google.security.zynamics.binnavi.disassembly.ICallgraphView) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) ImmutableBiMap(com.google.common.collect.ImmutableBiMap) SectionContainer(com.google.security.zynamics.binnavi.disassembly.types.SectionContainer) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) ListenerProvider(com.google.security.zynamics.zylib.general.ListenerProvider) TypeInstanceContainer(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceContainer) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 13 with IFilledList

use of com.google.security.zynamics.zylib.types.lists.IFilledList in project binnavi by google.

the class CTutorialLoader method readTutorials.

/**
   * Loads all tutorial files from the given directory.
   * 
   * @param directory Directory from which the tutorials are loaded.
   * 
   * @return List of tutorials loaded from the tutorial files in the given directory.
   */
public static IFilledList<CTutorial> readTutorials(final String directory) {
    final IFilledList<CTutorial> tutorials = new FilledList<CTutorial>();
    DirUtils.traverse(new File(directory), new IDirectoryTraversalCallback() {

        @Override
        public void entering(final File directory) {
        // Irrelevant
        }

        @Override
        public void leaving(final File directory) {
        // Irrelevant
        }

        @Override
        public void nextFile(final File file) {
            if (file.getAbsolutePath().endsWith("xml")) {
                try {
                    tutorials.add(loadTutorial(file));
                } catch (final ParserConfigurationException e) {
                    CUtilityFunctions.logException(e);
                } catch (final SAXException e) {
                    CUtilityFunctions.logException(e);
                } catch (final IOException e) {
                    CUtilityFunctions.logException(e);
                }
            }
        }
    });
    return tutorials;
}
Also used : FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) File(java.io.File) IDirectoryTraversalCallback(com.google.security.zynamics.zylib.io.IDirectoryTraversalCallback) SAXException(org.xml.sax.SAXException)

Example 14 with IFilledList

use of com.google.security.zynamics.zylib.types.lists.IFilledList in project binnavi by google.

the class CTracesNodeComponent method showRelevantViews.

/**
   * Shows the views that belong to a trace in the table in the lower half of the component.
   *
   * @param trace The trace list.
   *
   * @throws CouldntLoadDataException
   */
private void showRelevantViews(final TraceList trace) throws CouldntLoadDataException {
    final IFilledList<UnrelocatedAddress> addresses = new FilledList<UnrelocatedAddress>();
    for (final ITraceEvent traceEvent : trace) {
        addresses.add(traceEvent.getOffset().getAddress());
    }
    final List<INaviView> views = m_container.getViewsWithAddresses(addresses, false);
    if (m_container instanceof CProjectContainer) {
        for (final INaviModule module : m_container.getModules()) {
            if (module.isLoaded()) {
                views.addAll(module.getViewsWithAddresses(addresses, false));
            }
        }
    }
    m_model.setViews(views);
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) CProjectContainer(com.google.security.zynamics.binnavi.disassembly.CProjectContainer) ITraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent)

Example 15 with IFilledList

use of com.google.security.zynamics.zylib.types.lists.IFilledList in project binnavi by google.

the class CFunctionFilterComponent method createFilter.

@Override
public IFilter<INaviView> createFilter() {
    return new IFilter<INaviView>() {

        @Override
        public boolean checkCondition(final INaviView element) {
            final CFunctionTypePanel typePanel = dialog.getFunctionTypePanel();
            final INaviFunction function = module.getFunction(element);
            return ((typePanel.isShowAdjustorFunctions() && (function.getType() == FunctionType.ADJUSTOR_THUNK)) || (typePanel.isShowImportedFunctions() && (function.getType() == FunctionType.IMPORT)) || (typePanel.isShowLibraryFunctions() && (function.getType() == FunctionType.LIBRARY)) || (typePanel.isShowNormalFunctions() && (function.getType() == FunctionType.NORMAL)) || (typePanel.isShowThunkFunctions() && (function.getType() == FunctionType.THUNK)));
        }

        @Override
        public IFilledList<INaviView> get(final List<INaviView> elements) {
            return new FilledList<INaviView>(CollectionHelpers.filter(elements, new ICollectionFilter<INaviView>() {

                @Override
                public boolean qualifies(final INaviView item) {
                    return checkCondition(item);
                }
            }));
        }
    };
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) IFilter(com.google.security.zynamics.binnavi.Gui.FilterPanel.IFilter) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) ICollectionFilter(com.google.security.zynamics.zylib.types.common.ICollectionFilter) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) List(java.util.List) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Aggregations

FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)15 IFilledList (com.google.security.zynamics.zylib.types.lists.IFilledList)15 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)7 Test (org.junit.Test)7 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)6 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)5 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)4 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)4 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)4 ResultSet (java.sql.ResultSet)4 SQLException (java.sql.SQLException)4 CConnection (com.google.security.zynamics.binnavi.Database.CConnection)3 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)3 Pair (com.google.security.zynamics.zylib.general.Pair)3 ArrayList (java.util.ArrayList)3 AbstractSQLProvider (com.google.security.zynamics.binnavi.Database.AbstractSQLProvider)2 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)2 CBreakpointTableModel (com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.CBreakpointTableModel)2 DebugTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings)2 DebuggerProvider (com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider)2