Last night when my internet was being crappy I wrote out my ideas for a custom patcher in a text file, so I'm using the code tag to display it:
Patcher Idea
============
Creating a patch
----------------
There are several types of changes:
- Overwrites
- Relocations/copies
- ?
The patcher will scan through and find the differences between the files. This
will be stored in an array of "changes". Each "change" will store the starting
location and length of the change, then the data. For each change of a certain
size, the patcher will scan the file for it to check if it's a relocation. When
that is done, the patch will be saved in the following format:
Format
------
- Header
- Patch Author
- Author Comments
- Oringal Hash
- Modified Hash
- Data
- Number of Overwrites
- Overwrites
- Number of Relocations
- Relocations
Patching
--------
First the patcher checks if it's the right file by checking the hash. Then it
gets the number of overwrites, and changes each one. Same with relocations.
When this is finished, it checks the modified hash. If it's the same then it
saves the modified file. If it's not there was an error.
Unpatching
----------
Not possible unless when patching it makes a record of what's changed. Could
be cool to have it create an "unpatch" upon patching, instead of a backup.
Better to have option to choose between unpatch and backup.
XOR Patches. For changed data store the value that when XORed with the orginal
would result in the changed data. This way patches can be reversed. Not sure how
this would work with relocated data.