diff --git a/src/Cutter.cpp b/src/Cutter.cpp index 8dec4956..5cbbe1a9 100644 --- a/src/Cutter.cpp +++ b/src/Cutter.cpp @@ -772,6 +772,21 @@ QList CutterCore::getRegisterRefs() return ret; } +QJsonObject CutterCore::getRegisterJson() +{ + QJsonArray registerRefArray = cmdj("drrj").array(); + QJsonObject registerJson; + for (QJsonValue value : registerRefArray) { + QJsonObject regRefObject = value.toObject(); + + QJsonObject registers; + registers.insert("value", regRefObject["value"]); + registers.insert("ref", regRefObject["ref"]); + registerJson.insert(regRefObject["reg"].toString(), registers); + } + return registerJson; +} + QString CutterCore::getRegisterName(QString registerRole) { return cmd("drn " + registerRole).trimmed(); diff --git a/src/Cutter.h b/src/Cutter.h index 28a175d8..6b3eb41d 100644 --- a/src/Cutter.h +++ b/src/Cutter.h @@ -575,6 +575,7 @@ public: QList getBreakpoints(); QList getAllProcesses(); QList getRegisterRefs(); + QJsonObject getRegisterJson(); QList getXRefs(RVA addr, bool to, bool whole_function, const QString &filterType = QString::null); diff --git a/src/widgets/RegistersWidget.cpp b/src/widgets/RegistersWidget.cpp index 9a60a201..47722d6b 100644 --- a/src/widgets/RegistersWidget.cpp +++ b/src/widgets/RegistersWidget.cpp @@ -59,8 +59,9 @@ void RegistersWidget::setRegisterGrid() QLabel *registerLabel; QLineEdit *registerEditValue; QJsonObject registerValues = Core()->getRegisterValues().object(); + QJsonObject registerRefs = Core()->getRegisterJson(); QStringList registerNames = registerValues.keys(); - registerLen = registerNames.size(); + registerLen = registerValues.size(); for (const QString &key : registerNames) { regValue = RAddressString(registerValues[key].toVariant().toULongLong()); // check if we already filled this grid space with label/value @@ -79,7 +80,8 @@ void RegistersWidget::setRegisterGrid() QString regNameString = registerLabel->text(); QString regValueString = registerEditValue->text(); Core()->setRegister(regNameString, regValueString); - printf("dr %s %s\n", regNameString.toLocal8Bit().constData(), regValueString.toLocal8Bit().constData()); + printf("dr %s %s\n", regNameString.toLocal8Bit().constData(), + regValueString.toLocal8Bit().constData()); }); } else { QWidget *regNameWidget = registerLayout->itemAtPosition(i, col)->widget(); @@ -96,6 +98,12 @@ void RegistersWidget::setRegisterGrid() } // define register label and value registerLabel->setText(key); + if (registerRefs.contains(key)) { + // add register references to tooltips + QString reference = registerRefs[key].toObject()["ref"].toString(); + registerLabel->setToolTip(reference); + registerEditValue->setToolTip(reference); + } registerEditValue->setPlaceholderText(regValue); registerEditValue->setText(regValue); i++;