Search in sources :

Example 21 with Address

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);
}
Also used : MockOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) Reference(com.google.security.zynamics.binnavi.API.disassembly.Reference) OperandExpression(com.google.security.zynamics.binnavi.API.disassembly.OperandExpression) Test(org.junit.Test)

Example 22 with Address

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);
}
Also used : Trace(com.google.security.zynamics.binnavi.API.disassembly.Trace) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) Module(com.google.security.zynamics.binnavi.API.disassembly.Module) Test(org.junit.Test)

Example 23 with Address

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;
}
Also used : CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) ArrayList(java.util.ArrayList) Instruction(com.google.security.zynamics.binnavi.API.disassembly.Instruction) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 24 with Address

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());
}
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 25 with Address

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());
}
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) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Aggregations

Address (com.google.security.zynamics.binnavi.API.disassembly.Address)44 Test (org.junit.Test)32 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)30 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)19 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)17 Module (com.google.security.zynamics.binnavi.API.disassembly.Module)7 Trace (com.google.security.zynamics.binnavi.API.disassembly.Trace)5 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)5 Function (com.google.security.zynamics.binnavi.API.disassembly.Function)4 TracePoint (com.google.security.zynamics.binnavi.API.disassembly.TracePoint)4 ArrayList (java.util.ArrayList)4 MemoryModule (com.google.security.zynamics.binnavi.API.debug.MemoryModule)3 ReilInstruction (com.google.security.zynamics.binnavi.API.reil.ReilInstruction)2 InstructionGraph (com.google.security.zynamics.binnavi.API.reil.mono.InstructionGraph)2 InstructionGraphEdge (com.google.security.zynamics.binnavi.API.reil.mono.InstructionGraphEdge)2 InstructionGraphNode (com.google.security.zynamics.binnavi.API.reil.mono.InstructionGraphNode)2 EchoBreakpointHitReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointHitReply)2 RegisterValue (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue)2 RegisterValues (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues)2 ThreadRegisters (com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters)2