Search in sources :

Example 21 with UnrelocatedAddress

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

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

the class Debugger method toImagebase.

// ! Converts file addresses to memory addresses.
/**
   * Converts a file address to the same address in the relocated module.
   *
   * @param module The module the file address address belongs to.
   * @param address The file address to convert.
   *
   * @return The converted memory-relocated address.
   */
public Address toImagebase(final Module module, final Address address) {
    Preconditions.checkNotNull(module, "Error: Module argument can not be null");
    Preconditions.checkNotNull(address, "Error: Address argument can not be null");
    return new Address(m_debugger.fileToMemory(module.getNative(), new UnrelocatedAddress(new CAddress(address.toLong()))).getAddress().toBigInteger());
}
Also used : UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 23 with UnrelocatedAddress

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

the class CSteppingHelper method getAddress.

/**
   * Determines the start address of a node.
   *
   * @param node Node whose address is determined.
   *
   * @return The start address of the given node or null if the node does not have an address.
   */
private static BreakpointAddress getAddress(final INaviViewNode node) {
    if (node instanceof INaviCodeNode) {
        final INaviCodeNode ccnode = (INaviCodeNode) node;
        final INaviInstruction instruction = Iterables.getFirst(ccnode.getInstructions(), null);
        return new BreakpointAddress(instruction.getModule(), new UnrelocatedAddress(instruction.getAddress()));
    } else if (node instanceof INaviFunctionNode) {
        final INaviFunction function = ((INaviFunctionNode) node).getFunction();
        final INaviModule module = function.getModule();
        return new BreakpointAddress(module, new UnrelocatedAddress(function.getAddress()));
    } else {
        // Node types we can not step to
        return null;
    }
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) INaviFunctionNode(com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Example 24 with UnrelocatedAddress

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

the class CModuleTest method testGetViewsWithAddresses.

@Test
public void testGetViewsWithAddresses() throws CouldntLoadDataException, LoadCancelledException {
    final FilledList<UnrelocatedAddress> addresses = new FilledList<UnrelocatedAddress>();
    addresses.add(new UnrelocatedAddress(new CAddress(12345678)));
    m_module.load();
    assertNotNull(m_module.getViewsWithAddresses(addresses, true));
}
Also used : 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) Test(org.junit.Test)

Example 25 with UnrelocatedAddress

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

the class CBreakpointManagerTest method testRemoveEchoBreakpoint.

@Test
public void testRemoveEchoBreakpoint() {
    // Error condition: Null argument
    try {
        m_manager.removeBreakpoints(BreakpointType.ECHO, null);
        fail("Exception not raised");
    } catch (final NullPointerException ex) {
    }
    assertEquals(2, m_manager.getNumberOfBreakpoints(BreakpointType.ECHO));
    m_manager.removeBreakpoints(BreakpointType.ECHO, Sets.newHashSet(new BreakpointAddress(m_module, new UnrelocatedAddress(new CAddress(0x111)))));
    assertEquals(1, m_manager.getNumberOfBreakpoints(BreakpointType.ECHO));
    m_manager.removeBreakpoints(BreakpointType.ECHO, Sets.newHashSet(new BreakpointAddress(m_module, new UnrelocatedAddress(new CAddress(0x222)))));
    assertEquals(0, m_manager.getNumberOfBreakpoints(BreakpointType.ECHO));
}
Also used : 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) Test(org.junit.Test)

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