Search in sources :

Example 31 with Address

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

the class TraceLoggerTest method testStartErrors.

@Test
public void testStartErrors() throws CouldntSaveDataException, DebugExceptionWrapper {
    try {
        @SuppressWarnings("unused") final Trace trace = m_logger.start("Name", "Description", Lists.newArrayList(new TracePoint(m_mockModule, new Address(0x100))));
        fail();
    } catch (final IllegalArgumentException exception) {
    }
    m_mockDebugger.connect();
    try {
        @SuppressWarnings("unused") final Trace trace = m_logger.start(null, "Description", Lists.newArrayList(new TracePoint(m_mockModule, new Address(0x100))));
        fail();
    } catch (final NullPointerException exception) {
    }
    try {
        @SuppressWarnings("unused") final Trace trace = m_logger.start("Name", null, Lists.newArrayList(new TracePoint(m_mockModule, new Address(0x100))));
        fail();
    } catch (final NullPointerException exception) {
    }
    try {
        @SuppressWarnings("unused") final Trace trace = m_logger.start("Name", "Description", null);
        fail();
    } catch (final NullPointerException exception) {
    }
    try {
        @SuppressWarnings("unused") final Trace trace = m_logger.start("Name", "Description", Lists.newArrayList(new TracePoint(m_mockModule, null)));
        fail();
    } catch (final NullPointerException exception) {
    }
    @SuppressWarnings("unused") final Trace trace = m_logger.start("Name", "Description", Lists.newArrayList(new TracePoint(m_mockModule, new Address(0x100))));
    try {
        m_logger.start("Name", "Description", Lists.newArrayList(new TracePoint(m_mockModule, new Address(0x100))));
        fail();
    } catch (final IllegalArgumentException exception) {
    }
    m_logger.stop();
    try {
        m_logger.stop();
        fail();
    } catch (final NullPointerException exception) {
    }
}
Also used : Trace(com.google.security.zynamics.binnavi.API.disassembly.Trace) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) TracePoint(com.google.security.zynamics.binnavi.API.disassembly.TracePoint) Test(org.junit.Test)

Example 32 with Address

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

the class TraceLoggerTest method testEmptyHits.

@Test
public void testEmptyHits() throws CouldntSaveDataException, DebugExceptionWrapper {
    m_mockDebugger.connect();
    final Trace trace = m_logger.start("Name", "Description", Lists.newArrayList(new TracePoint(m_mockModule, new Address(0x100))));
    m_logger.stop();
    assertEquals("Name", trace.getName());
    assertEquals("Description", trace.getDescription());
    assertTrue(trace.getEvents().isEmpty());
}
Also used : Trace(com.google.security.zynamics.binnavi.API.disassembly.Trace) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) TracePoint(com.google.security.zynamics.binnavi.API.disassembly.TracePoint) Test(org.junit.Test)

Example 33 with Address

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

the class AddressTest method testConstructor.

@Test
public void testConstructor() {
    final Address address = new Address(0x123);
    assertEquals(0x123, address.toLong());
    assertEquals("123", address.toHexString());
    assertEquals("123", address.toString());
}
Also used : Address(com.google.security.zynamics.binnavi.API.disassembly.Address) Test(org.junit.Test)

Example 34 with Address

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

the class AddressTest method testPythonFunctions.

@Test
public void testPythonFunctions() {
    final Address address1 = new Address(100);
    final Address address2 = new Address(50);
    assertEquals(100 + 50, address1.__add__(address2).toLong());
    assertEquals(100 + 50, address1.__add__(50).toLong());
    assertEquals(100 + 50, address1.__add__(BigInteger.valueOf(50)).toLong());
    assertEquals(100 & 50, address1.__and__(address2).toLong());
    assertFalse(address1.__eq__(address2));
    assertTrue(address1.__eq__(100));
    assertTrue(address1.__ge__(address2));
    assertFalse(address1.__ge__(200));
    assertTrue(address1.__gt__(address2));
    assertFalse(address1.__gt__(address1));
    assertFalse(address1.__le__(address2));
    assertTrue(address1.__le__(address1));
    assertFalse(address1.__lt__(address2));
    assertTrue(address1.__lt__(200));
    assertEquals(100, address1.__long__());
    assertEquals(100 << 1, address1.__lshift__(1).toLong());
    assertEquals(100 * 50, address1.__mul__(address2).toLong());
    assertTrue(address1.__ne__(address2));
    assertFalse(address1.__ne__(address1));
    assertEquals(100 | 50, address1.__or__(address2).toLong());
    assertEquals(100 + 50, address1.__radd__(address2).toLong());
    assertEquals(100 & 50, address1.__rand__(address2).toLong());
    assertEquals(100 * 50, address1.__rmul__(address2).toLong());
    assertEquals(100 | 50, address1.__ror__(address2).toLong());
    assertEquals(100 >> 1, address1.__rshift__(1).toLong());
    assertEquals(-50, address1.__rsub__(address2).toLong());
    assertEquals(50, address1.__sub__(address2).toLong());
    assertEquals(100 ^ 50, address1.__xor__(address2).toLong());
    assertEquals(100 ^ 50, address1.__rxor__(address2).toLong());
}
Also used : Address(com.google.security.zynamics.binnavi.API.disassembly.Address) Test(org.junit.Test)

Example 35 with Address

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

the class BookmarkManagerTest method testGetBookmark.

@Test
public void testGetBookmark() {
    try {
        assertEquals(0x123, m_apiManager.getBookmark(null).getAddress().toLong());
    } catch (final NullPointerException exception) {
    }
    assertNull(m_apiManager.getBookmark(new Address(0x123)));
    m_apiManager.addBookmark(new Address(0x123), "Fark");
    assertEquals(1, m_apiManager.getNumberOfBookmarks());
    assertEquals(0x123, m_apiManager.getBookmark(new Address(0x123)).getAddress().toLong());
    assertEquals("Fark", m_apiManager.getBookmark(new Address(0x123)).getDescription());
}
Also used : Address(com.google.security.zynamics.binnavi.API.disassembly.Address) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

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