Created
September 27, 2017 21:12
-
-
Save wallabra/29e2cef6cf42a8998bc9f345a94aa39c to your computer and use it in GitHub Desktop.
Possible file format for patching binary files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* +------------------------+ | |
* | Executable Patch Table | | |
* +------------------------+ | |
* (not necessarily for executables though) | |
* | |
* This file describes a possible file format for | |
* patching binary files. | |
* | |
* I know, I know, there are already bsdiff and | |
* bspatch, but hey, this one supports multiple | |
* files! It's also just an idea of mine. :) | |
* Also, if the patches are too big, you can use | |
* bsdiff and provide a separate patch for each | |
* executable file. With appropriate instructions | |
* of usage, of course; to patch the right files! | |
* | |
* ©2017 Gustavo6046. MIT license. | |
* For more info read: | |
* https://opensource.org/licenses/MIT | |
*/ | |
struct EPT_Header | |
{ | |
int length; // header length | |
int applicableFiles; // variations of this patch (one per file) | |
EFT_FileVariationDesc* variations; // make sure the binary length of this list equals length. | |
}; | |
struct EPT_FileVariationDesc | |
{ | |
int lengthInHeader; // length inside header | |
int nextVariationPos; // position of next header variation (from start of file) in header | |
char* filename; // filename for which this patch applies; string length must equal lengthInHeader - 12 | |
int dataPosition; // absolute position (i.e. offset from start of file) of this variation's binary data | |
int length; // length of this variation | |
}; | |
struct EPT_Fragment | |
{ | |
int pos; // position from Start of File in the original file where this fragment applies. | |
int overwriteLen; // length of the data overwritten in the original file (0 for insertion only). | |
char* myData; // a bunch of bytes determining the data added to the same position after the | |
// optional overwriting step. | |
}; | |
struct EPT_File | |
{ | |
EPT_Header fileHeader; // the header for this file. | |
EPT_Fragment* binData; // a list of Patch Fragments: each is a fragment of | |
// binary data patched in a different location of | |
// the original file. | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment