Search in sources :

Example 76 with INaviModule

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

the class BreakpointManager method setEchoBreakpoint.

// ! Sets an echo breakpoint.
/**
   * Sets an echo 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 setEchoBreakpoint(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.ECHO, breakpoints);
    return echoBreakpointMap.get(breakpointManager.getBreakpoint(BreakpointType.ECHO, 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)

Example 77 with INaviModule

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

the class CDatabaseContent method refreshRawModules.

@Override
public void refreshRawModules() throws CouldntLoadDataException {
    Preconditions.checkArgument(m_database.isConnected(), "IE00687: Not connected to the database");
    Preconditions.checkArgument(m_database.isLoaded(), "IE00688: Raw modules were not loaded previously");
    final List<INaviRawModule> oldModules = m_rawModules;
    final List<INaviRawModule> refreshedModules = m_provider.loadRawModules();
    m_rawModules.clear();
    m_rawModules.addAll(refreshedModules);
    final List<INaviModule> newModules = initializeRawModules(m_modules, refreshedModules);
    for (final IDatabaseListener listener : m_listeners) {
        try {
            listener.changedRawModules(m_database, oldModules, refreshedModules);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
    for (final INaviModule naviModule : newModules) {
        for (final IDatabaseListener listener : m_listeners) {
            try {
                listener.addedModule(m_database, naviModule);
            } catch (final Exception exception) {
                CUtilityFunctions.logException(exception);
            }
        }
    }
}
Also used : INaviRawModule(com.google.security.zynamics.binnavi.disassembly.INaviRawModule) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) IDatabaseListener(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CouldntDeleteException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)

Example 78 with INaviModule

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

the class CCodeNodeParser method createLine.

/**
   * Creates raw instruction data from a code node provider.
   *
   * @param instructionSet Provides the raw data.
   *
   * @return The generated raw data object.
   *
   * @throws ParserException Thrown if not all instruction data could be read.
   */
private InstructionLine createLine(final ICodeNodeProvider instructionSet) throws ParserException {
    final InstructionLine row = new InstructionLine();
    row.setBasicBlock(instructionSet.getNodeId());
    row.setAddress(instructionSet.getInstructionAddress());
    row.setMnemonic(instructionSet.getMnemonic());
    row.setArchitecture(instructionSet.getInstructionArchitecture());
    final int moduleId = instructionSet.getModule();
    final IAddress parentFunction = instructionSet.getParentFunction();
    final INaviModule module = modules.get(moduleId);
    if (module == null) {
        throw new ParserException(String.format("Instruction with ID %d has unknown module with ID %d", row.getId(), moduleId));
    }
    final INaviFunction function = parentFunction == null ? null : module.getContent().getFunctionContainer().getFunction(parentFunction);
    row.setParentFunction(function);
    if ((parentFunction != null) && (function == null)) {
        throw new ParserException(String.format("Instruction with ID %d has unknown parent function with address %s", row.getId(), parentFunction.toHexString()));
    }
    row.setX(instructionSet.getX());
    row.setY(instructionSet.getY());
    row.setColor(new Color(instructionSet.getColor()));
    row.setBorderColor(new Color(instructionSet.getBorderColor()));
    row.setSelected(instructionSet.isSelected());
    row.setVisible(instructionSet.isVisible());
    row.setLocalNodeCommentId(instructionSet.getLocalNodeCommentId());
    row.setGlobalNodeComment(instructionSet.getGlobalNodeCommentId());
    row.setGlobalInstructionComment(instructionSet.getGlobalInstructionCommentId());
    row.setLocalInstructionComment(instructionSet.getLocalInstructionCommentId());
    row.setData(instructionSet.getData());
    row.setModule(module);
    return row;
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) Color(java.awt.Color) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress)

Example 79 with INaviModule

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

the class CCodeNodeParser method createCurrentNode.

/**
   * Creates a new code node.
   *
   * @param resultSet Provides the data for the code node.
   *
   * @return The created code node object.
   *
   * @throws ParserException Thrown if the node data could not be read.
   * @throws CPartialLoadException Thrown if not all required modules are loaded.
   */
private CCodeNode createCurrentNode(final ICodeNodeProvider resultSet) throws ParserException, CPartialLoadException {
    final int nodeId = resultSet.getNodeId();
    final int moduleId = resultSet.getModule();
    final IAddress parentFunction = resultSet.getParentFunction();
    final INaviModule module = modules.get(moduleId);
    if (module == null) {
        throw new ParserException(String.format("Node with ID %d has unknown parent module with ID %d", nodeId, moduleId));
    }
    if (!module.isLoaded()) {
        try {
            module.load();
        } catch (final CouldntLoadDataException e) {
            throw new CPartialLoadException("E00066: The view could not be loaded because not all modules that form the view could be loaded", module);
        } catch (final LoadCancelledException e) {
            throw new CPartialLoadException("E00067: The view could not be loaded because it was cancelled", module);
        }
    }
    final INaviFunction function = parentFunction == null ? null : module.getContent().getFunctionContainer().getFunction(parentFunction);
    if ((parentFunction != null) && (function == null)) {
        throw new ParserException(String.format("Node with ID %d has unknown parent function with address %s", nodeId, parentFunction.toHexString()));
    }
    final double x = resultSet.getX();
    final double y = resultSet.getY();
    final double width = resultSet.getWidth();
    final double height = resultSet.getHeight();
    final Color color = new Color(resultSet.getColor());
    final Color bordercolor = new Color(resultSet.getBorderColor());
    final boolean selected = resultSet.isSelected();
    final boolean visible = resultSet.isVisible();
    final Integer localCodeNodeCommentId = resultSet.getLocalNodeCommentId();
    final Integer globalCodeNodeCommentId = resultSet.getGlobalNodeCommentId();
    // TODO(timkornau): final new Set<CTag>! must replaced by a set which
    // contains the loaded node
    // tags from the DB
    final CCodeNode codeNode = new CCodeNode(nodeId, x, y, width, height, color, bordercolor, selected, visible, null, function, new HashSet<CTag>(), sqlProvider);
    if (localCodeNodeCommentId != null) {
        localCommentIdToCodeNode.put(localCodeNodeCommentId, codeNode);
    }
    if (globalCodeNodeCommentId != null) {
        globalCommentIdToCodeNode.put(globalCodeNodeCommentId, codeNode);
    }
    return codeNode;
}
Also used : CPartialLoadException(com.google.security.zynamics.binnavi.Database.Exceptions.CPartialLoadException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) Color(java.awt.Color) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Example 80 with INaviModule

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

the class Database method convertData.

/**
   * Converts the native objects stored in the database to API objects.
   */
private void convertData() {
    m_viewTagManager = new TagManager(m_database.getContent().getViewTagManager());
    m_nodeTagManager = new TagManager(m_database.getContent().getNodeTagManager());
    m_modules.clear();
    m_projects.clear();
    for (final INaviModule module : m_database.getContent().getModules()) {
        m_modules.add(new Module(this, module, m_nodeTagManager, m_viewTagManager));
    }
    for (final INaviProject project : m_database.getContent().getProjects()) {
        m_projects.add(new Project(this, project, m_nodeTagManager, m_viewTagManager));
    }
    m_debuggerTemplateManager = new DebuggerTemplateManager(m_database.getContent().getDebuggerTemplateManager());
}
Also used : INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) INaviRawModule(com.google.security.zynamics.binnavi.disassembly.INaviRawModule)

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