警告用户未签名的可执行文件
我有一个充当存根角色的 ClickOnce 应用程序 - 它是一个小型应用程序,只需下载另一个安装程序。它的工作方式是下载有效负载,运行它并关闭。它是用 C# .NET 编写的。我的问题是有效负载是动态的。如果应用程序下载的有效负载未签名,我希望我的 ClickOnce 应用程序向用户显示警告。当启用 UAC 时,此行为会自动出现,但是我的存根在许多不同的操作系统上运行,并且我不知道 UAC 是否已启用。如果我可以简单地调用 Windows 在运行可执行文件时发出的警告,我会很高兴 - 这可能吗?如果没有,你有什么推荐?
I have a ClickOnce application that plays the role of a stub - it's a small application that simply downloads another installer. The way it works is that it downloads the payload, runs it and closes. It's written in C# .NET. My problem is the payload is dynamic. I want my ClickOnce application to display a warning to the user if the payload that the application downloaded is not signed. This behavior is automatically present when UAC is enabled, however my stub is run on many different OS's and I don't know if UAC is enabled or not. I would love it if I could simply invoke the warning that Windows does when an executable is run - is this possible? If not, what do you recommend?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您正在谈论运行从网站下载的程序时显示的警告。
您需要将
Zone.Identifier
备用数据流添加到文件中。您可以使用此库来做到这一点:
I assume that you're talking about the warning shown when running a program downloaded from a website.
You need to add a
Zone.Identifier
Alternate Data Stream to the file.You can do that using this library:
在Win32中,用于验证Authenticode签名的函数是
WinVerifyTrust
。没有 .NET BCL 等效项(据我所知),但 pinvoke.net 有一篇关于如何从 C# 使用它的非常好的文章:http://www.pinvoke.net/default.aspx/wintrust.winverifytrust
In Win32, the function used to verify Authenticode signatures is
WinVerifyTrust
. There is no .NET BCL equivalent (as far as I know), but pinvoke.net has a pretty good article on how to use it from C#:http://www.pinvoke.net/default.aspx/wintrust.winverifytrust