use of com.google.security.zynamics.binnavi.API.disassembly.Address in project binnavi by google.
the class OperandExpressionTest method testReferences.
@Test
public void testReferences() throws CouldntSaveDataException, CouldntDeleteException {
final MockOperandExpressionListener listener = new MockOperandExpressionListener();
final MockOperandTreeNode node = new MockOperandTreeNode();
final OperandExpression expression = new OperandExpression(node);
expression.addListener(listener);
final Reference reference1 = expression.addReference(new Address(0x123), ReferenceType.CALL_VIRTUAL);
final Reference reference2 = expression.addReference(new Address(0x124), ReferenceType.DATA);
final List<Reference> references = expression.getReferences();
assertEquals(2, references.size());
assertEquals(reference1, references.get(0));
assertEquals(reference2, references.get(1));
assertEquals("addedReference;addedReference;", listener.events);
expression.deleteReference(reference1);
assertEquals(1, expression.getReferences().size());
assertEquals("addedReference;addedReference;removedReference;", listener.events);
expression.removeListener(listener);
}
use of com.google.security.zynamics.binnavi.API.disassembly.Address in project binnavi by google.
the class TraceTest method testEvent.
@Test
public void testEvent() {
final Trace trace = new Trace(new TraceList(1, "Name", "Description", new MockSqlProvider()));
final MockTraceListener listener = new MockTraceListener();
trace.addListener(listener);
final MockModule module = new MockModule();
final Module m = ModuleFactory.get(module);
trace.addEvent(0, m, new Address(123), TraceEventType.Breakpoint);
trace.addEvent(0, m, new Address(124), TraceEventType.EchoBreakpoint);
assertEquals(2, trace.getEvents().size());
assertEquals(123, trace.getEvents().get(0).getAddress().toLong());
assertEquals(TraceEventType.Breakpoint, trace.getEvents().get(0).getType());
assertEquals(124, trace.getEvents().get(1).getAddress().toLong());
assertEquals(TraceEventType.EchoBreakpoint, trace.getEvents().get(1).getType());
assertEquals("addedEvent;addedEvent;", listener.events);
trace.removeListener(listener);
}
use of com.google.security.zynamics.binnavi.API.disassembly.Address in project binnavi by google.
the class BreakpointHelpers method getBreakpoints.
/**
* Returns the addresses of a code node where breakpoints of a given type are set.
*
* @param debugger The debugger that set the breakpoints.
* @param node The code node to check.
* @param type The type of the breakpoints to search for.
*
* @return The addresses of the code node where breakpoints are set.
*/
private static List<Address> getBreakpoints(final Debugger debugger, final CodeNode node, final BreakpointType type) {
Preconditions.checkNotNull(debugger, "Error: Debugger argument can not be null");
Preconditions.checkNotNull(node, "Error: Node argument can not be null");
final BreakpointManager manager = debugger.getBreakpointManager();
final List<Address> breakpoints = new ArrayList<Address>();
for (final Instruction instruction : node.getInstructions()) {
final BreakpointAddress address = new BreakpointAddress(instruction.getNative().getModule(), new UnrelocatedAddress(new CAddress(instruction.getAddress().toLong())));
if (manager.getNative().hasBreakpoint(type, address)) {
breakpoints.add(new Address(address.getAddress().getAddress().toBigInteger()));
}
}
return breakpoints;
}
use of com.google.security.zynamics.binnavi.API.disassembly.Address 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.API.disassembly.Address in project binnavi by google.
the class Debugger method toFilebase.
// ! Converts memory addresses to file addresses.
/**
* Converts a memory-relocated address to the same address in the unrelocated module.
*
* @param module The module the relocated address belongs to.
* @param address The memory-relocated address to convert.
*
* @return The converted file address.
*/
public Address toFilebase(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.memoryToFile(module.getNative(), new RelocatedAddress(new CAddress(address.toLong()))).getAddress().toBigInteger());
}
Aggregations