如何创建二进制补丁?
为二进制文件制作补丁的最佳方法是什么?
我希望用户能够简单地应用它(一个简单的补丁
应用程序就很好了)。在文件上运行 diff 只会给出二进制文件 [...] 不同
。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
为二进制文件制作补丁的最佳方法是什么?
我希望用户能够简单地应用它(一个简单的补丁
应用程序就很好了)。在文件上运行 diff 只会给出二进制文件 [...] 不同
。
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(9)
查看
bsdiff
和bspatch
(网站, 手册页,论文,GitHub 分支 >)。要安装此工具:
PATH
中找到bzip2.exe
的副本;从“二进制文件”链接此处下载该文件。bsdiff
。bsdiff
。Check out
bsdiff
andbspatch
(website, manpage, paper, GitHub fork).To install this tool:
bzip2.exe
inPATH
; download that from the "Binaries" link here.bsdiff
.bsdiff
.Google Chrome 团队开发的 Courgette 看起来是最高效的工具用于二进制修补可执行文件。
引用他们的数据:
这里是 构建说明。这是 2018 年的 Windows 二进制文件,由 梅赫达德。
Courgette, by the Google Chrome team, looks like most efficient tool for binary patching executables.
To quote their data:
Here are instructions to build it. Here is a Windows binary from 2018 courtesy of Mehrdad.
xdelta(网站,GitHub)是另一种选择。它似乎是最近的,但除此之外我不知道它与 bsdiff 等其他工具相比如何。
用法:
xdelta -e -s old_file new_file delta_file
xdelta -d -s old_file delta_file demod_new_file
安装:
choco install xdelta3
brew install xdelta
xdelta
或xdelta3
形式提供。xdelta (website, GitHub) is another option. It seems to be more recent, but otherwise I have no idea how it compares to other tools like bsdiff.
Usage:
xdelta -e -s old_file new_file delta_file
xdelta -d -s old_file delta_file decoded_new_file
Installation:
choco install xdelta3
brew install xdelta
xdelta
orxdelta3
in your package manager.对于小而简单的补丁,最简单的方法是使用 -a (或 --text)选项告诉 diff 将文件视为文本。据我了解,更复杂的二进制差异仅对减少补丁的大小有用。
如果文件大小相同且补丁仅修改几个字节,则可以使用 xxd,它通常随操作系统一起安装。以下将每个文件转换为每行一个字节的十六进制表示形式,然后比较文件以创建紧凑补丁,然后应用该补丁。
对于支持进程替换的 shell(例如 bash 和 zsh),有一个更简单的方法可用:
这里 comm -13 删除仅出现在第一个输入中的行以及出现在两个输入中的行,只留下专用于第一个输入的行。第二个输入。
For small, simple patches, it's easiest just to tell diff to treat the files as text with the -a (or --text) option. As far as I understand, more complicated binary diffs are only useful for reducing the size of patches.
If the files are the same size and the patch just modifies a few bytes, you can use xxd, which is commonly installed with the OS. The following converts each file to a hex representation with one byte per line, then diffs the files to create a compact patch, then applies the patch.
For shells that support process substitution such as bash and zsh, there is a simpler method available:
Here the comm -13 removes lines that appear only in the first input as well as lines that appear in both inputs, leaving only the lines exclusive to the second input.
现代端口:对于 bsdiff/bspatch 非常有用的 .NET 端口:
https://github.com/ LogosBible/bsdiff.net
我个人的选择。
我测试了一下,它是所有链接中唯一的一个。开箱即用,我能够编译它(使用 Visual Studio,例如 Visual Studio 2013 )。 (其他地方的 C++ 源代码有点过时,至少需要一点改进,并且只有 32 位,它设置了实际内存(差异源大小)限制。这是此 C++ 代码 bsdiff 的端口,甚至测试补丁结果是否相同到原始代码。)
进一步的想法:使用 .NET 4.5,您甚至可以摆脱 #Zip 库,它是这里的依赖项。
我没有测量它是否比 C++ 代码稍慢,但它对我来说工作得很好(bsdiff:1-2 分钟内 90 MB 文件),对我来说时间关键的只是 bspatch,而不是 bsdiff。
我不太确定是否使用了 x64 机器的整个内存,但我假设是这样。支持 x64 的构建(“任何 CPU”)至少可以工作。我尝试使用 100 MB 的文件。
-
此外:如果您的主要目标是可执行文件,引用的 Google 项目“Courgette”可能是最佳选择。但构建它是一项工作(至少对于 Windows 测量而言),并且对于二进制文件,它也使用纯 bsdiff/bspatch,据我所理解的文档。
Modern port: Very useful .NET port for bsdiff/bspatch:
https://github.com/LogosBible/bsdiff.net
My personal choice.
I tested it, and it was the only one of all links. Out of the box I was able to compile it (with Visual Studio, e.g., Visual Studio 2013). (The C++ source elsewhere is a bit outdated and needs at least a bit polishing and is only 32 bit which sets real memory (diff source size) limits. This is a port of this C++ code bsdiff and even tests if the patch results are identical to original code.)
Further idea: With .NET 4.5 you could even get rid of the #Zip library, which is a dependency here.
I haven't measured if it is slightly slower than the C++ code, but it worked fine for me, (bsdiff: 90 MB file in 1-2 minutes), and time-critical for me is only the bspatch, not the bsdiff.
I am not really sure, if the whole memory of a x64 machine is used, but I assume it. The x64 capable build ("Any CPU") works at least. I tried with a 100 MB file.
-
Besides: The cited Google project 'Courgette' may be the best choice if your main target are executable files. But it is work to build it (for Windows measures, at least), and for binary files it is also using pure bsdiff/bspatch, as far as I have understood the documentation.
diff 和 git-diff 可以通过使用
-a
将二进制文件视为文本来处理它们。通过
git-diff
,您还可以使用--binary
生成二进制文件的 ASCII 编码,例如适合粘贴到电子邮件中。diff and git-diff can handle binary files by treating them as text with
-a
.With
git-diff
you can also use--binary
which produces ASCII encodings of binary files, suitable for pasting into an email for example.HDiffPatch 可以在 Windows、macOS、Linux 和 Android 上运行。
它支持二进制文件或目录之间的差异;
创建补丁:
hdiffz [-m|-s-64] [-c-lzma2] old_path new_path out_delta_file
应用补丁:
hpatchz old_path delta_file out_new_path
安装:
从最新版本下载,或者下载源代码&
制作
;Jojos Binary Diff 是另一种很好的二进制 diff 算法;
HDiffPatch can run on Windows, macOS, Linux, and Android.
It supports diffs between binary files or directories;
Creating a patch:
hdiffz [-m|-s-64] [-c-lzma2] old_path new_path out_delta_file
Applying a patch:
hpatchz old_path delta_file out_new_path
Install:
Download from last release, or download the source code &
make
;Jojos Binary Diff is another good binary diff algorithm;
https://github.com/reproteq/DiffPatchWpf
差异补丁Wpf
DiffPatchWpf 简单的二进制补丁制作工具。
比较两个二进制文件并将它们之间的差异保存在新文件 patch.txt 中,
快速轻松地将补丁应用到另一个二进制文件中。
现在,您可以快速轻松地应用另一个二进制文件中的差异。
示例:
1- 加载文件 Aori.bin
2- 加载文件 Amod.bin
3- 比较并保存 Aori-patch.txt
4- 加载文件 Bori.bin
5- 加载补丁 Aori-patch.txt
6- 应用补丁并保存文件 Bori -patched.bin
alt 标签
https://youtu.be/EpyuF4t5MWk
Microsoft Visual Studio Community 2019
版本 16.7.7
.NETFramework,版本=v4.7.2
在 Windows 10x64 位中测试
https://github.com/reproteq/DiffPatchWpf
DiffPatchWpf
DiffPatchWpf simple binary patch maker tool.
Compare two binary files and save the differences between them in new file patch.txt
Apply the patch in another binary fast and easy.
Now you can apply the differences in another binary quickly and easily.
example:
1- Load file Aori.bin
2- Load file Amod.bin
3- Compare and save Aori-patch.txt
4- Load file Bori.bin
5- Load patch Aori-patch.txt
6- Apply patch and save file Bori-patched.bin
alt tag
https://youtu.be/EpyuF4t5MWk
Microsoft Visual Studio Community 2019
Versión 16.7.7
.NETFramework,Version=v4.7.2
Tested in windows 10x64bits
假设您知道文件的结构,您可以使用 C / C++ 程序逐字节修改它:
http://msdn.microsoft.com/en-us/library/c565h7xx(VS.71).aspx
只需读入旧文件,然后写出新文件一个按照你喜欢的方式修改。
不要忘记在文件中包含文件格式版本号,以便您知道如何读取文件格式的任何给定版本。
Assuming you know the structure of the file you could use a C / C++ program to modify it byte by byte:
http://msdn.microsoft.com/en-us/library/c565h7xx(VS.71).aspx
Just read in the old file, and write out a new one modified as you like.
Don't forget to include a file format version number in the file so you know how to read any given version of the file format.