“DS:[40207A]”是什么意思?意思是在装配中?

发布于 2024-09-25 12:12:18 字数 128 浏览 1 评论 0原文

0040103A   CALL DWORD PTR DS:[40207A]                USER32.MessageBoxA

DS: 是什么意思?

0040103A   CALL DWORD PTR DS:[40207A]                USER32.MessageBoxA

What does DS: mean?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

拥抱影子 2024-10-02 12:12:18

该指令正在从内存 ds:[40207A] 加载新的 EIP 值。即地址 40207A 处有一个函数指针。 (它会推送返回地址,因为这是一个call,而不仅仅是一个jmp。)

ds: 意味着该指令正在引用数据段 - 在现代操作系统上几乎可以忽略,因为它们使用平面地址空间模型运行(代码、数据和堆栈段都引用相同的内存范围,并且内存保护是通过分页处理的)。

ds: 的作用是向您显示它绝对是一个内存操作数,并提醒您它使用哪个段/显示没有段覆盖前缀(可能除了 ds前缀,因为这已经是默认值)。

编辑:

一点详细说明 - 请注意,为了简单起见,这是在运行 Windows 的 32 位保护模式的上下文中。

段寄存器(CS、DS、SS、ES、FS、GS)保存一个指向描述符选择器。有两个描述符表:全局 (GDT) 和本地 (LDT),并且选择器有一个位指示要使用哪个。 Windows(几乎?)专门使用全局表。

描述符基本上是一个{开始地址,大小}对 - 还有更多内容,但这超出了本文的范围。

Windows 使用 平面内存模型:每个进程都有一个从内存地址 0 开始的 4GB 地址空间,并且使用分页将进程彼此隔离。

由于进程具有这种扁平的世界观,因此它们使用 {0, 4GB} 描述符与所有段一起运行 - 因此,Windows 可以仅使用一些全局描述符,并让所有进程都使用这些描述符,而不是分配每个进程描述符。

编辑2:

可移植可执行文件格式定义了部分,与x86 - 即使存在一些概念上的重叠。 PE EXE 几乎可以具有您想要的任何部分布局,但正常情况是分为(至少)代码(读/执行)、数据(读/写)、资源(只读?)。将可执行文件分割成多个部分可以将 x86 页级内存保护应用于内存范围。

编辑 3:

虽然普通段不会根据进程进行更改,但 Windows 使用 FS 寄存器来指向每个线程 TIB 结构。

编辑4:

请参阅了解概述。这是来自 80386 的旧文档,但该信息仍然适用。

The instruction is loading a new EIP value from memory at ds:[40207A]. i.e. there's a function pointer at address 40207A. (And it pushes a return address because this is a call not just a jmp.)

The ds: means the instruction is referencing memory in the Data Segment - and can pretty much be ignored on modern OSes, since they run with a flat address space model (code, data and stack segments all refer to the same memory range, and memory protection is handled with paging).

The ds: is there to show you it's definitely a memory operand, and to remind you which segment it uses / show that there were no segment override prefixes (except maybe a ds prefix because that's already the default).

EDIT:

A little elaboration - note that, to keep things simple, this is in the context of 32bit protected mode running Windows.

A segment register (CS,DS,SS,ES,FS,GS) holds a selector pointing to a descriptor. There's two descriptor tables: global (GDT) and local (LDT), and the selector has a bit indicating which to use. Windows (almost?) exclusively uses the global table.

A descriptor is basically a {beginning-address, size} pair - there's more to it, but that's outside the scope of this post.

Windows uses a Flat Memory Model: each process has a 4GB address space starting at memory address 0, and uses paging to isolate processes from eachother.

Since processes have this flat view of the world, they run with all segments using {0, 4GB} descriptors - and thus, instead of allocating per-process descriptors, Windows can use only a few global descriptors and have all processes use those.

EDIT 2:

The Portable Executable format defines sections, which are unrelated to the x86 segments - even if there's some conceptual overlap. The PE EXEs can have pretty much any section layout you wish, but the normal is to split into (at least) code (read/execute), data (read/write), resources (readonly?). Splitting the executable into sections makes it possible to apply x86 page-level memory protection to the memory ranges.

EDIT 3:

While the normal segments don't change per-process, Windows uses the FS register to point to the per-thread TIB structure.

EDIT 4:

See this for an overview. This is from an old document on the 80386, but the information still applies.

来日方长 2024-10-02 12:12:18

内存地址由段和偏移组成; DS 是“数据段”寄存器。

Memory addresses consist of a segment and an offset; DS is the "data segment" register.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文