Search in sources :

Example 26 with CAddress

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

the class CSearchWaiterTest method testDetach.

@Test
public void testDetach() throws Exception {
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger.connect();
    final CSearchWaiter waiter = new CSearchWaiter(debugger, new CAddress(0x300), 0x100, new byte[] { 10 });
    waiter.start();
    new Thread() {

        @Override
        public void run() {
            try {
                waiter.runExpensiveCommand();
            } catch (final Exception e) {
            }
        }
    }.start();
    Thread.sleep(250);
    debugger.connection.m_synchronizer.receivedEvent(new DetachReply(0, 0));
    Thread.sleep(250);
    assertFalse(waiter.isAlive());
    assertNull(waiter.getReply());
    debugger.close();
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) DetachReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.DetachReply) CSearchWaiter(com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Implementations.CSearchWaiter) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 27 with CAddress

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

the class CSearchWaiterTest method testSuccess.

@Test
public void testSuccess() throws Exception {
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger.connect();
    final CSearchWaiter waiter = new CSearchWaiter(debugger, new CAddress(0x300), 0x100, new byte[] { 10 });
    waiter.start();
    new Thread() {

        @Override
        public void run() {
            try {
                waiter.runExpensiveCommand();
            } catch (final Exception e) {
            }
        }
    }.start();
    Thread.sleep(250);
    debugger.connection.m_synchronizer.receivedEvent(new SearchReply(0, 0, new CAddress(0x300)));
    Thread.sleep(250);
    assertFalse(waiter.isAlive());
    assertNotNull(waiter.getReply());
    assertTrue(waiter.getReply().success());
    debugger.close();
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) SearchReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.SearchReply) CSearchWaiter(com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Implementations.CSearchWaiter) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 28 with CAddress

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

the class CMemorySectionWrapperTest method testSimple.

@Test
public void testSimple() {
    assertEquals("00000000 - 000003FE (1023 bytes)", new CMemorySectionWrapper(new MemorySection(new CAddress(0), new CAddress(1022))).toString());
    assertEquals("00000000 - 000003FF (1.00 KB)", new CMemorySectionWrapper(new MemorySection(new CAddress(0), new CAddress(1023))).toString());
    assertEquals("00000000 - 000005DC (1.47 KB)", new CMemorySectionWrapper(new MemorySection(new CAddress(0), new CAddress(1500))).toString());
    assertEquals("00000000 - 00102710 (1.01 MB)", new CMemorySectionWrapper(new MemorySection(new CAddress(0), new CAddress((1024 * 1024) + 10000))).toString());
}
Also used : MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) CMemorySectionWrapper(com.google.security.zynamics.binnavi.Gui.Debug.MemorySectionPanel.CMemorySectionWrapper) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 29 with CAddress

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

the class CStackMemoryProvider method hasData.

@Override
public boolean hasData(final long startAddress, final long numberOfBytes) {
    if (m_debugger == null) {
        return false;
    }
    if (m_debugger.getProcessManager().getTargetInformation().getDebuggerOptions().canMemmap()) {
        return m_memoryProvider != null && m_memoryProvider.hasData(BigInteger.valueOf(startAddress), (int) numberOfBytes);
    } else {
        final CAddress stackStart = new CAddress(getStartAddress());
        final int stackSize = getNumberOfEntries() * 4;
        final CAddress stackEnd = new CAddress(getStartAddress() + stackSize);
        final Pair<IAddress, Integer> realRange = MemoryRangeCalculator.calculateRequestRange(BigInteger.valueOf(startAddress), (int) numberOfBytes, stackStart, stackEnd);
        final long realStart = realRange.first().toLong();
        final long realSize = realRange.second();
        return m_memoryProvider != null && m_memoryProvider.hasData(BigInteger.valueOf(startAddress), (int) numberOfBytes, BigInteger.valueOf(realStart), (int) realSize);
    }
}
Also used : BigInteger(java.math.BigInteger) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 30 with CAddress

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

the class CGotoAddressField method zoomToAddress.

/**
 * Zooms to the current address.
 */
private void zoomToAddress() {
    if (!"".equals(getText())) {
        add(getText());
        final IAddress address = new CAddress(Long.parseLong(getText(), 16));
        m_textField.setSuccessful(ZyZoomHelpers.zoomToAddress(m_graph, address, m_modules.get(0), true));
    }
}
Also used : IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Aggregations

CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)315 Test (org.junit.Test)221 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)60 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)55 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)51 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)48 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)47 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)47 ArrayList (java.util.ArrayList)46 Date (java.util.Date)46 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)45 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)40 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)32 MemoryMap (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap)29 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)28 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)27 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)27 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)26 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)24 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)24