windows WoW64仿真层有什么作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5325750/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does WoW64 emulation layer do?
提问by Benjamin
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)
所有 WoW64 应用程序都经过 WoW64 仿真层。
我想知道这一层发生了什么。(特别是,他们如何转换地址空间)
Please give me some important points.
请给我一些重要的观点。
回答by zamanbakshi
Since you have already posted the diagram it is clear that you know why WOW64 exists. Now to answer your question:
由于您已经发布了图表,很明显您知道 WOW64 存在的原因。现在回答你的问题:
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.
进程启动:加载器像往常一样加载 64 位用户模式部分“Ntdll.dll”,但也会加载 32 位 Ntdll.dll,以防进程用于 32 位执行。现在加载程序负责使用 Wow64.dll 进行初始化,它在 32 位 Ntdll 中设置进程和线程上下文并“将 CPU 切换到 32 位模式”以执行。
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.
系统调用:现在一切都在 32 位模式下运行,直到系统调用。我们知道系统调用通过Ntdll.dll、User32.dll、Gdi32.dll等;在这种情况下是 32 位版本。这些库的单独 32 位版本位于 \Windows\Syswow64 位文件夹中。这些只是存根,而不是发出“本机系统调用”,实际上是在 Wow64.dll 中调用。现在,Wow64.dll 很容易转换到 64 位模式,将参数转换为 64 位对应的参数,使用 64 位版本发出系统调用,获得结果,并将输出重新转换为 32 位。然后它将 CPU 转换回 32 位模式并返回输出。
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.
异常分派、用户回调、文件系统和注册表操作以及 I/O 以相同的方式处理,在某处使用钩子。阅读下面规定的书。
(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.
64 位地址空间是 32 位地址空间的超集。另外,32 位/64 位中的相同指针(实际上是 PTE)不用于指整个地址空间,但用户空间和系统空间有单独的页表。
Please give me some important points.
请给我一些重要的观点。
To know windows, the most important point I can give you is to read 'Windows Internals' -- Russinovich
要了解 Windows,我能给你的最重要的一点是阅读“Windows Internals”——Russinovich
回答by Cody Gray
MSDNsays:
MSDN说:
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.
WOW64 是 x86 模拟器,它允许基于 32 位 Windows 的应用程序在 64 位 Windows 上无缝运行。WOW64 随操作系统一起提供,不必显式启用。
该系统将 32 位应用程序与 64 位应用程序隔离开来,这包括防止文件和注册表冲突。支持控制台、GUI 和服务应用程序。该系统为剪切和粘贴和 COM 等场景提供跨越 32/64 边界的互操作性。但是,32 位进程无法加载 64 位 DLL 进行执行,64 位进程无法加载 32 位 DLL 进行执行。
What specificallydo you not understand? Have you already read the Wikipedia articleon the WoW64 subsystem? I think you'll find that it provides a fairly comprehensive overview.
什么具体难道你不明白吗?您是否已经阅读了有关 WoW64 子系统的维基百科文章?我想您会发现它提供了相当全面的概述。
And Microsoft provides some additional details here: WOW64 Implementation Details
微软在这里提供了一些额外的细节:WOW64 Implementation Details
回答by SteelBytes
"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
关键是要知道 amd 和 intel x64 处理器支持并行运行 32 位和 64 位代码。这允许操作系统(运行本机 x64 时)为 32 位线程创建上下文,该线程具有与 64 位线程共存的 32 位寻址
in a similar way when the host os is running 32bit, it can create 16bit threads for running win16 and dos applications.
以类似的方式,当主机操作系统运行 32 位时,它可以创建 16 位线程来运行 win16 和 dos 应用程序。
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 :-)
请注意,我不认为在 64 位操作系统中运行时它可以创建 32 位和 16 位线程-我猜 amd 认为向后兼容性太强了 :-)