Is there any way to view the results of something like dr= in signed interger form?

> dr rax = 298; dr rdx = 42; dr=
 rax 0x0000012a           rbx 0x00000000           rcx 0x00000000
 rdx 0x0000002a           rsi 0x00000000           rdi 0x00000000
  r8 0x00000000            r9 0x00000000           r10 0x00000000
 r11 0x00000000           r12 0x00000000           r13 0x00000000
 r14 0x00000000           r15 0x00000000           rip 0x00005850
 rbp 0x00000000           rflags              rsp 0x00000000

Looking to read rax and rdx as dec.


Although radare2 provides a rich amount of commands to handle registers (see dr?), it is quite tricky to view the values of the registers in decimal mode. That said, I will show you two simple approaches (commands) that you can choose to achieve your goal.

We will start by executing the commands you mentioned, in order to change the values of rax and rdx:

[0x7f49250e4e06]> dr rax = 298
0x00000000 ->0x0000012a
[0x7f49250e4e06]> dr rdx = 42
0x00000000 ->0x0000002a

1. Print only one register
This is the more elegant solution. From the first part of your question, I understand that you want to print all the registers in decimal mode, but at the end you refer only to rax and rdx. If this is the case, the following command can show you the value of a specific register in decimal mode:

[0x7f49250e4e06]> ?vi rax
[0x7f49250e4e06]> ?vi rdx

The command I used is ?vi and is a subcommand of ?. The command ? and its subcommands are responsible for evaluation of mathematical expressions. By executing ??? you can get its help. The help description for ?vi is:

[0x7f49250e4e06]> ???  
| ?vi rsp-rbp                      show decimal value of math expr  

2. Print all the registers as json
Unlike the first solution, this solution is less elegant but will show you all the registers. In the following solution, we will take advantage of the fact that by appending j to a command, radare can provide a JSON formatted output for almost every command. And yes, this includes the commands for displaying registers. We will also take advantage of the fact that the numeric values of the JSON outputs are usually decimal.

[0x7f49250e4e06]> drj~{}
  "rax": 298,
  "rbx": 139952134190912,
  "rcx": 2,
  "rdx": 42,
  "r8": 231,
  "r9": 18446744073709551488,
  "r10": 2,
  "r11": 2,
  "r12": 139952134190912,
  "r13": 2,
  "r14": 139952134227496,
  "r15": 0,
  "rsi": 60,
  "rdi": 0,
  "rsp": 140737461504296,
  "rbp": 0,
  "rip": 139952131034630,
  "rflags": 582,
  "orax": 231

I appended ~{} in order to format the JSON result of the command

As you can see, the values of the registers are in decimal, including our modified rax and rdx. This way you can enjoy a JSON formatted output that will show you the values of the registers in decimal.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.