Example #1
0
bool MemoryAgent::doCreateBinEditor(quint64 addr, unsigned flags,
                       const QList<MemoryMarkup> &ml, const QPoint &pos,
                       QString title, QWidget *parent)
{
    const bool readOnly = (flags & DebuggerEngine::MemoryReadOnly) != 0;
    if (title.isEmpty())
        title = tr("Memory at 0x%1").arg(addr, 0, 16);
    // Separate view?
    if (flags & DebuggerEngine::MemoryView) {
        // Ask BIN editor plugin for factory service and have it create a bin editor widget.
        QWidget *binEditor = 0;
        if (QObject *factory = ExtensionSystem::PluginManager::instance()->getObjectByClassName(QLatin1String("BINEditor::BinEditorWidgetFactory")))
            binEditor = ExtensionSystem::invoke<QWidget *>(factory, "createWidget", (QWidget *)0);
        if (!binEditor)
            return false;
        connectBinEditorWidget(binEditor);
        MemoryView::setBinEditorReadOnly(binEditor, readOnly);
        MemoryView::setBinEditorNewWindowRequestAllowed(binEditor, true);
        MemoryView *topLevel = 0;
        // Memory view tracking register value, providing its own updating mechanism.
        if (flags & DebuggerEngine::MemoryTrackRegister) {
            RegisterMemoryView *rmv = new RegisterMemoryView(binEditor, parent);
            rmv->init(m_engine->registerHandler(), int(addr));
            topLevel = rmv;
        } else {
            // Ordinary memory view
            MemoryView::setBinEditorMarkup(binEditor, ml);
            MemoryView::setBinEditorRange(binEditor, addr, MemoryAgent::DataRange, MemoryAgent::BinBlockSize);
            topLevel = new MemoryView(binEditor, parent);
            topLevel->setWindowTitle(title);
        }
        m_views << topLevel;
        topLevel->move(pos);
        topLevel->show();
        return true;
    }
    // Editor: Register tracking not supported.
    QTC_ASSERT(!(flags & DebuggerEngine::MemoryTrackRegister), return false);
    EditorManager *editorManager = EditorManager::instance();
    if (!title.endsWith(QLatin1Char('$')))
        title.append(QLatin1String(" $"));
    IEditor *editor = editorManager->openEditorWithContents(
                Core::Constants::K_DEFAULT_BINARY_EDITOR_ID, &title);
    if (!editor)
        return false;
    editor->setProperty(Constants::OPENED_BY_DEBUGGER, QVariant(true));
    editor->setProperty(Constants::OPENED_WITH_MEMORY, QVariant(true));
    QWidget *editorBinEditor = editor->widget();
    connectBinEditorWidget(editorBinEditor);
    MemoryView::setBinEditorReadOnly(editorBinEditor, readOnly);
    MemoryView::setBinEditorNewWindowRequestAllowed(editorBinEditor, true);
    MemoryView::setBinEditorRange(editorBinEditor, addr, MemoryAgent::DataRange, MemoryAgent::BinBlockSize);
    MemoryView::setBinEditorMarkup(editorBinEditor, ml);
    m_editors << editor;
    editorManager->activateEditor(editor);
    return true;
}
Example #2
0
void MemoryView::read(MemoryView& dest) {
    const auto thisSize = size();

    if (thisSize < dest.size()) {
        raise<OverflowException>("dest", thisSize, 0, dest.size());
    }

    memcpy(dest.dataAddress(), dataAddress(), dest.size());
    // TODO(abbyssoul): return Result<>;
}
Example #3
0
/*static */ MemoryView*
MemoryView::Create(::Team* team, Listener* listener)
{
	MemoryView* self = new MemoryView(team, listener);

	try {
		self->_Init();
	} catch(...) {
		delete self;
		throw;
	}

	return self;
}
Example #4
0
void MemoryView::write(const MemoryView& source, size_type offset) {
    const auto thisSize = size();

    if (offset > thisSize) {  // Make sure that offset is within [0, size())
        raise<IndexOutOfRangeException>("offset", offset, 0, thisSize);
    }

    if (source.size() >= thisSize - offset) {  // Make sure that source is writing no more then there is room.
        raise<OverflowException>("source", source.size(), 0, thisSize - offset);
    }

    memcpy(dataAddress(offset), source.dataAddress(), source.size());

    // TODO(abbyssoul): return Result<>;
}
Example #5
0
void MemorySearch::openMemory() {
	auto items = m_ui.results->selectedItems();
	if (items.empty()) {
		return;
	}
	QTableWidgetItem* item = items[0];
	uint32_t address = item->text().toUInt(nullptr, 16);

	MemoryView* memView = new MemoryView(m_controller);
	memView->jumpToAddress(address);

	connect(m_controller, &GameController::gameStopped, memView, &QWidget::close);
	memView->setAttribute(Qt::WA_DeleteOnClose);
	memView->show();
}
Example #6
0
void MemoryView::read(MemoryView& dest, size_type bytesToRead, size_type offset) {
    const auto thisSize = size();

    if (thisSize < offset) {  // Make sure that offset is within [0, size())
        raise<IndexOutOfRangeException>("offset", offset, 0, thisSize);
    }

    if (bytesToRead > thisSize - offset) {  // Make sure that bytes to read is within [offset, size())
        raise<IndexOutOfRangeException>("bytesToRead", offset, 0, thisSize - offset);
    }

    if (dest.size() < bytesToRead) {  // Make sure that dest has enough space to store data
        raise<OverflowException>("dest.size()", dest.size(), 0, bytesToRead);
    }

    memcpy(dest.dataAddress(), dataAddress(offset), bytesToRead);

    // TODO(abbyssoul): return Result<>;
}
Example #7
0
bool MemoryAgent::doCreateBinEditor(quint64 addr, unsigned flags,
                       const QList<MemoryMarkup> &ml, const QPoint &pos,
                       QString title, QWidget *parent)
{
    const bool readOnly = (flags & DebuggerEngine::MemoryReadOnly) != 0;
    if (title.isEmpty())
        title = tr("Memory at 0x%1").arg(addr, 0, 16);
    // Separate view?
    if (flags & DebuggerEngine::MemoryView) {
        // Ask BIN editor plugin for factory service and have it create a bin editor widget.
        QWidget *binEditor = 0;
        if (QObject *factory = ExtensionSystem::PluginManager::instance()->getObjectByClassName("BINEditor::BinEditorWidgetFactory"))
            binEditor = ExtensionSystem::invoke<QWidget *>(factory, "createWidget", (QWidget *)0);
        if (!binEditor)
            return false;
        connectBinEditorWidget(binEditor);
        MemoryView::setBinEditorReadOnly(binEditor, readOnly);
        MemoryView::setBinEditorNewWindowRequestAllowed(binEditor, true);
        MemoryView *topLevel = 0;
        // Memory view tracking register value, providing its own updating mechanism.
        if (flags & DebuggerEngine::MemoryTrackRegister) {
            RegisterMemoryView *rmv = new RegisterMemoryView(binEditor, parent);
            rmv->init(m_engine->registerHandler(), int(addr));
            topLevel = rmv;
        } else {
            // Ordinary memory view
            MemoryView::setBinEditorMarkup(binEditor, ml);
            MemoryView::setBinEditorRange(binEditor, addr, MemoryAgent::DataRange, MemoryAgent::BinBlockSize);
            topLevel = new MemoryView(binEditor, parent);
            topLevel->setWindowTitle(title);
        }
        m_views << topLevel;
        topLevel->move(pos);
        topLevel->show();
        return true;
    }
    // Editor: Register tracking not supported.
    QTC_ASSERT(!(flags & DebuggerEngine::MemoryTrackRegister), return false; )