librz/core/tui: fix panel mode and visual modes cmd format and redundant quotes (#6520)

* Fix and add new gadget search cmds
* Fix some more commands and menus
* Fix /a error message
This commit is contained in:
MrQuantum1915 2026-06-18 08:36:17 +05:30 committed by GitHub
parent 5927b2f6dd
commit b9d2a03be3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 35 additions and 18 deletions

View file

@ -1862,7 +1862,7 @@ RZ_IPI RzCmdStatus rz_cmd_search_assemble_handler(RzCore *core, int argc, const
RzAsmCode *acode;
if (!(acode = rz_asm_massemble(core->rasm, argv[1]))) {
RZ_LOG_ERROR("Failed to assemble '%s'\n", argv[1]);
RZ_LOG_ERROR("Consider using \"/ar\" instead.\n");
RZ_LOG_ERROR("Consider using \"/ad\" instead.\n");
return RZ_CMD_STATUS_ERROR;
}
size_t len = acode->len;

View file

@ -122,7 +122,7 @@ static const char *menus_Tools[] = {
};
static const char *menus_Search[] = {
"String (Whole Bin)", "String (Data Sections)", "ROP", "Code", "Hexpairs",
"String (Whole Bin)", "String (Data Sections)", "ROP", "COP", "JOP", "Code", "Hexpairs",
NULL
};
@ -489,6 +489,8 @@ static int __system_shell_cb(void *user);
static int __string_whole_bin_cb(void *user);
static int __string_data_sec_cb(void *user);
static int __rop_cb(void *user);
static int __cop_cb(void *user);
static int __jop_cb(void *user);
static int __code_cb(void *user);
static int __hexpairs_cb(void *user);
static int __continue_cb(void *user);
@ -1634,7 +1636,7 @@ void __handleComment(RzCore *core) {
char buf[4095];
int i;
rz_line_set_prompt(core->cons->line, "[Comment]> ");
strcpy(buf, "\"CC ");
strcpy(buf, "CC \"");
i = strlen(buf);
if (rz_cons_fgets(buf + i, sizeof(buf) - i, 0, NULL) > 0) {
ut64 addr, orig;
@ -1648,18 +1650,18 @@ void __handleComment(RzCore *core) {
} else {
switch (buf[i]) {
case '-':
memcpy(buf, "\"CC-", 5);
memcpy(buf, "CC-\"", 4);
break;
case '!':
memcpy(buf, "\"CC!", 5);
memcpy(buf, "CC!\"", 4);
break;
default:
memcpy(buf, "\"CC ", 4);
memcpy(buf, "CC \"", 4);
break;
}
strcat(buf, "\"");
}
if (buf[3] == ' ') {
if (buf[2] == ' ') {
int j, len = strlen(buf);
char *duped = rz_str_dup(buf);
for (i = 4, j = 4; i < len; i++, j++) {
@ -3238,7 +3240,7 @@ int __clear_layout_cb(void *user) {
int __copy_cb(void *user) {
RzCore *core = (RzCore *)user;
__add_cmdf_panel(core, "How many bytes? ", "\"y %s\"");
__add_cmdf_panel(core, "How many bytes? ", "y %s");
return 0;
}
@ -3250,13 +3252,13 @@ int __paste_cb(void *user) {
int __write_str_cb(void *user) {
RzCore *core = (RzCore *)user;
__add_cmdf_panel(core, "insert string: ", "\"w %s\"");
__add_cmdf_panel(core, "insert string: ", "w %s");
return 0;
}
int __write_hex_cb(void *user) {
RzCore *core = (RzCore *)user;
__add_cmdf_panel(core, "insert hexpairs: ", "\"wx %s\"");
__add_cmdf_panel(core, "insert hexpairs: ", "wx %s");
return 0;
}
@ -3386,19 +3388,31 @@ int __string_data_sec_cb(void *user) {
int __rop_cb(void *user) {
RzCore *core = (RzCore *)user;
__add_cmdf_panel(core, "rop grep: ", "\"/R %s\"");
__add_cmdf_panel(core, "rop grep: ", "/R %s");
return 0;
}
int __cop_cb(void *user) {
RzCore *core = (RzCore *)user;
__add_cmdf_panel(core, "cop grep: ", "/C %s");
return 0;
}
int __jop_cb(void *user) {
RzCore *core = (RzCore *)user;
__add_cmdf_panel(core, "jop grep: ", "/J %s");
return 0;
}
int __code_cb(void *user) {
RzCore *core = (RzCore *)user;
__add_cmdf_panel(core, "search code: ", "\"/c %s\"");
__add_cmdf_panel(core, "search code: ", "/a %s");
return 0;
}
int __hexpairs_cb(void *user) {
RzCore *core = (RzCore *)user;
__add_cmdf_panel(core, "search hexpairs: ", "\"/x %s\"");
__add_cmdf_panel(core, "search hexpairs: ", "/x %s");
return 0;
}
@ -4588,6 +4602,10 @@ bool __init_panels_menu(RzCore *core) {
__add_menu(core, parent, menus_Search[i], __string_data_sec_cb);
} else if (!strcmp(menus_Search[i], "ROP")) {
__add_menu(core, parent, menus_Search[i], __rop_cb);
} else if (!strcmp(menus_Search[i], "COP")) {
__add_menu(core, parent, menus_Search[i], __cop_cb);
} else if (!strcmp(menus_Search[i], "JOP")) {
__add_menu(core, parent, menus_Search[i], __jop_cb);
} else if (!strcmp(menus_Search[i], "Code")) {
__add_menu(core, parent, menus_Search[i], __code_cb);
} else if (!strcmp(menus_Search[i], "Hexpairs")) {

View file

@ -2236,13 +2236,12 @@ RZ_IPI int rz_core_visual_cmd(RzCore *core, const char *arg) {
rz_core_visual_showcursor(core, true);
rz_cons_flush();
rz_cons_set_raw(false);
strcpy(buf, "\"wa ");
strcpy(buf, "wa ");
rz_line_set_prompt(line, ":> ");
rz_cons_enable_mouse(false);
if (rz_cons_fgets(buf + 4, sizeof(buf) - 4, 0, NULL) < 0) {
if (rz_cons_fgets(buf + 3, sizeof(buf) - 3, 0, NULL) < 0) {
buf[0] = '\0';
}
strcat(buf, "\"");
bool wheel = rz_config_get_b(core->config, "scr.wheel");
if (wheel) {
rz_cons_enable_mouse(true);
@ -2510,7 +2509,7 @@ RZ_IPI int rz_core_visual_cmd(RzCore *core, const char *arg) {
break;
}
if (core->print->col == 2) {
strcpy(buf, "\"w ");
strcpy(buf, "w \"");
rz_line_set_prompt(line, "insert string: ");
if (rz_cons_fgets(buf + 3, sizeof(buf) - 3, 0, NULL) < 0) {
buf[0] = '\0';

View file

@ -9,7 +9,7 @@ EXPECT=
EXPECT_ERR=<<EOF
ERROR: Cannot assemble 'add esp, 8' at line 3
ERROR: Failed to assemble 'add esp, 8'
ERROR: Consider using "/ar" instead.
ERROR: Consider using "/ad" instead.
EOF
RUN