use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class BreakpointsRemovedParser method parseSuccess.
@Override
public BreakpointsRemovedReply parseSuccess(final int packetId, final int argumentCount) throws IOException {
final int counter = parseInteger();
final List<Pair<RelocatedAddress, Integer>> addresses = new ArrayList<>();
for (int i = 0; i < counter; i++) {
final RelocatedAddress address = new RelocatedAddress(parseAddress());
final int error = parseInteger();
addresses.add(new Pair<RelocatedAddress, Integer>(address, error));
}
return new BreakpointsRemovedReply(packetId, 0, addresses);
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class ExceptionOccurredParser method parseSuccess.
@Override
public ExceptionOccurredReply parseSuccess(final int packetId, final int argumentCount) throws IOException {
Preconditions.checkArgument(argumentCount == 1, "IE00068: Unexpected number of argument while parsing exception occured packet");
final byte[] data = parseData();
Preconditions.checkNotNull(data, "IE00095: Data argument can not be null");
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
final DocumentBuilder builder = factory.newDocumentBuilder();
final Document document = builder.parse(new ByteArrayInputStream(data, 0, data.length));
final Node node = document.getFirstChild();
final long threadId = Long.valueOf(node.getAttributes().getNamedItem("threadId").getNodeValue());
final RelocatedAddress address = new RelocatedAddress(new CAddress(new BigInteger(node.getAttributes().getNamedItem("address").getNodeValue())));
final long exceptionCode = Long.valueOf(node.getAttributes().getNamedItem("exceptionCode").getNodeValue());
String exceptionName = node.getAttributes().getNamedItem("exceptionName").getNodeValue();
if (exceptionName.isEmpty()) {
exceptionName = "Unknown exception";
}
return new ExceptionOccurredReply(packetId, 0, threadId, exceptionCode, address, exceptionName);
} catch (final Exception exception) {
CUtilityFunctions.logException(exception);
throw new IllegalStateException("IE00097: Unexpected error while parsing exception occured packet");
}
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress 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());
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class CDebuggerFunctions method stepEnd.
/**
* Lets the debugger step to the end of the function.
*
* @param parent Parent window used for dialogs.
* @param debugger The debugger that steps to the end of the function.
* @param graph The graph where the step operation happens.
*/
public static void stepEnd(final JFrame parent, final IDebugger debugger, final ZyGraph graph) {
checkArguments(parent, debugger, graph);
if (!debugger.isConnected()) {
return;
}
final TargetProcessThread activeThread = debugger.getProcessManager().getActiveThread();
if (activeThread == null) {
return;
}
final RelocatedAddress currentAddress = activeThread.getCurrentAddress();
if (currentAddress == null) {
CMessageBox.showError(parent, "Could not step because the selected thread is not suspended");
return;
}
final Set<BreakpointAddress> relocatedBlockAddresses = CStepEndHelper.getEndAddresses(graph);
if (relocatedBlockAddresses.isEmpty()) {
CMessageBox.showError(parent, "Couldn't step to the end of the function");
return;
} else {
debugger.getProcessManager().setActiveThread(null);
debugger.getBreakpointManager().addBreakpoints(BreakpointType.STEP, relocatedBlockAddresses);
try {
debugger.resume();
} catch (final DebugExceptionWrapper e) {
debugger.getBreakpointManager().removeBreakpoints(BreakpointType.STEP, relocatedBlockAddresses);
debugger.getProcessManager().setActiveThread(activeThread);
CUtilityFunctions.logException(e);
final String innerMessage = "E00086: " + "Could not send step end command to the debug client";
final String innerDescription = CUtilityFunctions.createDescription("BinNavi could not send the step end command to the debug client.", new String[] { "There was a problem with the connection to the debug client." }, new String[] { "The state of the debugged process remains unchanged." });
NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
}
}
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class CMemoryRefreshButtonSynchronizerTest method testSwitchDebugger.
@Test
public void testSwitchDebugger() throws DebugExceptionWrapper {
final TargetProcessThread thread = new TargetProcessThread(0x666, ThreadState.RUNNING);
final MemoryModule module = new MemoryModule("narf.exe", "C:\\zort\\narf.exe", new RelocatedAddress(new CAddress(0x1000)), 123345);
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
debugger.connect();
debugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, new TargetInformation(32, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, true, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false))));
debugger.connection.m_synchronizer.receivedEvent(new ProcessStartReply(0, 0, new ProcessStart(thread, module)));
final MockDebugger debugger2 = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
debugger2.connect();
debugger2.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, new TargetInformation(32, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false))));
debugger2.connection.m_synchronizer.receivedEvent(new ProcessStartReply(0, 0, new ProcessStart(thread, module)));
m_model.setActiveDebugger(debugger);
debugger.getProcessManager().setActiveThread(thread);
assertTrue(m_refreshButton.isEnabled());
assertEquals(m_defaultAction, m_refreshButton.getAction());
m_model.setActiveDebugger(debugger2);
debugger2.getProcessManager().setActiveThread(thread);
assertTrue(m_refreshButton.isEnabled());
assertEquals(m_askAction, m_refreshButton.getAction());
m_synchronizer.dispose();
debugger.close();
debugger2.close();
}
Aggregations