Split avr into avr and avra

This commit is contained in:
Florian Märkl 2018-03-14 13:49:39 +01:00 committed by radare
parent 972e567664
commit 74566827d1
4 changed files with 48 additions and 18 deletions

View File

@ -2,11 +2,35 @@
#include "r_anal.h" #include "r_anal.h"
R_API void r_anal_print_rtti (RAnal *anal) { R_API void r_anal_rtti_print_at_vtable(RAnal *anal, ut64 addr) {
RVTableContext context; RVTableContext context;
r_anal_vtable_begin (anal, &context); r_anal_vtable_begin (anal, &context);
if (context.abi == R_ANAL_CPP_ABI_MSVC) { if (context.abi == R_ANAL_CPP_ABI_MSVC) {
r_anal_rtti_msvc_print_all (&context); r_anal_rtti_msvc_print_at_vtable (&context, addr);
} else {
eprint ("RTTI not supported yet for Itanium.\n");
}
}
static void rtti_msvc_print_all(RVTableContext *context) {
RList *vtables = r_anal_vtable_search (context);
RListIter *vtableIter;
RVTableInfo *table;
if (vtables) {
r_list_foreach (vtables, vtableIter, table) {
r_anal_rtti_msvc_print_at_vtable (context, table->saddr);
r_cons_print ("\n");
}
}
r_list_free (vtables);
}
R_API void r_anal_rtti_print_all(RAnal *anal) {
RVTableContext context;
r_anal_vtable_begin (anal, &context);
if (context.abi == R_ANAL_CPP_ABI_MSVC) {
rtti_msvc_print_all (&context);
} else { } else {
eprint ("RTTI not supported yet for Itanium.\n"); eprint ("RTTI not supported yet for Itanium.\n");
} }

View File

@ -302,16 +302,6 @@ static void rtti_msvc_print_complete_object_locator_recurse(RVTableContext *cont
} }
} }
R_API void r_anal_rtti_msvc_print_all(RVTableContext *context) { R_API void r_anal_rtti_msvc_print_at_vtable(RVTableContext *context, ut64 addr) {
RList *vtables = r_anal_vtable_search (context); rtti_msvc_print_complete_object_locator_recurse (context, addr);
RListIter *vtableIter;
RVTableInfo *table;
if (vtables) {
r_list_foreach (vtables, vtableIter, table) {
rtti_msvc_print_complete_object_locator_recurse (context, table->saddr);
r_cons_print ("\n");
}
}
r_list_free (vtables);
} }

View File

@ -548,7 +548,8 @@ static const char *help_msg_av[] = {
"av", "", "search for vtables in data sections and show results", "av", "", "search for vtables in data sections and show results",
"avj", "", "like av, but as json", "avj", "", "like av, but as json",
"av*", "", "like av, but as r2 commands", "av*", "", "like av, but as r2 commands",
"avr", "", "search for vtables and try to parse RTTI (see anal.cpp.abi)", "avr", "[@addr]", "try to parse RTTI at vtable addr (see anal.cpp.abi)",
"avra", "", "search for vtables and try to parse RTTI at each of them",
NULL NULL
}; };
@ -6413,6 +6414,20 @@ static bool anal_fcn_data_gaps (RCore *core, const char *input) {
return true; return true;
} }
static void cmd_anal_rtti(RCore *core, const char *input) {
switch (input[0]) {
case '\0': // "avr"
r_anal_rtti_print_at_vtable (core->anal, core->offset);
break;
case 'a': // "avra"
r_anal_rtti_print_all (core->anal);
break;
default :
r_core_cmd_help (core, help_msg_av);
break;
}
}
static void cmd_anal_virtual_functions(RCore *core, const char* input) { static void cmd_anal_virtual_functions(RCore *core, const char* input) {
switch (input[0]) { switch (input[0]) {
case '\0': // "av" case '\0': // "av"
@ -6421,7 +6436,7 @@ static void cmd_anal_virtual_functions(RCore *core, const char* input) {
r_anal_list_vtables (core->anal, input[0]); r_anal_list_vtables (core->anal, input[0]);
break; break;
case 'r': // "avr" case 'r': // "avr"
r_anal_print_rtti (core->anal); cmd_anal_rtti (core, input + 1);
break; break;
default : default :
r_core_cmd_help (core, help_msg_av); r_core_cmd_help (core, help_msg_av);

View File

@ -1694,8 +1694,9 @@ R_API RList *r_anal_vtable_get_methods(RVTableContext *context, RVTableInfo *tab
R_API void r_anal_list_vtables(RAnal *anal, int rad); R_API void r_anal_list_vtables(RAnal *anal, int rad);
/* rtti */ /* rtti */
R_API void r_anal_rtti_msvc_print_all(RVTableContext *context); R_API void r_anal_rtti_msvc_print_at_vtable(RVTableContext *context, ut64 addr);
R_API void r_anal_print_rtti(RAnal *anal); R_API void r_anal_rtti_print_at_vtable(RAnal *anal, ut64 addr);
R_API void r_anal_rtti_print_all(RAnal *anal);
/* plugin pointers */ /* plugin pointers */
extern RAnalPlugin r_anal_plugin_null; extern RAnalPlugin r_anal_plugin_null;