[译]UnPatcher:用于修补文件的COM对象
By robot-v1.0
本文链接 https://www.kyfws.com/applications/unpatcher-a-com-object-for-patching-files-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 4 分钟阅读 - 1660 个词 阅读量 0[译]UnPatcher:用于修补文件的COM对象
原文地址:https://www.codeproject.com/Articles/597/UnPatcher-a-COM-object-for-patching-files
原文作者:Alessandro Vergani
译文由本站 robot-v1.0 翻译
前言
An article on patching files.
有关修补文件的文章.
介绍(Introduction)
最近,我面对一个我认为在开发人员中很常见的问题:(Recently I faced myself with a problem that I think is very common among developers:)修补软件版本(patching asoftware release).(.)
有许多工具可以做到这一点,甚至是免费软件,但我想要类似于著名软件LiveUpdate的工具.(There are many tools for doing this, even freeware, but I wanted something similar to the LiveUpdateof a well-known software.)
由于我发现的所有补丁软件都不是免费的,因此我开始编写补丁算法时没有取得好的结果:它生成的补丁文件几乎与原始文件大小相同.(Since all patching software I found is not free-source, I started writing my patch algorithm withoutgood results: the patch file it generated is almost the same size of the original file.)
我开始四处寻求帮助,但没有一个能让我摆脱困境.然后一个帮助到达了:(I started asking around for help, but none can get me out of trouble. Then an help arrived:)布莱克`米勒(Blake Miller)告诉我查看Platform SDK.我查看了一下,发现了一个非常没有文档记录的用于创建和应用补丁的API集.(told me to look in the Platform SDK. I looked and I found a very-not documentedset of APIs for creating and applying patches.)
问题与解决方案(The problems and the solutions)
API的唯一文档在名为的文件中(The only documentation to the APIs is in a file called)补丁程序(PatchApi.h).这套功能不是很复杂,所以我毫无疑问地理解了每个功能的作用(除了标志,如果有人知道更多内容,请告诉我).(. This set of function isn’tvery complex so I understand without problems what each function does (apart from the flags, if someoneknow something more, please tell me).)
问题在于,仅存在用于修补程序创建例程的导入库((The problem is that there is an import library only for the patch creation routines() CreatePatch
和(and) CreatePatchEx
),而不是补丁应用功能.因此,我尝试创建一个未成功的函数.() and not for patch applying functions.So I tried creating one without success.)
我发现的唯一解决方案是动态加载实现API的DLL.这还不错:您可以在没有修补程序创建DLL的情况下交付修补程序.(The only solution I found was to dynamically load the DLLs implementig the API. This is not so bad:you can ship the patch program without the patch creation DLL.)
您可能已经注意到我写了DLL(复数).的确是这样:此API实现了两个DLL:(You may have noted that I wrote DLLs (plural). This is true: there are two DLLs implementig this API:) mspatchc.dll
(创建)和((creation) and) mspatcha.dll
(应用).((apply).)我没有在压缩文件中包含这些DLL(I’ve not included theseDLLs in the zips)(我不知道是否可以重新分配它们).您可以在Platform SDK中找到创建dll,而apply dll随MSIE 5.01一起提供(也许与其他MS产品一起使用,我在MSDN上查找时,仅发现IE带有此文件).((I don’t know if I can redistribute them). You can find the creation dll in thePlatform SDK and the apply dll comes with MSIE 5.01 (maybe with other MS products, I looked on MSDNand found only IE carrying this).)
最后一步(The last step)
我终于使它工作了,所以我写了一个实现补丁逻辑的简单COM dll.对象非常简单:它具有3个属性,4个方法和1个事件.(I finally got it working so I wrote a simple COM dll implementing the logic of patching.The object is very simple: it has 3 properties, 4 methods and 1 event.)
物产(Properties)
SourceFile
:旧文件名或要修补的文件.(: The old file name or the file to patch.)DestinationFile
:要生成的新文件名或修补文件.(: The new file name or the patched file to generate.)PatchFile
:是要创建或应用的补丁文件名.(: Is the patch file name to be created or applyed.)
方法(Methods)
CreatePatch
:创建补丁文件.(: Creates the patch file.)TestPatch
:测试补丁文件(: Tests the patch file)ApplyPatch
:应用补丁文件(: Applies the patch file)GetFileSignature
:返回唯一的(?)文件签名(: Returns a unique (?) file signature)
大事记(Events)
OnProgress
:在处理期间调用.(: Called during processing.)
最后的笔记(Final notes)
它可以根据UNICODE进行编译,但尚未经过良好测试.(It compiles under UNICODE, but it’s not well tested.)
包含的演示是用Visual Basic编写的.要使其正常工作,您首先需要通过执行以下操作来注册UnPatcher DLL:(The included demo is written in Visual Basic. To get it to work, you first need to register theUnPatcher DLL by doing:)
regsvr32 UnPatcher.dll
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
VB6 C++ VB VC6 Windows Visual-Studio Dev 新闻 翻译