* Implement r_core_search_cb() method

* Added boolt and ut8p macros (looking for better names)
This commit is contained in:
pancake 2010-11-15 11:06:10 +01:00
parent 49ab1886c2
commit 1a02d7b403
6 changed files with 69 additions and 30 deletions

56
TODO
View File

@ -7,6 +7,29 @@
TODO 0.7
========
* Refactor cursor stuff (already done?)imho yes
* w32 is required this?? r2 -d <pid> > dh native > dp=824 > ... -- not really :) for 0.6
* Create radare2-testsuite project
- tests for ired, rax2, radare2, rabin2 ...
* Record trace of register status for each function when running
- r_reg_arena_copy();
* Add lua and dalvik disassembler (volunteers?)
* Reimplement or fix the delta diffing in C
- first we need to do it for ired..
* Trace contents of buffers: filter search results..? cc 8080 @@ hit* .. check for values that has changed.
* Add dex format support to rabin (android)
* Is RCore->block and blocksize a RBuf ? refactor!11
* add support for sign/unsigned registers..or at least a way to cast them
* Implement rap:// upload/download protocol commands (maybe just system() with rsc2+wget?
* Add support for STATIC_PLUGINS in r_lang
- r_lang_define is implemented in lang.c, but requires the collaboration
of the plugins to properly setup the environment for the script execution.
- Add support for STATIC_PLUGINS in r_lang
- dlerror(/usr/lib/radare2/lang_perl.so): libperl.so: cannot open shared object file: No such file or directory
This issue is fixed by setting LD_LIBRARY_PATH...looks like dlopen ignores rpath
* merge asm.arch vm.arch
* Define and use boolean type return type
* Functions in r_util to get lil/big ut8,16,32 from ut8*
* dmi command must read from memory if no file path provided
- rabin from memory ftw
* rahash takes TOO long to load on big binaries
@ -17,9 +40,6 @@ TODO 0.7
jeje
0x0
^C
* search in which region there's rwx with matching hexpairs or string
- Use RIO
* merge asm.arch vm.arch
* _ZN7WebCore11CounterNode7recountERKNS_12AtomicStringE
- demangle c++ and objc names
WebCore.CounterNode.recount(AtomicString)
@ -42,9 +62,9 @@ Questions
Debugger
========
* Breakpoints are ignored in some situations.. we must check
for them and toggle a .dbg variable to break
* stepover waits for one unknown event
* stepover waits for one unknown event that cannot be stopped
* Implement DRX support
* Implement list threads on ALL supported platforms (win,lin,osx)
* ALL threads must be stopped when a breakpoint is handled..
* Floating point registers
* MMX/XMM/DRX control
@ -79,12 +99,12 @@ TODO edu
* Implement case-insensitive search (e search.casematters ?) any better name? Use /i?
* Implement /. to search using a file .. isnt zignatures about this?
* Implement /p to search for patterns
- implement it in r_core ?? or add r_io_bind support
* Implement search and replace /s
TODO pancake
------------
* rarc2 allows to compile invalid code like calling puts() out of context
* Implement DRX support
* Implement RAnalCall (analyze function arguments, return values, propagate types..)
- define number of arguments for given function
- warn if signature and analysis differs in number of args or so..
@ -130,28 +150,6 @@ Refactoring
- useful in r_sys_mkdir ?
* Finish and import the spp's getopt owns implementation in r_util (like in p9)
0.7
===
* Refactor cursor stuff
* r2 -d <pid> > dh native > dp=824 > ... -- not really :) for 0.6
* Create radare2-testsuite project
- tests for ired, rax2, radare2, rabin2 ...
* Record trace of register status for each function when running
- r_reg_arena_copy();
* Add lua and dalvik disassembler (volunteers?)
* Reimplement or fix the delta diffing in C
- first we need to do it for ired..
* Trace contents of buffers: filter search results..? cc 8080 @@ hit* .. check for values that has changed.
* Add dex format support to rabin (android)
* Is RCore->block and blocksize a RBuf ? refactor!11
* add support for sign/unsigned registers..or at least a way to cast them
* Implement rap:// upload/download protocol commands (maybe just system() with rsc2+wget?
* Add support for STATIC_PLUGINS in r_lang
- r_lang_define is implemented in lang.c, but requires the collaboration
of the plugins to properly setup the environment for the script execution.
- Add support for STATIC_PLUGINS in r_lang
- dlerror(/usr/lib/radare2/lang_perl.so): libperl.so: cannot open shared object file: No such file or directory
This issue is fixed by setting LD_LIBRARY_PATH...looks like dlopen ignores rpath
Future
======

View File

@ -598,3 +598,27 @@ reaccept:
}
return -1;
}
R_API int r_core_search_cb(RCore *core, ut64 from, ut64 to, RCoreSearchCallback cb) {
int ret, len = core->blocksize;
ut8 *buf;
if ((buf = malloc (len)) == NULL)
eprintf ("Cannot allocate blocksize\n");
else while (from<to) {
ut64 delta = to-from;
if (delta<len)
len = (int)delta;
if (!r_io_read_at (core->io, from, buf, len)) {
eprintf ("Cannot read at 0x%"PFMT64x"\n", from);
break;
}
for (ret=0; ret<len;) {
int done = cb (core, from, buf+ret, len-ret);
if (done<1) /* interrupted */
return R_FALSE;
ret += done;
}
from += len;
}
return R_TRUE;
}

View File

@ -101,6 +101,8 @@ typedef struct r_core_t {
RCoreRtrHost rtr_host[RTR_MAX_HOSTS];
} RCore;
typedef int (*RCoreSearchCallback)(RCore *core, ut64 from, ut8 *buf, int len);
#ifdef R_API
#define r_core_cast(x) (RCore*)(size_t)(x)
R_API int r_core_init(struct r_core_t *core);
@ -125,6 +127,7 @@ R_API int r_core_read_at(struct r_core_t *core, ut64 addr, ut8 *buf, int size);
R_API int r_core_visual(struct r_core_t *core, const char *input);
R_API int r_core_visual_cmd(struct r_core_t *core, int ch);
R_API int r_core_search_cb(RCore *core, ut64 from, ut64 to, RCoreSearchCallback cb);
R_API int r_core_serve(RCore *core, int fd);
R_API struct r_core_file_t *r_core_file_open(struct r_core_t *r, const char *file, int mode);
R_API struct r_core_file_t *r_core_file_get_fd(struct r_core_t *core, int fd);

View File

@ -8,6 +8,9 @@
#define ut16 unsigned short
#define ut8 unsigned char
#define st8 char
/* TODO: choose */
#define bt1 int
#define boolt int
#define R_FAIL -1
#define R_FALSE 0

View File

@ -136,6 +136,15 @@ enum {
#define R_SYS_ENDIAN "big"
#endif
// TODO: find better names and write vapis
#define ut8p_b(x) ((x)[0])
#define ut8p_bw(x) ((x)[0]|((x)[1]<<8))
#define ut8p_bd(x) ((x)[0]|((x)[1]<<8)|((x)[2]<<16)|((x)[3]<<24))
#define ut8p_bq(x) ((x)[0]|((x)[1]<<8)|((x)[2]<<16)|((x)[3]<<24)|((x)[4]<<32)|((x)[5]<<40)|((x)[6]<<48)|((x)[7]<<56))
#define ut8p_lw(x) ((x)[1]|((x)[0]<<8))
#define ut8p_ld(x) ((x)[3]|((x)[2]<<8)|((x)[1]<<16)|((x)[0]<<24))
#define ut8p_lq(x) ((x)[7]|((x)[6]<<8)|((x)[5]<<16)|((x)[4]<<24)|((x)[3]<<32)|((x)[2]<<40)|((x)[1]<<48)|((x)[0]<<56))
R_API RNum *r_num_new(RNumCallback cb, void *ptr);
#define R_BUF_CUR -1

View File

@ -22,7 +22,7 @@ public class RCore {
public RSign sign;
public RPrint print;
// TODO: public RVm vm;
public uint64 offset;
public uint64 offset;
public static unowned RCore cast(uint64 ptr);
public bool loadlibs();
@ -121,6 +121,8 @@ public class RCore {
// public static RList<RCoreAsmHit> AsmHit.list();
}
public delegate int SearchCallback (uint64 from, uint8 *buf, int len);
public bool search_cb(uint64 from, uint64 to, SearchCallback cb);
/* files */
public RCore.File file_open(string file, int mode);