Hex patcher

Hex patcher is an App Cloner developer option available to users with the Huge, Giant donation or Ultra donations.

This option allows hex-based replacement operations on arbitrary files contained inside the APK, whether it’s DEX files, resource files or any other files. For each hex patch entry you may provide a hex-based search pattern (no, single or multiple replacements) or, since App Cloner 2.15, you may specify a hex-based position / offset in the file (single replacement). If the position + replacement length is larger than the file size and error is generated during the cloning process.

The option shows a text editor where you can enter (or paste) one or more entries. Each entry must be separated by an empty line and the entry itself consists of 3 or 4 lines:

  1. An optional comment line starting with # or //. This may be used to describe what the patch does.
  2. The path and name of the file, on which the patch should be applied. Wildcards are allowed, e.g. you can use *.dex to apply the patch to all DEX files, e.g. classes.dex, classes2.dex, etc. If you are targeting files inside directories you must include the full path (directory/file.ext) or provide wildcards (*/file.ext).
  3. a) In search mode provide the search bytes as hex values. Each by must be separated by a single space.
    or
    b) In position mode provide the position / offset as a hex value, prefixed by the @ symbol.
  4. The replacement bytes as hex values. Each by must be separated by a single space. The length of the search and replacement bytes must be the same.

Tap the plus icon in the toolbar to open an editor to add a hex patch in the correct format. Tap the edit icon to edit the hex patch where the cursor is currently located. You can use the menu to delete the hex patch at the current cursor location or to reset / clear all hex patches, effectively disabling the option.

When using the search mode, the search and replace bytes may contain ?? or ** to represent wildcard bytes. In the search bytes they will match any byte. In the replace bytes they will be skipped (no replacement will be made). You may also use ? or * in the upper or lower part of a byte to match nibbles or half-bytes, for example 0? would match a byte from 00 to 0F.

You may also use the patterns $0, $1, etc. until $F, which in the search bytes will match any byte (exactly like ?? or **) but also remembering the matched byte’s index 0, 1, etc. In the replace bytes you can use $0, $1, etc. to reference and include the matched byte. This allows moving bytes to different positions within the pattern without changing them.

In the replace bytes you may also use S0, S1, etc. until SF. This will set the upper nibble (half-byte) to the value 0, 1, etc. For example, with S0 a byte 43 would become 03, with S1 a byte 04 would become 14.

Lastly, in the replace bytes you can use increments by writing +1, +2, etc. or decrements by writing -1, -2, etc.

All hex patches are processed in the order they appear. This means a hex patch may modify the result of a previous hex patch.

Use the Hex patcher option with great care. You’ll need to know what you’re doing, otherwise the clone could simply crash.