BitPatch

A tool to edit bytes at specific offsets.

BitPatch.zip, Version 1.1, Size: 41,012 bytes.
CRC32/MD5 codes: 1908D7F3/0D5EB049BAD0BB3432A6350BCD7AF098.
This is tested and known to work on all 32-bit versions of Windows.
Operation in Win64, and Wine under Linux, has not been tested, but it may work.

Editing a single bit or byte, or precise sequence of them at an exact location, is usually done by a hex editor. This works until you need to do it to a large number of files, especially LARGE files, when there may only be a few bytes in a header that must be changed. There are many other uses of a bit-patcher based on a readable text file that formats the details of patching, but this tool emphasises making it easy to read the patch data file's contents, and applying the results exactly as intended very quickly when making hundreds of small adjustments to enormous amounts of data. Automation is critical. It can eliminate the risk of error.

BitPatch also emphasises testing that a patch holds data that IS in the file(s) to be patched, exactly where specified, before changing it. This is not on a per-edit basis, it will report all differences by default, and only change a file is ALL edits match existing data. This can be extremely helpful to prevent harm to the wrong file, or version of a file. It's much more rigorous than testing by filename! If the data does not match, but the patch otherwise appears to be valid, the choice of forcing the patch is offered. This can even be automated, but don't. Just don't..

   

   

   

   

The first four images show the default print if no arguments are given, and the help text. The patch format details are not just an explanation, they are a working example, or would be if there was an appropriate file to be patched by it.

The images do not show the file comparison when BitPatch is used the way the command FC /B is used, but the main difference is that consecutive changed bytes will be grouped together, which is a rapid head start compared to FC /B if you're creating a patch file based on differences between two existing code or data files.

Another rapid head start could be this BitPatch example, which is an animated cursor of a spinning dice, black with glowing red dots. (Right-click the dice file, view it with the 'properties' dialog...) After applying the patch in that ZIP file, the dots will cycle through the primary and secondary colours as it spins.

Grouping patch bytes into a single edit helps to organise consecutive bytes for clarity and completeness. For example, if editing the palette of an icon or small bitmap, it is wise to include the whole palette even if few of its bytes will be edited. This makes it much easier to locate what you need to change. Editing text strings in a pre-compiled executable or library file is made much easier in BitPatch than it would be in a hex editor.

One of the most useful ways to use BitPatch is to distribute changed files when commercial or legal restrictions prevent this, but where it is lawful to do it to your own copy of a file, if you do not distribute it yourself. A whole customised operating system can be built this way, by listing files for other people to collect like a big Easter egg hunt, then when they have the right versions of each file, a script can automate the patching of all of them in a fraction of a second to complete the customisation. The script is yours, so you can distribute that, and BitPatch.

   

The fifth image shows a patch being done, then reversed. Then, after tweaking a single byte in the patch file so it can't match the main file's data, a second try shows what happens, and then it shows the result of forcing when the suggestion is made to do so. Several error conditions are handled by the program, most of them resulting in dull red text and an immediate exit, and examining what they say will usually lead to a quick solving of whatever went wrong, usually a commandline error like omitting a second file, or applying an empty patch, or trying to patch an empty file!

The only thing left to say is that this tool was built using LuaTools, a hybrid of C and the language Lua. (Lua is developed in the university in Rio, Brazil). LuaTools makes separate executable files that run independently of any Lua installation. I have made it available because I think people should be willing and able to make their own tools, so if I can make that easier, I do it.