Skip to main content

XPatch - XML-Based Binary Patching Tool

XPatch is a command-line tool that lets you apply binary patches to files using XML patch definitions. It can patch files, undo those changes, and check file integrity with MD5 checksums

Features

XML Patch Definitions : Define binary patches in XML for precise file modifications.
Dry Run Mode : Check if patches work before applying them.
Unpatch Support : Revert applied patches when needed.
MD5 Verification : Ensure file integrity before and after patching.


Usage

Basic Patching

xpatch PATCH_FILE.xml TARGET_FILE [OPTIONS]

Options

Flag Description
-n, --dry-run Test patch without modifying the file
-u Unpatch (revert changes) instead of patching
-v Verbose output (show detailed logs)
-m Verify MD5 checksum before patching

Patch XML Format

Example patch file (example.xml):

<patch name="example_patch" md5sum="d41d8cd98f00b204e9800998ecf8427e">
  <alter id="patch1" start="0x100" length="16">
    <from encoding="hex">48656c6c6f20576f726c6421</from> <!-- "Hello World!" -->
    <to encoding="hex">476f6f646279652021</to>         <!-- "Goodbye !" -->
  </alter>
</patch>

XML Structure

  • <patch> (Root element)
    • name: Patch identifier (optional)
    • md5sum: Expected MD5 of the target file (optional, used with -m)
  • <alter> (Patch operation)
    • id: Unique identifier for the patch
    • start: Byte offset where the patch starts (hex or decimal)
    • length: Number of bytes to replace (optional, defaults to <from> length)
  • <from> (Original data)
    • encoding="hex" (default) or encoding="text"
  • <to> (New data)
    • Must be ≤ length of <from>

Examples

1. Apply a Patch

xpatch example.xml target.bin -v -m
  • Verifies target.bin matches the expected MD5 (md5sum in XML).
  • Applies changes defined in example.xml.
  • Logs verbose output.

2. Dry Run (Test Patch Without Applying)

xpatch example.xml target.bin -n
  • Checks if the patch is applicable without modifying the file.

3. Unpatch (Revert Changes)

xpatch example.xml target.bin -u
  • Reverts the changes made by example.xml.

XPatch : The flexible binary patching tool. 🔧🔗

Release files for xpatch 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xpatch 1.2.0
File Size Uploaded
xpatch-1.2.0.tar.gz 46.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xpatch 1.2.0
File Interpreter ABI Platform
xpatch-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 78.0 kB

Release files / xpatch-1.2.0.tar.gz

Download URL xpatch-1.2.0.tar.gz
Size 46.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1f09c9eaf5e4680276ca2be95018b7a0ad15f6c0dbb46b23602e17868922f7cb
BLAKE2b-256 checksum
How to use checksums
5b07cab4dfb09d1b6eea51dc632a8f1e851e809425c5a8058dbec6fffa376a7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.17

Release files / xpatch-1.2.0-py3-none-any.whl

Download URL xpatch-1.2.0-py3-none-any.whl
Size 31.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3578e2edee57ea4f90747892d0466a14ebf5a05454efe3d14e949f7677eaa757
BLAKE2b-256 checksum
How to use checksums
1d2e56bce8a3f14b44d45e2a08c68642f75f43519e56aeca3f74b1b9de6c7420
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.17

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page