-
Notifications
You must be signed in to change notification settings - Fork 44
Home
If you develop in C# and your code is loaded as a module/plugin into a host application, you can use HarmonyX (later referred to as Harmony) to alter the functionality of all the available assemblies of that application. Where other patch libraries simply allow you to replace the original method, Harmony goes one step further and gives you:
- A way to keep the original method intact
- Execute your code before and/or after the original method
- Modify the original with IL code processors
- Multiple Harmony patches co-exist and don't conflict with each other
HarmonyX builds on top the original Harmony library, extending and streamlining its features. Most importantly, you get
- Streamlined exception messages
- Better logging
- New Harmony 2 features while keeping compatibility with Harmony 1
At the same time, HarmonyX is based on MonoMod, a robust tool for patching .NET assemblies. With it, you get additional additional features such as
- A way to patch methods marked with
extern
- Ability to use HarmonyX in environments where dynamic code generation is not supported (e.g. Unity's .NET Standard 2.0 API)
- Interop with MonoMod patches
HarmonyX works on any games that support running code in .NET. Currently HarmonyX is built against the following targets:
- .NET Framework 3.5
- .NET Framework 4.0
- .NET Standard 2.1
HarmonyX has been tested mainly on Unity games and has been confirmed to work on all Unity versions (even ones with dynamic code generation disabled).
HarmonyX supports patching on all architectures that MonoMod supports. At the time of the writing, that is x86, x64, ARM, ARM64.
- Basic usage
-
HarmonyX extensions
1.1. Patching and unpatching
1.2. Prefixes are flowthrough
1.3. Targeting multiple methods with one patch
1.4. Patching enumerators
1.5. Transpiler helpers
1.6. ILManipulators
1.7. Extended patch targets
1.8. New patch attributes -
Extending HarmonyX
2.1. Custom patcher backends -
Misc
4.1. Patch parameters - Implementation differences from Harmony