在32位保护模式/MSVC内联汇编中获取FS:[0]的线性地址 [英] Get linear address of FS:[0] in 32-bit protected mode / MSVC inline asm

查看:160
本文介绍了在32位保护模式/MSVC内联汇编中获取FS:[0]的线性地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual C ++内联汇编中使用了此指令

I used this instruction in Visual C++ inline assembly

lea eax, FS:[0]

为什么eax变为零?

如何获取FS:[0]的线性地址?

推荐答案

假定FS指向Windows 线程信息块(TIB),也称为线程环境块(TEB),您可以通过读取fs:[0x18]处的32位值来获得TIB的线性地址.在Visual C ++中执行此操作的最佳方法是使用 __readfsdword 内部的:

Assuming FS points to the Windows Thread Information Block (TIB), also known as the Thread Environment Block (TEB), you get the linear address of the TIB by reading the 32-bit value at fs:[0x18]. The best way to do this in Visual C++ is to use the __readfsdword intrinsic:

TEB *teb = (TEB *) __readfsdword(0x18);

这篇关于在32位保护模式/MSVC内联汇编中获取FS:[0]的线性地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆