19.2 Win10遭遇"应用程序的并行配置不正确"
http://scz.617.cn:8/windows/202111171024.txt
Q:
从VS 2019/Win10 SDK中复制如下文件到A机
C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\
signtool.exe
signtool.exe.manifest
A机未装VS 2019/Win10 SDK,在A机执行
Z:\Green\signtool\signtool.exe
报错
The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.
中文报错
应用程序无法启动,因为应用程序的并行配置不正确。有关详细信息,请参阅应用程序事件日志,或使用命令行 sxstrace.exe 工具。Process Monitor可以解决这类依赖库问题,此处略过。
A: scz@nsfocus 2021-11-17 10:24
这个报错太缺德,实际原因是signtool.exe的依赖库未就位,但这里面有很多微妙之处,下面一一解释。
有些解决方案忽悠你安装
Microsoft Visual C++ 20xx Redistributable Package
这就是为拍死苍蝇而引爆核弹。
就原始问题而言,在A机删除或重命名signtool.exe.manifest,一般signtool.exe就可以正常使用了。之所以碰上依赖库问题,正是.manifest文件引起的。.manifest文件本来是为了缓解"DLL地狱"现象而出场的技术,但有时候会坑你,比如原始问题所处场景。
signtool.exe.manifest内容如下
其中<dependency>指明依赖库。若signtool.exe.manifest存在,启动signtool.exe时不是简单的PE依赖关系,最终需要源自VS 2019/Win10 SDK的这些文件就位
PE就位还在其次,system32下可能就有,只是版本不同。但那几个.manifest是一定要就位的。.manifest技术是成熟技术,不科普,要点是,一旦主PE动用.manifest,依赖库也得动用.manifest,此时对依赖库的版本检查非常严格,mssign32.dll、wintrust.dll就不能用system32下的了。
删掉signtool.exe.manifest,signtool.exe可以直接用system32下的mssign32.dll、wintrust.dll。
下次碰上前述缺德的报错,直接找.manifest,看其中的<dependency>。若删除.manifest不能解决问题,就根据.manifest复制依赖库的.manifest,仍不能解决时继续复制依赖库本身。动用.manifest的情况下,用CFF Explorer之类的PE工具查看依赖库意义不大,甚至会误导。
主PE有可能在资源中内嵌.manifest,而不是单独的.manifest文件,此时无法删除.manifest,只好老老实实找匹配的依赖库及其.manifest。
A: scz@nsfocus 2021-11-17 11:55
前述报错提示中提到"event log"和sxstrace.exe,在此一并解释。先说事件查看器
eventvwr.msc
Windows Logs
Application
Error SideBySide
打开具体的Error,直白地告诉你,根据.manifest,哪个依赖库未就位。事件查看器提供的诊断信息可比前述报错强多了。
再简单介绍sxstrace.exe的使用方式。
在管理员级cmd中执行
$ SxsTrace Trace -logfile:signtool.etl
Tracing started. Trace will be saved to file signtool.etl.
Press Enter to stop tracing...
在普通cmd中执行
$ Z:\Green\signtool\signtool.exe
The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.
回到管理员级cmd中回车,停止跟踪,执行
$ SxsTrace Parse -logfile:signtool.etl -outfile:signtool.txt
Parsing log file signtool.etl...
Parsing finished! Output saved to file signtool.txt.
查看signtool.txt
SxsTrace提供的信息有个毛用,直接查看.manifest更快。这种看似专业的工具鸡肋得很。