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?
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.
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.
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).
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.
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).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With