获取线程信息/环境块(TIB/TEB)的官方方法 [英] Official way to get the Thread Information/Environment Block (TIB/TEB)
问题描述
在 Windows 中,如果没有记录,可以在 FS:0 中找到当前线程的线程信息块 (TIB) 是很常见的知识.但这仅适用于英特尔 CPU,其中 FS 寄存器首先存在.现在我想在基于 ARM 的 Windows 系统(Windows Phone 和 Windows RT)上访问 TIB.请问有相关的API吗?
In Windows, it's long been common, if undocumented, knowledge that the Thread Information Block (TIB) of the current thread can be found at FS:0. But that only works on Intel CPUs, where the FS register exists in the first place. Now I wanna get to the TIB on an ARM-based Windows system (Windows Phone and maybe Windows RT). Is there an API for that, please?
我想获取用于崩溃报告的线程堆栈基础.
I want to get the thread stack base for crash reporting purposes.
关于 TIB/TEB 的信息:http://www.microsoft.com/msj/存档/S2CE.aspx
Information about TIB/TEB: http://www.microsoft.com/msj/archive/S2CE.aspx
推荐答案
宏 NtCurrentTeb()
在 winnt.h
中可用于所有支持的架构,包括 ARM (Windows RT):
The macro NtCurrentTeb()
is available in winnt.h
for all supported architectures, including ARM (Windows RT):
#if defined(_M_ARM) && !defined(__midl) && !defined(_M_CEE_PURE)
__forceinline
struct _TEB *
NtCurrentTeb (
VOID
)
{
return (struct _TEB *)(ULONG_PTR)_MoveFromCoprocessor(CP15_TPIDRURW);
}
这篇关于获取线程信息/环境块(TIB/TEB)的官方方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!