mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-27 23:20:40 +00:00
Improve RConsBind and use it from RBin via iz^C ##bin
This commit is contained in:
parent
4a44ff4a90
commit
7c688dd174
@ -107,6 +107,7 @@ static void print_string(RBinFile *bf, RBinString *string, int raw) {
|
||||
|
||||
static int string_scan_range(RList *list, RBinFile *bf, int min,
|
||||
const ut64 from, const ut64 to, int type, int raw, RBinSection *section) {
|
||||
RBin *bin = bf->rbin;
|
||||
ut8 tmp[R_STRING_SCAN_BUFFER_SIZE];
|
||||
ut64 str_start, needle = from;
|
||||
int count = 0, i, rc, runes;
|
||||
@ -134,6 +135,11 @@ static int string_scan_range(RList *list, RBinFile *bf, int min,
|
||||
r_buf_read_at (bf->buf, from, buf, len);
|
||||
// may oobread
|
||||
while (needle < to) {
|
||||
if (bin && bin->consb.is_breaked) {
|
||||
if (bin->consb.is_breaked ()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
rc = r_utf8_decode (buf + needle - from, to - needle, NULL);
|
||||
if (!rc) {
|
||||
needle++;
|
||||
|
@ -1678,6 +1678,8 @@ R_API void r_cons_bind(RConsBind *bind) {
|
||||
}
|
||||
bind->get_size = r_cons_get_size;
|
||||
bind->get_cursor = r_cons_get_cursor;
|
||||
bind->cb_printf = r_cons_printf;
|
||||
bind->is_breaked = r_cons_is_breaked;
|
||||
}
|
||||
|
||||
R_API const char* r_cons_get_rune(const ut8 ch) {
|
||||
|
@ -2727,6 +2727,8 @@ R_API bool r_core_init(RCore *core) {
|
||||
/// XXX shouhld be using coreb
|
||||
r_parse_set_user_ptr (core->parser, core);
|
||||
core->bin = r_bin_new ();
|
||||
r_cons_bind (&core->bin->consb);
|
||||
// XXX we shuold use RConsBind instead of this hardcoded pointer
|
||||
core->bin->cb_printf = (PrintfCallback) r_cons_printf;
|
||||
r_bin_set_user_ptr (core->bin, core);
|
||||
core->io = r_io_new ();
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <r_util.h>
|
||||
#include <r_types.h>
|
||||
#include <r_io.h>
|
||||
#include <r_cons.h>
|
||||
#include <r_list.h>
|
||||
#include <r_bin_dwarf.h>
|
||||
#include <r_pdb.h>
|
||||
@ -319,6 +320,7 @@ typedef struct r_bin_t {
|
||||
PrintfCallback cb_printf;
|
||||
int loadany;
|
||||
RIOBind iob;
|
||||
RConsBind consb;
|
||||
char *force;
|
||||
int is_debugger;
|
||||
bool want_dbginfo;
|
||||
|
@ -60,10 +60,13 @@ R_LIB_VERSION_HEADER(r_cons);
|
||||
|
||||
typedef int (*RConsGetSize)(int *rows);
|
||||
typedef int (*RConsGetCursor)(int *rows);
|
||||
typedef bool (*RConsIsBreaked)(void);
|
||||
|
||||
typedef struct r_cons_bind_t {
|
||||
RConsGetSize get_size;
|
||||
RConsGetCursor get_cursor;
|
||||
PrintfCallback cb_printf;
|
||||
RConsIsBreaked is_breaked;
|
||||
} RConsBind;
|
||||
|
||||
typedef struct r_cons_grep_t {
|
||||
|
Loading…
Reference in New Issue
Block a user