Implement endian swap in visual bit editor ##visual

This commit is contained in:
pancake 2024-11-18 13:31:07 +01:00
parent fc4bfcde0f
commit e59c8b9386

View File

@ -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) {
@ -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"
@ -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);