Expand description
MPQ patch file support
This module implements support for binary patch files (PTCH format) used in Cataclysm and later WoW expansions. Patch files contain binary diffs that must be applied to base files to reconstruct the final file.
§Automatic Patch Handling
In most cases, you don’t need to use this module directly. The PatchChain
automatically detects and applies patch files when reading files from a chain of archives.
use wow_mpq::PatchChain;
let mut chain = PatchChain::new();
chain.add_archive("base.MPQ", 0)?;
chain.add_archive("patch-1.MPQ", 100)?;
// If the file exists as a patch in patch-1.MPQ, it will be automatically
// applied to the base file from base.MPQ
let data = chain.read_file("some/file.txt")?;§Patch File Format
Patch files use the PTCH format with three main sections:
- PTCH Header - Basic metadata (sizes, signatures)
- MD5 Block - Checksums for verification
- XFRM Block - Patch data (COPY or BSD0 type)
§Patch Types
- COPY (
0x59504f43) - Simple file replacement - BSD0 (
0x30445342) - Binary diff using bsdiff40 algorithm
§Manual Patch Application
For advanced use cases where you need to manually parse and apply patches:
use wow_mpq::patch::{PatchFile, apply_patch};
// Read patch file data (bypasses normal Archive::read_file rejection)
let patch_data = /* get patch data from archive */
let patch = PatchFile::parse(&patch_data)?;
// Apply patch to base file
let base_data = /* get base file data */
let patched = apply_patch(&patch, &base_data)?;Structs§
- Patch
File - Complete patch file with header and data
- Patch
Header - PTCH file header containing all metadata
Enums§
- Patch
Type - Patch file type
Functions§
- apply_
patch - Apply a patch file to base data