mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-26 22:50:48 +00:00
Remove global magic depth ##search
This commit is contained in:
parent
e8e1548870
commit
691311ce5c
@ -170,8 +170,7 @@ R_API bool r_anal_cc_exist(RAnal *anal, const char *convention) {
|
||||
}
|
||||
|
||||
R_API const char *r_anal_cc_arg(RAnal *anal, const char *convention, int n) {
|
||||
r_return_val_if_fail (anal, NULL);
|
||||
r_return_val_if_fail (n >= 0, NULL);
|
||||
r_return_val_if_fail (anal && n >= 0, NULL);
|
||||
if (!convention) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -4310,9 +4310,6 @@ R_API int r_core_config_init(RCore *core) {
|
||||
SETCB ("log.file", "", cb_log_config_file, "Save log messages to given filename");
|
||||
SETCB ("scr.tee", "", &cb_teefile, "pipe output to file of this name");
|
||||
#endif
|
||||
/* magic */
|
||||
SETI ("magic.depth", 100, "recursivity depth in magic description strings");
|
||||
|
||||
/* rap */
|
||||
SETBPREF ("rap.loop", "true", "run rap as a forever-listening daemon (=:9090)");
|
||||
|
||||
|
@ -1,12 +1,14 @@
|
||||
/* radare - LGPL - Copyright 2009-2022 - pancake */
|
||||
/* radare - LGPL - Copyright 2009-2023 - pancake */
|
||||
|
||||
#include <r_core.h>
|
||||
|
||||
#define NAH 32
|
||||
static R_TH_LOCAL int magicdepth = 99;
|
||||
|
||||
static R_TH_LOCAL RMagic *ck = NULL; // XXX: Use RCore->magic
|
||||
static R_TH_LOCAL char *ofile = NULL;
|
||||
|
||||
#define MAX_MAGIC_DEPTH 64
|
||||
|
||||
static int r_core_magic_at(RCore *core, RSearchKeyword *kw, const char *file, ut64 addr, int depth, int v, PJ *pj, int *hits) {
|
||||
const char *fmt;
|
||||
char *q, *p;
|
||||
@ -20,7 +22,8 @@ static int r_core_magic_at(RCore *core, RSearchKeyword *kw, const char *file, ut
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (--depth < 0) {
|
||||
depth++;
|
||||
if (depth > MAX_MAGIC_DEPTH) {
|
||||
ret = 0;
|
||||
goto seek_exit;
|
||||
}
|
||||
@ -137,15 +140,15 @@ static int r_core_magic_at(RCore *core, RSearchKeyword *kw, const char *file, ut
|
||||
// TODO: This must be a callback .. move this into RSearch?
|
||||
if (!pj) {
|
||||
if (kw) {
|
||||
r_cons_printf ("0x%08" PFMT64x " %d %s %s\n", addr + adelta, magicdepth - depth, flag, p);
|
||||
r_cons_printf ("0x%08" PFMT64x " %d %s %s\n", addr + adelta, depth, flag, p);
|
||||
R_FREE (flag);
|
||||
} else {
|
||||
r_cons_printf ("0x%08" PFMT64x " %d %s\n", addr + adelta, magicdepth - depth, p);
|
||||
r_cons_printf ("0x%08" PFMT64x " %d %s\n", addr + adelta, depth, p);
|
||||
}
|
||||
} else {
|
||||
pj_o (pj);
|
||||
pj_kN (pj, "offset", addr + adelta);
|
||||
pj_ki (pj, "depth", magicdepth - depth);
|
||||
pj_ki (pj, "depth", depth);
|
||||
pj_ks (pj, "info", p);
|
||||
pj_end (pj);
|
||||
}
|
||||
@ -153,7 +156,7 @@ static int r_core_magic_at(RCore *core, RSearchKeyword *kw, const char *file, ut
|
||||
if (must_report_progress) {
|
||||
r_cons_clear_line (1);
|
||||
}
|
||||
//eprintf ("0x%08"PFMT64x" 0x%08"PFMT64x" %d %s\n", addr+adelta, addr+adelta, magicdepth-depth, p);
|
||||
//eprintf ("0x%08"PFMT64x" 0x%08"PFMT64x" %d %s\n", addr+adelta, addr+adelta, depth, p);
|
||||
// walking children
|
||||
for (q = p; *q; q++) {
|
||||
switch (*q) {
|
||||
@ -164,7 +167,7 @@ static int r_core_magic_at(RCore *core, RSearchKeyword *kw, const char *file, ut
|
||||
{
|
||||
ut64 addr = 0LL;
|
||||
*q = 0;
|
||||
if (!strncmp (q + 1, "0x", 2)) {
|
||||
if (r_str_startswith (q + 1, "0x")) {
|
||||
sscanf (q + 3, "%"PFMT64x, &addr);
|
||||
} else {
|
||||
sscanf (q + 1, "%"PFMT64d, &addr);
|
||||
@ -181,7 +184,6 @@ static int r_core_magic_at(RCore *core, RSearchKeyword *kw, const char *file, ut
|
||||
R_FREE (p);
|
||||
r_magic_free (ck);
|
||||
ck = NULL;
|
||||
// return adelta+1;
|
||||
}
|
||||
adelta ++;
|
||||
delta ++;
|
||||
@ -205,8 +207,7 @@ static void r_core_magic(RCore *core, const char *file, int v, PJ *pj) {
|
||||
ut64 addr = core->offset;
|
||||
int hits = 0;
|
||||
|
||||
magicdepth = r_config_get_i (core->config, "magic.depth"); // TODO: do not use global var here
|
||||
r_core_magic_at (core, NULL, file, addr, magicdepth, v, pj, &hits);
|
||||
r_core_magic_at (core, NULL, file, addr, 0, v, pj, &hits);
|
||||
if (pj) {
|
||||
r_cons_newline ();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
option('cli', type: 'feature', value: 'auto', description: 'Build CLI programs ("auto" means they will be built when not a subproject)')
|
||||
option('static_runtime', type: 'boolean', value: false)
|
||||
option('static_runtime', type: 'boolean', value: false, description: 'Link all libraries statically')
|
||||
option('local', type: 'boolean', value: false, description: 'Adds support for local/side-by-side installation (sets rpath if needed)')
|
||||
option('blob', type: 'boolean', value: false, description: 'Compile just one binary which dispatch to the right handlers based on the name used to call it')
|
||||
option('wasan', type: 'boolean', value: false, description: 'Windows-specific hack to build with asan using msvc')
|
||||
|
@ -1,4 +1,12 @@
|
||||
#!/bin/sh
|
||||
export CFLAGS="-pg -g -O1 -no-pie"
|
||||
export CFLAGS="-O1 -g -ggdb"
|
||||
#-pg -g -O1"
|
||||
export CC=clang
|
||||
export LDFLAGS="$CFLAGS"
|
||||
sys/install.sh
|
||||
#sys/install.sh
|
||||
if [ -d bpg ];then
|
||||
meson setup bpg --reconfigure
|
||||
else
|
||||
meson setup bpg
|
||||
fi
|
||||
ninja -C bpg
|
||||
|
Loading…
Reference in New Issue
Block a user