Search in sources :

Example 16 with RegisterValue

use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue in project binnavi by google.

the class RegisterTest method testConstructor.

@Test
public void testConstructor() {
    final RegisterValue internalRegister = new RegisterValue("eax", BigInteger.TEN, new byte[0], false, true);
    final Register register = new Register(internalRegister);
    assertEquals("eax", register.getName());
    assertEquals(BigInteger.TEN, register.getValue());
    assertFalse(register.isProgramCounter());
    assertTrue(register.isStackPointer());
}
Also used : RegisterValue(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue) Register(com.google.security.zynamics.binnavi.API.debug.Register) Test(org.junit.Test)

Example 17 with RegisterValue

use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue in project binnavi by google.

the class CHistoryStringBuilderTest method testComplete3.

@SuppressWarnings("unchecked")
@Test
public void testComplete3() throws DebugExceptionWrapper, ParserConfigurationException, SAXException, IOException, MessageParserException, MaybeNullException {
    final CHistoryStringBuilder builder = new CHistoryStringBuilder();
    builder.setDebugger(m_debugger);
    m_debugger.connect();
    m_synchronizer.receivedEvent(DebuggerMessageBuilder.buildProcessStartReply(mockMemoryModule));
    m_debugger.getProcessManager().setTargetInformation(new TargetInformation(5, Lists.newArrayList(new RegisterDescription("eax", 4, true), new RegisterDescription("ebx", 4, false)), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 12, 0, new ArrayList<DebuggerException>(), false, false, false)));
    m_debugger.getProcessManager().addThread(new TargetProcessThread(1, ThreadState.RUNNING));
    m_synchronizer.receivedEvent(new BreakpointConditionSetReply(0, 0));
    m_synchronizer.receivedEvent(new BreakpointConditionSetReply(0, 1));
    m_synchronizer.receivedEvent(new EchoBreakpointHitReply(0, 0, 1, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(1, Lists.newArrayList(new RegisterValue("eip", BigInteger.ONE, new byte[0], false, false)))))));
    m_synchronizer.receivedEvent(new EchoBreakpointHitReply(0, 0, 1, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(1, Lists.newArrayList(new RegisterValue("eip", BigInteger.ONE, new byte[0], true, false)))))));
    m_debugger.getProcessManager().addThread(new TargetProcessThread(0, ThreadState.RUNNING));
    m_debugger.getProcessManager().getThread(0).setCurrentAddress(new RelocatedAddress(new CAddress(0)));
    m_debugger.getBreakpointManager().addBreakpoints(BreakpointType.ECHO, BREAKPOINT_ADDRESS);
    m_synchronizer.receivedEvent(new EchoBreakpointSetReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 0))));
    m_synchronizer.receivedEvent(new EchoBreakpointSetReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 1))));
    m_synchronizer.receivedEvent(new EchoBreakpointsRemovedReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 0))));
    m_synchronizer.receivedEvent(new EchoBreakpointsRemovedReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 1))));
    m_synchronizer.receivedEvent(new ExceptionOccurredReply(0, 0, 0, 0, new RelocatedAddress(new CAddress(0)), "Test exception"));
    m_synchronizer.receivedEvent(new HaltReply(0, 0, 0));
    m_synchronizer.receivedEvent(new HaltReply(0, 0, 1));
    m_synchronizer.receivedEvent(new ListFilesReply(0, 0, RemoteFileSystem.parse("<foo></foo>".getBytes())));
    m_synchronizer.receivedEvent(new ListFilesReply(0, 1, null));
    m_synchronizer.receivedEvent(new ListProcessesReply(0, 0, ProcessList.parse("<foo></foo>".getBytes())));
    m_synchronizer.receivedEvent(new ListProcessesReply(0, 1, null));
    m_synchronizer.receivedEvent(new MemoryMapReply(0, 0, new MemoryMap(new ArrayList<MemorySection>())));
    m_synchronizer.receivedEvent(new MemoryMapReply(0, 1, null));
    m_synchronizer.receivedEvent(new ModuleLoadedReply(0, 0, new MemoryModule("XXX", "YYYXXX", new RelocatedAddress(new CAddress(0)), 0), new TargetProcessThread(123, ThreadState.SUSPENDED)));
    m_synchronizer.receivedEvent(new ModuleUnloadedReply(0, 0, new MemoryModule("XXX", "YYYXXX", new RelocatedAddress(new CAddress(0)), 0)));
    m_synchronizer.receivedEvent(new ProcessClosedReply(0, 0));
    m_synchronizer.receivedEvent(new ReadMemoryReply(0, 0, new CAddress(0), new byte[8]));
    m_synchronizer.receivedEvent(new ReadMemoryReply(0, 1, null, null));
    m_synchronizer.receivedEvent(new RegistersReply(0, 0, new RegisterValues(new FilledList<ThreadRegisters>())));
    m_synchronizer.receivedEvent(new RegistersReply(0, 1, null));
    m_synchronizer.receivedEvent(new RequestTargetReply(0, 0));
    m_synchronizer.receivedEvent(new RequestTargetReply(0, 1));
    m_synchronizer.receivedEvent(new ResumeReply(0, 0));
    m_synchronizer.receivedEvent(new ResumeReply(0, 1));
    m_debugger.connect();
    m_debugger.getProcessManager().addThread(new TargetProcessThread(0, ThreadState.RUNNING));
    m_debugger.getProcessManager().getThread(0).setCurrentAddress(new RelocatedAddress(new CAddress(0)));
    m_synchronizer.receivedEvent(new ResumeThreadReply(0, 0, 0));
    m_synchronizer.receivedEvent(new ResumeThreadReply(0, 1, 0));
    m_synchronizer.receivedEvent(new SearchReply(0, 0, new CAddress(0)));
    m_synchronizer.receivedEvent(new SearchReply(0, 1, null));
    m_synchronizer.receivedEvent(new SelectFileReply(0, 0));
    m_synchronizer.receivedEvent(new SelectFileReply(0, 1));
    m_debugger.getProcessManager().addThread(new TargetProcessThread(0, ThreadState.RUNNING));
    m_debugger.getProcessManager().getThread(0).setCurrentAddress(new RelocatedAddress(new CAddress(0)));
    m_synchronizer.receivedEvent(new SetRegisterReply(0, 0, 0, 0));
    m_synchronizer.receivedEvent(new SetRegisterReply(0, 1, 0, 0));
    m_synchronizer.receivedEvent(new SingleStepReply(0, 0, 0, new RelocatedAddress(new CAddress(0)), new RegisterValues(new FilledList<ThreadRegisters>())));
    m_synchronizer.receivedEvent(new SingleStepReply(0, 1, 0, new RelocatedAddress(new CAddress(0)), new RegisterValues(new FilledList<ThreadRegisters>())));
    m_synchronizer.receivedEvent(new StepBreakpointHitReply(0, 0, 1, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(1, Lists.newArrayList(new RegisterValue("eip", BigInteger.ONE, new byte[0], false, false)))))));
    m_synchronizer.receivedEvent(new StepBreakpointHitReply(0, 0, 1, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(1, Lists.newArrayList(new RegisterValue("eip", BigInteger.ONE, new byte[0], true, false)))))));
    m_debugger.getBreakpointManager().addBreakpoints(BreakpointType.STEP, BREAKPOINT_ADDRESS);
    m_synchronizer.receivedEvent(new StepBreakpointSetReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 0))));
    m_synchronizer.receivedEvent(new StepBreakpointSetReply(0, 1, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 1))));
    m_synchronizer.receivedEvent(new StepBreakpointsRemovedReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 0))));
    m_synchronizer.receivedEvent(new StepBreakpointsRemovedReply(0, 1, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 1))));
    m_synchronizer.receivedEvent(new SuspendThreadReply(0, 0, 0));
    m_synchronizer.receivedEvent(new SuspendThreadReply(0, 1, 0));
    m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, TargetInformationParser.parse("<foo><size>32</size><registers></registers><options></options></foo>".getBytes())));
    m_synchronizer.receivedEvent(new TargetInformationReply(0, 1, null));
    m_debugger.getProcessManager().addThread(new TargetProcessThread(0, ThreadState.RUNNING));
    m_synchronizer.receivedEvent(new ThreadClosedReply(0, 0, 0));
    m_synchronizer.receivedEvent(new ThreadClosedReply(0, 1, 0));
    m_synchronizer.receivedEvent(new ThreadCreatedReply(0, 0, 0, ThreadState.RUNNING));
    m_synchronizer.receivedEvent(new ThreadCreatedReply(0, 1, 0, null));
    m_synchronizer.receivedEvent(new ValidateMemoryReply(0, 0, new CAddress(0), new CAddress(0)));
    m_synchronizer.receivedEvent(new ValidateMemoryReply(0, 1, null, null));
    m_synchronizer.receivedEvent(new WriteMemoryReply(0, 0));
    m_synchronizer.receivedEvent(new WriteMemoryReply(0, 1));
    m_synchronizer.receivedEvent(new TerminateReply(0, 0));
    m_synchronizer.receivedEvent(new TerminateReply(0, 1));
}
Also used : SetRegisterReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.SetRegisterReply) SearchReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.SearchReply) TerminateReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.TerminateReply) MemoryModule(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) StepBreakpointsRemovedReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointsRemovedReply) TargetInformationReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply) MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) ValidateMemoryReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.ValidateMemoryReply) StepBreakpointSetReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointSetReply) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) BreakpointConditionSetReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.BreakpointConditionSetReply) MemoryMapReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply) DebuggerOptions(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions) ModuleLoadedReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.ModuleLoadedReply) SuspendThreadReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.SuspendThreadReply) ThreadCreatedReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.ThreadCreatedReply) SingleStepReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.SingleStepReply) ThreadClosedReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.ThreadClosedReply) EchoBreakpointsRemovedReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointsRemovedReply) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) RegisterValue(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue) ModuleUnloadedReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.ModuleUnloadedReply) TargetInformation(com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation) EchoBreakpointHitReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointHitReply) ListProcessesReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.ListProcessesReply) ProcessClosedReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.ProcessClosedReply) RequestTargetReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.RequestTargetReply) WriteMemoryReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.WriteMemoryReply) ReadMemoryReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.ReadMemoryReply) ThreadRegisters(com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters) HaltReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.HaltReply) DebuggerException(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException) StepBreakpointHitReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointHitReply) RegistersReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.RegistersReply) SelectFileReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.SelectFileReply) ResumeReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.ResumeReply) RegisterValues(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues) BigInteger(java.math.BigInteger) RegisterDescription(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription) EchoBreakpointSetReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointSetReply) ExceptionOccurredReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.ExceptionOccurredReply) ResumeThreadReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.ResumeThreadReply) ListFilesReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.ListFilesReply) Test(org.junit.Test)

Example 18 with RegisterValue

use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue in project binnavi by google.

the class CStackMemoryProviderTest method testAddressMode.

@Test
public void testAddressMode() throws DebugExceptionWrapper {
    m_provider.setDebugger(m_debugger);
    m_debugger.connect();
    final TargetProcessThread thread = new TargetProcessThread(0, ThreadState.SUSPENDED);
    thread.setRegisterValues(Lists.newArrayList(new RegisterValue("esp", BigInteger.valueOf(0x123), new byte[0], false, true)));
    m_provider.setActiveThread(thread);
    m_debugger.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x100), new CAddress(0x180)))));
    m_debugger.getProcessManager().getMemory().store(0x120, new byte[] { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
    // Bytes + 32
    assertEquals("01000000", m_provider.getElement(0x120));
    m_provider.setDataLayout(StackDataLayout.Dwords);
    // Dwords + 32
    assertEquals("00000001", m_provider.getElement(0x120));
    m_provider.setAddressMode(AddressMode.BIT64);
    // Dwords + 64
    assertEquals("0000000000000001", m_provider.getElement(0x120));
    m_provider.setDataLayout(StackDataLayout.Bytes);
    // Bytes + 64
    assertEquals("0100000000000000", m_provider.getElement(0x120));
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) RegisterValue(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 19 with RegisterValue

use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue in project binnavi by google.

the class CStackMemoryProviderTest method testNumberOfEntries.

@Test
public void testNumberOfEntries() throws DebugExceptionWrapper {
    m_provider.setDebugger(m_debugger);
    m_debugger.getProcessManager().setTargetInformation(new TargetInformation(5, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 12, 0, new ArrayList<DebuggerException>(), false, false, false)));
    assertEquals(0, m_provider.getNumberOfEntries());
    m_debugger.connect();
    assertEquals(0, m_provider.getNumberOfEntries());
    final TargetProcessThread thread = new TargetProcessThread(0, ThreadState.SUSPENDED);
    thread.setRegisterValues(Lists.newArrayList(new RegisterValue("esp", BigInteger.valueOf(0x123), new byte[0], false, true)));
    m_provider.setActiveThread(thread);
    assertEquals(0, m_provider.getNumberOfEntries());
    m_debugger.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x100), new CAddress(0x180)))));
    assertEquals(0x80 / 0x04, m_provider.getNumberOfEntries());
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) RegisterValue(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) DebuggerException(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException) TargetInformation(com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation) DebuggerOptions(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 20 with RegisterValue

use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue in project binnavi by google.

the class CStackMemoryProviderTest method testStartAddress.

@Test
public void testStartAddress() throws DebugExceptionWrapper {
    m_provider.setDebugger(m_debugger);
    m_debugger.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x100), new CAddress(0x200)))));
    assertEquals(-1, m_provider.getStartAddress());
    m_debugger.connect();
    assertEquals(-1, m_provider.getStartAddress());
    final TargetProcessThread thread = new TargetProcessThread(0, ThreadState.SUSPENDED);
    thread.setRegisterValues(Lists.newArrayList(new RegisterValue("esp", BigInteger.valueOf(0x123), new byte[0], false, true)));
    assertEquals(-1, m_provider.getStartAddress());
    m_provider.setActiveThread(thread);
    assertEquals(0x100, m_provider.getStartAddress());
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) RegisterValue(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Aggregations

RegisterValue (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue)22 Test (org.junit.Test)16 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)14 ThreadRegisters (com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters)14 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)13 RegisterValues (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues)9 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)9 MemoryMap (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap)6 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)6 BigInteger (java.math.BigInteger)6 EchoBreakpointHitReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointHitReply)5 StepBreakpointHitReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointHitReply)5 StepBreakpointSetReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointSetReply)5 StepBreakpointsRemovedReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointsRemovedReply)4 BreakpointConditionSetReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.BreakpointConditionSetReply)3 EchoBreakpointSetReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointSetReply)3 EchoBreakpointsRemovedReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointsRemovedReply)3 TargetInformationReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply)3 ProcessManager (com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager)3 DebuggerOptions (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions)3