The patch file must have the same name as the target APK (this is case sensitive).
If the file is a custom patch for the application already exists, you can simply add at the beginning of the file name of any Text and save it as near the existing.
If you want to write a patch once a series of programs on a single firm, then the end the custom patch file name, you can use _%25ALL%25, for example the name of the patch for all the votes SVOX will look like this: com.svox.classic.langpack_%25ALL%25.txt. On the _%25ALL%25 is replaced by the name part of the package, which varies depending on the application of the firm. Do not use special characters/formatting in the patch file. (single spaces only)
To search for patterns of bytes to use IDA Pro 6.1. It can open dalvik-cache, odex, libraries and classes.dex.
If you want to patch dalvik-cache or odex, do not forget that the bytes of data in different firmware versions may vary. And do not forget that the bytes are not all classes.dex coincide with dalvik-cache and odex. In this you can see, if you open classes.dex and odex-file in IDA Pro.

[BEGIN]
<patch comments that are visible to the user pre-patch>
Patch for XYZ Pro 5.0.5

[PACKAGE]
<unpacks classes.dex and applies all the patches from the [CLASSES] to him. And generates, based on the modified classes.dex, odex-file.>

[CLASSES]
<pattern search/replace for classes.dex (see below)>
{"search":"63 R00 R01 R02 38 00 04 00 12 10 0F 00"}
{"original":"63 ?? ?? ?? 38 00 04 00 12 10 0F 00"}
{"replaced":"12 00 6A W00 W01 W02 00 00 12 00 0F 00"}

[LIB]
<pattern search/replace for named native libraries (see below)>
{"name":"libtitanium.so"}
{"original":"00 ** 50 e2"}
{"replaced":"00 00 50 e1"}

[OTHER FILES]
<pattern search/replace for named other files in /data/data/Package_Target_APK/ (see below)>
{"name":"/files/shell.dex"}
{"original":"0F 00 00 00 1A 00 00 00 0F 00 00 00 59 00 00 00 2F"}
{"replaced":"0F 00 00 00 0F 00 00 00 0F 00 00 00 59 00 00 00 2F"}

[ADD-BOOT]
<automatically adds the current user patch to BootList. Should be used in the patch library (or in the patch [CLASSES] without [ODEX] or without [PACKAGE])>

[END]
<patch comments that are visible to the user post-patch>
Congratulations! Program cracked!

“search” – search allows you to search for a pattern and store bytes at specific positions.
{"search":"63 R00 R01 R02 38 00 04 00 12 10 0F 00"}
In this example the bytes in green make up your pattern mask, while bytes in yellow labeled R00 -> R02 will be stored.
Stored bytes must be in order R00, R01, R02, R03…
Stored bytes cannot be repeated.

“original” – this is a pattern mask used to find the offset where the patch will be applied.
{"original":"63 ?? ?? ?? 38 00 04 00 12 10 0F 00"}
In this example the bytes in green make up your pattern mask, while bytes in yellow are wildcards (??, **)
“replaced” – this will follow an “original” statement, this is what the offset will be overwritten with.
{"replaced":"12 00 6A W00 W01 W02 00 00 12 00 0F 00"}
In this example, bytes in green will overwrite the target location.. bytes in yellow are stored bytes from the previously executed “search”
“name” – this is used to target a specific library by name (see above in [LIB])

[LIB-ARMEABI],[LIB-ARMEABI-V7A],[LIB-MIPS] or [LIB-X86] - for Libraries from /lib/armeabi/, /lib/armeabi-v7a/, /lib/mips/, /lib/x86/.

[ODEX-PATCH] - Uses for the patch has already been created odex. For example, an application has been patched with the automatic mode by Remove License Verification, but you need to make additional changes by using a Custom Patch. If we use a simple [PACKAGE]-[CLASSES], [ODEX] or [CLASSES]-[ODEX], odex-file will be created with no change and only then patched.
Example:

[BEGIN]
[ODEX-PATCH]
{"original":"63 ?? ?? ?? 38 00 04 00 12 10 0F 00"}
{"replaced":"12 00 6A ?? ?? ?? 00 00 12 00 0F 00"}
[END]
Congratulations! ODEX modified!

[CLASSES] without [PACKAGE] - Patches dalvik-cache applications. Do not forget that the system periodically updates dalvik-cache applications and all the changes of it disappear. Therefore, we must add then [ADD-BOOT]. Patch for dalvik-cache outdated, as unreliable. But he needed for the ROM Toolbox, as he found odex-file and behave hysterically.
Example:

[BEGIN]
[CLASSES]
{"original":"63 ?? ?? ?? 38 00 04 00 12 10 0F 00"}
{"replaced":"12 00 6A ?? ?? ?? 00 00 12 00 0F 00"}
[ADD-BOOT]
[END]
Congratulations!

[ODEX] - Copy dalvik-cache in /data/app/ and rename to odex-file, then all the patches applied to this odex-file. Checksums of the odex wrong, can not pass inspection, unlike odex-file created [PACKAGE] - [CLASSES].
Example:

[BEGIN]
[ODEX]
{"original":"63 ?? ?? ?? 38 00 04 00 12 10 0F 00"}
{"replaced":"12 00 6A ?? ?? ?? 00 00 12 00 0F 00"}
[END]
Congratulations!

[CLASSES]-[ODEX] - Patches dalvik-cache and then сopy dalvik-cache in /data/app/ and rename to odex-file. Checksums of the odex and of the dalvik-cache is wrong, can not pass inspection, unlike odex-file created [PACKAGE] - [CLASSES].
Example:

[BEGIN]
[CLASSES]
{"original":"63 ?? ?? ?? 38 00 04 00 12 10 0F 00"}
{"replaced":"12 00 6A ?? ?? ?? 00 00 12 00 0F 00"}
[ODEX]
[END]
Congratulations!

[SQLITE] - Sometimes the target application must change something in the database, then to help will come this possibility:
Example:

[BEGIN]
Trial Reset
[SQLITE]
{"database":"/data/data/com.package.megaapp/databases/settings.db"}
{"execute":"DELETE FROM table_settings WHERE name = 'SETTING__LIC'"}
{"execute":"UPDATE table_settings SET UsedDays=0 WHERE name='Trial_set'"}
[END]
Congratulations! You have new Trial Period!

database - path to database on Device.
execute - SQLite query.