Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is eax in the pt_regs struct? Only ax is present

I am trying to use the pt_regs struct to get and set registers such as eax, but compilation errors tell me that pt_regs has no such member eax.

However, I am able to get the ax register. Can anybody tell me what is happening?

I am using 32-bit Ubuntu linux with the 3.0.0 kernel. Thank you again.

like image 919
user490895 Avatar asked Apr 09 '12 08:04

user490895


1 Answers

Take a look at the definition of struct pt_regs in arch/x86/include/asm/ptrace.h.

Notice #ifndef __KERNEL__ stuff there, it means that the definition of that structure is different for kernel-mode and user-mode code.

For the kernel code, pt_regs::ax is probably the value you need. It should contain the value of %eax on a 32-bit system and %rax on a 64-bit one.

like image 129
Eugene Avatar answered Oct 17 '22 10:10

Eugene