Skip to content

Commit

Permalink
Fix "return" key in disassembler widget (#3090)
Browse files Browse the repository at this point in the history
Fix graph jumps
  • Loading branch information
Yappa authored and whoppa committed Mar 9, 2023
1 parent e69a007 commit 16b195a
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 6 deletions.
2 changes: 1 addition & 1 deletion rizin
Submodule rizin updated 53 files
+11 −1 .github/workflows/ci.yml
+2 −5 librz/analysis/arch/x86/x86_il.c
+2 −3 librz/asm/arch/arm/armass.c
+9 −4 librz/asm/asm.c
+2 −1 librz/asm/p/asm_sparc_gnu.c
+2 −2 librz/bin/format/pe/dotnet.c
+6 −62 librz/cons/dietline.c
+27 −0 librz/core/cil.c
+8 −23 librz/core/cmd/cmd_debug.c
+1 −1 librz/core/cmd/cmd_open.c
+1 −1 librz/core/cmd/cmd_print.c
+4 −1 librz/core/cmd_descs/cmd_debug.yaml
+13 −1 librz/core/cmd_descs/cmd_descs.c
+1 −1 librz/core/cmd_descs/cmd_descs.h
+2 −2 librz/core/tui/vmenus.c
+1 −2 librz/debug/p/native/linux/linux_debug.c
+85 −0 librz/il/definitions/float.c
+36 −0 librz/il/definitions/value.c
+490 −0 librz/il/il_export.c
+458 −4 librz/il/il_opcodes.c
+98 −0 librz/il/il_vm_eval.c
+2 −0 librz/il/meson.build
+415 −0 librz/il/theory_fbasic.c
+4 −0 librz/il/theory_init.c
+1 −0 librz/include/meson.build
+1 −0 librz/include/rz_il/definitions/definitions.h
+21 −0 librz/include/rz_il/definitions/float.h
+14 −1 librz/include/rz_il/definitions/sort.h
+2 −0 librz/include/rz_il/definitions/value.h
+280 −0 librz/include/rz_il/rz_il_opcodes.h
+1 −0 librz/include/rz_il/rz_il_vm.h
+0 −10 librz/include/rz_types_base.h
+2 −0 librz/include/rz_userconf.h.in
+11 −44 librz/include/rz_util/rz_alloc.h
+41 −0 librz/include/rz_util/rz_float.h
+0 −3 librz/include/rz_util/rz_mem.h
+7 −2 librz/io/p/io_ptrace.c
+1 −1 librz/main/rz-ax.c
+3 −7 librz/parse/filter.c
+26 −57 librz/util/alloc.c
+2 −2 librz/util/annotated_code.c
+715 −123 librz/util/float/float.c
+167 −141 librz/util/float/float_internal.c
+1 −54 librz/util/mem.c
+3 −1 meson.build
+1 −1 snapcraft.yaml
+7 −4 test/db/analysis/x86_32
+9 −1 test/db/archos/linux-x64/asm_x64_as
+6 −6 test/db/asm/x86_16
+183 −183 test/db/asm/x86_32
+228 −228 test/db/asm/x86_64
+699 −0 test/unit/test_float.c
+153 −0 test/unit/test_il_vm.c
1 change: 1 addition & 0 deletions src/common/CutterSeekable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ void CutterSeekable::seekToReference(RVA offset)
}

RVA target;
// finds the xrefs for calls, lea, and jmp
QList<XrefDescription> refs = Core()->getXRefs(offset, false, false);

if (refs.length()) {
Expand Down
10 changes: 10 additions & 0 deletions src/common/DisassemblyPreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,13 @@ RVA DisassemblyPreview::readDisassemblyOffset(QTextCursor tc)

return userData->line.offset;
}

RVA DisassemblyPreview::readDisassemblyArrow(QTextCursor tc)
{
auto userData = getUserData(tc.block());
if (!userData && userData->line.arrow != RVA_INVALID) {
return RVA_INVALID;
}

return userData->line.arrow;
}
6 changes: 6 additions & 0 deletions src/common/DisassemblyPreview.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,11 @@ bool showDisasPreview(QWidget *parent, const QPoint &pointOfEvent, const RVA off
* @return The disassembly offset of the hovered asm text
*/
RVA readDisassemblyOffset(QTextCursor tc);

/*!
* @brief Reads the arrow offset for the cursor position
* @return The jump address of the hovered asm text
*/
RVA readDisassemblyArrow(QTextCursor tc);
}
#endif
2 changes: 1 addition & 1 deletion src/translations
Submodule translations updated 1 files
+16 −16 zh-CN/cutter_zh.ts
36 changes: 35 additions & 1 deletion src/widgets/DisassemblerGraphView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,41 @@ void DisassemblerGraphView::blockDoubleClicked(GraphView::GraphBlock &block, QMo
QPoint pos)
{
Q_UNUSED(event);
seekable->seekToReference(getAddrForMouseEvent(block, &pos));
RVA arrow = NULL;
RVA offset = getAddrForMouseEvent(block, &pos);
DisassemblyBlock *db = blockForAddress(offset);

Instr lastInstruction = db->instrs.back();

// Handle the blocks without any paths
if (offset == lastInstruction.addr && db->false_path == RVA_INVALID
&& db->true_path == RVA_INVALID) {
return;
}

// Handle the blocks with just one path
if (offset == lastInstruction.addr && db->false_path == RVA_INVALID) {
seekable->seek(db->true_path);
return;
}

// Handle blocks with two paths
if (offset == lastInstruction.addr && db->false_path != RVA_INVALID) {
// gets the offset for the next instruction
RVA nextOffset = lastInstruction.addr + lastInstruction.size;
// sets "arrow" to the path that isn't going to the next offset
if (db->false_path == nextOffset) {
arrow = db->true_path;
} else if (db->true_path == nextOffset) {
arrow = db->false_path;
}

seekable->seek(arrow);
return;
}

// Handle "call" instruction to functions
seekable->seekToReference(offset);
}

void DisassemblerGraphView::blockHelpEvent(GraphView::GraphBlock &block, QHelpEvent *event,
Expand Down
12 changes: 9 additions & 3 deletions src/widgets/DisassemblyWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,13 @@ void DisassemblyWidget::moveCursorRelative(bool up, bool page)

void DisassemblyWidget::jumpToOffsetUnderCursor(const QTextCursor &cursor)
{
// Handles "jmp" and conditonal jump instructions
RVA arrow = DisassemblyPreview::readDisassemblyArrow(cursor);
if (arrow != RVA_INVALID) {
seekable->seek(arrow);
}

// Handles "call" and "lea" instructions
RVA offset = DisassemblyPreview::readDisassemblyOffset(cursor);
seekable->seekToReference(offset);
}
Expand All @@ -627,9 +634,8 @@ bool DisassemblyWidget::eventFilter(QObject *obj, QEvent *event)
jumpToOffsetUnderCursor(cursor);

return true;
} else if (Config()->getPreviewValue()
&& event->type() == QEvent::ToolTip
&& obj == mDisasTextEdit->viewport()) {
} else if (Config()->getPreviewValue() && event->type() == QEvent::ToolTip
&& obj == mDisasTextEdit->viewport()) {
QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);

auto cursorForWord = mDisasTextEdit->cursorForPosition(helpEvent->pos());
Expand Down

0 comments on commit 16b195a

Please sign in to comment.