Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Substitutes for x86 assembly 'call' instruction?

Tags:

What are some alternatives to the x86 call instruction? Maybe something like a push of the return address then a jump?

Also is their a command for obtaining the current position in memory?

like image 842
rick Avatar asked Aug 15 '11 01:08

rick


People also ask

What is RET equivalent to in assembly?

ret is basically how you write pop eip (or IP / RIP) in x86, so popping into an architectural register and using a register-indirect jump is architecturally equivalent.

What does the x86 call instruction do?

The CALL instruction performs two operations: It pushes the return address (address immediately after the CALL instruction) on the stack. It changes EIP to the call destination. This effectively transfers control to the call target and begins execution there.

What does call instruction do in assembly language?

The call instruction calls near procedures using a full pointer. call causes the procedure named in the operand to be executed. When the called procedure completes, execution flow resumes at the instruction following the call instruction (see the return instruction).

Is x86 assembly a language?

x86 assembly language is the name for the family of assembly languages which provide some level of backward compatibility with CPUs back to the Intel 8008 microprocessor, which was launched in April 1972. It is used to produce object code for the x86 class of processors.


2 Answers

The call instruction actually does this for you. For example call my_func would do something like:

push ret_address
jmp my_func

A subsequent ret call would just use the address you just pushed to jmp back in a sense. Is there a specific reason that you don't want to use call or is it not available for you? For current position in memory you can try to read the eip register (can't write to it).

like image 145
Jesus Ramos Avatar answered Oct 01 '22 14:10

Jesus Ramos


You can just push a dword value and jmp to the procedure. The push would be the return address :

push return_address (push eax if address in eax)
jmp call_address

Remember to also push arguments if they exist for that particular call.

What do you mean by current position in memory ? I suppose that you mean the current instruction pointer. You cannot get that directly, but you can use a seh handler(structured exception handler) to get that value upon causing a handled exception.

like image 45
Spyros Avatar answered Oct 01 '22 15:10

Spyros