WoW64 仿真层有什么作用?

发布于 2024-10-22 13:55:18 字数 155 浏览 2 评论 0原文

在此处输入图像描述

所有 WoW64 应用程序都经过 WoW64 模拟层。
我想知道这一层发生了什么。(特别是他们如何转换地址空间)

请给我一些重要的观点。

enter image description here

All WoW64 apps go through WoW64 emulation layer.
I'd like to know what happen in this layer.(especially, how they can convert address space)

Please give me some important points.

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

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

发布评论

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

评论(3

鲜肉鲜肉永远不皱 2024-10-29 13:55:18

既然您已经发布了图表,那么很明显您知道 WOW64 存在的原因。现在回答你的问题:

<块引用>

我想知道这一层发生了什么。

我想你想知道它是如何实现的。

进程启动:加载程序照常加载 64 位用户模式部分“Ntdll.dll”,但如果进程用于 32 位执行,也会加载 32 位 Ntdll.dll。现在,加载程序负责使用 Wow64.dll 进行初始化,它在 32 位 Ntdll 中设置进程和线程上下文,并“将 CPU 切换到 32 位模式”以执行。

系统调用:现在一切都在 32 位模式下运行,直到发生系统调用。我们知道系统调用要经过Ntdll.dll、User32.dll、Gdi32.dll等;在本例中为 32 位版本。这些库有一个单独的 32 位版本,位于 \Windows\Syswow64 位文件夹中。这些只是存根,它们实际上在 Wow64.dll 中调用,而不是发出“本机系统调用”。现在,Wow64.dll 可以轻松转换到 64 位模式、将参数转换为其 64 位对应项、使用 64 位版本发出系统调用、获取结果并将输出重新转换为 32 位。然后它将 CPU 转换回 32 位模式并返回输出。

异常分派、用户回调、文件系统和注册表操作以及 I/O 都以相同的方式处理,只是在某处使用钩子。阅读下面规定的书。

<块引用>

(特别是他们如何转换地址空间)。

64 位地址空间是 32 位地址空间的超集。另外,32 位/64 位中的相同指针(实际上是 PTE)不用于引用整个地址空间,但用户空间和系统空间有单独的页表。

<块引用>

请告诉我一些要点。

要了解 Windows,我能给你的最重要的一点是阅读《Windows 内部原理》——Russinovich

Since you have already posted the diagram it is clear that you know why WOW64 exists. Now to answer your question:

I'd like to know what happen in this layer.

I think you want to know how it is implemented.

Process startup: The loader loads 64-bit user-mode part 'Ntdll.dll' as usual, but also loads 32-bit Ntdll.dll in case the process is for 32-bit execution. It is now the loaders responsibility to initialize using Wow64.dll, which sets up process and thread contexts in 32-bit Ntdll and 'switches the CPU to 32-bit mode' for execution.

System Call: Everything is now running in 32-bit mode, until a system call. We know that system calls go through Ntdll.dll, User32.dll, and Gdi32.dll etc; in this case the 32-bit versions. There is a separate 32-bit version of these libraries located in \Windows\Syswow64 bit folder. These are just stubs that instead of issuing 'native system calls,' actually call in Wow64.dll. Now, it's simple for Wow64.dll to transition to 64-bit mode, convert parameters to their 64-bit counterparts, issue the system call using 64-bit versions, get the result, and reconvert the output to 32-bit. It then transitions CPU back to 32-bit mode and returns the output.

Exception dispatching, user callbacks, file system and registry operations, and I/O is handled in the same way, using hooks somewhere down the line. Read the book prescribed below.

(especially, how they can convert address space).

64-bit address space is a superset of 32-bit address space. Plus, the same pointer (actually PTE) in 32-bit/64-bit isn't used to refer to the whole address space, but there are separate page tables for user-space and for system space.

Please give me some important points.

To know windows, the most important point I can give you is to read 'Windows Internals' -- Russinovich

煮酒 2024-10-29 13:55:18

MSDN 说:

WOW64 是 x86 模拟器,允许基于 32 位 Windows 的应用程序在 64 位 Windows 上无缝运行。 WOW64 随操作系统提供,无需显式启用。

系统将 32 位应用程序与 64 位应用程序隔离,其中包括防止文件和注册表冲突。支持控制台、GUI 和服务应用程序。该系统为剪切粘贴和 COM 等场景提供跨 32/64 边界的互操作性。但是,32位进程无法加载64位DLL来执行,64位进程也无法加载32位DLL来执行。

您具体不明白什么?您是否已经阅读过有关 WoW64 子系统的维基百科文章?我想您会发现它提供了相当全面的概述。

Microsoft 在此提供了一些其他详细信息:WOW64 实施详细信息

MSDN says:

WOW64 is the x86 emulator that allows 32-bit Windows-based applications to run seamlessly on 64-bit Windows. WOW64 is provided with the operating system and does not have to be explicitly enabled.

The system isolates 32-bit applications from 64-bit applications, which includes preventing file and registry collisions. Console, GUI, and service applications are supported. The system provides interoperability across the 32/64 boundary for scenarios such as cut and paste and COM. However, 32-bit processes cannot load 64-bit DLLs for execution, and 64-bit processes cannot load 32-bit DLLs for execution.

What specifically do you not understand? Have you already read the Wikipedia article on the WoW64 subsystem? I think you'll find that it provides a fairly comprehensive overview.

And Microsoft provides some additional details here: WOW64 Implementation Details

眼泪淡了忧伤 2024-10-29 13:55:18

“特别是,他们如何转换地址空间”,

关键是要知道 AMD 和 intel x64 处理器支持并行运行 32 位和 64 位代码。这允许操作系统(运行本机 x64 时)为具有 32 位寻址的 32 位线程创建一个上下文,该上下文与 64 位线程

以类似的方式共存,当主机操作系统运行 32 位时,它可以创建 16 位线程来运行 win16 和 dos应用程序。

请注意,我不认为在 64 位操作系统中运行时它可以创建 32 位和 16 位线程 - 我猜 amd 认为这太向后兼容了:-)

"especially, how they can convert address space"

the key to that is knowing that amd and intel x64 processors have support for running 32bit and 64bit code side by side. this allows the os (when running native x64) to create a context for a 32bit thread that has 32bit addressing that coexists with the 64bit threads

in a similar way when the host os is running 32bit, it can create 16bit threads for running win16 and dos applications.

note, I don't think when running in the os 64bit that it can create 32bit AND 16bit threads - I guess amd decided that was just too much backwards compatability :-)

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