use of com.google.security.zynamics.zylib.gui.JHexPanel.JHexView in project binnavi by google.
the class CMemoryFunctions method searchMemory.
/**
* Shows a Search dialog and searches through the memory of target process afterwards.
*
* @param parent Parent window used for dialogs.
* @param debugger Debugger that requests the target memory.
* @param memoryView Memory view where the search result is shown.
*/
public static void searchMemory(final Window parent, final IDebugger debugger, final CMemoryViewer memoryView) {
checkArguments(parent, debugger);
Preconditions.checkNotNull(memoryView, "IE01431: Memory view argument can not be null");
// Show the search dialog
final CSearchDialog dlg = new CSearchDialog(parent);
final byte[] data = dlg.getSearchData();
// Make sure that the user entered data and clicked the OK button
if (data != null && data.length != 0) {
final JHexView hexView = memoryView.getHexView();
final long start = hexView.getCurrentOffset();
final int size = (int) (hexView.getLastOffset() - hexView.getCurrentOffset());
final CSearchWaiter waiter = new CSearchWaiter(debugger, new CAddress(start), size, data);
CProgressDialog.showEndless(parent, "Loading memory" + " ...", waiter);
hexView.uncolorizeAll();
if (waiter.getException() == null) {
final SearchReply reply = waiter.getReply();
if (reply != null) {
final IAddress offset = reply.getAddress();
if (reply.success()) {
// Make sure that the memory data is actually available
if (hexView.isEnabled() && hexView.getDefinitionStatus() == DefinitionStatus.DEFINED) {
// It is not necessary to make sure that the offset is
// actually part of the currently visible memory range.
// If it is not, the new memory range is loaded automatically.
hexView.colorize(5, offset.toLong(), data.length, Color.BLACK, Color.YELLOW);
hexView.gotoOffset(offset.toLong());
hexView.requestFocusInWindow();
}
} else {
// Tell the user that the search string was not found
CMessageBox.showInformation(parent, "The specified search string was not found.");
}
}
} else {
CUtilityFunctions.logException(waiter.getException());
final String innerMessage = "E00079: " + "Could not search through memory";
final String innerDescription = CUtilityFunctions.createDescription("It was not possible to send the search request to the debug client.", new String[] { "There was a problem with the connection to the debug client." }, new String[] { "The search operation could not be started." });
NaviErrorDialog.show(parent, innerMessage, innerDescription, waiter.getException());
}
}
}
use of com.google.security.zynamics.zylib.gui.JHexPanel.JHexView in project binnavi by google.
the class CMemoryViewerSynchronizerTest method testNewThread.
/**
* This test makes sure that the synchronizer can handle new threads.
*
* Fix for Case 2036: Listener issue in the memory viewer
*/
@Test
public void testNewThread() {
final IGraphModel graphModel = new MockGraphModel();
final CDebugPerspectiveModel model = new CDebugPerspectiveModel(graphModel);
final JHexView hexView = new JHexView();
final CMemoryProvider provider = new CMemoryProvider();
model.setActiveDebugger(m_debugger);
final TargetProcessThread thread = new TargetProcessThread(0, ThreadState.RUNNING);
m_debugger.getProcessManager().addThread(thread);
m_debugger.getProcessManager().setActiveThread(thread);
final CMemoryViewerSynchronizer synchronizer = new CMemoryViewerSynchronizer(hexView, provider, model);
synchronizer.dispose();
}
use of com.google.security.zynamics.zylib.gui.JHexPanel.JHexView in project binnavi by google.
the class CMemoryViewerSynchronizerTest method testActiveDebugger.
@Test
public void testActiveDebugger() {
final IGraphModel graphModel = new MockGraphModel();
final CDebugPerspectiveModel model = new CDebugPerspectiveModel(graphModel);
final JHexView hexView = new JHexView();
final CMemoryProvider provider = new CMemoryProvider();
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
model.setActiveDebugger(debugger);
final CMemoryViewerSynchronizer synchronizer = new CMemoryViewerSynchronizer(hexView, provider, model);
debugger.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))));
assertEquals(AddressMode.BIT32, hexView.getAddressMode());
debugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, new TargetInformation(64, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false))));
assertEquals(AddressMode.BIT64, hexView.getAddressMode());
synchronizer.dispose();
}
Aggregations