为什么在 64 位 Windows 上 64 位 DLL 转到 System32,而 32 位 DLL 转到 SysWoW64?
我想知道
在 64 位 Windows 系统上什么时候需要将文件放在 C:\Windows\System32
或 C:\Windows\SysWOW64
下。
我有两个 DLL,一个用于 32 位,一个用于 64 位。
从逻辑上讲,我认为应该将 32 位 DLL 放在 C:\Windows\System32 下,将 64 位 DLL 放在 C:\Windows\SysWOW64 下。
令我惊讶的是,相反! 32位DLL进入C:\Windows\SysWOW64,64位DLL进入C:\Windows\System 32。
非常令人困惑的东西。 这背后的原因是什么?
I would like to know when do we need to place a file under
C:\Windows\System32
or C:\Windows\SysWOW64
, on a 64-bits windows system.
I had two DLL's, one for 32-bit, one for 64-bit.
Logically, I thought I'd place the 32-bit DLL under C:\Windows\System32, and the 64-bit DLL under C:\Windows\SysWOW64.
To my surprise, it's the other way around! The 32-bit one goes into C:\Windows\SysWOW64, and the 64-bit DLL goes into C:\Windows\System32.
Very confusing stuff. What's the reason behind this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我相信其目的是重命名 System32,但有太多应用程序针对该路径进行了硬编码,因此删除它是不可行的。
SysWoW64 并不是为 64 位系统的 dll 设计的,它实际上类似于“Windows on Windows64”,意思是在 64 位 Windows 上运行 32 位应用程序所需的位。
这篇文章解释了一些:
如果您谈论的是安装程序,您确实不应该硬编码系统文件夹的路径。 相反,让 Windows 根据您的安装程序是否在模拟层上运行来为您处理。
I believe the intent was to rename System32, but so many applications hard-coded for that path, that it wasn't feasible to remove it.
SysWoW64 wasn't intended for the dlls of 64-bit systems, it's actually something like "Windows on Windows64", meaning the bits you need to run 32bit apps on a 64bit windows.
This article explains a bit:
If you're talking about an installer, you really should not hard-code the path to the system folder. Instead, let Windows take care of it for you based on whether or not your installer is running on the emulation layer.
我应该补充一点:你不应该把你的 dll 放入 \system32\ 无论如何! 修改你的代码,修改你的安装程序...为你的位找到一个不在 c:\windows\ 下的地方,
例如,你的安装程序将你的 dll 放入:(
注意:实际上执行此操作的方法是使用环境变量:%ProgramFiles% 或
%ProgramFiles(x86)% 查找 Program Files 的位置....您不会假设它是 c:\program files\ ....)
,然后设置注册表标记:
使用您的 dll 的代码读取注册表,然后动态链接到该位置的 dll。
以上是明智的做法。
您永远不会将您的 dll 或第三方 dll 安装到 \system32\ 或 \syswow64 中。 如果必须静态加载,请将 dll 放入 exe 目录中(可以在其中找到它们)。 如果您无法预测 exe 目录(例如,其他 exe 将调用您的 dll),您可能必须将 dll 目录放入搜索路径(如果可能的话,请避免这样做!)
system32 和 syswow64 用于 Windows 提供的文件。 ..不适用于其他任何人的文件。 人们养成把东西放在那里的坏习惯的唯一原因是它总是在搜索路径中,并且许多应用程序/模块使用静态链接。 (所以,如果你真正认真对待它,真正的罪过是静态链接——这是本机代码和托管代码中的罪过——总是总是动态链接!)
I should add: You should not be putting your dll's into \system32\ anyway! Modify your code, modify your installer... find a home for your bits that is NOT anywhere under c:\windows\
For example, your installer puts your dlls into:
(Note: The way you actually do this is to use the environment var: %ProgramFiles% or
%ProgramFiles(x86)% to find where Program Files is.... you do not assume it is c:\program files\ ....)
and then sets a registry tag :
The code that uses your dlls reads the registry, then dynamically links to the dlls in that location.
The above is the smart way to go.
You do not ever install your dlls, or third party dlls into \system32\ or \syswow64. If you have to statically load, you put your dlls in your exe dir (where they will be found). If you cannot predict the exe dir (e.g. some other exe is going to call your dll), you may have to put your dll dir into the search path (avoid this if at all poss!)
system32 and syswow64 are for Windows provided files... not for anyone elses files. The only reason folks got into the bad habit of putting stuff there is because it is always in the search path, and many apps/modules use static linking. (So, if you really get down to it, the real sin is static linking -- this is a sin in native code and managed code -- always always always dynamically link!)
遇到了同样的问题并研究了几分钟。
我被教导使用 Windows 3.1 和 DOS,还记得那些日子吗? 不久之后,我严格使用 Macintosh 计算机一段时间,然后在购买 x64 位计算机后开始回归 Windows。
这些更改背后有实际原因(有些人会说具有历史意义),这是必要的程序员继续他们的工作。
大多数更改如上所述:
Program Files
与Program Files (x86)
一开始,16/86 位文件是在“86”Intel 处理器上写入的。
System32
实际上意味着System64
(在 64 位 Windows 上)当开发人员第一次开始使用 Windows7 时,存储其他应用程序时存在一些兼容性问题。
SysWOW64
实际上意味着SysWOW32
本质上,用简单的英语来说,它的意思是“64 位计算机上的 Windows on Windows”。 每个文件夹都指示应用程序希望使用它们的 DLL 所在的位置。
以下两个链接包含您需要的所有基本信息:
MSDN 文件系统重定向器
SysWow64 解释
希望这能解决问题!
Ran into the same issue and researched this for a few minutes.
I was taught to use Windows 3.1 and DOS, remember those days? Shortly after I worked with Macintosh computers strictly for some time, then began to sway back to Windows after buying a x64-bit machine.
There are actual reasons behind these changes (some would say historical significance), that are necessary for programmers to continue their work.
Most of the changes are mentioned above:
Program Files
vsProgram Files (x86)
In the beginning the 16/86bit files were written on, '86' Intel processors.
System32
really meansSystem64
(on 64-bit Windows)When developers first started working with Windows7, there were several compatibility issues where other applications where stored.
SysWOW64
really meansSysWOW32
Essentially, in plain english, it means 'Windows on Windows within a 64-bit machine'. Each folder is indicating where the DLLs are located for applications it they wish to use them.
Here are two links with all the basic info you need:
MSDN File System Redirector
SysWow64 Explained
Hope this clears things up!
System32 是 Windows 历史上放置所有 32 位 DLL 的位置,而 System 则是放置 16 位 DLL 的位置。 当微软创建 64 位操作系统时,我认识的每个人都希望这些文件位于 System64 下,但微软认为将 64 位文件放在 System32 下更有意义。 我能找到的唯一理由是,他们希望 32 位的所有内容都可以在 64 位 Windows 上运行,而无需更改程序中的任何内容 - 只需重新编译,就可以了。 他们解决这个问题的方法是创建一个名为 Windows32 On Windows64 的 32 位 Windows 子系统,以便 32 位应用程序仍然可以运行。 因此,为 32 位子系统的 System 目录创建了缩写 SysWOW64。 Sys 是 System 的缩写,WOW64 是 Windows32OnWindows64 的缩写。
由于 Windows 16 已经与 Windows 32 分离,因此不需要 Windows 16 On Windows 64 等效项。 在 32 位子系统中,当程序要使用 system32 目录中的文件时,它们实际上是从 SysWOW64 目录中获取文件。 但这个过程是有缺陷的。
这是一个可怕的设计。 根据我的经验,为了编写 64 位应用程序,我必须做更多的更改,简单地将 System32 目录更改为读取 System64 将是一个非常小的更改,并且是预编译器指令旨在处理的更改。
System32 is where Windows historically placed all 32bit DLLs, and System was for the 16bit DLLs. When microsoft created the 64 bit OS, everyone I know of expected the files to reside under System64, but Microsoft decided it made more sense to put 64bit files under System32. The only reasoning I have been able to find, is that they wanted everything that was 32bit to work in a 64bit Windows w/o having to change anything in the programs -- just recompile, and it's done. The way they solved this, so that 32bit applications could still run, was to create a 32bit windows subsystem called Windows32 On Windows64. As such, the acronym SysWOW64 was created for the System directory of the 32bit subsystem. The Sys is short for System, and WOW64 is short for Windows32OnWindows64.
Since windows 16 is already segregated from Windows 32, there was no need for a Windows 16 On Windows 64 equivalence. Within the 32bit subsystem, when a program goes to use files from the system32 directory, they actually get the files from the SysWOW64 directory. But the process is flawed.
It's a horrible design. And in my experience, I had to do a lot more changes for writing 64bit applications, that simply changing the System32 directory to read System64 would have been a very small change, and one that pre-compiler directives are intended to handle.
其他人已经很好地解释了这个可笑的难题……我认为克里斯霍夫曼在这里做得更好:https://www.howtogeek.com/326509/whats-the-difference- Between-the-system32-and -syswow64-folders-in-windows/
我的两个想法:
我们在生活中都会犯愚蠢的短视错误。 当微软将他们的(当时的)Win32 DLL 目录命名为“System32”时,这在当时是有意义的……他们只是没有考虑到如果/当使用 64 位(或 128 位)版本时会发生什么他们的操作系统是后来开发的 - 这样的目录名称会导致巨大的向后兼容性问题。 事后看来总是20-20,所以我不能因为这样的错误而责怪他们(太多)。 ...然而...当微软后来开发了他们的 64 位操作系统时,即使有事后诸葛亮的好处,为什么哦为什么他们不仅会再次犯同样的短视错误,而且有目的地让事情变得更糟这是一个误导性的名字吗?!? 他们真丢人!!! 为什么不至少将目录命名为“SysWin32OnWin64”以避免混淆?!? 当他们最终生产出 128 位操作系统时会发生什么……那么他们要把他们的 32 位、64 位和 128 位 DLL 放在哪里?!?
对我来说,所有这些逻辑似乎仍然完全有缺陷。 在 32 位版本的 Windows 上,System32 包含 32 位 DLL; 在 64 位版本的 Windows 上,System32 包含 64 位 DLL ...这样开发人员就不必更改代码,对吗? 这种逻辑的问题在于,那些开发人员现在要么正在制作需要 64 位 DLL 的 64 位应用程序,要么正在制作需要 32 位 DLL 的 32 位应用程序……无论哪种方式,他们不是仍然被搞砸了吗? 我的意思是,如果他们仍在制作 32 位应用程序,现在要在 64 位 Windows 上运行,他们现在需要更改代码以查找/引用他们所使用的相同 ol' 32 位 DLL以前使用过(现在位于 SysWOW64 中)。 或者,如果他们正在开发 64 位应用程序,那么他们将需要为新操作系统重新编写旧应用程序......因此无论如何都需要重新编译/重建!!!< /p>
微软有时会伤害我。
Other folks have already done a good job of explaining this ridiculus conundrum ... and I think Chris Hoffman did an even better job here: https://www.howtogeek.com/326509/whats-the-difference-between-the-system32-and-syswow64-folders-in-windows/
My two thoughts:
We all make stupid short-sighted mistakes in life. When Microsoft named their (at the time) Win32 DLL directory "System32", it made sense at the time ... they just didn't take into consideration what would happen if/when a 64-bit (or 128-bit) version of their OS got developed later - and the massive backward compatibility issue such a directory name would cause. Hindsight is always 20-20, so I can't really blame them (too much) for such a mistake. ...HOWEVER... When Microsoft did later develop their 64-bit operating system, even with the benefit of hindsight, why oh why would they make not only the exact same short-sighted mistake AGAIN but make it even worse by PURPOSEFULLY giving it such a misleading name?!? Shame on them!!! Why not AT LEAST actually name the directory "SysWin32OnWin64" to avoid confusion?!? And what happens when they eventually produce a 128-bit OS ... then where are they going to put their 32-bit, 64-bit, and 128-bit DLLs?!?
All of this logic still seems completely flawed to me. On 32-bit versions of Windows, System32 contains 32-bit DLLs; on 64-bit versions of Windows, System32 contains 64-bit DLLs ... so that developers wouldn't have to make code changes, correct? The problem with this logic is that those developers are either now making 64-bit apps needing 64-bit DLLs or they're making 32-bit apps needing 32-bit DLLs ... either way, aren't they still screwed? I mean, if they're still making a 32-bit app, for it to now run on a 64-bit Windows, they'll now need to make a code change to find/reference the same ol' 32-bit DLL they used before (now located in SysWOW64). Or, if they're working on a 64-bit app, they're going to need to re-write their old app for the new OS anyway ... so a recompile/rebuild was going to be needed anyway!!!
Microsoft just hurts me sometimes.