如何连接code 86中相对短JMP [英] How encode a relative short jmp in x86

查看:290
本文介绍了如何连接code 86中相对短JMP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我想用下面的运算codeS做一个短跳转:


  

EB CB JMP REL8


  
  

跳转短,RIP = RIP + 8位位移标志
  扩展为64位


  
  

(其中CB是一个字节的符号值重新presenting相对偏移在有关方向的 EIP 报名)


也许始终偏移将是<青霉>偏移+ 2 的,因为EIP在执行时间(基准方向),在这短暂的跳跃是twobyte指令的基础上,但加数总是发生


  

30 EB = JMP 0x00000032(+30)


  
  

EB E2 = JMP 0xffffffe4(-30)


  
  

然后EIP可以有意同一个方向,因为FE + 2 00 EIP


  
  

EB FE = JMP 00000000


我觉得很奇怪,的 overoffset 的途中发生岔虽然数量为负。但在英特尔,我觉得没有提到(也许是因为3000页)。


  

英特尔®64和IA-32架构
  软件开发人员手册:卷。 2A 3-423


  
  

    

近跳转,其中跳跃范围从目前的 EIP值限制在-128到+127的一个。


  

然后我考虑三种可能性:


  1. 是+2,因为是的后/未来价值的EIP的执行时间

  2. 的codeD值不是一个2S部件连接codeD签号码。

  3. 这似乎在手册中,但我还没有看到,因为我傻


解决方案

REL8 是相对于下一条指令的内存地址,因为可以很容易地通过创建两个可执行文件予以确认和拆卸他们:

  @label:
    JMP @label
    NOP

这拆解为(与ndisasm,它在16位,32位和64位$ C $相同c):

  EBFE JMP短为0x0
90 NOP

然后,另一个可执行文件:

  JMP @label
@标签:
    NOPEB00 JMP短0X2
90 NOP

因此​​, REL8 为en codeD始终相对于下一条指令后 JMP 。反汇编(至少 ndisasm udcli ),但是,显示它相对于 JMP 指令本身。这可能引起一些混乱。

Suppose I want to do a short jump using the following opcodes:

EB CB or JMP rel8

"Jump short, RIP = RIP + 8-bit displacement sign extended to 64-bits"

(where CB is a byte signed value representing the relative offset relating to direction in EIP register)

Maybe always the offset will be offset+2 because the EIP in execution time (the reference direction) in this short jump is the base of the twobyte instruction, but the addend occurs always

eb 30 = jmp 0x00000032 (+30)

eb e2 = jmp 0xffffffe4 (-30)

then EIP can be intentionally the same direction because fe + 2 is 00 or EIP.

eb fe = jmp 0x00000000

I find it surprising that the overoffset ocurred bifurcated although the number is negative. But in the Intel I find no mention (maybe because 3000 pages).

Intel® 64 and IA-32 Architectures Software Developer’s Manual: Vol. 2A 3-423

A near jump where the jump range is limited to –128 to +127 from the current EIP value.

Then I contemplate three possibilities:

  1. is +2 because is the after/future value of EIP in execution time
  2. The coded value is not a 2s component encoded signed number.
  3. this appears in the manual but I have not seen because i'm stupid

解决方案

The rel8 is relative to the next instruction's memory address, as can easily be confirmed by creating two executables and disassembling them:

@label:
    jmp @label
    nop

This disassembles as (with ndisasm, it's the same in 16-bit, 32-bit and 64-bit code):

EBFE jmp short 0x0
90   nop

Then, another executable:

    jmp @label
@label:
    nop

EB00 jmp short 0x2
90   nop

So, the rel8 is encoded always relative to the next instruction after jmp. Disassemblers (at leastndisasm and udcli), however, show it relative to the jmp instruction itself. That may possibly cause some confusion.

这篇关于如何连接code 86中相对短JMP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆