Yesterday I implemented again the '-l' flag which allows to load
user defined plugins to radare.
I have added this functionality to ease the parallel development
of external functionalities.
Currently it's under development and I plan to do some ABI changes,
so until I get a certain stability i'll not ensure binary compatibility
between versions for the plugins.
The plugin interface is quite simple and allows to load multiple
types of plugins. Currently only two: io and hack.
A hack plugin must fill the plugin_hack_t structure giving it's
name, description and a pointer to the function implementing the
business.
Here's a sample plugin written in C found in src/hacks/hello.c:
;--------------------------------------------------------------
/* example plugin */
#include "plugin.h"
extern int radare_plugin_type;
extern struct plugin_hack_t radare_plugin;
void my_hack(char *input)
{
printf("Hello hack! %s\n", radare_plugin.config->file);
}
int radare_plugin_type = PLUGIN_TYPE_HACK;
struct plugin_hack_t radare_plugin = {
.name = "hello",
.desc = "Hello hack example",
.callback = &my_hack
};
main() { printf("i'm a plugin!\n"); }
;--------------------------------------------------------------
The 'hack' plugins can be accessed with the 'H'ack command.
I'll add a dir.plugins eval to configure a base path for the plugins
directory. This model is quite handy for w32 development and 'homebrew'
plugins.
$ echo H hello | radare -v -L hacks -l hello /bin/ls
Hello hack! /bin/ls
$
As you see the config and ps structures (debugger and core structures)
are stored inside the radare_plugin structure after the plugin registry,
so you can easily access to the core api without adding a dependency
and allowing assembly-based plugins to be implemented easily.
A linked list of core functions will be exported in a similar way
config or ps does.
The asm version of the plugin is quite similar to the C one.
http://radare.nopcode.org/hg/radare?raw-file/2fd6a9e27c57/src/hacks/hello.s
I plan to finish a mostly stable architecture for plugins for 0.9.3
with some examples and a little of documentation.
--pancake
_______________________________________________
radare mailing list
[email protected]
https://lists.nopcode.org/mailman/listinfo/radare