Skip to content

Commit

Permalink
Implement endian swap in visual bit editor ##visual
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Nov 18, 2024
1 parent fc4bfcd commit e59c8b9
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions libr/core/vmenus.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,18 @@ R_API bool r_core_visual_bit_editor(RCore *core) {
wordsize = 1;
}
break;
case 'e': // swap endian
{
ut8 a[8];
memcpy (a, buf, sizeof (a));
const int nbyte = x / 8;
const int last = R_MIN (nbyte + wordsize, 8);
int i;
for (i = nbyte; i < last; i++) {
buf[i] = a[last - 1 - i + nbyte];
}
}
break;
case 'Q':
case 'q':
if (analop.bytes) {
Expand Down Expand Up @@ -851,6 +863,7 @@ R_API bool r_core_visual_bit_editor(RCore *core) {
" q - quit the bit editor\n"
" R - randomize color palette\n"
" b - toggle bitsInLine\n"
" e - toggle endian of the selected word\n"
" j/k - toggle bit value (same as space key)\n"
" J/K - next/prev instruction (so+1,so-1)\n"
" h/l - select next/previous bit\n"
Expand Down Expand Up @@ -4809,12 +4822,12 @@ R_API void r_core_visual_colors(RCore *core) {
#define CASE_RGB(x,X,y) \
case x:if ((y) > 0x00) { (y)--; } break;\
case X:if ((y) < 0xff) { (y)++; } break;
CASE_RGB ('R','r',rcolor.r);
CASE_RGB ('G','g',rcolor.g);
CASE_RGB ('B','b',rcolor.b);
CASE_RGB ('E','e',rcolor.r2);
CASE_RGB ('F','f',rcolor.g2);
CASE_RGB ('V','v',rcolor.b2);
CASE_RGB ('R', 'r', rcolor.r);
CASE_RGB ('G', 'g', rcolor.g);
CASE_RGB ('B', 'b', rcolor.b);
CASE_RGB ('E', 'e', rcolor.r2);
CASE_RGB ('F', 'f', rcolor.g2);
CASE_RGB ('V', 'v', rcolor.b2);
case 'Q':
case 'q':
free (res);
Expand Down

0 comments on commit e59c8b9

Please sign in to comment.