rizinorg / rizin

UNIX-like reverse engineering framework and command-line toolset.
https://rizin.re
GNU Lesser General Public License v3.0
2.66k stars 355 forks source link

Remove use of `rz_core_cmd_strf()` inside `librz/` #3842

Open XVilka opened 1 year ago

XVilka commented 1 year ago
ℤ rg rz_core_cmd_strf

librz/core/agraph.c
2138:         char *res = rz_core_cmd_strf(core, "pD %d @ 0x%08" PFMT64x, size, addr);
2171:         body = rz_core_cmd_strf(core, "%s 0x%08" PFMT64x, "aeab", addr);
2173:         body = rz_core_cmd_strf(core, "%s %d @ 0x%08" PFMT64x, cmd, size, addr);

librz/core/linux_heap_jemalloc.c
112:  char *va = rz_core_cmd_strf(core, "dmi libjemalloc.2 %s$~[1]", symname);

librz/core/core.c
407:  bnd->cmdstrf = (RzCoreCmdStrF)rz_core_cmd_strf;

librz/core/tui/vmenus.c
491:          char *trace_addr_str = rz_core_cmd_strf(core, "dtdq %d", delta);

librz/include/rz_core.h
452:RZ_API char *rz_core_cmd_strf(RzCore *core, const char *fmt, ...) RZ_PRINTF_CHECK(2, 3);

librz/core/cmd/cmd.c
313:          rz_core_cmd_strf(core, "#!c %s", file);
5478:RZ_API char *rz_core_cmd_strf(RzCore *core, const char *fmt, ...) {

librz/core/cmd/cmd_analysis.c
2447:                         char *s = rz_core_cmd_strf(core, "pxr 8 @ 0x%08" PFMT64x, xref->to);
3345:         char *str = rz_core_cmd_strf(core, "fd @ 0x%" PFMT64x, xref->from);

See also this callback:

ℤ rg cmdstrf
librz/parse/p/parse_wasm_pseudo.c
15:     char *s = analysis->coreb.cmdstrf(analysis->coreb.core, "is~FUNC[6:%u]", fcn_id);

librz/include/rz_bind.h
35:     RzCoreCmdStrF cmdstrf;

librz/core/core.c
376:    bnd->cmdstrf = (RzCoreCmdStrF)rz_core_cmd_strf;

librz/analysis/p/analysis_wasm.c
31:     char *s = analysis->coreb.cmdstrf(analysis->coreb.core, "is~FUNC[2:%u]", fcn_id);
byteninjaa0 commented 1 year ago

after doing the changes we can then remove the rzcore.h ?

XVilka commented 1 year ago

Of course not.

byteninjaa0 commented 1 year ago

yes you are right i am stupid i thought replacing it with rz_core_cmd() will work since rz_core_cmd_strf() depends on there being a global RzCore instance to operate on

HN026 commented 10 months ago

is this still unassigned, I want to work on this.

byteninjaa0 commented 10 months ago

In rizin, issues are assigned to members only. However you can work on any issue you want. you can comment on a issue if you need any help.

XVilka commented 4 months ago

@giridharprasath after converting /R to the rzshell, please see this one as well (the command call of the corresponding ROP command):

librz/core/tui/rop.c
37: char *ropstr = rz_core_cmd_strf(core, "\"/Rl %s\" @e:scr.color=0", linestr);
81:             char *output = rz_core_cmd_strf(core, "piu 10 @ 0x%08" PFMT64x, addr + delta);
183:                ropstr = rz_core_cmd_strf(core, "\"/Rl %s\" @e:scr.color=0", linestr);
210:                char *line = rz_core_cmd_strf(core, "piuq@0x%08" PFMT64x, addr + delta);