x86 assembly instruction: call *Reg

对着背影说爱祢 提交于 2019-11-30 02:56:00

问题


Can anybody give me some information about indirect function calls in x86 assembly, i.e. instructions like

call *Reg

So where the address of the function label is stored in a register. Somehow I couldn't find information about it via google.

And furthermore, what does it mean if I get a Trace/breakpoint exception when running an x86 assembly program which has such an instruction?


回答1:


Intel and AMD publish very good documentation regarding x86. Here's a link to Intels instruction set reference which (of course) has a section on CALL. http://www.intel.com/design/intarch/manuals/243191.HTM

OP Code: FF /2 
Instruction: CALL r/m32 
Description: Call near, absolute indirect, address given in r/m32

Using NASM syntax

lbl_start:
 MOV EAX, lbl_function1
 CALL EAX
 RETN

lbl_function1:
 MOV EAX, 1
 RET 0

If you're getting an exception it could mean almost anything. Here's a few common issues...

  • you're not setting the register to an address within the program
    • you're setting the register value but it's being changed by an API call that happens before your CALL reg32
    • you're setting the register value to the data located at a specific address rather than the address itself
  • you're encoding your CALL reg32 OP Code incorrectly, (ex: FF D0 is CALL EAX in hex)


来源:https://stackoverflow.com/questions/8419161/x86-assembly-instruction-call-reg

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!