#ifndef R2_EGG_H #define R2_EGG_H #include #include #include #include #ifdef __cplusplus extern "C" { #endif R_LIB_VERSION_HEADER(r_egg); #define R_EGG_INCDIR_ENV "EGG_INCDIR" #define R_EGG_INCDIR_PATH "/lib/radare2/" R2_VERSION "/egg" // rename to REggShellcode #define R_EGG_PLUGIN_SHELLCODE 0 #define R_EGG_PLUGIN_ENCODER 1 typedef struct r_egg_plugin_t { const char *name; const char *desc; int type; RBuffer* (*build) (void *egg); } REggPlugin; typedef struct r_egg_lang_t { int pushargs; int nalias; int nsyscalls; char *conditionstr; char *syscallbody; char *includefile; char *setenviron; char *mathline; // used for confusing mathop int commentmode; int varsize; int varxs; int lastctxdelta; int nargs; int docall; int nfunctions; int nbrackets; int slurpin; int slurp; int line; char elem[1024]; int attsyntax; int elem_n; char *callname; char *endframe; char *ctxpush[32]; char *file; char *dstvar; char *dstval; char *includedir; char *ifelse_table[32][32]; // used to solve if-else problem in a not so ugly way int ndstval; int skipline;// BOOL int quoteline; int quotelinevar; int stackframe; int stackfixed; int oc; int mode; int inlinectr; struct { char *name; char *body; // int fastcall; /* TODO: NOT YET USED */ } inlines[256]; int ninlines; struct { char *name; char *arg; } syscalls[256]; struct { char *name; char *content; } aliases[256]; char *nested[32]; char *nested_callname[32]; // char *nestede[32] = {0}; // seems nestede are not used any more // (only one place that gives nestede[] value, where could be replaced) int nestedi[32]; } REggLang; typedef struct r_egg_t { RBuffer *src; RBuffer *buf; RBuffer *bin; RList *list; //RList *shellcodes; // XXX is plugins nao? RAsm *rasm; RSyscall *syscall; REggLang lang; Sdb *db; RList *plugins; RList *patches; // struct r_egg_emit_t *remit; int arch; int endian; int bits; ut32 os; int context; } REgg; /* XXX: this may fail in different arches */ #if 0 r2 -q - <plugins R_API void r_egg_option_set (REgg *egg, const char *k, const char *v); R_API char *r_egg_option_get (REgg *egg, const char *k); R_API void r_egg_if(REgg *egg, const char *reg, char cmp, int v); R_API void r_egg_printf(REgg *egg, const char *fmt, ...); R_API int r_egg_compile(REgg *egg); R_API int r_egg_padding (REgg *egg, const char *pad); R_API int r_egg_assemble(REgg *egg); R_API int r_egg_assemble_asm(REgg *egg, char **asm_list); R_API void r_egg_pattern(REgg *egg, int size); R_API RBuffer *r_egg_get_bin(REgg *egg); //R_API int r_egg_dump (REgg *egg, const char *file) { } R_API char *r_egg_get_source(REgg *egg); R_API RBuffer *r_egg_get_bin(REgg *egg); R_API char *r_egg_get_assembly(REgg *egg); R_API void r_egg_append(REgg *egg, const char *src); R_API int r_egg_run(REgg *egg); R_API int r_egg_patch(REgg *egg, int off, const ut8 *b, int l); R_API void r_egg_finalize(REgg *egg); /* lang.c */ R_API char *r_egg_mkvar(REgg *egg, char *out, const char *_str, int delta); R_API int r_egg_lang_parsechar(REgg *egg, char c); R_API void r_egg_lang_include_path (REgg *egg, const char *path); R_API void r_egg_lang_include_init (REgg *egg); /* plugin pointers */ extern REggPlugin r_egg_plugin_xor; extern REggPlugin r_egg_plugin_shya; extern REggPlugin r_egg_plugin_exec; #endif #ifdef __cplusplus } #endif #endif