Fix ?t'. avoid the use of "" prefixes ##shell

This commit is contained in:
pancake 2024-09-27 02:58:03 +02:00 committed by pancake
parent 71c98b18d5
commit a2504a72e6
8 changed files with 76 additions and 45 deletions

View File

@ -4018,7 +4018,7 @@ static bool bin_classes(RCore *r, PJ *pj, int mode) {
}
// C struct
r_cons_printf ("\"\"td struct %s {", cname);
r_cons_printf ("'td struct %s {", cname);
if (r_list_empty (c->fields)) {
// XXX workaround because we cant register empty structs yet
// XXX https://github.com/radareorg/radare2/issues/16342

View File

@ -1172,9 +1172,12 @@ static int cmd_rap(void *data, const char *input) {
case '-': // "=l-"
session_stop (core);
break;
default: // "=l?"
case '?': // "=l?"
r_core_cmd_help (core, help_msg_equal_l);
break;
default:
r_core_return_invalid_command (core, "=l", input[1]);
break;
}
break;
case 'j': // "=j"
@ -1341,7 +1344,9 @@ static int cmd_yank(void *data, const char *input) {
r_core_yank_cat_string (core, r_num_math (core->num, input + 1));
break;
case 't': // "yt"
if (input[1] == 'f') { // "ytf"
switch (input[1]) {
case 'f': // "ytf"
{
ut64 tmpsz;
const char *file = r_str_trim_head_ro (input + 2);
const ut8 *tmp = r_buf_data (core->yank_buf, &tmpsz);
@ -1359,10 +1364,17 @@ static int cmd_yank(void *data, const char *input) {
R_LOG_ERROR ("Cannot dump to '%s'", file);
}
}
} else if (input[1] == ' ') {
}
break;
case ' ':
r_core_yank_to (core, input + 1);
} else {
break;
case '?':
r_core_cmd_help_contains (core, help_msg_y, "yt");
break;
default:
r_core_return_invalid_command (core, "yt", input[1]);
break;
}
break;
case 'f': // "yf"
@ -1376,9 +1388,12 @@ static int cmd_yank(void *data, const char *input) {
case 'a': // "yfa"
r_core_yank_file_all (core, input + 2);
break;
default:
case '?':
r_core_cmd_help_contains (core, help_msg_y, "yf");
break;
default:
r_core_return_invalid_command (core, "yf", input[1]);
break;
}
break;
case '!': // "y!"
@ -2899,7 +2914,7 @@ static bool cmd_r2cmd(RCore *core, const char *_input) {
} else if (r_str_startswith (input, "radiff2")) {
rc = __runMain (core->r_main_radiff2, input);
} else if (r_str_startswith (input, "r2.")) {
r_core_cmdf (core, "\"\"js console.log(r2.%s)", input + 3);
r_core_cmdf (core, "'js console.log(r2.%s)", input + 3);
} else if (r_str_startswith (input, "r2")) {
if (input[2] == ' ' || input[2] == 0) {
r_sys_cmdf ("%s", input);
@ -4055,12 +4070,12 @@ static int r_core_cmd_subst(RCore *core, char *cmd) {
if (res != -1) {
return res;
}
if (R_UNLIKELY (r_str_startswith (cmd, "?t\"\""))) {
char *c = r_str_newf ("?t\"\"%s", cmd + 4);
// XXX char *c = r_str_newf ("?t'%s", cmd + 4);
int res = r_core_cmd_call (core, c);
free (c);
return res;
if (R_UNLIKELY (r_str_startswith (cmd, "?t"))) {
if (r_str_startswith (cmd + 2, "\"\"")) {
return r_core_cmd_callf (core, "?t'%s", cmd + 4);
} else if (r_str_startswith (cmd + 2, "'")) {
return r_core_cmd_callf (core, "?t'%s", cmd + 3);
}
}
if (R_UNLIKELY (r_str_startswith (cmd, "GET /cmd/"))) {

View File

@ -681,11 +681,22 @@ static int cmd_help(void *data, const char *input) {
}
core->curtab ++;
break;
case '\'':
{
struct r_prof_t prof;
r_prof_start (&prof);
r_core_cmd_call (core, input + 2);
r_prof_end (&prof);
r_core_return_value (core, (ut64)(int)prof.result);
eprintf ("%lf\n", prof.result);
}
break;
case '"':
{
struct r_prof_t prof;
r_prof_start (&prof);
if (input[1] == '"') {
// R2_600 - deprecate '""'
r_core_cmd_call (core, input + 3);
} else {
r_core_cmd (core, input + 1, 0);

View File

@ -16,12 +16,12 @@ R_API bool r_core_patch_line(RCore *core, char *str) {
if (q) {
*q = 0;
}
r_core_cmdf (core, "\"\"s %s", str);
r_core_cmdf (core, "\"\"w %s", p+1);
r_core_cmdf (core, "'s %s", str);
r_core_cmdf (core, "'w %s", p+1);
break;
case ':':
r_core_cmdf (core, "\"\"s %s", str);
r_core_cmdf (core, "\"\"wa %s", p);
r_core_cmdf (core, "'s %s", str);
r_core_cmdf (core, "'wa %s", p);
break;
case 'v':
q = strchr (p + 1, ' ');
@ -31,12 +31,12 @@ R_API bool r_core_patch_line(RCore *core, char *str) {
} else {
return 0;
}
r_core_cmdf (core, "\"\"s %s", str);
r_core_cmdf (core, "\"\"wv%s %s", p + 1, q);
r_core_cmdf (core, "'s %s", str);
r_core_cmdf (core, "'wv%s %s", p + 1, q);
break;
default:
r_core_cmdf (core, "\"\"s %s", str);
r_core_cmdf (core, "\"\"wx %s", p);
r_core_cmdf (core, "'s %s", str);
r_core_cmdf (core, "'wx %s", p);
break;
}
return true;

View File

@ -435,6 +435,10 @@ static char *get_project_name(const char *prj_script) {
file = strdup (buf + 14);
break;
}
if (r_str_startswith (buf, "'e prj.name = ")) {
file = strdup (buf + strlen ("'e prj.name"));
break;
}
}
fclose (fd);
} else {

View File

@ -16,7 +16,8 @@ Usage: - open editor and run the r2 commands in the saved document
| -i [file] same as . [file], to run a script
| -s [addr] same as r2 -e asm.cpu=
| -L same as Lo (or r2 -L)
| -P project same as 'P [prjname]' to load a project
| -p project same as 'P [prjname]' to load a project
| -P patchfile apply given patch file (see doc/rapatch2.md)
| -v same as -V
| -V show r2 version, same as ?V
| -- seek one block backward. Same as s-- (see `b` command)

View File

@ -700,7 +700,7 @@ fs classes
"f method._JNIEnv.CallStaticObjectMethod(_jclass*,__jmethodID*,_...) = 0x60ea"
"f method._JNIEnv.CallStaticIntMethod(_jclass*,__jmethodID*,_...) = 0x695e"
"f method._JNIEnv.CallStaticVoidMethod(_jclass*,__jmethodID*,_...) = 0x697c"
""td struct _JNIEnv { char empty[0];};
'td struct _JNIEnv { char empty[0];};
"f class.SystemClassLoaderInjector = 0x699c"
"f method.SystemClassLoaderInjector.inject(_JNIEnv*,__jobject*,__jstring*,__jstring*) = 0x74f8"
"f method.SystemClassLoaderInjector.findBaseDexClassloader(_JNIEnv*,__jobject*) = 0x699c"
@ -713,38 +713,38 @@ fs classes
"f method.SystemClassLoaderInjector.appendArray(_JNIEnv*,__jobject*,__jobject*) = 0x6e5c"
"f method.SystemClassLoaderInjector.injectInAliyunOs(_JNIEnv*,__jobject*,__jstring*,__jstring*) = 0x6f68"
"f method.SystemClassLoaderInjector.injectBelowApiLevel14(_JNIEnv*,__jobject*,__jstring*,__jstring*) = 0x720c"
""td struct SystemClassLoaderInjector { char empty[0];};
'td struct SystemClassLoaderInjector { char empty[0];};
"f class.std = 0x886c"
"f method.std.terminate() = 0x9470"
"f method.std.uncaught_exception() = 0x886c"
"f method.std.unexpected() = 0x9494"
"f method.std.set_terminate(void_(*)()) = 0x94ac"
"f method.std.set_unexpected(void_(*)()) = 0x94c8"
""td struct std { char empty[0];};
'td struct std { char empty[0];};
"f class.std::exception = 0x8884"
"f method.std::exception.~exception() = 0x8884"
"f method.std::exception.what()_const = 0x88f4"
""td struct std::exception { char empty[0];};
'td struct std::exception { char empty[0];};
"f class.std::bad_exception = 0x889c"
"f method.std::bad_exception.~bad_exception() = 0x889c"
"f method.std::bad_exception.what()_const = 0x8904"
""td struct std::bad_exception { char empty[0];};
'td struct std::bad_exception { char empty[0];};
"f class.__cxxabiv1::__forced_unwind = 0x88c4"
"f method.__cxxabiv1::__forced_unwind.~__forced_unwind() = 0x88c4"
""td struct __cxxabiv1::__forced_unwind { char empty[0];};
'td struct __cxxabiv1::__forced_unwind { char empty[0];};
"f class.__cxxabiv1::__foreign_exception = 0x88dc"
"f method.__cxxabiv1::__foreign_exception.~__foreign_exception() = 0x88dc"
""td struct __cxxabiv1::__foreign_exception { char empty[0];};
'td struct __cxxabiv1::__foreign_exception { char empty[0];};
"f class.__eh_globals_init = 0x8984"
"f method.__eh_globals_init.~__eh_globals_init() = 0x8984"
""td struct __eh_globals_init { char empty[0];};
'td struct __eh_globals_init { char empty[0];};
"f class.__cxxabiv1 = 0x943c"
"f method.__cxxabiv1.__terminate(void_(*)()) = 0x943c"
"f method.__cxxabiv1.__unexpected(void_(*)()) = 0x9488"
""td struct __cxxabiv1 { char empty[0];};
'td struct __cxxabiv1 { char empty[0];};
"f class.__cxxabiv1::__fundamental_type_info = 0x94e4"
"f method.__cxxabiv1::__fundamental_type_info.~__fundamental_type_info() = 0x94e4"
""td struct __cxxabiv1::__fundamental_type_info { char empty[0];};
'td struct __cxxabiv1::__fundamental_type_info { char empty[0];};
"f class.std::type_info = 0x97bc"
"f method.std::type_info.~type_info() = 0x97bc"
"f method.std::type_info.__is_pointer_p()_const = 0x97d4"
@ -752,23 +752,23 @@ fs classes
"f method.std::type_info.__do_catch(std::type_info_const*,_void**,_unsigned_int)_const = 0x9854"
"f method.std::type_info.__do_upcast(__cxxabiv1::__class_type_info_const*,_void**)_const = 0x97e4"
"f method.std::type_info.operator==(std::type_info_const&)_const = 0x9808"
""td struct std::type_info { char empty[0];};
'td struct std::type_info { char empty[0];};
"f class.__cxxabiv1::__pointer_type_info = 0x9528"
"f method.__cxxabiv1::__pointer_type_info.__is_pointer_p()_const = 0x9528"
"f method.__cxxabiv1::__pointer_type_info.~__pointer_type_info() = 0x9530"
"f method.__cxxabiv1::__pointer_type_info.__pointer_catch(__cxxabiv1::__pbase_type_info_const*,_void**,_unsigned_int)_const = 0x9574"
""td struct __cxxabiv1::__pointer_type_info { char empty[0];};
'td struct __cxxabiv1::__pointer_type_info { char empty[0];};
"f class.__cxxabiv1::__pbase_type_info = 0x9dd0"
"f method.__cxxabiv1::__pbase_type_info.~__pbase_type_info() = 0x9df0"
"f method.__cxxabiv1::__pbase_type_info.__do_catch(std::type_info_const*,_void**,_unsigned_int)_const = 0x9e34"
"f method.__cxxabiv1::__pbase_type_info.__pointer_catch(__cxxabiv1::__pbase_type_info_const*,_void**,_unsigned_int)_const = 0x9dd0"
""td struct __cxxabiv1::__pbase_type_info { char empty[0];};
'td struct __cxxabiv1::__pbase_type_info { char empty[0];};
"f class.__cxxabiv1::__si_class_type_info = 0x95f4"
"f method.__cxxabiv1::__si_class_type_info.~__si_class_type_info() = 0x95f4"
"f method.__cxxabiv1::__si_class_type_info.__do_find_public_src(int,_void_const*,___cxxabiv1::__class_type_info_const*,_void_const*)_const = 0x9638"
"f method.__cxxabiv1::__si_class_type_info.__do_dyncast(int,___cxxabiv1::__class_type_info::__sub_kind,___cxxabiv1::__class_type_info_const*,_void_const*,___cxxabiv1::__class_type_info_const*,_void_const*,___cxxabiv1::__class_type_info::__dyncast_result&)_const = 0x969c"
"f method.__cxxabiv1::__si_class_type_info.__do_upcast(__cxxabiv1::__class_type_info_const*,_void_const*,___cxxabiv1::__class_type_info::__upcast_result&)_const = 0x977c"
""td struct __cxxabiv1::__si_class_type_info { char empty[0];};
'td struct __cxxabiv1::__si_class_type_info { char empty[0];};
"f class.__cxxabiv1::__class_type_info = 0x9868"
"f method.__cxxabiv1::__class_type_info.~__class_type_info() = 0x98d8"
"f method.__cxxabiv1::__class_type_info.__do_upcast(__cxxabiv1::__class_type_info_const*,_void_const*,___cxxabiv1::__class_type_info::__upcast_result&)_const = 0x991c"
@ -776,28 +776,28 @@ fs classes
"f method.__cxxabiv1::__class_type_info.__do_upcast(__cxxabiv1::__class_type_info_const*,_void**)_const = 0x9868"
"f method.__cxxabiv1::__class_type_info.__do_find_public_src(int,_void_const*,___cxxabiv1::__class_type_info_const*,_void_const*)_const = 0x98c4"
"f method.__cxxabiv1::__class_type_info.__do_dyncast(int,___cxxabiv1::__class_type_info::__sub_kind,___cxxabiv1::__class_type_info_const*,_void_const*,___cxxabiv1::__class_type_info_const*,_void_const*,___cxxabiv1::__class_type_info::__dyncast_result&)_const = 0x998c"
""td struct __cxxabiv1::__class_type_info { char empty[0];};
'td struct __cxxabiv1::__class_type_info { char empty[0];};
"f class.__gnu_cxx = 0x9ec4"
"f method.__gnu_cxx.__verbose_terminate_handler() = 0x9ec4"
"f method.__gnu_cxx.__throw_concurrence_lock_error() = 0x12780"
"f method.__gnu_cxx.__throw_concurrence_unlock_error() = 0x127c8"
""td struct __gnu_cxx { char empty[0];};
'td struct __gnu_cxx { char empty[0];};
"f class.__gnu_cxx::__concurrence_lock_error = 0x126b0"
"f method.__gnu_cxx::__concurrence_lock_error.what()_const = 0x126b0"
"f method.__gnu_cxx::__concurrence_lock_error.~__concurrence_lock_error() = 0x126f8"
""td struct __gnu_cxx::__concurrence_lock_error { char empty[0];};
'td struct __gnu_cxx::__concurrence_lock_error { char empty[0];};
"f class.__gnu_cxx::__concurrence_unlock_error = 0x126c0"
"f method.__gnu_cxx::__concurrence_unlock_error.what()_const = 0x126c0"
"f method.__gnu_cxx::__concurrence_unlock_error.~__concurrence_unlock_error() = 0x126d0"
""td struct __gnu_cxx::__concurrence_unlock_error { char empty[0];};
'td struct __gnu_cxx::__concurrence_unlock_error { char empty[0];};
"f class.std::bad_cast = 0x12bc8"
"f method.std::bad_cast.~bad_cast() = 0x12bd8"
"f method.std::bad_cast.what()_const = 0x12bc8"
""td struct std::bad_cast { char empty[0];};
'td struct std::bad_cast { char empty[0];};
"f class.std::bad_typeid = 0x12c1c"
"f method.std::bad_typeid.~bad_typeid() = 0x12c2c"
"f method.std::bad_typeid.what()_const = 0x12c1c"
""td struct std::bad_typeid { char empty[0];};
'td struct std::bad_typeid { char empty[0];};
EOF
RUN

View File

@ -72,7 +72,7 @@ fs classes
"f field.Employee.property.firstName = 0x00000000"
"f field.Employee.property.shortWord = 0x00000000"
"f field.Employee.property.wideWord = 0x00000000"
""td struct Employee { struct objc_class * isa; short _shortWord; struct NSString* _username; struct NSString* _firstName; uint64_t _wideWord; void* username; void* firstName; void* shortWord; void* wideWord;};
'td struct Employee { struct objc_class * isa; short _shortWord; struct NSString* _username; struct NSString* _firstName; uint64_t _wideWord; void* username; void* firstName; void* shortWord; void* wideWord;};
EOF
RUN
@ -343,7 +343,7 @@ fs classes
"f field.Employee.property.firstName = 0x00000000"
"f field.Employee.property.shortWord = 0x00000000"
"f field.Employee.property.wideWord = 0x00000000"
""td struct Employee { struct objc_class * isa; short _shortWord; struct NSString* _username; struct NSString* _firstName; uint64_t _wideWord; void* username; void* firstName; void* shortWord; void* wideWord;};
'td struct Employee { struct objc_class * isa; short _shortWord; struct NSString* _username; struct NSString* _firstName; uint64_t _wideWord; void* username; void* firstName; void* shortWord; void* wideWord;};
EOF
RUN
@ -616,7 +616,7 @@ fs classes
"f field.Employee.property.firstName = 0x00000000"
"f field.Employee.property.shortWord = 0x00000000"
"f field.Employee.property.wideWord = 0x00000000"
""td struct Employee { struct objc_class * isa; short _shortWord; struct NSString* _username; struct NSString* _firstName; uint64_t _wideWord; void* username; void* firstName; void* shortWord; void* wideWord;};
'td struct Employee { struct objc_class * isa; short _shortWord; struct NSString* _username; struct NSString* _firstName; uint64_t _wideWord; void* username; void* firstName; void* shortWord; void* wideWord;};
EOF
RUN