GetFileVersionInfo() 返回错误的文件版本信息

sec*_*ark 3 winapi winsxs

我有一个应用程序需要检查各种系统 EXE 和 DLL 的版本,以确定它们是否易受攻击。这是一个本机 C++ 应用程序,它在其清单中不提供任何特定的 WinSxS 链接。在 Windows 7 上,当我在绝对路径(例如“c:\windows\system32\taskeng.exe”)上调用 GetFileVersionInfo 时,我会收到“C:\Windows\winsxs\x86_microsoft-windows-taskscheduler-engine_31bf3856ad364e35_6”的版本信息。 1.7600.16385_none_e582a352202e02c8\taskeng.exe"

因此,澄清一下,Windows 资源管理器报告的版本 c:\windows\system32\taskeng.exe 是 6.1.7600.16699。GetFileVersionInfo() 报告的 c:\windows\system32\taskeng.exe 版本为 6.1.7600.16385。

如何强制我的应用程序不通过 WinSxS 重定向其文件?

bde*_*eem 5

这是一个 PowerShell 脚本来显示差异。FileVersion 是一个不同于 [FileMajorPart].[FileMinorPart].[FileBuildPart].[FilePrivatePart] 的组成的字符串。

PS C:\> [System.Diagnostics.FileVersionInfo]::GetVersionInfo("c:\windows\system32\taskeng.exe") | Format-List -property *


Comments           :
CompanyName        : Microsoft Corporation
FileBuildPart      : 7601
FileDescription    : Task Scheduler Engine
FileMajorPart      : 6
FileMinorPart      : 1
FileName           : c:\windows\system32\taskeng.exe
FilePrivatePart    : 17514
FileVersion        : 6.1.7600.16385 (win7_rtm.090713-1255)
InternalName       : TaskEng
IsDebug            : False
IsPatched          : False
IsPrivateBuild     : False
IsPreRelease       : False
IsSpecialBuild     : False
Language           : English (United States)
LegalCopyright     : © Microsoft Corporation. All rights reserved.
LegalTrademarks    :
OriginalFilename   : taskeng.exe.mui
PrivateBuild       :
ProductBuildPart   : 7601
ProductMajorPart   : 6
ProductMinorPart   : 1
ProductName        : Microsoft® Windows® Operating System
ProductPrivatePart : 17514
ProductVersion     : 6.1.7600.16385
SpecialBuild       :
Run Code Online (Sandbox Code Playgroud)