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));
}
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());
}
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;
}
}
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));
}
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));
}
Aggregations