I know we can edit opcodes in radare2's visual mode using i.
But is there any way to edit instructions directly in visual mode?
In my case, the instruction is:
jae 0x8048450 And I want change it to:
jnbe 0x8048450 This is called assembling - the reverse of "disassembling".
You can do so with the command wa (presumably, "write assembly"). It can be found in the Radare2 cheat sheet:
wa jnz 0x400d24 wa jnbe 0x8048450, radare2 write ja 0x10090882. radare2 result: Written 6 bytes (jnbe 0x8048450) = wx 0f874a840408. why? jnbe notation. jnbe 0x8048450 and ja 0x10090882 are not same operations. I received SIGSEGV after this change! ja and jnbe? Because they are exactly the same instruction (look at that web page I linked to–their codes are the same!). But the address in your examples are not the same, so it should not be surprising you get a different result. It also has nothing to do with the segfault–you changed the code, and so you probably broke something. 731c jae 0x8048450 after wa ja 0x8048450 --> 0f8718000000 ja 0x8048450 and it's not true. And 731c jae 0x8048450 after i + 771c --> 771c jae 0x8048450 and it's true. wa ja 0x8048450 and i + 771c should be same. am i right? In visual mode, you can use the A command, to launch the interactive assembler, type your opcodes, and see in real time the corresponding hex code.
You could have found this command by typing ?, to get help, in visual mode.