问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/10070625/where-is-eax-in-the-pt-regs-struct-only-ax-is-present