Search in sources :

Example 76 with UnrelocatedAddress

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

the class CStepEndHelper method getEndAddresses.

/**
   * Returns the addresses of all final instructions of a graph.
   *
   * @param graph The graph whose final addresses are returned.
   *
   * @return The final addresses of the graph.
   */
public static Set<BreakpointAddress> getEndAddresses(final ZyGraph graph) {
    final Set<BreakpointAddress> instructions = new HashSet<BreakpointAddress>();
    graph.iterate(new INodeCallback<NaviNode>() {

        @Override
        public IterationMode next(final NaviNode node) {
            if ((node.getRawNode() instanceof INaviCodeNode) && node.getChildren().isEmpty()) {
                final INaviCodeNode cnode = (INaviCodeNode) node.getRawNode();
                final INaviInstruction lastInstruction = Iterables.getLast(cnode.getInstructions());
                instructions.add(new BreakpointAddress(lastInstruction.getModule(), new UnrelocatedAddress(lastInstruction.getAddress())));
            }
            return IterationMode.CONTINUE;
        }
    });
    return instructions;
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) IterationMode(com.google.security.zynamics.zylib.types.common.IterationMode) HashSet(java.util.HashSet) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Example 77 with UnrelocatedAddress

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

the class CStepOverHelper method stepInCodeNode.

/**
   * Adds the addresses of a instructions that follow another instruction to a list when
   * single-stepping in a code node.
   * 
   * @param node The code node where the step over operation happens.
   * @param address The address in question.
   * @param instructions List to extend with the successor instructions.
   */
private static void stepInCodeNode(final INaviCodeNode node, final UnrelocatedAddress address, final Set<BreakpointAddress> instructions) {
    final int instructionIndex = CCodeNodeHelpers.getInstruction(node, address.getAddress());
    if (instructionIndex != -1) {
        if (instructionIndex < node.instructionCount() - 1) {
            // ... and the basic block is large enough that the following
            // instruction is also part of the basic block.
            final INaviInstruction instruction = Iterables.get(node.getInstructions(), instructionIndex + 1);
            instructions.add(new BreakpointAddress(instruction.getModule(), new UnrelocatedAddress(instruction.getAddress())));
        } else {
            // ... but the instruction is the last instruction of the basic block,
            // so we have to look into the child nodes of the basic block.
            instructions.addAll(CSteppingHelper.getSuccessors(node));
        }
    }
}
Also used : UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Example 78 with UnrelocatedAddress

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

the class CRelocationNotifier method collectWronglyPlacedModules.

/**
   * Finds wrongly relocated modules by comparing a snapshot of the modules in an address space
   * being reported by the debug client with those configured in
   * com.google.security.zynamics.binnavi.
   *
   * @param debugger The active debugger.
   * @param viewContainer The view container that is being debugged.
   * @param memoryModules The modules whose base addresses are checked.
   *
   * @return A list of wrongly relocated modules.
   */
private static List<Pair<INaviModule, MemoryModule>> collectWronglyPlacedModules(final IDebugger debugger, final IViewContainer viewContainer, final List<MemoryModule> memoryModules) {
    final List<Pair<INaviModule, MemoryModule>> wronglyPlacedModules = new ArrayList<Pair<INaviModule, MemoryModule>>();
    final List<INaviModule> modules = viewContainer.getModules();
    for (final INaviModule module : modules) {
        for (final MemoryModule memoryModule : memoryModules) {
            if (module.getConfiguration().getName().equalsIgnoreCase(memoryModule.getName())) {
                final RelocatedAddress assumedAddress = debugger.fileToMemory(module, new UnrelocatedAddress(module.getConfiguration().getFileBase()));
                final IAddress memoryAddress = memoryModule.getBaseAddress().getAddress();
                if (!assumedAddress.getAddress().equals(memoryAddress)) {
                    wronglyPlacedModules.add(new Pair<INaviModule, MemoryModule>(module, memoryModule));
                }
            }
        }
    }
    return wronglyPlacedModules;
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) ArrayList(java.util.ArrayList) MemoryModule(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) Pair(com.google.security.zynamics.zylib.general.Pair)

Example 79 with UnrelocatedAddress

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

the class CInstructionGenerator method createExpression.

@Override
public IFilterExpression<CViewWrapper> createExpression(final String text) {
    final Pattern pattern = Pattern.compile(RULE_REGEX);
    final Matcher matcher = pattern.matcher(text);
    matcher.matches();
    final String value = matcher.group(2);
    try {
        final List<INaviView> views = m_container.getViewsWithAddresses(Lists.newArrayList(new UnrelocatedAddress(new CAddress(new BigInteger(value, 16)))), true);
        return new CInstructionFilterExpression(views);
    } catch (final CouldntLoadDataException e) {
        return null;
    }
}
Also used : Pattern(java.util.regex.Pattern) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) Matcher(java.util.regex.Matcher) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) BigInteger(java.math.BigInteger) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 80 with UnrelocatedAddress

use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress 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)

Aggregations

UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)81 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)60 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)60 Test (org.junit.Test)49 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)28 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)15 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)15 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)13 Address (com.google.security.zynamics.binnavi.API.disassembly.Address)12 ArrayList (java.util.ArrayList)11 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)10 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)9 HashSet (java.util.HashSet)9 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)8 DebugTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings)8 DebuggerProvider (com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider)8 Breakpoint (com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)8 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)8 CBreakpointTableModel (com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.CBreakpointTableModel)7 TraceLogger (com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger)7