Search in sources :

Example 11 with RelocatedAddress

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

the class MemoryModuleTest method testConstructor.

@Test
public void testConstructor() {
    final com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule internalModule = new com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule("dll", "C:\\dll", new RelocatedAddress(new CAddress(0x100)), 0x200);
    final MemoryModule module = new MemoryModule(internalModule);
    assertEquals("dll", module.getName());
    assertEquals(0x100, module.getBaseAddress().toLong());
    assertEquals(0x200, module.getSize());
}
Also used : RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 12 with RelocatedAddress

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

the class ProcessTest method testModules.

@Test
public void testModules() {
    final MockProcessListener listener = new MockProcessListener();
    final ProcessManager manager = new ProcessManager();
    manager.addModule(new MemoryModule("Hannes", "C:\\Hannes.dll", new RelocatedAddress(new CAddress(0x100)), 0x100));
    final Process process = new Process(manager);
    assertEquals(1, process.getModules().size());
    process.addListener(listener);
    final MemoryModule dll = new MemoryModule("Foobert.dll", "C:\\Foobert.dll", new RelocatedAddress(new CAddress(0x100)), 0x100);
    manager.addModule(dll);
    assertEquals("addedModule/Foobert.dll;", listener.events);
    assertEquals(2, process.getModules().size());
    manager.removeModule(dll);
    assertEquals("addedModule/Foobert.dll;removedModule/Foobert.dll;", listener.events);
    assertEquals(1, process.getModules().size());
    process.removeListener(listener);
}
Also used : RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) ProcessManager(com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager) MemoryModule(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 13 with RelocatedAddress

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

the class ThreadTest method testGetCurrentAddress.

@Test
public void testGetCurrentAddress() {
    final MockThreadListener listener = new MockThreadListener();
    m_thread.addListener(listener);
    m_internalThread.setCurrentAddress(new RelocatedAddress(new CAddress(0x200)));
    assertEquals("changedProgramCounter;", listener.events);
    assertEquals(0x200, m_thread.getCurrentAddress().toLong());
    m_thread.removeListener(listener);
}
Also used : RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 14 with RelocatedAddress

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

the class CBreakpointModuleSynchronizer method isWithinModule.

/**
   * Checks whether the given breakpoint is within the boundaries of the specified module.
   * 
   * @param module The module against which the breakpoint is tested.
   * @param breakpoint The breakpoint to be tested.
   * @return True of the breakpoint is within the given module, false otherwise.
   */
private static boolean isWithinModule(final IDebugger debugger, final MemoryModule module, final Breakpoint breakpoint) {
    final RelocatedAddress bpAddress = debugger.fileToMemory(breakpoint.getAddress().getModule(), breakpoint.getAddress().getAddress());
    final boolean addressOk = (bpAddress.getAddress().toBigInteger().compareTo(module.getBaseAddress().getAddress().toBigInteger()) >= 0) && (bpAddress.getAddress().toBigInteger().compareTo(module.getBaseAddress().getAddress().toBigInteger().add(BigInteger.valueOf(module.getSize()))) <= 0);
    return addressOk && (module.getName().compareToIgnoreCase(breakpoint.getAddress().getModule().getConfiguration().getName()) == 0);
}
Also used : RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)

Example 15 with RelocatedAddress

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

the class SingleStepParser method parseSuccess.

@Override
public SingleStepReply parseSuccess(final int packetId, final int argumentCount) throws IOException {
    final long tid = parseThreadId();
    final RelocatedAddress address = new RelocatedAddress(parseAddress());
    try {
        final RegisterValues registerValues = RegisterValuesParser.parse(parseData());
        return new SingleStepReply(packetId, 0, tid, address, registerValues);
    } catch (final MessageParserException e) {
        return new SingleStepReply(packetId, PARSER_ERROR, tid, address, null);
    }
}
Also used : SingleStepReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.SingleStepReply) MessageParserException(com.google.security.zynamics.binnavi.debug.connection.packets.parsers.MessageParserException) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) RegisterValues(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues)

Aggregations

RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)59 Test (org.junit.Test)32 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)25 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)22 BigInteger (java.math.BigInteger)20 MemoryModule (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule)15 ArrayList (java.util.ArrayList)13 EchoBreakpointsRemovedReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointsRemovedReply)12 EchoBreakpointSetReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointSetReply)10 DebuggerOptions (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions)10 ThreadRegisters (com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters)10 BreakpointsRemovedReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.BreakpointsRemovedReply)9 StepBreakpointSetReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointSetReply)9 RegisterDescription (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription)9 RegisterValue (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue)9 RegisterValues (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues)9 TargetInformation (com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation)9 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)8 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)8 TargetInformationReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply)7