How to print EIP address in C?

QuestionsHow to print EIP address in C?
sethbeckerman5 Staff asked 8 years ago

This is my C program … I was trying to print out ESP, EBP and EIP.

I don't have problem with ESP and EBP.

But when I try to put EIP code, I'm getting the following error when compiling it.

What's wrong with this code?

Is it possible to print out EIP value via C programming?

If yes, please let me know how to do it.

Update

I've tested the code here …

Thanks @Antti Haapala and others for your help. The code works … However, when I load it into GDB, the EIP value is different.

Here is the new code


View on Stack Overflow