I'm trying to skip exactly 1 instruction without using labels, an example with labels would be:
cmp r12, r13
je dest ; skip the jmp
jmp whatever
dest:
nop
However, my limitation is that I can't use labels, so I assume I must create a jump relative to the RIP register. For example (pseudo):
cmp r12, r13
je rip+0x05 ; this would obviously depend on the length of the next instruction
jmp whatever
nop
However, I lack knowledge to produce anything working, also as far as I know, it's not possible to read/write the RIP register without hacks.
EDIT: I'm only familiar with Intel syntax and I use Keystone as assembler. I will take the bytes from the assembly and load it into an executable memory location. I'm using my own website to get the bytes from the assembly, you might get the idea if you look at it.
EDIT 2: I tried Jesters and Margaret Blooms comments, which suggest to use:
je .+0x05
; or
je $+0x05
However, I can confirm that both don't work with Keystone! Luckily, I noticed that Keystone is able to process this code:
je +0x05
Is anyone able to confirm that this works?
EDIT 3: I tried it out with NASM and the $ prefix works fine with my tested code. I used this to test it:
section .text
global _WinMain@16
_WinMain@16:
jmp $+2+2 ; skip this jmp and the next jmp (each 2 bytes)
jmp $
ret 16
It works as expected. Also defuse produces the same output as Keystone. The only difference is that defuse uses the $ prefix and Keystone doesn't need one at all! Keystone equivalent is:
jmp +4
jmp .
ret 16