mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-26 00:55:59 +00:00
Implement the new RAnal.cmd() ##api
This commit is contained in:
parent
3500cdc523
commit
52a738bdcb
@ -860,3 +860,14 @@ R_API void r_anal_purge_imports(RAnal *anal) {
|
||||
r_list_purge (anal->imports);
|
||||
R_DIRTY (anal);
|
||||
}
|
||||
|
||||
R_API bool r_anal_cmd(RAnal *anal, const char *cmd) {
|
||||
RListIter *iter;
|
||||
RAnalPlugin *ap;
|
||||
r_list_foreach (anal->plugins, iter, ap) {
|
||||
if (ap->cmd && ap->cmd (anal, cmd)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -2,12 +2,21 @@
|
||||
|
||||
#include <r_anal.h>
|
||||
|
||||
static bool nullcmd(RAnal *anal, const char *cmd) {
|
||||
if (r_str_startswith (cmd, "null")) {
|
||||
r_cons_println ("nothing to see");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
RAnalPlugin r_anal_plugin_null = {
|
||||
.meta = {
|
||||
.name = "null",
|
||||
.desc = "Fallback/Null analysis plugin",
|
||||
.license = "LGPL3",
|
||||
}
|
||||
},
|
||||
.cmd = nullcmd
|
||||
};
|
||||
|
||||
#ifndef R2_PLUGIN_INCORE
|
||||
|
@ -21,6 +21,7 @@ static RCoreHelpMessage help_msg_aex = {
|
||||
static RCoreHelpMessage help_msg_a = {
|
||||
"Usage:", "a", "[abdefFghoprxstc] [...]",
|
||||
"a", "", "alias for aai - analysis information",
|
||||
"a:", "[cmd]", "run a command implemented by an analysis plugin (like : for io)",
|
||||
"a*", "", "same as afl*;ah*;ax*",
|
||||
"aa", "[?]", "analyze all (fcns + bbs) (aa0 to avoid sub renaming)",
|
||||
"a8", " [hexpairs]", "analyze bytes",
|
||||
@ -13760,16 +13761,9 @@ static int cmd_anal(void *data, const char *input) {
|
||||
case 'h': // "ah"
|
||||
cmd_anal_hint (core, input + 1);
|
||||
break;
|
||||
#if 0
|
||||
/// XXX this must be renamed to 'a:' // "a:" and cmd_ext must be command like in io
|
||||
case '!': // "a!"
|
||||
if (core->anal && core->anal->cur && core->anal->cur->cmd_ext) {
|
||||
return core->anal->cur->cmd_ext (core->anal, input + 1);
|
||||
} else {
|
||||
r_cons_printf ("No plugins for this analysis plugin\n");
|
||||
}
|
||||
case ':':
|
||||
r_anal_cmd (core->anal, r_str_trim_head_ro (input + 1));
|
||||
break;
|
||||
#endif
|
||||
case 'j': // "aj"
|
||||
r_core_cmd_call (core, "aflj");
|
||||
break;
|
||||
|
@ -14,7 +14,7 @@ static RCoreHelpMessage help_msg_o = {
|
||||
"o++"," [file]", "create and open file in read-write mode (see ot and omr)",
|
||||
"o-","[?][#!*$.]","close opened files",
|
||||
"o.","","show current filename (or o.q/oq to get the fd)",
|
||||
"o:"," [len]","open a malloc://[len] copying the bytes from current offset",
|
||||
"o:"," [len]","open a malloc://[len] copying the bytes from current offset", // XXX R2_590 - should be an alias for ':' no need for a malloc:// wrapper imho
|
||||
"o=","","list opened files (ascii-art bars)",
|
||||
"oL","","list all IO plugins registered",
|
||||
"oa","[-] [A] [B] [filename]","specify arch and bits for given file",
|
||||
|
@ -765,7 +765,7 @@ typedef struct r_anal_esil_dfg_node_t {
|
||||
ut32 /*RAnalEsilDFGTagType*/ type;
|
||||
} RAnalEsilDFGNode;
|
||||
|
||||
typedef int (*RAnalCmdExt)(/* Rcore */RAnal *anal, const char* input);
|
||||
typedef int (*RAnalCmdCallback)(/* Rcore */RAnal *anal, const char* input);
|
||||
|
||||
typedef int (*RAnalOpCallback)(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *data, int len, RAnalOpMask mask);
|
||||
typedef int (*RAnalOpAsmCallback)(RAnal *a, ut64 addr, const char *str, ut8 *outbuf, int outlen);
|
||||
@ -784,21 +784,7 @@ typedef int (*REsilTrapCB)(REsil *esil, int trap_type, int trap_code);
|
||||
|
||||
typedef struct r_anal_plugin_t {
|
||||
RPluginMeta meta;
|
||||
#if 0
|
||||
char *name;
|
||||
char *desc;
|
||||
char *license;
|
||||
char *arch;
|
||||
char *author;
|
||||
char *version;
|
||||
|
||||
int endian; // bitmask to define little, big, etc.
|
||||
char *cpus;
|
||||
int bits;
|
||||
int esil; // can do esil or not
|
||||
int jmpmid; // can do jump in the middle
|
||||
#endif
|
||||
int fileformat_type;
|
||||
int (*init)(void *user);
|
||||
int (*fini)(void *user);
|
||||
//int (*reset_counter) (RAnal *anal, ut64 start_addr);
|
||||
@ -808,13 +794,7 @@ typedef struct r_anal_plugin_t {
|
||||
|
||||
// legacy r_anal_functions
|
||||
RAnalOpCallback op;
|
||||
#if 0
|
||||
RAnalOpAsmCallback opasm;
|
||||
#endif
|
||||
|
||||
// command extension to directly call any analysis functions
|
||||
// RAnalCmdExt cmd_ext;
|
||||
|
||||
RAnalCmdCallback cmd;
|
||||
RAnalRegProfCallback set_reg_profile;
|
||||
RAnalRegProfGetCallback get_reg_profile;
|
||||
#if 1
|
||||
@ -853,6 +833,8 @@ R_API RAnalType *r_anal_str_to_type(RAnal *a, const char* s);
|
||||
R_API RAnalType *r_anal_type_free(RAnalType *t);
|
||||
R_API RAnalType *r_anal_type_loadfile(RAnal *a, const char *path);
|
||||
|
||||
R_API bool r_anal_cmd(RAnal *a, const char *cmd);
|
||||
|
||||
/* block.c */
|
||||
typedef bool (*RAnalBlockCb)(RAnalBlock *block, void *user);
|
||||
typedef bool (*RAnalAddrCb)(ut64 addr, void *user);
|
||||
|
Loading…
x
Reference in New Issue
Block a user