小软件补丁如何修复大软件?
我一直想知道的一件事是软件补丁是如何工作的。 许多软件似乎只是在需要安装在旧版本上的二进制文件上发布新版本,但某些软件(特别是 Windows 等操作系统)似乎能够发布非常小的补丁来纠正错误或向现有版本添加功能软件。
大多数时候,我看到的补丁不可能替换整个应用程序,甚至无法替换应用程序中使用的小文件。 对我来说,实际的二进制文件似乎正在被修改。
这些类型的补丁实际上是如何实施的? 谁能向我指出任何解释其工作原理的资源,或者它是否只是像替换应用程序中的链接库等小组件一样简单?
我可能永远不需要以这种方式进行部署,但我很好奇它是如何工作的。 如果我的理解是正确的,即补丁实际上只能修改二进制文件的一部分,那么这可以在 .NET 中实现吗? 如果是的话,我想学习它,因为这是我最熟悉的框架,我想了解它是如何工作的。
One thing I've always wondered about is how software patches work. A lot of software seems to just release new versions on their binaries that need to be installed over older versions, but some software (operating systems like Windows in particular) seem to be able to release very small patches that correct bugs or add functionality to existing software.
Most of the time the patches I see can't possibly replace entire applications, or even small files that are used within applications. To me it seems like the actual binary is being modified.
How are these kinds of patches actually implemented? Could anyone point me to any resources that explain how this works, or is it just as simple as replacing small components such as linked libraries in an application?
I'll probably never need to do a deployment in this manner, but I am curious to find out how it works. If I'm correct in my understanding that patches can really modify only portions of binary files, is this possible to do in .NET? If it is I'd like to learn it since that's the framework I'm most familiar with and I'd like to understand how it works.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这通常是使用二进制差异算法来实现的——将最近发布的版本与新代码进行差异。 如果用户运行的是最新版本,您只需应用差异。 对于软件特别有效,因为版本之间编译的代码通常非常相似。 当然,如果用户没有运行最新版本,您无论如何都必须下载整个内容。
通用二进制差异算法有几种实现:bsdiff 和 xdelta 是很好的开源实现。 我找不到 .NET 的任何实现,但由于所讨论的算法与平台无关,如果您喜欢一个项目,那么移植它们应该不会太困难。
This is usually implemented using binary diff algorithms -- diff the most recently released version against the new code. If the user's running the most recent version, you only need to apply the diff. Works particularly well against software, because compiled code is usually pretty similar between versions. Of course, if the user's not running the most recent version you'll have to download the whole thing anyway.
There are a couple implementations of generic binary diff algorithms: bsdiff and xdelta are good open-source implementations. I can't find any implementations for .NET, but since the algorithms in question are pretty platform-agnostic it shouldn't be too difficult to port them if you feel like a project.
如果您正在谈论修补 Windows 应用程序,那么您想要查看的是 .MSP 文件。 它们与 .MSI 类似,但只是补丁和应用程序。
请查看修补和升级 MSDN 文档。
.MSP 文件的作用是将更新的文件加载到应用程序安装中。 这通常是更新的 dll 和资源文件,但可以包括任何文件。
除了修补已安装的应用程序之外,位于 C:\WINDOWS\Installer 中的修复文件也会更新。 然后,如果用户从“添加/删除程序”中选择“修复”,也会使用更新的补丁文件。
我认为 John Millikin 讨论的二进制 diff 方法必须在其他操作系统中使用。 虽然你可以让它在 Windows 中工作,但它会有点陌生。
If you are talking about patching windows applications then what you want to look at are .MSP files. These are similar to an .MSI but just patch and application.
Take a look at Patching and Upgrading in the MSDN documents.
What an .MSP files does is load updated files to an application install. This typically is updated dll's and resource files, but could include any file.
In addition to patching the installed application, the repair files located in C:\WINDOWS\Installer are updated as well. Then if the user selects "Repair" from Add / Remove programs the updated patch files are used as well.
I'm thinking that the binary diff method discussed by John Millikin must be used in other operating systems. Although you could make it work in windows it would be somewhat alien.