Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Value Conversions #694

Open
sraboy opened this Issue Feb 15, 2019 · 1 comment

Comments

Projects
None yet
1 participant
@sraboy
Copy link

sraboy commented Feb 15, 2019

I'd like to be able to highlight some arbitrary bytes and see a conversion in a tooltip or context menu. I imagine this would be easier for registers but I'm also talking about highlighting some arbitrary bytes in the Stack/Dump views. Endianness could either be automatically detected from the architecture or maybe both BE/LE versions of the value could be shown.

I imagine the simplest implementation would be a base-10 conversion in a tooltip. However, it would also be nice to see ASCII and octal, like IDA's context menu does on constants. It would also be great if, for integers, it could show both signed/unsigned versions of the value.

@sraboy

This comment has been minimized.

Copy link
Author

sraboy commented Feb 15, 2019

I cannot for the life of me capture a screenshot of the tooltip so here's a quick hack for QHexView that shows what I mean:

diff --git a/qhexview.cpp b/qhexview.cpp
index 3f16810..a69da53 100644
--- a/qhexview.cpp
+++ b/qhexview.cpp
@@ -28,6 +28,7 @@ The license chosen is at the discretion of the user of this software.
 #include <QSignalMapper>
 #include <QTextStream>
 #include <QtGlobal>
+#include <QtEndian>
 
 #include <cctype>
 #include <climits>
@@ -626,6 +627,21 @@ int64_t QHexView::pixelToWord(int x, int y) const {
 	return word;
 }
 
+//------------------------------------------------------------------------------
+// Name: setToolTip
+//------------------------------------------------------------------------------
+void QHexView::updateToolTip() {
+	if(selectedBytesSize() <= 0) {
+		return;
+	}
+
+	auto sb = selectedBytes();
+	QString tooltip = "Hex: " + sb.toHex();
+	tooltip += "\nUInt32: " + QString::number(qFromLittleEndian<quint32>(sb.data()));
+	tooltip += "\nInt32: " + QString::number(qFromLittleEndian<qint32>(sb.data()));
+	setToolTip(tooltip);
+}
+
 //------------------------------------------------------------------------------
 // Name: mouseDoubleClickEvent
 //------------------------------------------------------------------------------
@@ -666,6 +682,8 @@ void QHexView::mouseDoubleClickEvent(QMouseEvent *event) {
 			viewport()->update();
 		}
 	}
+
+	updateToolTip();
 }
 
 //------------------------------------------------------------------------------
@@ -702,6 +720,8 @@ void QHexView::mousePressEvent(QMouseEvent *event) {
 	if (event->button() == Qt::RightButton) {
 
 	}
+
+	updateToolTip();
 }
 
 //------------------------------------------------------------------------------
@@ -743,6 +763,7 @@ void QHexView::mouseMoveEvent(QMouseEvent *event) {
 
 		}
 		viewport()->update();
+		updateToolTip();
 	}
 }
 
diff --git a/qhexview.h b/qhexview.h
index 3e14d18..2fcf31b 100644
--- a/qhexview.h
+++ b/qhexview.h
@@ -157,6 +157,7 @@ private:
 	void drawHexDumpToBuffer(QTextStream &stream, uint64_t offset, uint64_t size, const QByteArray &row_data) const;
 	void ensureVisible(int64_t index);
 	void updateScrollbars();
+	void updateToolTip();
 
 private:
 	std::unique_ptr<CommentServerBase> commentServer_;

@sraboy sraboy referenced this issue Feb 16, 2019

Merged

UI Tweaks #7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.