Address versus Value at Address

流过昼夜 提交于 2019-12-25 03:24:32

问题


I am currently dealing with a problem relating to some kernel-mode code referencing %gs. Here’s what’s going on:

I have a fairly large structure which is stored in the %gs register. I am trying to get/set the cpu_active_thread value from that structure, which happens to be at offset 0x8 inside that structure. In other words, I am trying to get/set %gs:0x8. The problem is, when I get the value, the result is the literal value 0x8. (As this is not a valid address, I am crashing later on.) How can I change this so that I am getting the value eight bytes into the structure based in %gs?

If you need to know how I am getting the data out of the structure, I am using these macros. Thanks!

Edit: I am using clang. The macros above are used as such:

static inline thread_t
get_active_thread(void)
{
    CPU_DATA_GET(cpu_active_thread,thread_t)
}

来源:https://stackoverflow.com/questions/25294924/address-versus-value-at-address

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!