Page 1 of 1

Dynamic code

Posted: Sat Oct 22, 2011 8:36 am
by Holus
Maybe a stupid question, but is there a way (in protected mode) to determine your the EIP?

I want to change some code based on the place I’m executing.
But this code is generated so it’s no option to make a label to determine it.

Is there an other way?

Re: Dynamic code

Posted: Sat Oct 22, 2011 8:44 am
by XanClic

Code: Select all

db 0xE8
dd 0x00000000
pop eax
This is a relative call with offset 0, so the EIP will effectively not be changed, however, it will be pushed onto the stack, so EAX will contain the address of the POP EAX instruction after executing it.

Re: Dynamic code

Posted: Sat Oct 22, 2011 9:07 am
by Holus
XanClic wrote:

Code: Select all

db 0xE8
dd 0x00000000
pop eax
Pfff sometimes a little code can make a big deference.

I tested it and EAX = Where code "0xE8" is + 3.
Now i can start calculating!!

Thanks!!!