Search in sources :

Example 86 with CAddress

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());
        }
    }
}
Also used : JHexView(com.google.security.zynamics.zylib.gui.JHexPanel.JHexView) CSearchDialog(com.google.security.zynamics.binnavi.Gui.Debug.SearchMemory.CSearchDialog) SearchReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.SearchReply) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 87 with CAddress

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);
    }
}
Also used : BigInteger(java.math.BigInteger) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 88 with CAddress

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);
}
Also used : CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 89 with CAddress

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);
}
Also used : CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 90 with CAddress

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()));
}
Also used : CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Aggregations

CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)315 Test (org.junit.Test)221 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)60 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)55 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)51 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)48 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)47 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)47 ArrayList (java.util.ArrayList)46 Date (java.util.Date)46 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)45 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)40 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)32 MemoryMap (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap)29 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)28 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)27 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)27 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)26 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)24 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)24