Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create binary patches?

Tags:

patch

binary

What's the best way to go about making a patch for a binary file?

I want it to be simple for users to apply (a simple patch application would be nice). Running diff on the file just gives Binary files [...] differ.

like image 578
Mike Avatar asked Dec 22 '09 09:12

Mike


People also ask

How to patch binary file?

Patching A Binary To patch an instruction, right-click on the instruction you want to modify and go to “Patch Instruction”. From there, you will see textboxes that you can type into.

How does binary patching work?

Binary patching is the process of modifying a compiled executable to change the code that is run. Radare allows for assembly code to be written inline, compiled and inserted into the binary without any hassle.

What is file patching?

A patch file is a text file that consists of a list of differences between the original file and the modified file. It is the best and easiest way to share changes to a document with friends and colleagues, without having to send repetitive information.


2 Answers

Check out bsdiff and bspatch (website, manpage, paper, GitHub fork).

To install this tool:

  • Windows: Download and extract this package. You will also need a copy of bzip2.exe in PATH; download that from the "Binaries" link here.
  • macOS: Install Homebrew and use it to install bsdiff.
  • Linux: Use your package manager to install bsdiff.
like image 137
Heinzi Avatar answered Oct 12 '22 04:10

Heinzi


Courgette, by the Google Chrome team, looks like most efficient tool for binary patching executables.

To quote their data:

Here are the sizes for the recent 190.1 -> 190.4 update on the developer channel:

  • Full update: 10,385,920 bytes
  • bsdiff update: 704,512 bytes
  • Courgette update: 78,848 bytes

Here are instructions to build it. Here is a Windows binary from 2018 courtesy of Mehrdad.

like image 29
Maxim Kholyavkin Avatar answered Oct 12 '22 03:10

Maxim Kholyavkin