WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 6187d45

Browse files
committed
Fixing Set-to-data shortkey
The underlying functionality makes it possible to switch a certain memory in Cutter to data (via the shortcut `d`). This functionality is comparable to other similar products. The functionality already existed in cutter. Unfortunately it was broken due to two problems: * The underlying action was not added to a widget - this is now fixed, by adding it to the `setToDataMenu` - like other related actions * If the underlying meta was not prevously data, it simply just ignored the action, as the size of the data returned uninitilialized memory. This is now fixed. Returning -1 from `CutterCore::sizeofDataMeta` indicates that the Meta at the address is currently no data.
1 parent 61f412c commit 6187d45

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/core/Cutter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ void CutterCore::setToData(RVA addr, int size, int repeat)
866866

867867
int CutterCore::sizeofDataMeta(RVA addr)
868868
{
869-
ut64 size;
869+
ut64 size = -1;
870870
CORE_LOCK();
871871
rz_meta_get_at(core->analysis, addr, RZ_META_TYPE_DATA, &size);
872872
return (int)size;

src/menus/DisassemblyContextMenu.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ void DisassemblyContextMenu::addSetToDataMenu()
284284

285285
auto switchAction = new QAction(this);
286286
initShortcutAction(switchAction, "Disassembly.setToData", SLOT(on_actionSetToData_triggered()));
287+
setToDataMenu->addAction(switchAction);
287288
}
288289

289290
void DisassemblyContextMenu::addEditMenu()
@@ -912,6 +913,10 @@ void DisassemblyContextMenu::on_actionSetAsStringAdvanced_triggered()
912913
void DisassemblyContextMenu::on_actionSetToData_triggered()
913914
{
914915
int size = Core()->sizeofDataMeta(offset);
916+
if (size < 0) {
917+
setToData(1);
918+
return;
919+
}
915920
if (size > 8 || (size && (size & (size - 1)))) {
916921
return;
917922
}

0 commit comments

Comments
 (0)