SuspendThread WOW64 suspending in kernel code

南笙酒味 提交于 2019-12-05 08:11:34

I've confirmed that this is an OS issue returning stale contents when GetThreadContext is called under WOW64.

More info here.

Thanks to everyone who attempted to answer this question. I'm working with MS to resolve this.

See this explanation : GetThreadContext in Wow64

This article explains, that the transition between x86 and amd64 modes is done in user-mode.

What does your thread do in user-mode? It seems like it's already in kernel-mode when you call SuspendThread. Is it possible that it's executing a system function in the moment you suspend it?

What could be causing the OS to suspend a thread while it's running non-user-mode code?

Many system or library calls may result in switch to the kernel-mode. And because the Windows Kernel is designed to be reentrant in most cases, switching from one thread to another while the first one is in kernel-mode is pretty normal.

How do I prevent that?

Just an idea: Create a thread that is just executing an empty loop (e.g. for(;;);) and suspend that thread. This one should not be suspended in kernel-mode.


Also, why is it important to you that the ESP registers etc. are correct? I hope you are writing some kind of debugger or something related, because that's what SuspendThread is for.

Technically, when a thread isn't running at all, it's running neither kernel-mode code nor user-mode code. So your observations do not contradict the statement.

Beisdes, you shouldn't be messing with this. It would be an OS bug if you (in user mode) could control whether kernel mode code was executed.

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