Patching Files: Difference between revisions

From wowdev
Jump to navigation Jump to search
m (Note about ZBSDIFF1)
mNo edit summary
Line 2: Line 2:
Have a look at "http://www.daemonology.net/bsdiff/" or "http://www.pokorra.de/coding/bsdiff.html"
Have a look at "http://www.daemonology.net/bsdiff/" or "http://www.pokorra.de/coding/bsdiff.html"


Depending on version, this might not be BSDIFF4 but ZBSDIFF1, which is a variant of BSDIFF4 with seemingly no differences than exchanging BZ2 library calls with their libz inflate equivalents.
Depending on version, this might not be BSDIFF40 but ZBSDIFF1, which is a variant of BSDIFF40 with seemingly no differences than exchanging BZ2 library calls with their libz inflate equivalents.


struct zbsdiff1_header {
  char magic[8]; // "ZBSDIFF1" or "BSDIFF40"
  uint64_t control_block_size;
  uint64_t diff_block_size;
  uint64_t output_file_size;
} header;
char compressed_control_block[header.control_block_size];
char compressed_diff_block[header.diff_block_size];
char compressed_extra_block[0]; // to the end of the file
where compressed blocks are either BZ2 or zlib compressed depending on <tt>header.magic</tt>.
To patch a file, first decompress the blocks, then interpret <tt>control_block</tt> as
struct {
  uint64_t bytes_from_diff_block;
  uint64_t bytes_from_extra_block;
  uint64_t seek_in_input;
};
and iterate the data according to <tt>control_block</tt>:
* Copy <tt>bytes_from_diff_block</tt> data from input, <tt>+=</tt> bytes from <tt>diff_block</tt> and copy to output.
* Copy <tt>bytes_from_extra_block</tt> bytes from <tt>extra_block</tt> to the output.
* Seek <tt>seek_in_input</tt> in input.
* Repeat.
For an implementation, consult <tt>bspatch</tt> from BSDIFF4.


[[Category:Client]]
[[Category:Client]]

Revision as of 23:53, 29 December 2016

For updating files WoW uses bsdiff. Have a look at "http://www.daemonology.net/bsdiff/" or "http://www.pokorra.de/coding/bsdiff.html"

Depending on version, this might not be BSDIFF40 but ZBSDIFF1, which is a variant of BSDIFF40 with seemingly no differences than exchanging BZ2 library calls with their libz inflate equivalents.

struct zbsdiff1_header {
  char magic[8]; // "ZBSDIFF1" or "BSDIFF40"
  uint64_t control_block_size;
  uint64_t diff_block_size;
  uint64_t output_file_size;
} header;
char compressed_control_block[header.control_block_size];
char compressed_diff_block[header.diff_block_size];
char compressed_extra_block[0]; // to the end of the file

where compressed blocks are either BZ2 or zlib compressed depending on header.magic.

To patch a file, first decompress the blocks, then interpret control_block as

struct {
  uint64_t bytes_from_diff_block;
  uint64_t bytes_from_extra_block;
  uint64_t seek_in_input;
};

and iterate the data according to control_block:

  • Copy bytes_from_diff_block data from input, += bytes from diff_block and copy to output.
  • Copy bytes_from_extra_block bytes from extra_block to the output.
  • Seek seek_in_input in input.
  • Repeat.

For an implementation, consult bspatch from BSDIFF4.