从 32 位进程打开 %SystemRoot%\system32\calc.exe 会重定向到另一个文件。哪个、为什么以及如何?
我目前正在用 C++ 编写一些测试代码,这些代码与 PE 文件混淆以了解其文件格式结构。我的项目设置为编译为 64 位。在我的代码中,我打开 %SystemRoot%\system32\calc.exe 并读取 IMAGE_DOS_HEADER 和 IMAGE_NT_HEADERS 结构。同时,我使用十六进制编辑器插件在 Notepad++ 中打开了相同的 calc.exe。我将代码读取的值与 Notepad++ 进行了比较,发现它们是不同的。我将 calc.exe 从 System32 复制到 C:\Temp\calc.exe,现在值匹配。
Notepad++ 似乎是一个 32 位应用程序(尚未检查 PE 文件,但由于它默认安装到 Program Files (x86),因此这似乎是一个安全的假设)。
这是 WinSxS 在工作吗?或者还有什么原因造成这种情况?哪个文件实际上被输入到打开 %SystemRoot%\system32\calc.exe 的 32 位应用程序?
只是好奇。预先感谢您对此的任何启发。
I'm currently writing some test code in C++ that messes around with PE files to understand its file format structure. My project is set to compile to 64 bit. In my code I open %SystemRoot%\system32\calc.exe and read the IMAGE_DOS_HEADER and IMAGE_NT_HEADERS structures. At the same time I have the same calc.exe opened in Notepad++ with the hex editor plugin. I compared the values my code reads with Notepad++ and noticed they were different. I copied calc.exe from System32 to C:\Temp\calc.exe, and now the values match.
Notepad++ seems to be a 32 bit application (haven't checked the PE file, but since it's installed to Program Files (x86) by default, it seems to be a safe assumption to make).
Is this WinSxS at work? Or what else is causing this? And which file is actually fed to 32-bit applications opening %SystemRoot%\system32\calc.exe?
Just curious. Thanks in advance for any light shed on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,这就是 WOW 重定向器。您会看到 C:\Windows\SysWOW64 中也有一个 calc.exe。这是使用 %SystemRoot%\System32\calc.exe 路径时打开的文件。
可以通过 Wow64DisableWow64FsRedirection
更多详情请参见文件系统重定向
Yes, this is the WOW redirector. You'll see that there is a calc.exe in C:\Windows\SysWOW64 as well. That's the file that is opened when you use the %SystemRoot%\System32\calc.exe path.
This can be temporarily disabled to access the 64-bit version of the file with Wow64DisableWow64FsRedirection
More details can be found at File System Redirector
禁用 WowFs 重定向是不必要的,有时甚至不是一个选项(例如,当您尝试使用 Notepad++ 打开 system32 目录中的文件时)。您可以使用虚拟目录%windir%\Sysnative 代替%windir%\System32(您不会在资源管理器中看到它,但您可以在地址栏中键入它)
WOW64 由三个DLL 实现:wow64.dll、wow64cpu。 dll 和 wow64win.dll(和 32 位 NTDLL)。重定向(除其他外)在 wow64.dll 中实现,CPU 模拟/帮助例程在 wow64cpu.dll 中实现,wow64win.dll 包含对 win32k.sys(负责 Windows GUI 的内核模式驱动程序)的 thunk。
Disabling WowFs redirection is unnecessary and sometimes is not even an option (for instance, when you are attempting to get Notepad++ to open files in the system32 directory). You can use the virtual directory %windir%\Sysnative instead of %windir%\System32 (you will not see it in explorer, but you can type it in the address bar)
WOW64 is implemented in three DLLs: wow64.dll, wow64cpu.dll, and wow64win.dll (and 32-bit NTDLL). Redirection (among other things) is implemented in wow64.dll, CPU emulation / helper routines in wow64cpu.dll, and wow64win.dll contains thunks to win32k.sys (the kernel mode driver responsible for the windows GUI).
如果我没记错的话,当 32 位应用程序尝试打开 system32 目录时,它会自动重定向到 syswow64 目录。
If I remember well, when a 32bit apps tries to open system32 directory, it's automatically redirected to syswow64 dir.