mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-27 08:12:44 +00:00
Implement tpv command and some random code cleannup ##types
This commit is contained in:
parent
20cf00fe7f
commit
67bcc0db5d
@ -2972,7 +2972,7 @@ static bool __stepOut(RAnalEsil *esil, const char *cmd) {
|
||||
return false;
|
||||
}
|
||||
|
||||
R_API int r_anal_esil_parse(RAnalEsil *esil, const char *str) {
|
||||
R_API bool r_anal_esil_parse(RAnalEsil *esil, const char *str) {
|
||||
int wordi = 0;
|
||||
int dorunword;
|
||||
char word[64];
|
||||
|
@ -5843,7 +5843,7 @@ static void cmd_anal_esil(RCore *core, const char *input) {
|
||||
r_anal_esil_free (esil);
|
||||
core->anal->esil = NULL;
|
||||
break;
|
||||
case 0: //lolololol
|
||||
case 0: //lolololol
|
||||
r_anal_esil_free (esil);
|
||||
// reinitialize
|
||||
{
|
||||
@ -9516,11 +9516,11 @@ static void cmd_anal_class_vtable(RCore *core, const char *input) {
|
||||
ut64 offset_arg = r_num_get (core->num, cstr); // Should I allow negative offset?
|
||||
char *class_arg = NULL;
|
||||
if (end) {
|
||||
class_arg = r_str_trim_head_ro (end);
|
||||
class_arg = (char *)r_str_trim_head_ro (end);
|
||||
}
|
||||
|
||||
if (class_arg) {
|
||||
end = r_str_trim_head_wp (class_arg); // in case of extra unwanted stuff at the cmd end
|
||||
end = (char *)r_str_trim_head_wp (class_arg); // in case of extra unwanted stuff at the cmd end
|
||||
*end = '\0';
|
||||
}
|
||||
r_anal_class_list_vtable_offset_functions (core->anal, class_arg, offset_arg);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2009-2019 - pancake, oddcoder, Anton Kochkov, Jody Frankowski */
|
||||
/* radare - LGPL - Copyright 2009-2020 - pancake, oddcoder, Anton Kochkov, Jody Frankowski */
|
||||
|
||||
#include <string.h>
|
||||
#include "r_anal.h"
|
||||
@ -26,8 +26,9 @@ static const char *help_msg_t[] = {
|
||||
"to", " <path>", "Load types from C header file",
|
||||
"toe", "[type.name]", "Open cfg.editor to edit types",
|
||||
"tos", " <path>", "Load types from parsed Sdb database",
|
||||
"tp", " <type> [addr|varname]", "cast data at <address> to <type> and print it",
|
||||
"tpx", " <type> <hexpairs>", "Show value for type with specified byte sequence",
|
||||
"tp", " <type> [addr|varname]", "cast data at <address> to <type> and print it (XXX: type can contain spaces)",
|
||||
"tpv", " <type> @ [value]", "Show offset formatted for given type",
|
||||
"tpx", " <type> <hexpairs>", "Show value for type with specified byte sequence (XXX: type can contain spaces)",
|
||||
"ts", "[?]", "Print loaded struct types",
|
||||
"tu", "[?]", "Print loaded union types",
|
||||
"tx", "[f?]", "Type xrefs",
|
||||
@ -1556,7 +1557,16 @@ static int cmd_type(void *data, const char *input) {
|
||||
case 'p': // "tp"
|
||||
if (input[1] == '?') { // "tp?"
|
||||
r_core_cmd0 (core, "t?~tp\n");
|
||||
} else { // "tp"
|
||||
} else if (input[1] == 'v') { // "tpv"
|
||||
const char *type_name = r_str_trim_head_ro (input + 2);
|
||||
char *fmt = r_type_format (TDB, type_name);
|
||||
if (fmt && *fmt) {
|
||||
ut64 val = core->offset;
|
||||
r_core_cmdf (core, "pf %s @v:0x%08" PFMT64x "\n", fmt, val);
|
||||
} else {
|
||||
eprintf ("Usage: tpv [type] @ [value]\n");
|
||||
}
|
||||
} else if (input[1] == ' ' || input[1] == 'x' || !input[1]) {
|
||||
char *tmp = strdup (input);
|
||||
char *ptr = strchr (tmp, ' ');
|
||||
if (!ptr) {
|
||||
@ -1574,7 +1584,7 @@ static int cmd_type(void *data, const char *input) {
|
||||
}
|
||||
if (input[1] == 'x' && arg) { // "tpx"
|
||||
r_core_cmdf (core, "pf %s @x:%s", fmt, arg);
|
||||
eprintf ("pf %s @x:%s", fmt, arg);
|
||||
// eprintf ("pf %s @x:%s", fmt, arg);
|
||||
} else {
|
||||
ut64 addr = arg ? r_num_math (core->num, arg): core->offset;
|
||||
if (!addr && arg) {
|
||||
@ -1591,6 +1601,8 @@ static int cmd_type(void *data, const char *input) {
|
||||
break;
|
||||
}
|
||||
free (tmp);
|
||||
} else { // "tp"
|
||||
eprintf ("Usage: tp?\n");
|
||||
}
|
||||
break;
|
||||
case '-': // "t-"
|
||||
|
@ -1490,7 +1490,7 @@ R_API bool r_anal_esil_set_pc(RAnalEsil *esil, ut64 addr);
|
||||
R_API int r_anal_esil_setup(RAnalEsil *esil, RAnal *anal, int romem, int stats, int nonull);
|
||||
R_API void r_anal_esil_free(RAnalEsil *esil);
|
||||
R_API int r_anal_esil_runword(RAnalEsil *esil, const char *word);
|
||||
R_API int r_anal_esil_parse(RAnalEsil *esil, const char *str);
|
||||
R_API bool r_anal_esil_parse(RAnalEsil *esil, const char *str);
|
||||
R_API bool r_anal_esil_dumpstack(RAnalEsil *esil);
|
||||
R_API int r_anal_esil_mem_read(RAnalEsil *esil, ut64 addr, ut8 *buf, int len);
|
||||
R_API int r_anal_esil_mem_write(RAnalEsil *esil, ut64 addr, const ut8 *buf, int len);
|
||||
|
Loading…
x
Reference in New Issue
Block a user