1

I have something like this:

(fcn) fcn.140001020 20
   fcn.140001020 ();
           ; XREFS: CALL 0x140001080  CALL 0x140001098  CALL 0x1400010b0  CALL 0
           ; XREFS: CALL 0x140001794  CALL 0x1400017ad  CALL 
           0x140001029      mov dword [0x140018a38], eax

I want to be able to give the address 0x140018a38 a name so it will appear something like that:

           0x140001029      mov dword [myGlobal], eax
MkInitCpIO
  • 11
  • 1

1 Answers1

0

ENVIRONMENT

  • radare2: radare2 4.2.0-git 23519 @ linux-x86-64 git.4.1.1-84-g0c46c3e1e commit: 0c46c3e1e30bb272a5a05fc367d874af32b41fe4 build: 2020-01-08__09:49:0
  • system: Ubuntu 18.04.3 LTS

SOLUTION

  • I am unsure if radare2 implements the exact functionality your looking for, but we can get close using the Cf and CCa commands.
    • CCa[-at]|[at] [text] [@addr] # add/remove comment at given address
    • Cf[?][-] [sz] [0|cnt][fmt] [a0 a1...] [@addr] # format memory (see pf?)

EXAMPLE

user@host:~$ r2 /my/example
[0x00000000]> aaaa
...
[0x00000000]> s fcn.140001020
[0x140001020]> pd 1
(fcn) fcn.140001020 20
   fcn.140001020 ();
           ; XREFS: CALL 0x140001080  CALL 0x140001098  CALL 0x1400010b0  CALL 0
           ; XREFS: CALL 0x140001794  CALL 0x1400017ad  CALL 
           0x140001029      mov dword [0x140018a38], eax
[0x140001020]> CCa 0x140001020 0x140018a38 = myGlobal
[0x140001020]> pd 1
(fcn) fcn.140001020 20
   fcn.140001020 ();
           ; XREFS: CALL 0x140001080  CALL 0x140001098  CALL 0x1400010b0  CALL 0
           ; XREFS: CALL 0x140001794  CALL 0x1400017ad  CALL 
           0x140001029      mov dword [0x140018a38], eax ; 0x140001029 = myGlobal
[0x140001020]> Cf 2 w myGlobal @ 0x140018a38
[0x140001020]> pd 1 @ 0x140018a38
            0x140018a38 format w myGlobal {
 myGlobal : 0x140018a38 = 0xffff
} 2
[0x140001020]> q
user@host:~$ 
Kuma
  • 427
  • 5
  • 17
  • Also consider checking out https://reverseengineering.stackexchange.com/ for reverse engineering questions! – Kuma Jan 17 '20 at 14:22