diff options
| author | Xusheng <xusheng@vector35.com> | 2024-07-26 15:57:14 +0800 |
|---|---|---|
| committer | Xusheng <xusheng@vector35.com> | 2024-08-02 12:17:53 +0800 |
| commit | abbae639d8ba182e8b3cf2d5a9844a9b1f9844a1 (patch) | |
| tree | 272322e3269b09201c12489d93e7fbeb614fb140 /examples/triage/analysisinfo.cpp | |
| parent | 7a9a2503aae0c2b92b437b2ea7796efaae93a822 (diff) | |
Support setting user global pointer value
Diffstat (limited to 'examples/triage/analysisinfo.cpp')
| -rw-r--r-- | examples/triage/analysisinfo.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/examples/triage/analysisinfo.cpp b/examples/triage/analysisinfo.cpp new file mode 100644 index 00000000..a10b4472 --- /dev/null +++ b/examples/triage/analysisinfo.cpp @@ -0,0 +1,76 @@ +#include <QtCore/QTimer> +#include "analysisinfo.h" +#include "fontsettings.h" +#include "util.h" + +AnalysisInfoWidget::AnalysisInfoWidget(QWidget* parent, BinaryViewRef data): QWidget(parent), m_data(data) +{ + m_layout = new QGridLayout(); + m_layout->setContentsMargins(0, 0, 0, 0); + m_layout->setVerticalSpacing(1); + + auto* gpValueLayout = new QHBoxLayout(); + gpValueLayout->setContentsMargins(0, 0, 0, 0); + m_gpLabel = new NavigationAddressLabel(""); + m_gpLabel->setFont(getMonospaceFont(this)); + gpValueLayout->addWidget(m_gpLabel); + + m_gpExtraLabel = new QLabel; + gpValueLayout->addWidget(m_gpExtraLabel); + + m_layout->addWidget(new QLabel("Global Pointer Value:"), 0, 0); + m_layout->addLayout(gpValueLayout, 0, 1); + + const auto scaledWidth = UIContext::getScaledWindowSize(20, 20).width(); + this->m_layout->setColumnMinimumWidth(AnalysisInfoWidget::m_maxColumns * 3 - 1, scaledWidth); + this->m_layout->setColumnStretch(AnalysisInfoWidget::m_maxColumns * 3 - 1, 1); + setLayout(m_layout); + + updateDisplay(); + + auto* timer = new QTimer(this); + connect(timer, &QTimer::timeout, this, &AnalysisInfoWidget::timerExpired); + timer->setInterval(100); + timer->setSingleShot(false); + timer->start(); +} + + +AnalysisInfoWidget::~AnalysisInfoWidget() +{ + +} + + +void AnalysisInfoWidget::timerExpired() +{ + auto gpValue = m_data->GetGlobalPointerValue(); + if (gpValue == m_lastGPValue) + return; + + m_lastGPValue = gpValue; + updateDisplay(); +} + + +void AnalysisInfoWidget::updateDisplay() +{ + auto callingConvention = m_data->GetDefaultPlatform()->GetDefaultCallingConvention(); + auto gpRegister = callingConvention->GetGlobalPointerRegister(); + std::string gpString, gpExtraString; + if (gpRegister == BN_INVALID_REGISTER) + { + gpString = "N/A"; + } + else + { + auto gpValue = m_data->GetGlobalPointerValue(); + gpString = getStringForRegisterValue(m_data->GetDefaultArchitecture(), gpValue); + gpExtraString = std::string(" @ ") + m_data->GetDefaultArchitecture()->GetRegisterName(gpRegister); + if (m_data->UserGlobalPointerValueSet()) + gpExtraString += " (*)"; + } + + m_gpLabel->setText(QString::fromStdString(gpString)); + m_gpExtraLabel->setText(QString::fromStdString(gpExtraString)); +} |
