Create function when z/ finds byte ##signatures
This commit is contained in:
parent
0657c1f100
commit
88edfb775b
|
@ -608,6 +608,7 @@ struct ctxSearchCB {
|
||||||
RCore *core;
|
RCore *core;
|
||||||
bool bytes_only;
|
bool bytes_only;
|
||||||
bool rad;
|
bool rad;
|
||||||
|
int newfuncs;
|
||||||
int count;
|
int count;
|
||||||
int bytes_count;
|
int bytes_count;
|
||||||
int graph_count;
|
int graph_count;
|
||||||
|
@ -689,10 +690,17 @@ static int searchBytesHitCB(RSignItem *it, RSearchKeyword *kw, ut64 addr, void *
|
||||||
struct ctxSearchCB *ctx = (struct ctxSearchCB *)user;
|
struct ctxSearchCB *ctx = (struct ctxSearchCB *)user;
|
||||||
apply_flag (ctx->core, it, addr, kw->keyword_length, kw->count, "bytes", ctx->rad);
|
apply_flag (ctx->core, it, addr, kw->keyword_length, kw->count, "bytes", ctx->rad);
|
||||||
RAnalFunction *fcn = r_anal_get_fcn_in (ctx->core->anal, addr, 0);
|
RAnalFunction *fcn = r_anal_get_fcn_in (ctx->core->anal, addr, 0);
|
||||||
// TODO: create fcn if it does not exist
|
if (!fcn) {
|
||||||
if (ctx->bytes_only && fcn) {
|
RCore *c = ctx->core;
|
||||||
apply_name (ctx->core, fcn, it, ctx->rad);
|
r_core_af (c, c->offset, NULL, false);
|
||||||
apply_types (ctx->core, fcn, it);
|
fcn = r_anal_get_fcn_in (ctx->core->anal, addr, 0);
|
||||||
|
ctx->newfuncs++;
|
||||||
|
}
|
||||||
|
if (ctx->bytes_only) {
|
||||||
|
if (fcn) {
|
||||||
|
apply_name (ctx->core, fcn, it, ctx->rad);
|
||||||
|
apply_types (ctx->core, fcn, it);
|
||||||
|
}
|
||||||
ctx->bytes_count++;
|
ctx->bytes_count++;
|
||||||
ctx->count++;
|
ctx->count++;
|
||||||
}
|
}
|
||||||
|
@ -821,6 +829,9 @@ static bool fill_search_metrics(RSignSearchMetrics *sm, RCore *c, void *user) {
|
||||||
|
|
||||||
static void print_ctx_hits(struct ctxSearchCB *ctx) {
|
static void print_ctx_hits(struct ctxSearchCB *ctx) {
|
||||||
int prints = 0;
|
int prints = 0;
|
||||||
|
if (ctx->newfuncs) {
|
||||||
|
eprintf ("New functions: %d\n", ctx->newfuncs);
|
||||||
|
}
|
||||||
if (ctx->bytes_count) {
|
if (ctx->bytes_count) {
|
||||||
eprintf ("bytes: %d\n", ctx->bytes_count);
|
eprintf ("bytes: %d\n", ctx->bytes_count);
|
||||||
prints++;
|
prints++;
|
||||||
|
|
|
@ -337,7 +337,7 @@ z/
|
||||||
f~?
|
f~?
|
||||||
e search.align=1
|
e search.align=1
|
||||||
z/
|
z/
|
||||||
f~?
|
f~sign?
|
||||||
EOF
|
EOF
|
||||||
EXPECT=<<EOF
|
EXPECT=<<EOF
|
||||||
0
|
0
|
||||||
|
@ -387,7 +387,7 @@ za foo b 11223344
|
||||||
e zign.minsz = 0
|
e zign.minsz = 0
|
||||||
fs *
|
fs *
|
||||||
z/
|
z/
|
||||||
f~?
|
f~sign?
|
||||||
f-*
|
f-*
|
||||||
e zign.minsz = 5
|
e zign.minsz = 5
|
||||||
z/
|
z/
|
||||||
|
|
Loading…
Reference in New Issue