Search in sources :

Example 71 with INaviModule

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

the class PostgreSQLProviderTest method testSetDescription1.

@Test
public void testSetDescription1() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
    final INaviProject project = getProvider().loadProjects().get(0);
    final CAddressSpace addressSpace = getProvider().createAddressSpace(project, "SOME_OTHER_ADDRESS_SPACE");
    final INaviModule module = getProvider().loadModules().get(0);
    module.load();
    final CFunction function = (CFunction) module.getContent().getFunctionContainer().getFunctions().get(0);
    final CView view = (CView) module.getContent().getViewContainer().getViews().get(0);
    final CTagManager tagManager = getProvider().loadTagManager(TagType.VIEW_TAG);
    final ITreeNode<CTag> tag = tagManager.getRootTag().getChildren().get(0);
    getProvider().setDescription(addressSpace, "New Description");
    getProvider().setDescription(function, "New Description");
    getProvider().setDescription(module, "New Description");
    getProvider().setDescription(project, "New Description");
    getProvider().setDescription(tag.getObject(), "New Description");
    getProvider().setDescription(module.getContent().getTraceContainer().getTraces().get(0), "New Description");
    getProvider().setDescription(view, "New Description");
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 72 with INaviModule

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

the class PostgreSQLProviderTestSetup method testCreateViewModule4.

@Test
public void testCreateViewModule4() throws CouldntLoadDataException, CouldntSaveDataException, CPartialLoadException, LoadCancelledException {
    final INaviModule module = getProvider().loadModules().get(0);
    module.load();
    final INaviView view = module.getContent().getViewContainer().getViews().get(223);
    view.load();
    final CView newView = getProvider().createView(module, view, "Module View Name", "Module View Description");
    assertEquals("Module View Name", newView.getName());
    assertEquals("Module View Description", newView.getConfiguration().getDescription());
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 73 with INaviModule

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

the class PostgreSQLProviderTestSetup method testCreateTraceModule4.

@Test
public void testCreateTraceModule4() throws CouldntSaveDataException, CouldntLoadDataException {
    final INaviModule module = getProvider().loadModules().get(0);
    final TraceList trace = getProvider().createTrace(module, "Trace Name", "Trace Description");
    assertEquals("Trace Name", trace.getName());
    assertEquals("Trace Description", trace.getDescription());
    assertEquals(0, trace.getEventCount());
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 74 with INaviModule

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

the class CDatabase method load.

@Override
public void load() throws CouldntLoadDataException, InvalidDatabaseVersionException, LoadCancelledException {
    Preconditions.checkArgument(isConnected(), "IE00686: Not connected to the database");
    try {
        if (!loadReporter.report(LoadEvents.LOADING_DATABASE)) {
            throw new LoadCancelledException();
        }
        if (!loadReporter.report(LoadEvents.DETERMINING_DATABASE_VERSION)) {
            throw new LoadCancelledException();
        }
        final DatabaseVersion databaseVersion = provider.getDatabaseVersion();
        final DatabaseVersion currentVersion = new DatabaseVersion(Constants.PROJECT_VERSION);
        if ((databaseVersion.compareTo(currentVersion) != 0) && currentVersion.needsUpgrading(databaseVersion)) {
            throw new InvalidDatabaseVersionException(databaseVersion);
        }
        if (!loadReporter.report(LoadEvents.LOADING_USERS)) {
            throw new LoadCancelledException();
        }
        loadUserManager();
        if (!loadReporter.report(LoadEvents.LOADING_VIEW_TAGS)) {
            throw new LoadCancelledException();
        }
        final CTagManager viewTagManager = loadViewTagManager();
        if (!loadReporter.report(LoadEvents.LOADING_NODE_TAGS)) {
            throw new LoadCancelledException();
        }
        final CTagManager nodeTagManager = loadNodeTagManager();
        if (!loadReporter.report(LoadEvents.LOADING_DEBUGGERS)) {
            throw new LoadCancelledException();
        }
        final DebuggerTemplateManager debuggerDescriptionManager = provider.loadDebuggers();
        if (!loadReporter.report(LoadEvents.LOADING_PROJECTS)) {
            throw new LoadCancelledException();
        }
        final List<INaviProject> projects = provider.loadProjects();
        if (!loadReporter.report(LoadEvents.LOADING_RAW_MODULES)) {
            throw new LoadCancelledException();
        }
        final List<INaviRawModule> rawModules = provider.loadRawModules();
        if (!loadReporter.report(LoadEvents.LOADING_MODULES)) {
            throw new LoadCancelledException();
        }
        final List<INaviModule> modules = provider.loadModules();
        debuggerDescriptionManager.addListener(internalDebuggerTemplateListener);
        content = new CDatabaseContent(provider, this, listeners, projects, modules, rawModules, viewTagManager, nodeTagManager, debuggerDescriptionManager);
    } catch (final CouldntLoadDataException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        close();
        throw exception;
    } catch (final InvalidDatabaseVersionException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        throw exception;
    } catch (final LoadCancelledException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        close();
        throw exception;
    } finally {
        isLoading = false;
    }
    content.initializeRawModules(content.getModules(), content.getRawModules());
    for (final IDatabaseListener listener : listeners) {
        try {
            listener.loadedDatabase(this);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
    loadReporter.report(LoadEvents.LOADING_FINISHED);
}
Also used : InvalidDatabaseVersionException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseVersionException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) DebuggerTemplateManager(com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplateManager) IDatabaseListener(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) CouldntInitializeDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntInitializeDatabaseException) CouldntLoadDriverException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDriverException) InvalidExporterDatabaseFormatException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidExporterDatabaseFormatException) SQLException(java.sql.SQLException) InvalidDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseException) CouldntConnectException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntConnectException) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CouldntUpdateDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntUpdateDatabaseException) InvalidDatabaseVersionException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseVersionException) INaviRawModule(com.google.security.zynamics.binnavi.disassembly.INaviRawModule) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)

Example 75 with INaviModule

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

the class BreakpointManager method setBreakpoint.

// ! Sets a regular breakpoint.
/**
   * Sets a regular breakpoint at the given address.
   *
   * @param module The module the breakpoint is tied to. This argument can be null.
   * @param address The address of the breakpoint.
   *
   * @return The set breakpoint. Null is returned if no breakpoint was set.
   */
public Breakpoint setBreakpoint(final Module module, final Address address) {
    Preconditions.checkNotNull(address, "Error: Address argument can not be null");
    final INaviModule realModule = module == null ? null : module.getNative();
    final BreakpointAddress breakpointAddress = new BreakpointAddress(realModule, new UnrelocatedAddress(new CAddress(address.toLong())));
    final Set<BreakpointAddress> breakpoints = Sets.newHashSet(breakpointAddress);
    breakpointManager.addBreakpoints(BreakpointType.REGULAR, breakpoints);
    return echoBreakpointMap.get(breakpointManager.getBreakpoint(BreakpointType.REGULAR, breakpointAddress));
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Aggregations

INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)180 Test (org.junit.Test)105 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)69 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)39 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)39 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)29 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)28 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)28 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)24 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)22 ArrayList (java.util.ArrayList)19 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)18 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)13 BigInteger (java.math.BigInteger)13 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)12 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)11 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)11 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)9 CAddressSpace (com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace)9 COperandTree (com.google.security.zynamics.binnavi.disassembly.COperandTree)9