Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check the EIP value with assembly language? [duplicate]

Tags:

x86

assembly

I want to get the current value of the EIP register with assembly language. Is that possible?

like image 648
smwikipedia Avatar asked Oct 31 '10 08:10

smwikipedia


People also ask

How do I find my EIP value?

Probably the simplest method of obtaining the value in EIP is Call $+5, which is a CALL to the next instruction. The value of EIP is then pulled off the stack and placed into a register. A simple form of this can be observed within the Bloxor shellcode encoder.

What is EIP assembly?

EIP stands for Extended Instruction Pointer and is used to track the address of the current instruction running inside the application.

What does the EIP do?

The EIP Card is a Treasury-sponsored, VISA-branded, prepaid debit card that provides a safe, convenient and secure way for EIP recipients to access their Economic Impact Payments without having to go to a bank or credit union to cash a check.

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.


1 Answers

Assuming 32-bit x86, use the following function:

get_eip: mov eax, [esp]          ret 

Then, to get the value of EIP in EAX, simply:

call get_eip 
like image 198
user200783 Avatar answered Oct 17 '22 07:10

user200783