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

Implement Vbw command to browse window types in visual ##visual #23047

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
86 changes: 67 additions & 19 deletions libr/core/visual.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ static void setcursor(RCore *core, bool cur) {
core->print->col = core->print->cur_enabled? 1: 0;
}

// R2_600 make this function static and disMode must be taken from core->visual.disMode instead of an argument
R_API void r_core_visual_applyDisMode(RCore *core, int disMode) {
core->visual.currentFormat = R_ABS (disMode) % 5;
switch (core->visual.currentFormat) {
Expand Down Expand Up @@ -484,7 +485,7 @@ R_API bool r_core_visual_hud(RCore *core) {
r_cons_context ()->color_mode = use_color;

r_core_visual_showcursor (core, true);
if (c && *c && r_file_exists (c)) {
if (R_STR_ISNOTEMPTY (c) && r_file_exists (c)) {
res = r_cons_hud_file (c);
}
if (!res && homehud) {
Expand Down Expand Up @@ -2295,6 +2296,65 @@ static bool fix_cursor(RCore *core) {
return res;
}

static void visual_windows(RCore *core) {
// TODO add more formats
// hud for all modes from visual
//int pidx = core->visual.printidx;
//int mode = core->visual.hexMode; // MODE_PX
//int mode = core->visual.disMode; // MODE_DB/PD
//int mode = core->visual.currentFormat; // MODE_OV / CD
RList *pmodes = r_list_newf (free);
r_list_append (pmodes, strdup ("0:0 standard hexdump"));
r_list_append (pmodes, strdup ("0:1 hexdump with flag names and colors"));
r_list_append (pmodes, strdup ("0:2 pxr recursive hexdump regsize word"));
r_list_append (pmodes, strdup ("0:5 hexdump with st32"));
r_list_append (pmodes, strdup ("0:7 hexdump with ut16"));
r_list_append (pmodes, strdup ("0:8 hexdump with ut32"));
r_list_append (pmodes, strdup ("0:6 bit viewer at byte level hexdump"));
r_list_append (pmodes, strdup ("1:0 standard disassembly view"));
r_list_append (pmodes, strdup ("1:2 disassembly with esil expressions"));
r_list_append (pmodes, strdup ("1:2 pseudo disassembly"));
r_list_append (pmodes, strdup ("2:0 standard debugger"));
r_list_append (pmodes, strdup ("3:0 raw byte image pixel view"));
r_list_append (pmodes, strdup ("3:5 entropy bars"));
r_list_append (pmodes, strdup ("4:0 code dump"));
r_list_append (pmodes, strdup ("4:1 assembly code"));
r_list_append (pmodes, strdup ("4:2 hex bytes"));
char *res = r_cons_hud (pmodes, NULL);
if (R_STR_ISNOTEMPTY (res)) {
int a, b;
sscanf (res, "%d:%d", &a, &b);
core->visual.printidx = a;
switch (core->visual.printidx) {
case R_CORE_VISUAL_MODE_PD:
case R_CORE_VISUAL_MODE_DB:
core->visual.disMode = b;
r_core_visual_applyDisMode (core, core->visual.disMode);
break;
case R_CORE_VISUAL_MODE_PX:
core->visual.hexMode = b;
r_core_visual_applyHexMode (core, core->visual.hexMode);
core->visual.currentFormat = b;
printfmtSingle[0] = printHexFormats[R_ABS (core->visual.hexMode) % PRINT_HEX_FORMATS];
break;
case R_CORE_VISUAL_MODE_OV:
// core->visual.hexMode = b;
core->visual.current4format = b;
core->visual.currentFormat = b;
break;
case R_CORE_VISUAL_MODE_CD:
// core->visual.hexMode = b;
core->visual.current5format = b;
// core->visual.currentFormat = b;
core->visual.currentFormat = R_ABS (core->visual.current5format) % PRINT_5_FORMATS;
printfmtSingle[4] = print5Formats[core->visual.currentFormat];
break;
}
}
r_list_free (pmodes);
free (res);
}

static bool insert_mode_enabled(RCore *core) {
if (!core->visual.ime) {
return false;
Expand Down Expand Up @@ -2472,8 +2532,8 @@ R_API void r_core_visual_browse(RCore *core, const char *input) {
"# Browse stuff:\n"
" _ hud mode (V_)\n"
" 1 bit editor (vd1)\n"
" b blocks\n"
" a anal classes\n"
" b blocks\n"
" c classes\n"
" C comments\n"
" d debug traces\n"
Expand All @@ -2495,6 +2555,7 @@ R_API void r_core_visual_browse(RCore *core, const char *input) {
" t types\n"
" T themes\n"
" v vars\n"
" w window panels\n"
" x xrefs\n"
" X refs\n"
" z browse function zignatures\n"
Expand Down Expand Up @@ -2547,6 +2608,9 @@ R_API void r_core_visual_browse(RCore *core, const char *input) {
case 'v': // "vbv"
r_core_visual_anal (core, "v");
break;
case 'w': // "vbw"
visual_windows (core);
return;
case 'e': // "vbe"
r_core_visual_config (core);
break;
Expand Down Expand Up @@ -3082,7 +3146,7 @@ R_API int r_core_visual_cmd(RCore *core, const char *arg) {
} else {
r_cons_printf ("[t] ");
}
r_cons_flush();
r_cons_flush ();
r_cons_set_raw (true);
int ch = r_cons_readchar ();
if (isdigit (ch)) {
Expand Down Expand Up @@ -4025,22 +4089,6 @@ static void visual_title(RCore *core, int color) {
int pc, hexcols = r_config_get_i (core->config, "hex.cols");
if (core->visual.autoblocksize) {
switch (core->visual.printidx) {
#if 0
case R_CORE_VISUAL_MODE_PXR: // prc
case R_CORE_VISUAL_MODE_PRC: // prc
r_core_block_size (core, (int)(core->cons->rows * hexcols * 3.5));
break;
case R_CORE_VISUAL_MODE_PXa: // pxa
case R_CORE_VISUAL_MODE_PW: // XXX pw
r_core_block_size (core, (int)(core->cons->rows * hexcols));
break;
case R_CORE_VISUAL_MODE_PC: // XXX pc
r_core_block_size (core, (int)(core->cons->rows * hexcols * 4));
break;
case R_CORE_VISUAL_MODE_PXA: // pxA
r_core_block_size (core, hexcols * core->cons->rows * 8);
break;
#endif
case R_CORE_VISUAL_MODE_PX: // x
if (core->visual.currentFormat == 3 || core->visual.currentFormat == 9 || core->visual.currentFormat == 5) { // prx
r_core_block_size (core, (int)(core->cons->rows * hexcols * 4));
Expand Down
2 changes: 1 addition & 1 deletion libr/debug/p/native/xnu/xnu_threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ static bool xnu_thread_get_gpr(RDebug *dbg, xnu_thread_t *thread) {
regs, count,
regs, &count);
if (rc != KERN_SUCCESS) {
R_LOG_WARN ("failed to convert %d", rc);
R_LOG_DEBUG ("failed to convert %d", rc);
}
#endif
#if __arm64e__
Expand Down
Loading