Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to use API in Visual Mode #4339

Open
wants to merge 26 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f124717
Refactor to use API in Visual Mode
HN026 Mar 6, 2024
b31cdef
Merge remote-tracking branch 'origin' into rz_core_seek_first_basic_b…
HN026 Mar 11, 2024
218d35a
Seek to a basic Block
HN026 Mar 11, 2024
e4b73d5
Merge remote-tracking branch 'origin' into rz_core_seek_first_basic_b…
HN026 Mar 14, 2024
8f4ca29
Implemented an API for `~...`
HN026 Mar 15, 2024
451c7b4
Merge remote-tracking branch 'origin' into rz_core_seek_first_basic_b…
HN026 Mar 16, 2024
f180342
Changes and shifted to Visual.c
HN026 Mar 16, 2024
6bd97f4
Merge remote-tracking branch 'origin' into rz_core_seek_first_basic_b…
HN026 Mar 17, 2024
aa4d719
Afb function
HN026 Mar 17, 2024
c060829
Refactor to use API in Visual Mode
HN026 Mar 6, 2024
8df818c
Seek to a basic Block
HN026 Mar 11, 2024
da5f4f9
Implemented an API for `~...`
HN026 Mar 15, 2024
bd6421f
Changes and shifted to Visual.c
HN026 Mar 16, 2024
42fadc8
Afb function
HN026 Mar 17, 2024
75f6fff
Merge branch 'rizinorg:dev' into dev
HN026 Mar 24, 2024
737deda
refactor
HN026 Mar 24, 2024
b809714
Merge remote-tracking branch 'origin/rz_core_seek_first_basic_block_A…
HN026 Mar 24, 2024
ce4beb8
free to RZ_FREE
HN026 Mar 24, 2024
5042768
Update visual.c
HN026 Mar 24, 2024
cedcabb
Merge remote-tracking branch 'origin' into rz_core_seek_first_basic_b…
HN026 Mar 26, 2024
65e737e
Merge remote-tracking branch 'origin' into rz_core_seek_first_basic_b…
HN026 Mar 26, 2024
1ae6f5d
refactor and function namechanges
HN026 Mar 26, 2024
0ba5529
NULL check
HN026 Mar 26, 2024
06bc8c9
Merge remote-tracking branch 'origin' into rz_core_seek_first_basic_b…
HN026 Mar 31, 2024
03204e8
vbt to direct API
HN026 Mar 31, 2024
a2ef3ea
JSON mode changes
HN026 Mar 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions librz/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2446,3 +2446,32 @@ RZ_API RzCmdStatus rz_core_core_plugins_print(RzCore *core, RzCmdStateOutput *st
rz_cmd_state_output_array_end(state);
return RZ_CMD_STATUS_OK;
}

/**
* \brief Seeks to any basic block of the current function.
*
* \param core The RzCore instance.
*/
RZ_API void rz_core_seek_bb(RZ_NONNULL RzCore *core) {
rz_return_if_fail(core);
RzAnalysisFunction *fcn = rz_analysis_get_fcn_in(core->analysis, core->offset, 0);
if (fcn) {
RzAnalysisBlock *bb;
void **iter;
rz_pvector_foreach (fcn->bbs, iter) {
bb = *iter;
rz_cons_printf("0x%08" PFMT64x " 0x%08" PFMT64x " 00:0000 %llu\n", bb->addr, bb->addr + bb->size, bb->size);
}
rz_cons_flush();
char *input = rz_cons_input("Enter an address: ");
ut64 addr = strtoull(input, NULL, 16);
free(input);
rz_pvector_foreach (fcn->bbs, iter) {
bb = *iter;
if (bb->addr <= addr && addr < bb->addr + bb->size) {
rz_core_seek(core, addr, true);
break;
}
}
}
HN026 marked this conversation as resolved.
Show resolved Hide resolved
}
2 changes: 1 addition & 1 deletion librz/core/tui/visual.c
Original file line number Diff line number Diff line change
Expand Up @@ -1987,7 +1987,7 @@ RZ_IPI void rz_core_visual_browse(RzCore *core, const char *input) {
rz_debug_switch_to_first_thread(core->dbg);
break;
case 'b':
rz_core_cmd0(core, "s $(afb~...)");
rz_core_seek_bb(core);
break;
case 'i':
// XXX ii shows index first and iiq shows no offset :(
Expand Down
2 changes: 2 additions & 0 deletions librz/include/rz_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,8 @@ RZ_API bool rz_core_plugin_add(RzCore *core, RZ_NONNULL RzCorePlugin *plugin);
RZ_API bool rz_core_plugin_del(RzCore *core, RZ_NONNULL RzCorePlugin *plugin);
RZ_API bool rz_core_plugin_fini(RzCore *core);

RZ_API void rz_core_seek_bb(RZ_NONNULL RzCore *core);

// #define rz_core_ncast(x) (RzCore*)(size_t)(x)
RZ_API RZ_OWN RzList /*<char *>*/ *rz_core_theme_list(RZ_NONNULL RzCore *core);
RZ_API char *rz_core_theme_get(RzCore *core);
Expand Down
Loading