use of com.google.security.zynamics.zylib.disassembly.CAddress 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.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);
}
}
use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class ReilHelpers method createNop.
/**
* Creates a NOP instruction.
*
* @param offset The offset of the instruction
*
* @return The created instruction
*/
public static ReilInstruction createNop(final long offset) {
final ReilOperand firstOperand = createOperand(OperandSize.EMPTY, "");
final ReilOperand secondOperand = createOperand(OperandSize.EMPTY, "");
final ReilOperand thirdOperand = createOperand(OperandSize.EMPTY, "");
return new ReilInstruction(new CAddress(offset), ReilHelpers.OPCODE_NOP, firstOperand, secondOperand, thirdOperand);
}
use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class ReilHelpers method createUndef.
/**
* Creates an UNDEF instruction.
*
* @param offset The offset of the instruction
* @param size The size of the value
* @param value The value to be undefined
*
* @return The created instruction
*/
public static ReilInstruction createUndef(final long offset, final OperandSize size, final String value) {
final ReilOperand firstOperand = createOperand(OperandSize.EMPTY, "");
final ReilOperand secondOperand = createOperand(OperandSize.EMPTY, "");
final ReilOperand thirdOperand = createOperand(size, value);
return new ReilInstruction(new CAddress(offset), ReilHelpers.OPCODE_UNDEF, firstOperand, secondOperand, thirdOperand);
}
use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class CModuleOverviewPanel method updateSaveButton.
/**
* Updates the Save button depending on the input state.
*/
private void updateSaveButton() {
final String fileBaseText = m_debuggerPanel.getFileBase();
final boolean fileBaseChanged = "".equals(fileBaseText) || !new CAddress(Convert.hexStringToLong(fileBaseText)).equals(m_module.getConfiguration().getFileBase());
final boolean imageBaseChanged = isImageBaseModified();
m_saveButton.setEnabled(!m_stdEditPanel.getNameString().equals(m_module.getConfiguration().getName()) || !m_stdEditPanel.getDescription().equals(m_module.getConfiguration().getDescription()) || fileBaseChanged || imageBaseChanged || (m_debuggerPanel.getSelectedDebugger() != m_module.getConfiguration().getDebuggerTemplate()));
}
Aggregations