Windows 上的 GS 寄存器有什么用? [英] What is the GS register used for on Windows?
问题描述
我找到了关于 FS 寄存器用途的 MSDN 文档:
I've found MSDN documentation on the purpose of the FS register:
https://msdn.microsoft.com/en-us/library/ms253960(v=vs.90).aspx
其中说明:
"在 x86 环境中,FS 寄存器指向的当前值线程信息块 (TIB) 结构."
"In an x86 environment, the FS register points to the current value of the Thread Information Block (TIB) structure."
但我似乎找不到任何关于 GS 注册在基于 Windows 的环境中的用途的严格文档.
But I cannot seem to find any rigorous documentation of the purpose of the GS register in a Windows based environment.
谁能告诉我在哪里看,或者给个解释?
Can someone tell me where to look, or give an explanation?
推荐答案
在 32 位 Windows 上 GS
保留供将来使用.FS
段指向线程信息块.
On 32 bit Windows GS
is reserved for future use.
The FS
segment points to the Thread information block.
在 x64 模式下,FS
和 GS
段寄存器已交换.
In x64 mode the FS
and GS
segment registers have been swapped around.
在 x86 模式下 FS:[0]
指向 TIB 的开始,在 X64 中,它是 GS:[0]
.
Win64 使用 GS
的原因是 FS
寄存器用于 32 位兼容层(混淆地称为 Wow64).
由于 32 位应用程序使用 FS
,因此简化了 Win64 的簿记.
32 位应用程序永远不会导致 GS
被改变,64 位应用程序永远不会导致 FS
被改变.
In x86 mode FS:[0]
points to the start of the TIB, in X64 it's GS:[0]
.
The reason Win64 uses GS
is that there the FS
register is used in the 32 bit compatibility layer (confusingly called Wow64).
Because 32-bit apps use FS
the bookkeeping for Win64 is simplified.
32 bit applications never cause GS
to be altered and 64 bit applications never cause FS
to be altered.
请注意,GS
在 Win64 和 Wow64 中为非零这一事实可用于检测 32 位应用程序是否在 64 位 Windows 中运行.
在真正"的 32 位 Windows 中,GS
始终为零.
Note that the fact that GS
is non-zero in Win64 and Wow64 can be used to detect if a 32-bit application is running in 64-bit Windows.
In a 'true' 32 bit Windows GS
is always zero.
这篇关于Windows 上的 GS 寄存器有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!